function showwin2(nwin,sw,sh)
{
	winobjarray = new Array;
 var a = nwin.replace(/#/,"%23") ;
 var w = 640, h = 480;
 if (document.all || document.layers)
 {
	 w = screen.availWidth;
 	h = screen.availHeight;
 }

 var popW = w, popH = h;
 var leftPos = (w-popW)/2, topPos = (h-popH)/2;
 var newwinname = 'winname'+winobjarray.length;
 winobjarray[winobjarray.length] = window.open(a, newwinname,'width=' + sw + ',height=' + sh + ',menubar=no,top='+ topPos +',pixelLeft='+ leftPos + 'pixelTop=' + topPos + 'left=' + leftPos + ',resizable=no,scrollbars=yes,status=yes',false);
}

function submitSeminarRegistrationInfo()
{
    document.frmSeminarRegistration.hdnNextCall.value = "SaveSeminarRegistrationInfo";
}

function showMe(control)
{
	var myUl = control.childNodes[6];
	alert(myUl);
	
}
function getUrlParam(name)
{  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}

// Function called when contry combo box is changed
function updateAddress()
{
    document.frmRegistration.hdnNextCall.value = "GenerateRegistrationForm";
    document.frmRegistration.hdnTriggeredControl.value = document.frmRegistration.txtCountry.value;
    if (document.frmRegistration.txtStateProvince!=null)
    {
        document.frmRegistration.txtStateProvince.value="";
    }   
    if (document.frmRegistration.txtEmail.value == '')
    {
    alert(lc('wwInvalidEmailAddressAlert1'));
    }
   else if ((document.getElementById("txtEmail").value.indexOf('@') < 1) || (document.getElementById("txtEmail").value.indexOf('.') < 1) || (document.getElementById("txtEmail").value.indexOf(' ') > 1)) 
    { 
	    alert(lc('wwInvalidEmailAddressAlert'));
	    document.getElementById("txtEmail").focus();
    }	        
    else
    {
    document.frmRegistration.submit();
    }
    //alert(document.frmRegistration.hdnTriggeredControl.value);    
}

// JavaScript validation for registration page 
function validateRegForm() 
{
    var count = 0;
    var controlIds = "txtEmail~txtFirstName~txtLastName~txtJobTitle~txtPrimaryRole~txtPrimaryMarketFocus~txtCompany";                                                        
    var ControlsNew = "txtAddress1~txtAddress2~txtAddress3~txtCity~txtStateProvince~txtKounty~txtPostalCode";                
    var ControlsIdsNew = "txtPhone~txtSecretQuestion~txtSecretAnswer";
    
    var arrControls = controlIds.split("~");
    for(count=0;count<arrControls.length;count++)
    {          
        var controlId = arrControls[count];
        if (document.getElementById(controlId) != null)
        {	            
            if (document.getElementById(controlId).value == '') 
            {
		    alert(ControlName(controlId) + " " + lc("wwControlNameIsRequired"));
                document.getElementById(controlId).focus();
                return false;
            }
             else if(controlId == "txtEmail")
            {
                if ((document.getElementById(controlId).value.indexOf('@') < 1) || (document.getElementById(controlId).value.indexOf('.') < 1) || (document.getElementById(controlId).value.indexOf(' ') > 1)) 
                { 
	                alert(lc('wwInvalidEmailAddressAlert'));
	                document.getElementById(controlId).focus();
                    return false;
                }	        		
            }
        }             
    } //end of for
       
    arrControls = ControlsNew.split("~");
    for(count=0;count<arrControls.length;count++)
    {            
        var controlId = arrControls[count];
        if (document.getElementById(controlId) != null)
        {
            if (document.getElementById(controlId).title == 'Required') 
            {
                if (document.getElementById(controlId).value == '') 
                {
                    alert(ControlName(controlId) + " " + lc("wwControlNameIsRequired"));
                    document.getElementById(controlId).focus();
                    return false;
                }
            }		
        }             
    } // end of for

    arrControls = ControlsIdsNew.split("~");
    for(count=0;count<arrControls.length;count++)
    {            
        var controlId = arrControls[count];            
        
        if (document.getElementById(controlId) != null)
        {	            
            if (document.getElementById(controlId).value == '') 
            {
                alert(ControlName(controlId) + ' is required.');
                document.getElementById(controlId).focus();
                return false;
            }                   	        
         } // end of if   
    }// end of for
      
    // Validation for Question and answer section of FID-1 or 2 or 4
    var Fid = document.getElementById("fID").value;
    if(Fid == "1" || Fid == "4" || Fid=="2")
      {
         var QuestionConrolIds = "ans_1~ans_2~ans_3~ans_4~ans_5";
         arrControls = QuestionConrolIds.split("~");  
         
         for(count=0;count<arrControls.length;count++)
         {       
           var controlId = arrControls[count]; 
           
     	   if(document.getElementById(controlId) != null)
       	   {
       	   	   if(document.getElementById(controlId).title == "Required")
	       	   {
	       	   		var bStatus;
	       	   		var rdobtn;
	       	   		
	       	   		if(document.getElementById(controlId).type == 'radio')
	       	   		{
	       	   			switch(controlId)
					    {       
					    	case "ans_1":
				       	   		rdobtn= document.frmRegistration.ans_1;
				       	   		break;
					    	case "ans_2":
				       	   		rdobtn = document.frmRegistration.ans_2;
				       	   		break;
					    	case "ans_3":
				       	   		rdobtn = document.frmRegistration.ans_3;
				       	   		break;
					    	case "ans_4":
				       	   		rdobtn = document.frmRegistration.ans_4;
				       	   		break;
					    	case "ans_5":
				       	   		rdobtn = document.frmRegistration.ans_5;
				       	   		break;
		       	   		}
		       	   		
				     	var isChkd = -1;
						for (i=rdobtn.length-1; i > -1; i--) 
			  			{
							if (rdobtn[i].checked) 
					  		{
		    				  isChkd = i;
    						}
		  			  	}
					  	if (isChkd == -1) 
			  			{
			    			bStatus = false;
					 	 } else 
					  	{
			    			bStatus = true;
			  			}
		       	   	}
		       	   	else
		       	   	{
		       	   		bStatus = valbutton(document.getElementById(controlId));
		       	   	}
		       	   	if(!bStatus)
		       	   	{
		       	   	    
	    	   	   		alert(ControlName(controlId));
		    	   	   	return false;
		       		 }
       		   	}
       		}
       	}
      }
      
     //  Calling Save web service

	//omniture on_click code begin

	s.linkTrackVars="events,state,zip";
	s.linkTrackEvents="event5";

	var stateOptionNodes;
	var numberOfStateOptionNodes;
	if (document.getElementById('txtStateProvince')) {
		stateOptionNodes = document.getElementById('txtStateProvince').childNodes;
 		numberOfStateOptionNodes = stateOptionNodes.length;
	} else {
		stateOptionNodes = "";
		numberOfStateOptionNodes = 0;
	}
	
	for(var currentOptionNode = 0; currentOptionNode < numberOfStateOptionNodes; currentOptionNode++)
	{


		if(stateOptionNodes[currentOptionNode].getAttribute('SELECTED') == true)
		{
			s.state = stateOptionNodes[currentOptionNode].getAttribute('value');
		}

	}

	if (document.getElementById('txtPostalCode')) {
		s.zip = document.getElementById('txtPostalCode').getAttribute('value');
	}

	s.events = "event5";
	s.tl(this,'o','Registration Page');

	//omniture on_click code end
	

  document.frmRegistration.hdnNextCall.value = "SaveRegistrationDetails";
 	document.frmRegistration.submit();
}

// Function called to validate email address
function validateEmail()
{
   if ((document.frmSearch.srchEmail.value.length==0) || (document.frmSearch.srchEmail.value==null)) 
   {
      alert(lc("wwControlNameEmail") + " " + lc("wwControlNameIsRequired"));
	  document.frmSearch.srchEmail.focus();
      //return false;
   }
   else if ((document.frmSearch.srchEmail.value.indexOf('@') < 1) || (document.frmSearch.srchEmail.value.indexOf('.') < 1) || (document.frmSearch.srchEmail.value.indexOf(' ') > 1)) 
   { 
        alert(lc('wwInvalidEmailAddressAlert'));
	    document.frmSearch.srchEmail.focus();
        //return false;
   }
   else 
   { 
	   document.frmSearch.hdnNextCall.value = "SearchbyEmail";
	   document.frmSearch.submit();
	   //return true;
    }
}
	


// function called to validate the secret nswer
function validateAnswer()
{
    document.frmSearchEmail.hdnNextCall.value = "ValidateAnswer";    
    if (document.frmSearchEmail.action.indexOf("?")>0)
    {
        document.frmSearchEmail.action = document.frmSearchEmail.action + "&hdnUserID=" + document.frmSearchEmail.hdnUserID.value;	
    }
    else
    {
        document.frmSearchEmail.action = document.frmSearchEmail.action + "?hdnUserID=" + document.frmSearchEmail.hdnUserID.value;
    }
    document.frmSearchEmail.submit();
}

// Function part of javascript client side validation
function ControlName(ControlId)
{
    var strControlName;
    switch(ControlId)
    {       
	  case "txtFirstName": {strControlName = lc("wwControlNameFirstName"); break;}
        case "txtLastName":  { strControlName = lc("wwControlNameLastName"); break;}
        case "txtJobTitle": { strControlName = lc("wwControlNameJobTitle"); break;}
        case "txtPrimaryRole": { strControlName = lc("wwControlNamePrimaryRole"); break;}
        case "txtPrimaryMarketFocus": { strControlName = lc("wwControlNamePrimaryMarketFocus"); break;}
        case "txtCompany": { strControlName = lc("wwControlNameCompany"); break;}
        case "txtAddress1": { strControlName = lc("wwControlNameAddress1"); break;}
        case "txtAddress2": { strControlName = lc("wwControlNameAddress2"); break;}
        case "txtAddress3": { strControlName = lc("wwControlNameAddress3"); break;}
        case "txtCity": { strControlName = lc("wwControlNameCity"); break;}
        case "txtStateProvince": { strControlName = lc("wwControlNameStateProvince"); break;}
        case "txtPostalCode": { strControlName = lc("wwControlNamePostalCode"); break;}
        case "txtKounty": { strControlName = lc("wwControlNameCountry"); break;}
        case "txtEmail": { strControlName = lc("wwControlNameEmail"); break;}
        case "txtPhone": { strControlName = lc("wwControlNamePhone"); break;}
        case "txtSecretQuestion": { strControlName = lc("wwControlNameSecretQuestion"); break;}
        case "txtSecretAnswer": { strControlName = lc("wwControlNameSecretAnswer"); break;}	
        
        case "ans_1": {strControlName = lc("wwAnswerRequireQuestion","#1"); break;} 
		case "ans_2": {strControlName = lc("wwAnswerRequireQuestion","#2"); break;}
		case "ans_3": {strControlName = lc("wwAnswerRequireQuestion","#3"); break;}
		case "ans_4": {strControlName =lc("wwAnswerRequireQuestion","#4"); break;}
		case "ans_5": {strControlName = lc("wwAnswerRequireQuestion","#5"); break;}

    }   
    return strControlName;
}

// Function called when reset button is called
// Resets the page to default registration page when in hdnRegPagemode = 0
function resetRegistrationForm()
{
	document.frmRegistration.reset();       
    //alert(document.frmRegistration.hdnRegPageMode.value);
    /*if(document.frmRegistration.hdnRegPageMode.value == "0")
    {
       // alert("Testing reset");
        document.frmRegistration.hdnNextCall.value = "";
        document.frmRegistration.reset();       
    }  */  
}

// Function called when This is not me hyperlink is clicked

function thisIsNotMe()
{
    var strUrl = document.URL;
    strUrl = strUrl + "&ridCkie=delIt";
    strUrl = strUrl.replace("hdnUserID", "oldUserID");
    strUrl = strUrl.replace("uid","oldUid"); 
    document.location.href = strUrl;    
}

function KeyDownHandler(evt)
{     
    var key;
    var controlType="";
    if (document.all)
    {
        key = window.event.keyCode;
        controlType = window.event.srcElement.type;
    }
    else
    {
        key = evt.which;
        controlType = evt.target.type;
    }

    if(key==13 && controlType != 'button' && controlType!= 'reset')
         document.frmRegistration.cmdContinue.click();
        //validateRegForm();
}

/*function KeyDownHandler(btn)
{     
  // process only the Enter key
  if (event.keyCode == 13)
  {    
      event.keyCode = 0;
      // submit the form by programmatically clicking the specified button
      btn.click();
  }
}*/

/*function KeyDownHandlerTemp(btn)
{
    //alert(navigator.appName.length);
    //alert(e.which);
    var intKeyCode = 0;
    if (navigator.appName == "Microsoft Internet Explorer")
    {        
        if (window.event.keyCode == 13)
        {
            event.keyCode = 0;
            // submit the form by programmatically clicking the specified button
            btn.click();
         }
     }
     if (navigator.appName == "Netscape")
     {
        //var e = event;       
        event = event || window.event;
       // alert(event.target);
        intKeyCode = event.target;
       // alert(intKeyCode);
        intKeyCode = e.which;
       // alert(intKeyCode);
        if (intKeyCode == 13)
        {
            e.which = 0;
            btn.click();
        }
    }
}*/

// Validate Question and answer
function valbutton(control) 
{
	switch(control.type)
    {       
        case "radio":
      		  var isChkd = -1;
			  for (i=control.length-1; i > -1; i--) 
			  {
			  	if (control[i].checked) 
			  	{
    			  isChkd = i;
    			}
  			  }
			  if (isChkd == -1) 
			  {
			    return false;
			  } else 
			  {
			    return true;
			  }
			  break;
        case "text":
        	if(control.value == '')
        	{
        		return false;	
        	}
        	else
        	{
        		return true;
        	}
        	break;
        case "checkbox":
        	return control.checked;
        	break;
        case "select-one":
			if(control.selectedIndex < 1)
				return false;
			else
				return true;
			break;
         case "select-multiple":
		    if(control.selectedIndex < 0)
				return false;
			else
				return true;
		
		}
}
// This function Hides and Displays the image strip based on the Hide Details or View Details in Product Level 4 Page.
function ShowHide()
{
		// To identify the browsers IE and Mozilla.
		if(document.all)
		{
			myStyle = document.getElementById("AllToggle").innerText
			newText	= (myStyle=="View") ? "Hide": "View"
		
			document.getElementById("AllToggle").innerText = newText
		} 
		else
		{
			myStyle = document.getElementById("AllToggle").textContent
			newText	= (myStyle=="View") ? "Hide": "View"

			document.getElementById("AllToggle").textContent = newText
		}
		
		newVal = (myStyle=="View") ? "block": "none"

		var Start = 1;
		var Stop  = 20;
		
		for (i=Start; i<=Stop; ++i)
		{
			if (document.getElementById(i + "_data") && document.getElementById(i + "_data").style.display)
			{
				document.getElementById(i + "_data").style.display = newVal
			}
		}
}


//This code snippet is used to populate all the query string values into an object of type hashtable
var objURL = new Object();
window.location.search.replace(new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),
function( $0, $1, $2, $3 )
{
	objURL[ $1 ] = $3;
}
);
//This function is used to populate default values into the hidden variables.
//This function is specific to Text Boxes only, assuming that the functionality will be there only for FID=2
//This can be extended in future if required.  Also populates the hidden variables.
function PopulateDefaults(vForm)
{
    var vAnswer1, vAnswer2, vAnswer3, vAnswer4, vAnswer5;
    vAnswer1 = objURL ['p_dflt1'];
    vAnswer2 = objURL ['p_dflt2'];
    vAnswer3 = objURL ['p_dflt3'];
    vAnswer4 = objURL ['p_dflt4'];
    vAnswer5 = objURL ['p_dflt5'];
    if (vForm.ans_1 != undefined)
    {
        if (vForm.ans_1.type=="text" && vAnswer1 != undefined)
        {
            vForm.ans_1.value = Url.decode(vAnswer1);
            vForm.hdnP_Dflt_1.value = Url.decode(vAnswer1);
        }
    }
    if (vForm.ans_2 != undefined)
    {
        if (vForm.ans_2.type=="text" && (vAnswer2 != undefined))
        {
            vForm.ans_2.value = Url.decode(vAnswer2);
            vForm.hdnP_Dflt_2.value = Url.decode(vAnswer2);
        }
    }
    if (vForm.ans_3 != undefined)
    {
        if (vForm.ans_3.type=="text" && (vAnswer3 != undefined))
        {
            vForm.ans_3.value = Url.decode(vAnswer3);
            vForm.hdnP_Dflt_3.value = Url.decode(vAnswer3);
        }
    }
    if (vForm.ans_4 != undefined)
    {
        if (vForm.ans_4.type=="text" && (vAnswer4 != undefined))
        {
            vForm.ans_4.value = Url.decode(vAnswer4);
            vForm.hdnP_Dflt_4.value = Url.decode(vAnswer4);
        }
    }
    if (vForm.ans_5 != undefined)
    {
        if (vForm.ans_5.type=="text" && (vAnswer5 != undefined))
        {
            vForm.ans_5.value = Url.decode(vAnswer5);
            vForm.hdnP_Dflt_5.value = Url.decode(vAnswer5);
        }
    }
}

//The new functions added for url encoding, decoding and getting the query string values

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}
//function to open the document in a new window for Level 3 and 4.
function openDocument(vDocument)
{
	window.open(vDocument);
	return;
}

//function to open the image on the product detail screen
function showgraphic(imgPath)
{
	var winname = 'ProductDetail';	
	window.open(imgPath, winname, 'width=450,height=450,menubar=no,resizable=yes,scrollbars=no');
	return;
}


/* code added by Sriram for Phase III Actities */

// JavaScript methods for Level 5 My Favorite and BOM
// This method checks the number validation on BOM Qty text box and sets the hdnNextCall hidden field with
// the corresponding web method.
function validateBOMQty(vMerchFlag)

{

    if (document.prod.hdnUserID.value=='')

    {       

            return false;

    }

    else

    {    

        var strBomQty = document.getElementById("txtBOMQuantity").value;

        var intBomQtyLen = strBomQty.length;

        var charBomQty;

        var intPos;

        var boolValidflag = false;

        

        if(vMerchFlag == '0')

        {

            if (document.prod.chkFavProduct.checked)

            {

                document.prod.hdnBookMark.value = 1;

            }

            else

            {

                document.prod.hdnBookMark.value = 0;

            }        

        }

        else

        {

            document.prod.hdnBookMark.value = 0;

        }

        var strhdnBOM = document.prod.hdnBOM.value;

 

        var strhdnMyFavorite = document.prod.hdnMyFavorite.value; //added this flag know the page status

        // Checks the numeric status of each character and sets false if it finds character.

        if(intBomQtyLen == 0)

        {

            boolValidflag = true;

        }

        for(intPos=0;intPos<intBomQtyLen;intPos++)

        {

            charBomQty = strBomQty.substring(intPos,intPos+1);

            if(charBomQty.charCodeAt(0) >= 48 && charBomQty.charCodeAt(0)<=57)

            {

              boolValidflag = true;

            }

            else

            {

              boolValidflag = false;

            }

        }

        // Validates the BOM Qty text box for numeric data and returns the error message.

        if(boolValidflag == false)

        {

            alert("BOM Qty must be numeric");

            return false;

        }

        // Checks the BOM and BookMark and sets the hdnNextCall with the web method name.

        // call web method for both BOM and Bookmark

//if page status is chagned which can be identified when either of the below hdn variable are set to true, call the webservice.

        else if (strhdnBOM == "true" || strhdnMyFavorite == "true")

        {

            if(vMerchFlag == '1')

            {

                document.prod.hdnNextCall.value ="UpdateCart";

            }

            else

            {   

                document.prod.hdnNextCall.value ="UpdateMyFavBOM";

            }

        }       

        document.prod.submit();           

    }

}




function updateMyFav()
 {
	document.prod.hdnNextCall.value = "UpdateMyFavList";
	updateChkCtrlMyFav();
	document.prod.submit();  
 }
 
 function updateChkCtrlMyFav()
 {
    var intCount = document.prod.hdnItemsCount.value;
    for(var i=1;i < intCount; i++)
    {
        if(document.getElementById("chkFavorite_"+i).checked)
            document.getElementById("chkFavorite_"+i).value = "1";
        else
            document.getElementById("chkFavorite_"+i).value = "0";
    }
 }

 function updateActiveBOM(aPN)
 {
      if(validateUpdate(aPN))
      {
            document.frmBOM.hdnNextCall.value = "UpdateActiveBOM";
            document.frmBOM.hdnBOMDisplayFlag.value = "0";
             updateChkCtrlBOM();           
            document.frmBOM.submit();  
      }
 }
 function updateChkCtrlBOM()
 {
    var intCount = document.frmBOM.hdnItemsCount.value;
    for(var i=1;i < intCount; i++)
    {
        if(document.getElementById("chkFavorite_"+i).type == "checkbox")
        {
        if(document.getElementById("chkFavorite_"+i).checked)
            document.getElementById("chkFavorite_"+i).value = "1";
        else
            document.getElementById("chkFavorite_"+i).value = "0";
        }
    }
 }
 
function saveActiveBOM(aPN)
 {
    if(descNotice(aPN))
    {
	    document.frmBOM.hdnNextCall.value = "SaveActiveBOM";
	    //alert(document.frmBOM.column.value)
	    updateChkCtrlBOM();
	    document.frmBOM.submit();
	}
 }
 
function getQuote(aPN)
 {
   if(descNotice(aPN))
    {
	    document.frmBOM.hdnNextCall.value = "UpdateActiveBOM";
	    document.frmBOM.hdnBOMDisplayFlag.value = "4";
	    updateChkCtrlBOM();
	    document.frmBOM.submit();
	}
 }
 
function printPage(aPN)
 {
 
   if(descNotice(aPN))
    {    
	    document.frmBOM.hdnNextCall.value = "UpdateActiveBOM";
		document.frmBOM.hdnBOMDisplayFlag.value = "2";
		updateChkCtrlBOM();
	    document.frmBOM.target="_blank";
	    document.frmBOM.action=document.getElementById("printpage").href;
	    document.frmBOM.submit();
	}
 }
 
function exportToFile(aPN)
 {
   if(descNotice(aPN))
    {
	    document.frmBOM.hdnNextCall.value = "UpdateActiveBOM";
	    document.frmBOM.hdnBOMDisplayFlag.value = "3";
	    updateChkCtrlBOM();
	    document.frmBOM.submit();
	}
 }
 
 function emailBOM(aPN)
 {
   if(descNotice(aPN))
    {
	    document.frmBOM.hdnNextCall.value = "SendBOMEmail";
		document.frmBOM.hdnBOMDisplayFlag.value = "1";
		updateChkCtrlBOM();
	    document.frmBOM.submit();
	}
 }

 
 function sendEmailBOM()
 {
	// validating the email ToAddress
    if (document.frmBOM.txtToAddr.value == '')
    {
        alert(lc('wwInvalidEmailAddressAlert1'));
    }
    else if ((document.getElementById("txtToAddr").value.indexOf('@') < 1) || (document.getElementById("txtToAddr").value.indexOf('.') < 1) || (document.getElementById("txtToAddr").value.indexOf(' ') > 1)) 
    { 
	    alert(lc('wwInvalidEmailAddressAlert'));
	    document.getElementById("txtToAddr").focus();
    }	        
    else
    {
        document.frmBOM.hdnNextCall.value = "SendBOMEmail";
        document.frmBOM.submit();
    }
 }
 
 function submitBOM()
 {
//  document.frmBOMGetQuote.hdnNextCall.value = "SubmitBOM";	
   document.frmBOMGetQuote.hdnNextCall.value = "UpdateDistributorInfo";
    document.frmBOMGetQuote.submit();	
 }
 // Validation for removing the saved bom
 function confirmSavedBOMDelete(strAutoId)
 {
    if (confirm(lc('wwConfirmSavedBOMDelete'))) 
	{
	    document.frmBOMSave.hdnDeleteBOMID.value = strAutoId;
	    document.frmBOMSave.hdnNextCall.value = "DeleteBOM";
	    document.frmBOMSave.submit();
	} 
 }
 //View Active BOM from Saved BOM
 function viewActiveBOM()
 {
    document.frmBOMSave.hdnNextCall.value = "GetMyActiveBOMList";
	document.frmBOMSave.submit();
 }
 
 //Function to be called on click of column sort (Called in Saved BOM Page)
  function SaveBOMSubmit()
 {     
        //alert(document.frmBOMSave.hdnColumnName.value);
	    //document.frmBOMSave.hdnColumnName.value=document.frmBOMSave.hdnColumnName.value;
	    document.frmBOMSave.hdnNextCall.value = "GetMySaveBOMList";
	    document.frmBOMSave.submit();	
 }
 // To set the GetRegistration web method 
 function UpdateCustomerInfo()
 {
        //document.frmBOMGetQuote.hdnFID.value = "3";
        //document.frmBOMGetQuote.hdnTarget.value = "";        
        //document.frmBOMGetQuote.hdnNextCall.value = "GenerateRegistrationForm";
	//document.frmBOMGetQuote.submit();
	document.location.href="/Registration/index.htm?fID=3&trgt=/products/BillOfMaterials/index.htm|GetQuote=true";
 }
 
 function UpdateQuoteDistributorInfo()
 {
        document.frmBOMGetQuote.hdnNextCall.value = "UpdateDistributorInfo";
	    document.frmBOMGetQuote.submit();
 }
 
 function makeActiveBOM()
 {
    if (confirm(lc('wwMakeActiveBOM'))) 
	{
        document.frmBOMDetailInfo.hdnNextCall.value = "MakeActiveBOM";
	    document.frmBOMDetailInfo.submit();
	}
 }

// On key press of Find button in Save BOM
function findSavedBOMKeyPress(evt)
{
    var key;
    if (document.all)
        key = window.event.keyCode;
    else
        key = evt.which;

    if(key==13)
    {
        findSavedBOM();
    }
}
 
function findSavedBOM()
{
    document.frmBOMSave.hdnNextCall.value = "GetMySaveBOMList";//"FindSavedBOM";
	document.frmBOMSave.submit();
}
function validateUpdate(aPN)
{    
	if (aPN.length > 0)
	{
		var jsNewString
		jsNewString = aPN.toUpperCase();
		
		var objFrmElements = document.frmBOM.elements; 
        var iCount;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                   if(jsNewString==objFrmElements[iCount].value.toUpperCase())
                   {
                      alert (lc('wwValidateUpdate'));
	                  return false;
                   }
                }
           }
        }
    }
     return true;
}
// Validation for Get Quote.
function descNotice(aPN)
{
	if (validateUpdate(aPN)) 
	{
	    //var objHiddenDC = document.frmBOM.strPartNumber_1.value; //document.getElementsByName("hdnDC");
	    
	    var objFrmElements = document.frmBOM.elements; 
        var iCount,bPartExists=false;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                    bPartExists = true;
                    break;
                }
           }
        }
	    
		if ((bPartExists == false) && (aPN.length < 1)) 
		{
			alert(lc('wwDescNotice'))
			return false;
		}
		if (document.frmBOM.txtComments.value.length < 1) 
		{
			alert(lc('wwDescNotice1'));
			return false;
		} else 
		{
			return true;
		}
	} 
	else 
	{
		return false;
	}
}

//Download Literature
function submitDownloadLiterature()
 {
    var objFrmElements = document.frmDownloadLiterature.elements;     
    var litid='';
    for(iCount=0;iCount<objFrmElements.length;iCount++)
    {  
        if (objFrmElements[iCount].type == 'checkbox' && objFrmElements[iCount].checked)
           {    
                   if(litid.length == 0)
                   { 
                        litid= objFrmElements[iCount].value;                                         
                   }
                   else
                   {                   
                       litid=litid + ',' + objFrmElements[iCount].value;
                   }                      
           }
      }
      if(litid.length >0 )
      {       
        document.frmDownloadLiterature.hdnLitID.value=litid;
        //document.frmDownloadLiterature.hdnTarget.value = "../ProductRegistration/?strRegion=usa&strLocale=en&strCountry=US&cartman=1&trgt=../Support/CustomerService/DownloadLiterature&LSID=WS Literature Request USA - EG&fID=4&ttl=" + document.frmDownloadLiterature.hdnTitle.value + "&quest=True&custinfo=True&rplBar=True&rtnID=False&ntfy=&orms=False&llitids=" + litid;
        document.frmDownloadLiterature.hdnNextCall.value = "GenerateRegistrationForm";    
        //document.frmDownloadLiterature.action=document.frmDownloadLiterature.hdnTarget.value;

		document.frmDownloadLiterature.hdnFID.value="4";
	    document.frmDownloadLiterature.submit();
	  }
	  else
	  {
	    alert ("Please select ... to be mailed");
	  }	  
 } 
 function updateCart(aPN)
 {
   if(validateCart(aPN))
    {
	    document.frmCart.hdnNextCall.value = "UpdateCartItemList";	    
	    document.frmCart.submit();
	}
 }
 
 function validateCart(aPN)
{
	if (validateUpdate(aPN)) 
	{    
	    var objFrmElements = document.frmCart.elements; 
        var iCount,bPartExists=false;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                    bPartExists = true;
                    break;
                }
           }
        }
	    
		if ((bPartExists == false) && (aPN.length < 1)) 
		{
			alert(lc('wwUpdateCart'));
			return false;
		}
		else 
		{
			return true;
		}
	} 
	else 
	{
		return false;
	}
}

function getBOMDetailInfo(vParentID)
 {
    document.frmBOMSave.hdnNextCall.value = "GetBOMDetailInfo";	
    document.frmBOMSave.hdnParentID.value = vParentID;
	document.frmBOMSave.submit();	
 }
 
 function UpdateSort(strColumnName)
 {
    document.frmBOMSave.hdnColumnName.value = strColumnName;    
    if(document.frmBOMSave.hdnSortOrder.value == "ascending")
    {        
        document.frmBOMSave.hdnSortOrder.value = "descending"
    }
    else
    {     
        document.frmBOMSave.hdnSortOrder.value = "ascending"
    }
	document.frmBOMSave.hdnNextCall.value = "GetMySaveBOMList";
	document.frmBOMSave.submit();
 } 
 
 function showSavedBOMs()
 {
    document.frmBOM.hdnNextCall.value = "GetMySaveBOMList";
    document.frmBOM.submit();
 }
 
 function showSavedBOMs_2()
 {
    document.frmBOMDetailInfo.hdnNextCall.value = "GetMySaveBOMList";
    document.frmBOMDetailInfo.submit();
 }

function AddToActiveBOM(varIndex)
 {
    var vPartNum;
    var vParam;
    var vIGID;
    var vQty;
    var vFavorite;
    document.prod.hdnNextCall.value = "UpdateMyFavBOM";
    document.prod.hdnA_PartNum.value = document.getElementById("strPartNumber_" + varIndex).value; //PartNum
    document.prod.hdnA_Param.value = document.getElementById("strParam_" + varIndex).value; //ClassID
    document.prod.hdnA_IGID.value = document.getElementById("strIGID_" + varIndex).value; //GroupID
    //alert(document.getElementById("chkFavorite_"+ varIndex));
    if (document.getElementById("chkFavorite_"+ varIndex).checked) // strFavorite;
    {
        document.prod.hdnA_CheckBox.value = 1; 
    }
    else
    {
        document.prod.hdnA_CheckBox.value = 0;
    }
    document.prod.submit();
}



/* End Code Added By Sriram For Phase III Activities */

function LoadBom()
{
    document.location.href= '/Products/BillofMaterials/index.htm';
}

function LoadFav()
{
    document.location.href= '/Products/FavoriteProductsList/index.htm';
}

function LoadLocateDistributor()
{
    document.location.href = '/Support/LocateDistributor/index.htm';
}
function LoadProduct(vWhere)
{
	if (vWhere==1)
	{
		document.location.href='/Products/ProductOverviews/index.htm';
	}
	else if (vWhere==2)
	{
		document.location.href='/Products/ProductOverviews/Merchandising/index.htm';
	}
}

//Cart Javascript Methods


function descNoticeCart(aPN)
{
	if (validateUpdateCart(aPN)) 
	{    
	    //var objHiddenDC = document.frmBOM.strPartNumber_1.value; //document.getElementsByName("hdnDC");
	    
	    var objFrmElements = document.frmCart.elements; 
        var iCount,bPartExists=false;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                    bPartExists = true;
                    break;
                }
           }
        }
	    
		if ((bPartExists == false) && (aPN.length < 1)) 
		{
			alert(lc('wwDescNoticeCart'))
			return false;
		}
		else 
		{
			return true;
		}
	} 
	else 
	{
		return false;
	}
}

function updateCart(aPN)
 {
   if(validateCart(aPN))
    {
	    document.frmCart.hdnNextCall.value = "UpdateCartItemList";
	    document.frmCart.hdnCARTDisplayFlag.value = "2"; 
	    document.frmCart.submit();
	}
 } 
 function placeOrder(aPN)
 {   
   if(descNoticeCart(aPN))
    {
	    document.frmCart.hdnNextCall.value = "UpdateCartItemList";
		document.frmCart.hdnCARTDisplayFlag.value = "3";
	    document.frmCart.submit();
	}
 } 
function printCart(aPN)
 {
   if(descNoticeCart(aPN))
    {
	    document.frmCart.hdnNextCall.value = "UpdateCartItemList";
		document.frmCart.hdnCARTDisplayFlag.value = "1";

    	    document.frmCart.target="_blank";
	    document.frmCart.action=document.getElementById("printpage").href;		
	    document.frmCart.submit();
	}
 } 
 function validateCart(aPN)
{
	if (validateUpdateCart(aPN)) 
	{    
	    var objFrmElements = document.frmCart.elements; 
        var iCount,bPartExists=false;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                    bPartExists = true;
                    break;
                }
           }
        }	    
		if ((bPartExists == false) && (aPN.length < 1)) 
		{
			alert(lc('wwValidateCart'));
			return false;
		}
		else 
		{
			return true;
		}
	} 
	else 
	{
		return false;
	}
}


function validateUpdateCart(aPN)
{    
	//alert(aPN.length);
	if (aPN.length > 0)
	{
		var jsNewString
		jsNewString = aPN.toUpperCase();
		
		var objFrmElements = document.frmCart.elements; 
        var iCount;
        
        for(iCount=0;iCount<objFrmElements.length;iCount++)
        {
           if(objFrmElements[iCount].type == "hidden")
           {
                if(objFrmElements[iCount].name.indexOf("strPartNumber_") >= 0)
                {
                   if(jsNewString==objFrmElements[iCount].value.toUpperCase())
                   {
                      alert (lc('wwValidateUpdateCart'));
	                  return false;
                   }
                }
           }
        }
    }
     return true;
}


function sendEmailCART()
{
 document.frmMyInfo.hdnNextCall.value="DMCartPlaceOrder"; 
 document.frmMyInfo.hdnTarget.value=""; //to be set by the site studio
 document.frmMyInfo.submit(); 
}

 function UpdateCartCustomerInfo()
 {
        //document.frmMyInfo.hdnFID.value = "3";
        //document.frmMyInfo.hdnTarget.value = "";        
        //document.frmMyInfo.hdnNextCall.value = "GenerateRegistrationForm";
	//document.frmMyInfo.submit();
	document.location.href="/Registration/index.htm?fID=3&trgt=/products/Cart/index.htm|GetCart=true";
 }
//end of CART javascript methods

function LoadCart()
{
	document.location.href='/Products/Cart/index.htm';
}

function NeedHelp(vForWhat)
{
	if (vForWhat == 1)
	{
		alert("Update site studio static page link for BOM Active Cart - Help Page");
	}
	else if (vForWhat == 2)
	{
		alert("Update site studio static page link for BOM Saved Cart - Help Page");
	}
	else if (vForWhat == 3)
	{
		alert("Update site studio static page link for DM Cart - Help Page");
	}
	else if (vForWhat == 4)
	{
		alert("Update site studio static page link for BOM Detail Page - Help Page");
	}
}

function Register(vForWhat)
{
strLocation = new String(window.location); 
 strLocation = strLocation.replace("?","|"); 
 strLocation = strLocation.replace(/&/g,"~"); 
 document.location.href = "/Registration/index.htm?fID=3&trgt="+strLocation;
//	if (vForWhat==1)
//	{
//		alert("Update Redirect URL to Registration page from Product Level 5");
//	}
//	else if (vForWhat==2)
//	{
//		alert("Update Redirect URL to Registration Page from Distributor merchandising product level 5");
//	}
}

// On key press of Search email
function ValidateEmailKeyPress(evt)
{
    var key;
    if (document.all)
        key = window.event.keyCode;
    else
        key = evt.which;

    if(key==13)
    {
        validateEmail();
    }
}

function validateAnswerKeyPress(evt)
{
    var key;
    if (document.all)
        key = window.event.keyCode;
    else
        key = evt.which;

    if(key==13)
    {
        validateAnswer();
    }
}

// On key press of BOM description
function ValidateBOMKeyPress(evt)
{
    var key;
    if (document.all)
        key = window.event.keyCode;
    else
        key = evt.which;

    if(key==13)
    {
            document.frmBOM.hdnNextCall.value = "UpdateActiveBOM";
            document.frmBOM.hdnBOMDisplayFlag.value = "0";
            updateChkCtrlBOM();           
            document.frmBOM.submit();  
     }
}

function SecNewUser()
{
    var hdnAppID = document.frmExtranets.hdnAppID.value;
    var hdnParam1 = document.frmExtranets.hdnParam1.value;
    document.location.href="/registration/index.htm?fID=3&rplbar=True&ridCkie=delIt&trgt=/login/index.htm&appid=" + hdnAppID + "&param1=" +  hdnParam1 + "&doF=add";
}



function ChangeEmailAddress()
{
  document.frmRegistration.hdnNextCall.value = "ChangeEmailAddress";
  document.frmRegistration.submit();
}
function SecChangeProfile(vAppID, vParam1)
{
    var vUID = new String("0");
    if (GetCookie('intUserId') != null) 
    {
       vUID = GetCookie('intUserId');
    }
    document.location.href="/registration/index.htm?trgt=/login/index.htm&LSID=WS+Literature+Request+USA+%2D+EG&fID=3&ttl=Website+Registration&quest=True&custinfo=True&rplBar=True&rtnID=False&ntfy=&orms=False&uid=" + vUID + "&appid=" + vAppID + "&param1=" + vParam1 + "&doF=CPWD";
}
function ValidateupdateEmailKeyPress(evt)
{
    var key;
    if (document.all)
        key = window.event.keyCode;
    else
        key = evt.which;

    if(key==13)
    {
         document.frmUpdateEmail.hdnNextCall.value = "SaveChangeEmailAddress";
  	 document.frmUpdateEmail.submit();
    }
}

function updateEmail()
{
  document.frmUpdateEmail.hdnNextCall.value = "SaveChangeEmailAddress";
  document.frmUpdateEmail.submit();
}

function SecChangePwd(vAppID, vParam1)
{
    var vUID = new String("0");
    if (GetCookie('intUserId') != null && GetCookie('intUserId') != "") 
    {
       vUID = GetCookie('intUserId');
    }
    if (vUID=="0")
    {
        document.location.href="/registration/index.htm?trgt=/login/changepassword/index.htm&LSID=WS+Literature+Request+USA+%2D+EG&fID=3&ttl=Log+Into+Special+Access+Account&quest=True&custinfo=True&rplBar=True&rtnID=False&ntfy=&orms=False&appid=" + vAppID + "&param1=" + vParam1 + "&doF=CPWD";
    }
    else 
    {
        document.location.href="/login/changepassword/index.htm?uid=" + vUID + "&appid=" + vAppID + "&param1=" + vParam1 + "&trgt=/login/index.htm";
    }
}

//cookies function
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;	
    if (document.cookie.substring(i, j) == arg) {	
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
    }
  return null;
  }
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
  }
//end of cookies function


function SetChangePassword(vAppID,vParam)
{

if (GetCookie('intUserId') == null) 
    {
       document.location.href="/registration/index.htm?trgt=/login/changepassword/&LSID=WS+Literature+Request+USA+%2D+EG&fID=3&ttl=Log+Into+Special+Access+Account&quest=True&custinfo=True&rplBar=True&rtnID=False&ntfy=&orms=False&appid=" + vAppID + "&param1=" + vParam1 + "&doF=CPWD";        
    }
    else 
    {
       if(document.frmChangePassword.txtNewPassword.value != document.frmChangePassword.txtConfirmPassword.value) {
         alert ("Confirm password does not match, please re-enter.");
       } else if((document.frmChangePassword.txtNewPassword.value.length < 7) || (document.frmChangePassword.txtNewPassword.value.length > 20)) {
         alert ("New Password does not meet length requirements, please re-enter.");
       } else {
         var getName = GetCookie('intUserID');        
         document.frmChangePassword.hdnNextCall.value = "ChangePassword";        
         document.frmChangePassword.submit();
       }
    }
}
function ValidateLogin()
{
	//added ajb 5/2/08
	if (document.frmExtranets.txtUserName.value =="")
	{
		alert("Please Enter a User Name");
		return false;
	}
	if (document.frmExtranets.txtUserName.value =="")
	{
		alert("Please Enter a Password");
		return false;
	}
	
    document.frmExtranets.hdnNextCall.value = "VerifyExtranetLogin";
    document.frmExtranets.submit();
}

function ResetPassword()
{
 document.frmExtranets.hdnNextCall.value = "ResetPassword";
 document.frmExtranets.submit();

}

function GotoLogin(vAppID, vParam1)
{
		vAppID += '';
		vParam1 += '';
		
    if (vAppID=='')
    {
        if (document.getElementById("hdnAppID") != null)
        {
            vAppID = document.getElementById("hdnAppID").value;
        }
		}
		if (vParam1=='')
		{        
        if (document.getElementById("hdnParam1") != null)
        {
            vParam1 = document.getElementById("hdnParam1").value;
        }
    }
    document.location.href="/login/index.htm?appid=" + vAppID + "&param1=" +vParam1;
}

 function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }

function omniture_currentRefinement(refineByParent, refineByValue)
{

	//omniture on_click code begin

	s.linkTrackVars = 'prop9';
	s.prop9 = refineByParent + ":" + refineByValue;


	s.tl(this,'o','Current Refinements');

	//omniture on_click code end

}

