<!--
//brings popup to top
window.focus();

//a copy of this function exists on the servers at Allegis (dc.allegis.com) 
//and are used in Find a Distributor on the Internet plus various applications 
//on the Extranet (e.g. Competitive Price Support).  
//Testing and implementing changes to this function must be coordinated with Allegis.

function ContactUsPopupSize(strFormKey)
{
    if(strFormKey == "FNYAM" || strFormKey == "FNYAS" || strFormKey == "FNYEUR" || strFormKey == "FINDDC" || strFormKey == "FINDDCSR" || strFormKey == "FINDDCPR")
    {
        return "scrollbars=yes,resizable=yes,height=500,width=800,top=75,left=75";
    }
    else
    {
        return "scrollbars=yes,resizable=yes,height=500,width=580,top=75,left=75";
    }
}

function ContactUsPopup(strFormKey, strAppText, strHiddenText)
	{
	var strURL, strCallingPage;
	
	strCallingPage = location.href;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = "/applications/Contact/Contact.asp?key=" + escape(strFormKey) + "&apptext=" + escape(strAppText) + "&hiddentext=" + escape(strHiddenText) + "&caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", ContactUsPopupSize(strFormKey));
	}
	
//added 1/24/2002 stj
function ContactUsPopup2(strFormKey, strAppText, strHiddenText)
	{
	var strURL, strCallingPage;
	
	strCallingPage = location.href;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = strDCC_ROOT + "/applications/Contact/Contact.asp?key=" + escape(strFormKey) + "&apptext=" + escape(strAppText) + "&hiddentext=" + escape(strHiddenText) + "&caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", ContactUsPopupSize(strFormKey));
	}
	
function ContactUsPopupWcm(strFormKey)
{
    ContactUsPopup(strFormKey, "", "");
}
	
function ContactUsPopupGlobalTools()
	{
	var strURL, strCallingPage;
	
	strCallingPage = location.href;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = strDCC_ROOT + "/content/support/contact_us.aspx?popup=true&caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", "scrollbars=yes,resizable=yes,height=500,width=800,top=75,left=75");
	}
	
function ContactUsPopupAskExpert()
	{
	var strURL, strCallingPage;
	
	strCallingPage = location.href;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = strDCC_ROOT + "/applications/Contact/ask_an_expert_menu.asp?caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", "scrollbars=yes,resizable=yes,height=500,width=580,top=75,left=75");
	}
	
function ContactUsPopup2Step()
	{
	var strURL, strCallingPage;
	
	strCallingPage = location.href;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = "/content/support/contact_us.aspx?popup=true&caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", "scrollbars=yes,resizable=yes,height=500,width=800,top=75,left=75");
	}
	
function ContactUsPopupFromLinkTo(strCallingPage)
	{
	var strURL;
	
	if (! window.focus)
		{
		return true;
		}
	strURL = "/content/support/contact_us.aspx?popup=true&caller=" + escape(strCallingPage);
	window.open(strURL, "ContactUS", "scrollbars=yes,resizable=yes,height=500,width=800,top=75,left=75");
	}
	
//ADDED from menu.js
function show(id) {
	if (document.all)
		document.all[id].style.visibility='visible';
	else if (document.layers)
		document.layers[id].visibility='show';
	else 
		document.getElementById(id).style.visibility='visible';
}

function hide(id) {
	if (document.all)
		document.all[id].style.visibility='hidden';
	else if (document.layers)
		document.layers[id].visibility='hide';
	else 
		document.getElementById(id).style.visibility='hidden';
}

//Will do display:none for IE
function show2(id) {
	if (document.all)
		document.all[id].style.display='';
	else if (document.layers)
		document.layers[id].visibility='show';
	else 
		document.getElementById(id).style.display='';
}

function hide2(id) {
	if (document.all)
		document.all[id].style.display='none';
	else if (document.layers)
		document.layers[id].visibility='hide';
	else 
		document.getElementById(id).style.display='none';
}


function nsbg() {
}

function checkObject(strThat) {
	if (is_ie) {
		if (document.all[strThat]) return true 
	}
	else if (is_nav) {
		if (is_nav6) {
			if (document.getElementById(strThat)) return true 
		}
		else {
			if (document.layers[strThat]) return true 
		}
	}
	return false
}

function getObject(strThat) {
	if (is_ie)
		return document.all[strThat]
	else if (is_nav)
		if (is_nav6) 
			return document.getElementById(strThat)
		else
			return document.layers[strThat]
}

function getStyle(strThat) {
	var objTemp = getObject(strThat)
	if (is_ie || is_nav6)
		return objTemp.style
	else if (is_nav)
		return objTemp
}

function getObjStyle(objThat) {
	if (is_ie || is_nav6)
		return objThat.style
	else if (is_nav)
		return objThat
}

function callPopup(mylink, windowname, strStyle)
	{
	var href;
	
	if (! window.focus)
		{
		return true;
		}
	
	if (typeof(mylink) == "string")
		{
		href = mylink;
		}
	else
		{
		href = mylink.href;
		}
	window.open(href, windowname, strStyle);
	}

function callParent(mylink, blnKeepOpen)
	{
	var pos, strLink;
	
	//Check if popup=true is in link and remove
	pos = mylink.indexOf("popup=true");
	if (pos >= 0)
		{
		mylink = mylink.substring(0, pos - 1);
		}
	
	//If more than 1 popup open, parent is a popup, append popup=true
	if (window.name.indexOf("1") >= 0)
		{
		if (mylink.indexOf("?") >=0)
			{
			strLink = myLink + "&popup=true";
			}
		else
			{
			strLink = mylink + "?popup=true";
			}
		}
	else
		{
		strLink = mylink;
		}
	
	window.opener.location.href = strLink;
	
	if (!blnKeepOpen)
		{
		window.close();
		}
	}

	
function IndustryHome_onclick(parmLocalePath, parmError)
{
	var field, field_value;
	
	field = document.frmIndustry.cboIndustry;
	field_value = field[field.selectedIndex].value;

	
	if (field_value != "INIT")
	{
		location.href = strDCC_ROOT + parmLocalePath + field_value;
	}
	else
	{
		alert(parmError);
	}
}

function findDataSheetsGoOnClick()
	{
	var ctry_field, ctry_value;
	var search_field, search_value;
	
	ctry_field = document.frmFindDataSheet.Country;
	ctry_value = ctry_field[ctry_field.selectedIndex].value;
	
	search_value = document.frmFindDataSheet.searchfor.value;
	
	if(ctry_value != "INIT" && search_value != "")
		{
		document.frmFindDataSheet.submit();
		}
	else
		{
		alert("You must select a country and product name or number.");
		}
	}
	
function searchOnGo()
	{
	if(document.sitesearch.txtSearch.value == "Search for..." || document.sitesearch.txtSearch.value == "")
		{
		alert("Please type what you would like to search for and then click Go.");
		}
	else
		{
		document.sitesearch.submit();
		}
	}
	
function IsEnterKey(event)
{
	var code = 0;
	var NS4;
	NS4 = (document.layers) ? true : false;
	
	if (NS4)
	{
		code = event.which;
	}
	else
	{
		code = event.keyCode;
	}
		
	if (code==13)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//SO YOU CAN CANCEL Suppress the enter key getting clicked
function SuppressEnter(event)
{
	if(IsEnterKey(event))
	{
		event.cancelBubble = true;
	}
}

function preferences_onclick(strJump)
{
	currentUrl = location.href;
	
	if(currentUrl.indexOf("popup=true") >= 0)
	{
		window.opener.location.href = "/_mem_bin/membership/mypreferences.asp?jump=" + strJump + "&dest=" + escape(window.opener.location.href);;
		window.close();
	}
	else
	{
		location.href = "/_mem_bin/membership/mypreferences.asp?jump=" + strJump + "&dest=" + escape(currentUrl);
	}
}

function SubBox_onclick()
{
	var useThisEmail, strSubscriptionCde;
	
	if(document.getElementsByName("frmSubscription").length > 1)
	{
		var email = document.frmSubscription(0).txtEmail.value;
		var email2 = document.frmSubscription(1).txtEmail.value;
		
		if (email != ENTEREMAIL)
		{
			useThisEmail = email;
			strSubscriptionCde = document.frmSubscription(0).subscriptionCode.value;
		}
		else if (email2 != ENTEREMAIL)
		{
			useThisEmail = email2;
			strSubscriptionCde = document.frmSubscription(1).subscriptionCode.value;
		}
		else
		{
			useThisEmail = "";
		}
	}
	else
	{
		var useThisEmail = document.frmSubscription.txtEmail.value;
		strSubscriptionCde = document.frmSubscription.subscriptionCode.value;
	}
	
	if (useThisEmail == ENTEREMAIL)
	{
		useThisEmail = "";
	}
	
	if (emailCheck(useThisEmail))
	{
		WriteSpotlightTag("esubmit", "molykote");
		var newLocation = "location.href = \"" + MYROOT + "/_mem_bin/membership/membershipsave.asp?do=SUB&subtype=" + strSubscriptionCde + "&email=" + encodeURIComponent(useThisEmail) + "&dest=" + escape(DESTURL) + "\";";
		setTimeout(newLocation, 500);
	}
}

function WriteSpotlightTag(category, type)
{
	if(blnAddSpotlight)
	{
		var axel = Math.random()+"";
		var a = axel * 10000000000000;
		var start = "http";
		if(blnHttps)
		{
			start = "https";
		}
		else
		{
		}
		document.write('<IMG SRC="' + start + '://ad.doubleclick.net/activity;src=756405;type=' + type + ';cat=' + category + ';ord=1;num='+ a + '?" WIDTH=1 HEIGHT=1 BORDER=0>');
	}
	else
	{
		//Internal - Do Nothing
	}
}

function CheckForEnter(event)
{ 	
	if(IsEnterKey(event))
	{
		SubBox_onclick();
	}
}

function ValidateSubComponent(event)
{
	event.returnValue = false;
	SubBox_onclick();
}

function emailCheck(emailStr) 
	{
	//The following pattern is used to check if the entered e-mail address
	//fits the user@domain format.  It also is used to separate the username
	//from the domain.
	var emailPat=/^(.+)@(.+)$/;
	
	//ADDED STJOBE 12/05/2002
	//Got this regular expression from web, had to modify to add more special characters that are allowed
	
	//The following string represents the pattern for matching all special
    //characters.  We don't want to allow special characters in the address. 
    //These characters include ( ) < > @ , ; : \ " . [ ]()
	var specialChars="<>@;:=\\.\\[\\](),";
	
	//The following string represents the range of characters allowed in a 
    //username or domainname.  It really states which chars aren't allowed.
	var validChars="\[^\\s" + specialChars + "\]";
	
	//The following pattern applies if the "user" is a quoted string (in
    //which case, there are no rules about which characters are allowed
    //and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
    //is a legal e-mail address.
	var quotedUser="(\"[^\"]*\")";
	
	//The following pattern applies for domains that are IP addresses,
	//rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
    //e-mail address. NOTE: The square brackets are required.
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
	//The following string represents an atom (basically a series of
    //non-special characters.)
	var atom=validChars + '+';
		
	//The following string represents one word in the typical username.
	//For example, in john.doe@somewhere.com, john and doe are words.
	//Basically, a word is either an atom or quoted string.
	var word="(" + atom + "|" + quotedUser + ")";

	//The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

	//The following pattern describes the structure of a normal symbolic
    //domain, as opposed to ipDomainPat, shown above.
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

	//Finally, let's start trying to figure out if the supplied address is valid.

	//Begin with the coarse pattern to simply break up user@domain into
	//different pieces that are easy to analyze.
	var matchArray = emailStr.match(emailPat);

	if (matchArray==null) 
		{
		//Too many/few @'s or something; basically, this address doesn't
        //even fit the general mould of a valid e-mail address.
		alert(cstEmailAddIncorrect);
		return false;
		}
		
	var user=matchArray[1];
	var domain=matchArray[2];

	// See if "user" is valid 
	//if (user.match(userPat)==null) 
	//	{
	//	// user is not valid
	//	alert(cstUsernameInvalid);
	//	return false;
	//	}

	//if the e-mail address is at an IP address (as opposed to a symbolic
    //host name) make sure the IP address is valid.
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
		{
		//this is an IP address
		for (var i=1;i<=4;i++) 
			{
			if (IPArray[i]>255) 
				{
				alert(cstDestIPAddInvalid);
				return false;
				}
			}
		return true;
		}

	//Domain is symbolic name
	var domainArray=domain.match(domainPat);
	if (domainArray==null) 
		{
		alert(cstDomainNameInvalid);
		return false;
		}

	//Domain name seems valid, but now make sure that it ends in a
    //three-letter word (like com, edu, gov) or a two-letter word,
    //representing country (uk, nl), and that there's a hostname preceding 
    //the domain or country.

	//Now we need to break up the domain to get a count of how many atoms
    //it consists of.
	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4) 
		{
		//STJOBE 1/28/2002 -- changed to allow 4 in domain instead of 3 (.name, .info) 160845PM
		//the e-mail address must end in a two letter or three letter or four letter word.
		alert(cstInvalidEmailAddrEnd);
		return false;
		}

	//Make sure there's a host name preceding the domain.
	if (len<2) 
		{
		var errStr=cstMissingHostName;
		alert(errStr);
		return false;
		}
		
	
	//STJOBE -- ADDED 12/5/2002 -- To validate a different way -- eliminates more special characters.
	//May want to just use this, but not sure...
	var validAddress = new RegExp("^([a-zA-Z0-9!\\\"#\\$%&'\\*\\+_\\\-\\./]+)@((\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");

	if(!validAddress.test(emailStr))
		{
		alert(cstInvalidSpecialChar);
		return false;
		}

	//If we've gotten this far, everything's valid!
	
	return true;
	}
	
function ExpandSelection(cid) {
    var selections = document.body.getElementsByTagName("tr")
    for(var i=0; i < selections.length; i++) {
        if ( selections[i].id == cid )
            selections[i].style.display = (selections[i].style.display!="")? "" : "none"
        else
            if ( selections[i].id.substring(0,9) == "Selection" )
                selections[i].style.display = "none"
    }
}
 
function mOvr(src) {
 src.style.cursor = "hand"
 src.bgColor = "white"
 src.getElementsByTagName("A")[0].style.color = "#006563"
}
 
function mOut(src) {
 src.style.cursor = "default"
 src.bgColor = "#339999"
 src.getElementsByTagName("A")[0].style.color = "white"
}
 
function mClk(src) { 
   src.getElementsByTagName("A")[0].click()
}

//Validate search input field on msds/pds search right column block
function SDSGo_Click()
{
	if(document.frmFindDataSheet.searchfor.value == "" || document.frmFindDataSheet.searchfor.value == cstFindDSInstruct)
	{
		alert(cstSDSPDSValidationMsg);
		return false;
	}
	return true;
}

function ImageSelectorScrollLeft()
{	
	var imgArray, nextImageSrc, nextImageAlt, nextImageClass;
	var holdImageSrc, holdImageAlt, holdImageClass;
	var i;
	imgArray = document.SelectorImage;
	
	nextImageSrc = imgArray[0].src;
	nextImageClass = imgArray[0].className;
	nextImageAlt = imgArray[0].alt;
	
	for(i=imgArray.length - 1;i>=0;i--)
	{
		holdImageSrc = imgArray[i].src;
		holdImageClass = imgArray[i].className;
		holdImageAlt = imgArray[i].alt;
		
		imgArray[i].src = nextImageSrc;
		imgArray[i].className = nextImageClass;
		imgArray[i].alt = nextImageAlt;
		
		nextImageSrc = holdImageSrc;
		nextImageClass = holdImageClass;
		nextImageAlt = holdImageAlt;
	}
}

function ImageSelectorScrollRight()
{
	var imgArray, nextImageSrc, nextImageAlt, nextImageClass;
	var holdImageSrc, holdImageAlt, holdImageClass;
	var i;
	imgArray = document.SelectorImage;
	
	nextImageSrc = imgArray[imgArray.length-1].src;
	nextImageClass = imgArray[imgArray.length-1].className;
	nextImageAlt = imgArray[imgArray.length-1].alt;
	
	for(i=0;i<imgArray.length;i++)
	{
		holdImageSrc = imgArray[i].src;
		holdImageClass = imgArray[i].className;
		holdImageAlt = imgArray[i].alt;
		
		imgArray[i].src = nextImageSrc;
		imgArray[i].className = nextImageClass;
		imgArray[i].alt = nextImageAlt;
		
		nextImageSrc = holdImageSrc;
		nextImageClass = holdImageClass;
		nextImageAlt = holdImageAlt;
	}				
}

function ImageSelectorHandleClick(object, clickedIndex)
{
	var clickedSrc, currentLocation, temp;

	clickedSrc = object.src;
	
	currentLocation = location.href;
	
	temp = currentLocation.indexOf("?");
	
	if(temp >= 0)
	{
		//parse off ? and after
		currentLocation = currentLocation.substring(0, temp);
	}
	
	location.href = currentLocation + "?src=" + escape(clickedSrc) + "&index=" + clickedIndex;	
}

//-->

