// JavaScript Document// popup window function

function winBRopen(theURL, Name, popW, popH, scroll) { // V 1.0
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable=no'
	Win = window.open(theURL, Name, winProp)
	if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }

}


//alternating row color
function alternate(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
     if(i % 2 == 0){ 
       rows[i].className = "color1"; 
     }else{ 
       rows[i].className = "color2"; 
     }       
   } 
 } 
}

//alternating row color 
function alternateB(id){ 
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);   
   var rows = table.getElementsByTagName("tr");   
   for(i = 0; i < rows.length; i++){           
 //manipulate rows 
     if(i % 2 == 0){ 
       rows[i].className = "color1"; 
     }else{ 
       rows[i].className = "color2"; 
     }       
   } 
 } 
}



//product registration drop-down validation; replaced with version 2 below 10/8/09
function valRegForm()
	{
		
	if (document.RegForm.MachineType.options[document.RegForm.MachineType.selectedIndex].value == "" && document.RegForm.OtherMachineType.value == ""){

	window.alert("Please select Machine Type");
	return false;
	}	

	if (document.RegForm.ControlType.options[document.RegForm.ControlType.selectedIndex].value == ""){

	window.alert("Please select Control Type");
	return false;
	}
	
	if (document.RegForm.GaugeType.options[document.RegForm.GaugeType.selectedIndex].value == ""){

	window.alert("Please select Gauge Type");
	return false;
	}
	
	if (document.RegForm.Product.options[document.RegForm.Product.selectedIndex].value == ""){
	window.alert("Please select Product");
	return false;
	}	
	
	var validchars="1234567890ABCDEF";
	var userclr=document.RegForm.PC_MAC_ID.value;
	var usrerr=0;
	for (count = 0; count<=12; count++){
		var digit = userclr.charAt(count).toUpperCase();
		if (validchars.indexOf(digit) == -1)
		{usrerr=1;}
	}


	
	if (document.RegForm.PC_MAC_ID.value.length < 12 || document.RegForm.PC_MAC_ID.value.length > 12 || usrerr !=0)
	{
	window.alert("Please enter valid PC MAC ID");
	return false;
	}
}

// NEW product reg validation (10/8/09 - replaces function above) to include new fields (OtherGaugeType and OtherControlType)
function valRegForm2()
	{
		
	if (document.RegForm.MachineType.options[document.RegForm.MachineType.selectedIndex].value == "" && document.RegForm.OtherMachineType.value == ""){

	window.alert("Please select Machine Type");
	return false;
	}	

	if (document.RegForm.ControlType.options[document.RegForm.ControlType.selectedIndex].value == "" && document.RegForm.OtherControlType.value == ""){

	window.alert("Please select Control Type");
	return false;
	}
	
	if (document.RegForm.GaugeType.options[document.RegForm.GaugeType.selectedIndex].value == "" && document.RegForm.OtherGaugeType.value == ""){

	window.alert("Please select Gauge Type");
	return false;
	}
	
	if (document.RegForm.Product.options[document.RegForm.Product.selectedIndex].value == ""){
	window.alert("Please select Product");
	return false;
	}	
	
	var validchars="1234567890ABCDEF";
	var userclr=document.RegForm.PC_MAC_ID.value;
	var usrerr=0;
	for (count = 0; count<=12; count++){
		var digit = userclr.charAt(count).toUpperCase();
		if (validchars.indexOf(digit) == -1)
		{usrerr=1;}
	}


	
	if (document.RegForm.PC_MAC_ID.value.length < 12 || document.RegForm.PC_MAC_ID.value.length > 12 || usrerr !=0)
	{
	window.alert("Please enter valid PC MAC ID");
	return false;
	}
}


//customer info drop-down validation
function valCustomerForm()
	{
		
	if (document.CustomerForm.State.options[document.CustomerForm.State.selectedIndex].value == "")
	{
	window.alert("Please select State");
	return false;
	}	

}

//info request info drop-down validation
function valInfoForm()
	{
		
	if (document.InfoForm.State.options[document.InfoForm.State.selectedIndex].value == "")
	{
	window.alert("Please select State");
	return false;
	}	

}