

//this will switch all units to mm if any mm unit is selected
function toMillimeters(){
	document.getElementById('height_unit_mm').checked= true
	document.getElementById('length_unit_mm').checked= true 
	document.getElementById('width_unit_mm').checked= true
	
	document.getElementById('height_unit_in').checked= false
	document.getElementById('length_unit_in').checked= false
	document.getElementById('width_unit_in').checked= false
        
}
//this will switch all units to inches if any inches unit is selected 
function toInches(){
	document.getElementById('height_unit_mm').checked= false
	document.getElementById('length_unit_mm').checked= false
	document.getElementById('width_unit_mm').checked= false
	
	document.getElementById('height_unit_in').checked= true
	document.getElementById('length_unit_in').checked= true
	document.getElementById('width_unit_in').checked= true
}


<!-- Begin
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=200,left = 50,top = 50');");
	}
	
	function sendData(sortColumn){
	var partList = ''
	var loopNo = 0
	for (i=0;i<document.form1.compare.length;i++) {
	if (document.form1.compare[i].checked) {
	loopNo = loopNo + 1
	partList = partList +'&part' + loopNo + '=' + document.form1.compare[i].value
	}
	}
	location.href="finderpower.cfm?mode=post&sort=" + sortColumn + partList
}

function getURL(){
	var regexS = "[\\?&]"+ "part1"+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results != null ){
	//alert(results[1])
	document.getElementById(results[1]).checked = true;
	}
	
	var regexS = "[\\?&]"+ "part2"+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results != null ){
	document.getElementById(results[1]).checked = true;
	}
	var regexS = "[\\?&]"+ "part3"+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results != null ){
	document.getElementById(results[1]).checked = true;
	}
	var regexS = "[\\?&]"+ "part4"+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results != null ){
	document.getElementById(results[1]).checked = true;
	}
}

//initial checkCount of zero
var checkCount=0
//maximum number of allowed checked boxes
var maxChecks=4

function setChecks(obj){
	//increment/decrement checkCount
	if(obj.checked){
	checkCount=checkCount+1
	}else{
	checkCount=checkCount-1
	}
	//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert
	if (checkCount>maxChecks){
	obj.checked=false
	checkCount=checkCount-1
	alert('You may select up to '+maxChecks+' parts for comparison')
	}
}
	// End -->
	
	function validateFields(oForm) {
		//alert('hello');
		if((trim(oForm.frequency.value)=="")||(!isFloat(oForm.frequency.value))){
			alert('Please enter a numeric frequency value.');
			oForm.frequency.focus();
			document.getElementById('frequency').style.border = '1px solid #FF0000';
			
			return false;
		}
		if((trim(oForm.L.value)=="")||(!isFloat(oForm.L.value))){
			alert('Please enter a numeric inductance value.');
			document.getElementById('L').style.border = '1px solid #FF0000';
			oForm.L.focus();
			return false;
		}
		if(trim(oForm.acurrent.value) != ""){
			if(!isFloat(oForm.acurrent.value)){
				alert('Please enter a numeric current value');
				document.getElementById('acurrent').style.border = '1px solid #FF0000';
				oForm.acurrent.focus();
				return false;
			}
		}
		if(trim(oForm.dcr.value) != ""){
			if(!isFloat(oForm.dcr.value)){
				alert('Please enter a numeric DCR value');
				document.getElementById('dcr').style.border = '1px solid #FF0000';
				oForm.dcr.focus();
				return false;
			}
		}
		if(trim(oForm.srf.value) != ""){
			if(!isFloat(oForm.srf.value)){
				alert('Please enter a numeric SRF value');
				document.getElementById('srf').style.border = '1px solid #FF0000';
				oForm.srf.focus();
				return false;
			}
		}
		if(trim(oForm.length.value) != ""){
			if(!isFloat(oForm.length.value)){
				alert('Please enter a numeric length value');
				document.getElementById('alength').style.border = '1px solid #FF0000';
				oForm.length.focus();
				return false;
			}
		}		
		if(trim(oForm.width.value) != ""){
			if(!isFloat(oForm.width.value)){
				alert('Please enter a numeric width value');
				document.getElementById('awidth').style.border = '1px solid #FF0000';
				oForm.width.focus();
				return false;
			}
		}
		if(trim(oForm.height.value) != ""){
			if(!isFloat(oForm.height.value)){
				alert('Please enter a numeric height value');
				document.getElementById('aheight').style.border = '1px solid #FF0000';
				oForm.height.focus();
				return false;
			}
		}
		return true;
	}

function validatePower(oForm) {
		//alert('hello');
		if((trim(oForm.frequency.value)=="")||(!isFloat(oForm.frequency.value))){
			alert('Please enter a numeric frequency value.');
			oForm.frequency.focus();
			document.getElementById('frequency').style.border = '1px solid #FF0000';
			return false;
		}
		if((trim(oForm.L.value)=="")||(!isFloat(oForm.L.value))){
			alert('Please enter a numeric inductance value.');
			document.getElementById('L').style.border = '1px solid #FF0000';
			oForm.L.focus();
			return false;
		}
		if(trim(oForm.acurrent.value) != ""){
			if(!isFloat(oForm.acurrent.value)){
				alert('Please enter a numeric current value');
				document.getElementById('acurrent').style.border = '1px solid #FF0000';
				oForm.acurrent.focus();
				return false;
			}
		}
		if(trim(oForm.dcr.value) != ""){
			if(!isFloat(oForm.dcr.value)){
				alert('Please enter a numeric DCR value');
				document.getElementById('dcr').style.border = '1px solid #FF0000';
				oForm.dcr.focus();
				return false;
			}
		}
		if(trim(oForm.length.value) != ""){
			if(!isFloat(oForm.length.value)){
				alert('Please enter a numeric length value');
				document.getElementById('alength').style.border = '1px solid #FF0000';
				oForm.length.focus();
				return false;
			}
		}		
		if(trim(oForm.width.value) != ""){
			if(!isFloat(oForm.width.value)){
				alert('Please enter a numeric width value');
				document.getElementById('awidth').style.border = '1px solid #FF0000';
				oForm.width.focus();
				return false;
			}
		}
		if(trim(oForm.height.value) != ""){
			if(!isFloat(oForm.height.value)){
				alert('Please enter a numeric height value');
				document.getElementById('aheight').style.border = '1px solid #FF0000';
				oForm.height.focus();
				return false;
			}
		}
		return true;
	}

	
   function isFloat(inputString){
	  if(!isNaN(parseFloat(inputString))){
		  return true;
	  }else{
		  return false;
	  }
   }


	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}