//CSS Dropdown Menu
sfHover = function() { 
	var sfEls = document.getElementById("topnav").getElementsByTagName("li"); 
	for (var i=0; i<sfEls.length; i++) { 
		sfEls[i].onmouseover=function() { 
			this.className+=" sfhover"; 
		} 

		sfEls[i].onmouseout=function() { 
			this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); 
		} 
	} 
} 
if (window.attachEvent) window.attachEvent("onload", sfHover);


//Search and InfoLink Search
function checkSearch () 
{
  if (document.SearchForm.text.value == "")
  {
    window.alert("Please enter a text value to be searched for.");
    return false;
  }
  with (window.document.SearchForm)
  {
	if (document.SearchForm.content[0].checked==true){
		return true;
	}else{
		document.SearchForm.text.value = trim(document.SearchForm.text.value.toLowerCase());
		window.location.href = "http://www.rbi-infolink.com/infolinksearch/aspx/ResultsFrame.aspx?pub=EC&lead_source=search&isn=" + document.SearchForm.text.value;
		return false;
	}
  }
}

function trim(psText) {
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}

function stripQts2(name){
var newName = "";
var test = name.split(unescape("%27%27")); //split the field on ascii code for double ''
for(i=0;i<test.length;i++){
	if(i!=(test.length - 1)){
		
		newName = newName + test[i] + "'"  // put it back together with an "'" 
	}
	else{
		newName = newName + test[i] // make sure end of string has no "'"
	}
}
	userQuery = newName;
}

function replaceQuote(name){
var tempQuery=name
userQuery = "";

for (i = 0; i < tempQuery.length; i++)
  if ((tempQuery.charAt(i)=='%') &&
     (tempQuery.charAt(i+1)=='2') &&
     (tempQuery.charAt(i+2)=='2'))
       {userQuery = userQuery + '&quot;';
        i=i+2;
       }
  else
       {if (tempQuery.charAt(i)=="+")
	     userQuery = userQuery + " "
		else
		 userQuery = userQuery + tempQuery.charAt(i);
       }

userQuery=unescape(userQuery);
stripQts2(userQuery);
document.write(userQuery);
}


//Cookies
function makeCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function deleteCookie(name)
{
	makeCookie(name,"",-1);
}


// Digi-Key
function fGetAct(schfrm)
{
	var fm = ifLog.document.frmLog;
	if (schfrm.name == "Sform")
	{
		//Digi Key Search
		fm.SOURCE.value = "DKS";
		fm.SCHTXT.value = schfrm.Keywords.value;
	}
	else
	{
		//OnlineComponents Search
		fm.SOURCE.value = "OCS";
		fm.SCHTXT.value = schfrm.pn.value;
	}
	fm.submit();
}


// Product Search
function searchProductCategory() {
 var lsCategory=getSelectValue('ProductDatabase','category');
 window.location='index.asp?layout=productDbResults&category='+lsCategory;
}

function getSelectValue(psFormName, psFieldName) {
 return eval('document.' + psFormName + '.' + psFieldName + '.options[document.' + psFormName + '.' + psFieldName + '.selectedIndex].value');
}

function changeURL() {
	var urls = document.pdsearch2.communities;
	location= urls.options[urls.selectedIndex].value
}
