//Top Nav 
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);


//The following 2 functions are for the centers navs
	function initClickTabs(rtImgClass, classname, rtArr, rtindex, rtNum, rtSelected) {
		var inc=0
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		for (q=0; q<alltags.length; q++){
			if (alltags[q].className==classname){
				rtArr[inc++]=alltags[q]
			}
		}
		
		if (!document.getElementById) return

		var rtPreLoad = new Array();		
		var rtTempSrc;
		var rtTabs = document.getElementsByTagName('li');

		for (var i = 0; i < rtTabs.length; i++) {
			for (var w = 1; w <= rtNum; w++) {				
				tempnm = rtImgClass + w;				
				if (rtTabs[i].id == tempnm) {
					rtindex.value = w;
					var src = rtTabs[i].className;
					var hsrc = 'lion';

					rtTabs[i].setAttribute('hsrc', hsrc);
					rtTabs[i].setAttribute('tbid', w);
					rtTabs[i].setAttribute('ibid', i);
					if (w == rtSelected) {
						rtTabs[i].className='lion';
						rtindex = i;
					}

					rtTabs[i].onclick = function() {
						rtTempSrc = this.getAttribute('className');
						this.className=this.getAttribute('hsrc');
						ShowContent(this.getAttribute('tbid'), rtNum, rtArr);
						if (rtindex != this.getAttribute('ibid')) {
							rtTabs[rtindex].className='lioff';
							rtindex = this.getAttribute('ibid');
						}
					}	

					
				}
			}

		}
		ShowContent(rtSelected, rtNum, rtArr);
	}
	

	function ShowContent(divOn, numDivs, arrName){
		//get chosen message index (to show it):
		selindex = divOn - 1;
		for (p=0;p<numDivs;p++)
		{
		  if (p == selindex) {
		    arrName[p].style.display="block" //show current message
		  } else {
		    arrName[p].style.display="none" //hide previous message
		  }

		}
	}

//The following function is for the tabbed news nav on community pages
	function initRollTabs(rtImgClass, classname, rtArr, rtindex, rtNum, rtSelected) {
		var inc=0
		var alltags=document.all? document.all : document.getElementsByTagName("*")
		for (q=0; q<alltags.length; q++){
			if (alltags[q].className==classname){
				rtArr[inc++]=alltags[q]
			}
		}
		
		if (!document.getElementById) return

		var rtPreLoad = new Array();		
		var rtTempSrc;
		var rtTabs = document.getElementsByTagName('li');

		for (var i = 0; i < rtTabs.length; i++) {
			for (var w = 1; w <= rtNum; w++) {				
				tempnm = rtImgClass + w;				
				if (rtTabs[i].id == tempnm) {
					rtindex.value = w;
					var src = rtTabs[i].className;
					var hsrc = 'lion';

					rtTabs[i].setAttribute('hsrc', hsrc);
					rtTabs[i].setAttribute('tbid', w);
					rtTabs[i].setAttribute('ibid', i);
					if (w == rtSelected) {
						rtTabs[i].className='lion';
						rtindex = i;
					}

					rtTabs[i].onmouseover = function() {
						rtTempSrc = this.getAttribute('className');
						this.className=this.getAttribute('hsrc');
						ShowContent(this.getAttribute('tbid'), rtNum, rtArr);
						if (rtindex != this.getAttribute('ibid')) {
							rtTabs[rtindex].className='lioff';
							rtindex = this.getAttribute('ibid');
						}
					}	

					
				}
			}

		}
		ShowContent(rtSelected, rtNum, rtArr);
	}


//For forms
function clearInput(){
	document.emailLookUp.email.value='';
}

function submitForm(){
	document.emailLookUp.submit();
}


//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);
}

//Article Email
function appendLocation(theLink) {
    var thisPage = "" + location;
    var bits = thisPage.split("&");
    var s = ""
    for (var i = 0; i < bits.length; i++) {
      s += bits[i] + "^"
    }
    if (s == "") {
      theLink.href = theLink.href + "&refPage=" + thisPage
     } else {
       theLink.href = theLink.href + "&refPage=" + s
    }
    return true;
}

//Share Tools

function shareExpandItTop(type){
 var shareExpandItTop = document.getElementById('shareExpandItBoxTop');
 if(type =="show") {
 shareExpandItTop.className = "expanded";
 } else {
 shareExpandItTop.className = "collapsed";
 }
}

function shareExpandItBtm(type){
 var shareExpandItBtm = document.getElementById('shareExpandItBoxBtm');

 if(type =="show") {
 shareExpandItBtm.className = "expanded";
 } else {
 shareExpandItBtm.className = "collapsed";
 }
}

//Subscription Tools

function subscriptionExpandItTop(type){
 var subscriptionExpandItTop = document.getElementById('subscriptionExpandItBoxTop');

 if(type =="show") {
 subscriptionExpandItTop.className = "expanded";
 } else {
 subscriptionExpandItTop.className = "collapsed";
 }
}

function subscriptionExpandItBtm(type){
 var subscriptionExpandItBtm = document.getElementById('subscriptionExpandItBoxBtm');

 if(type =="show") {
 subscriptionExpandItBtm.className = "expanded";
 } else {
 subscriptionExpandItBtm.className = "collapsed";
 }
}

//Search Nav Bar
var selectedBucketType = '';

function doSearchStuff(){
	var i = 0;
	var searchField = document.getElementById('SearchText');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
	
		for(i=0;i<2;i++){
		if(document.SearchForm.stype[i].checked == true){
			window.location.href  = '/search/' + document.SearchForm.stype[i].value +'?q=' + escape(document.SearchForm.q.value);
		}
	}
	
	return false;
}


function toggleHeaderSearch(id,button){
	var divArray = new Array("radioednnetwork","radioelectronicsindustry");

	var div = "radio" + id;
	var i;

	for(i=0;i<2;i++){

		if (divArray[i] != div){
			if (document.getElementById(divArray[i]).className == 'selected'){
				document.getElementById(divArray[i]).className = "unselected";
			}
		}
		else
		{
			if (document.getElementById(divArray[i]).className == 'unselected'){
				document.getElementById(divArray[i]).className = "selected";
			}
		}//end div
		
	}//end for
	document.SearchForm.stype[button].checked=true;
}

//Search Results
function toggleLayer(sourceElement, elementId)
{
	var element;

	if (document.getElementById)
	{
		// this is the way the standards work
		element = document.getElementById(elementId);
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		element = document.all[elementId];
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		element = document.layers[elementId];
	}

	element.style.display = element.style.display ? '' : 'inline';
	
	sourceElement.innerHTML = element.style.display ? '<img src="/contents/images/zibbArrowLeft.gif" hspace="2" alt="" style="border:0;"/><strong style="text-decoration:none;">less</strong>' : '<strong style="text-decoration:none;">more</strong><img src="/contents/images/zibbArrow.gif" hspace="2" alt="" style="border:0;"/>';
}

function ss(w, id)
{
	window.status = w;
	return true;
}

function cs()
{
	window.status = "";
}
function jump(url)
{
	if (document.images && url)
	{
		if (arguments.length > 1)
		{
			type = arguments[1];
		}
		else
		{
			type = 'result';
		}
	
 		new Image().src = '/contents/images/_jump.gif?url=' + escape(url).replace(/\+/g, '%2B') + '&type=' + type;
	}
	
	return true;
}

function trim(psText) 
{
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}

function booleanOperator(txt) {
  if ((txt=='and') || (txt=='or') || (txt=='not') || (txt=='within') || (txt=='near') || (txt=='atleast'))
    return true
  else
    return false;
}


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);
}


//For User-Generated Forms
function CheckThisForm(ThisForm)
{
var x;
var count;
var vertnum;
var temp;
        
	
	
	if (ThisForm.mail_Title.value == "")
	{
		alert("Title is required.");
		ThisForm.mail_Title.focus();
		return false;
	}
	
	if (ThisForm.mail_Category.value == "")
	{
		alert("Type of press release is required.");
		ThisForm.mail_Category.focus();
		return false;
	}

	if (ThisForm.mail_CompanyName.value == "")
	{
		alert("Your Company Name is required.");
		ThisForm.mail_CompanyName.focus();
		return false;
	}
		
   if ((ThisForm.mail_PubDate.value == "")||(ThisForm.mail_PubDate.value == "mm/dd/yyyy"))
	{
		alert("Publication Date is required.");
		ThisForm.mail_PubDate.focus();
		return false;
   }
   else if (!CheckDate(ThisForm.mail_PubDate.value)) 
	{
		strMsg = "The date is invalid. (format should be MM/DD/YYYY)";		
      alert(strMsg);
		ThisForm.mail_PubDate.focus();
      return false;
	}
	
	ToDay = new Date();
	month1 = ToDay.getMonth()+1;
	day1   = ToDay.getDate();
	if (month1 < 10) month1 = '0'+month1;
        if (day1 <10) day1 = '0'+day1;
	var TodayDate = month1 + '/' + day1 + '/' + ToDay.getFullYear();
	
	/*if ( !CheckDiffDate(TodayDate,ThisForm.mail_PubDate.value) )
	{
		strMsg = "You entered a start date which is earlier than today's date";	
		alert(strMsg);
		ThisForm.mail_PubDate.focus();
      return false;
	}*/
	
	if (ThisForm.mail_Name.value == "")
	{
		alert("Your name is required.");
		ThisForm.mail_Name.focus();
		return false;
	}
	
	if (ThisForm.mail_EmailAddress.value == "")
	{
		alert("Email address is required.");
		ThisForm.mail_EmailAddress.focus();
		return false;
	}
	else if (!ValidEmail(ThisForm.mail_EmailAddress.value)) 
	{
		strMsg = "The Email address you typed is invalid.";		
		alert(strMsg);
		ThisForm.mail_EmailAddress.focus();
      return false;
	}
	
	if (ThisForm.mail_Description.value == "")
	{
		alert("Description is required.");
		ThisForm.mail_Description.focus();
		return false;
   }
   
    if(ThisForm.ihtfwbox.value == "")
	{
      alert("Please enter text for verification question.");
      ThisForm.ihtfwbox.focus();
      return false;
    }
   
}

function CheckDate(sDate) 
{
	var flag;
	var dYear = (new Date());
	var splitString = sDate.split("/");
	var MM = splitString[0];
	var DD = splitString[1];
	var YY = splitString[2];

	dYear = dYear.getYear();
	flag = 1;
   if ((typeof(MM) == 'undefined') || (typeof(DD) == 'undefined') || (typeof(YY) == 'undefined')) {return false;} 

	if (MM.length !== 2) {return false;}
	if (DD.length !== 2) {return false;}
	if (YY.length !== 4) {return false;}
	if ( isNaN(MM) || isNaN(DD) || isNaN(YY) ) {return false;}
	if ( MM.charAt(0) == '0' ) { MM = MM.substring(1,2); }
	if ( DD.charAt(0) == '0' ) { DD = DD.substring(1,2); }
	
	var IntMM = parseInt(MM);
	var IntDD = parseInt(DD);
	if (IntDD > 0)
	{
		if (IntDD < 29) 
			{flag = 0;}
		else if ( ( IntMM==1 || IntMM==3 || IntMM==5 || IntMM==7 || IntMM==8 || IntMM==10 || IntMM==12 ) && IntDD<32 ) 
			{flag = 0;}
		else if ( ( IntMM==4 || IntMM==6 || IntMM==9 || IntMM==11 ) && IntDD<31 ) 
			{flag = 0;}
		else if ( IntMM==2 && parseInt(YY / 4) == parseFloat(YY / 4) && IntDD==29 ) {flag = 0;}
	}
	if (flag == 1) {return false;}
	return true;   
}


function CheckDiffDate(sDate,eDate) 
{
	var splitString = sDate.split("/");
	var Start = splitString[2] + splitString[0] + splitString[1];
	splitString = eDate.split("/");
	var End = splitString[2] + splitString[0] + splitString[1];
	
	if ( Start>End ) {return false;}
	return true;
}


function ValidEmail(emailin) {
	var invalidChars = " /:,;";
	var invalidChar;
	if (emailin == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		invalidChar = invalidChars.charAt(i)
		if (emailin.indexOf(invalidChar,0) != -1) {
			return false;
		}
	}
	atPos = emailin.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (emailin.indexOf("@",atPos+1) != -1) {
		return false;
	}
	periodPos = emailin.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > emailin.length)	{
		return false;
	}
	return true;					
}

/* Privacy Pop up 11-16-2007
var myDate=new Date()
var today = new Date()
myDate.setFullYear(2008,1,1)
 
if ((!getCookie('EDN-PrivacyPolicy')) && (today < myDate))
{
makeCookie('EDN-PrivacyPolicy','Y',60);
window.open('/index.asp?layout=articleBody&articleID=CA6501955&cache=FALSE', 'privacy_policy_popup', 'width=298, height=270, resizable=no, scrollbars=no' ); 
}
*/

//Resource Center Zibb
function doSearchRC(){
	var i = 0;
	var searchField = document.getElementById('SearchTextRC');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
	
		//for(i=0;i<3;i++){
		//if(document.SearchForm.stype[i].checked == true){
			window.location.href  = '/index.asp?layout=SearchResultsRC&content=SiteResourceCenter&q=' + escape(document.SearchFormRC.q.value);
		//}
	//}
	
	return false;
}

function doSearchRC2(){
	var i = 0;
	var searchField = document.getElementById('SearchTextRC2');

	switch (searchField.value)
	{
		case "":
		case "Enter Keywords":
			window.alert("Please enter a search term.");
			searchField.focus();
			return false;
	}
	
		//for(i=0;i<3;i++){
		//if(document.SearchForm.stype[i].checked == true){
			window.location.href  = '/index.asp?layout=SearchResultsRC&content=SiteResourceCenter&q=' + escape(document.SearchFormRC2.q.value);
		//}
	//}
	
	return false;
}
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}