// JavaScript Document

// MENU JS NEEDED FOR < IE 7
activateMenu = function(nav) {
	if (document.all && document.getElementById(nav).currentStyle) {  
		var navroot = document.getElementById(nav);
		var lis=navroot.getElementsByTagName("LI");  
		for (i=0; i<lis.length; i++) {
			if(lis[i].lastChild.tagName=="UL"){
				lis[i].onmouseover=function() {		
				   this.lastChild.style.display="block";
				}
				lis[i].onmouseout=function() {                       
					this.lastChild.style.display="none";
				}
			}
		}
	}
}

window.onload= function(){
   activateMenu('nav');  
}


// PRINT FUNCTION
function PrintThisPage() 
{ 
	 var thisDate = new Date();
	 var thisYear=thisDate.getYear();
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,resizable=yes,"; 
       sOption+="scrollbars=yes,width=630,height=500,left=100,top=25"; 

   var sWinHTML = document.getElementById('main_content_td').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><head><LINK href=style/meritec_main.css rel=Stylesheet><style>tfoot { display: table-footer-group; }</style></head><body><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><thead><tr><th width=100%></thead><TFOOT><TR><td align=\"center\"><br><br><br><br><nobr>888-MERITEC (888-637-4832) or (440) 354-3148</nobr><br><nobr>www.meritec.com • <a href=\"mailto:info@meritec.com\">info@meritec.com</a></nobr><br><nobr>&copy;1997-' + thisYear + ' Meritec. All Rights Reserved.</nobr></TFOOT><tbody><tr><td>'); 
       winprint.document.write(sWinHTML);
       winprint.document.write('</td></tr></tbody></table>');           
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}

function StopTimer(){
	window.clearInterval(pic_timer);
}

function ResumeTimer(){
	pic_timer=window.setInterval("picflip()",10);
}
		
function picflip(){
	
if (count>0 && count<=100){
		//image_holder.filters.alpha.opacity +=1;
		
	}else if (count>100 && count<=300){
	}else if (count>300 && count<=450){
		//image_holder.filters.alpha.opacity -=1;
		if (count == 401){
			if (ssNum < image_array.length){
				document.getElementById("image_holder").innerHTML="<a href='" + link_array[ssNum] + "'><image oncontextmenu='return false;'  border='0' src='images/" + image_array[ssNum] + "' width='275' height='206'></a>";
				ssNum++;
			}else{
				ssNum=1;
				document.getElementById("image_holder").innerHTML="<a href='" + link_array[0] + "'><image oncontextmenu='return false;'  border='0' src='images/" + image_array[0] + "' width='275' height='206'></a>";
			}
		}
	
	}else {
		
		count=0;

	}
 count++;
}

// ADD FAVORITE ON LEFT SIDENAV
function addFavorite(){
	if (document.all)
		window.external.AddFavorite(location.href, document.title);
	else if (window.sidebar)
		window.sidebar.addPanel(document.title, location.href, "")
}

// EMAIL ADDRESS ERROR ON LEFTNAV OPTIN
function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) {
			alert('Please enter a valid email address');return false
		} else {
			return true
		}
	}
}

// SEARCH FUNCTION FOR CATNAV IN LEFT SIDENAV
function getRadioValue(control) {
	for (var i = 0; i < control.length; i++) {
		if (control[i].checked) {
			return control[i].value;
		}
	}
	return null;
}

function ctlLeftNavSearch_OnClick() {
 var url;
 var theform = document.LeftNavSearch;
 
 if (theform.keyword.value.length < 2) {
  	alert('Please enter at least two characters.');
  	theform.keyword.focus();
 } else {
	var iIndex = theform.ddlLeftNavSearchType.selectedIndex;
	var sSearchType = getRadioValue(theform.ddlLeftNavSearchType);

	if (sSearchType == '3') {
		url = 'http://www.meritec.com/search/search.php';
		url += '?query_string=' + escape(theform.keyword.value);
	} else {
		// Version 2.7 release
		// 1. using default Domain, like "orientalmotor.thomasnet.com" in our sample 
		// 2. using root category shortName, like "all-categories" in our sample
		url = "http://meritec.thomasnet.com/keyword/all-categories?&plpver=10&key=all&keycateg=100"
		url += "&SchType=" + sSearchType;
		url += "&keyword=" + escape(theform.keyword.value);
		url += "&refer=" + escape(document.location.href);
	}
	document.location.href = url;
 }			
}	

function showSelects() {
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}

function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}
