function orientationCheck(orientation){
	if(orientation == 1 && document.myform.series.options[document.myform.series.selectedIndex].value != 'MDP' && (document.myform.series.options[document.myform.series.selectedIndex].value == 'MRP' || document.myform.series.options[document.myform.series.selectedIndex].value == 'MSP')){
		document.getElementById('locationRow').style.visibility = 'visible';
		if(document.myform.interface.options[document.myform.interface.selectedIndex].value == '01'){
			document.myform.location.options.length = 3;
			document.myform.location.options[2] = new Option('None','None');
		}
		if(document.myform.interface.options[document.myform.interface.selectedIndex].value == '02'){
			document.myform.location.options.length = 2;
		}
	}
	else if(orientation == 0 || document.myform.series.options[document.myform.series.selectedIndex].value == 'MDP' || document.myform.series.options[document.myform.series.selectedIndex].value == 'MMP'){
		document.getElementById('locationRow').style.visibility = 'hidden';
		document.myform.location.selectedIndex = 0;
	}	
}
function resetCheck(){
	document.myform.modelNumber.value = '';
	document.myform.spec.style.visibility = 'hidden';
	if(document.myform.lowCost.checked == true){
		document.getElementById('interfaceRow').style.visibility = 'hidden';
		document.getElementById('locationRow').style.visibility = 'hidden';
	}
	if(!document.myform.lowCost.checked && document.myform.series.options[document.myform.series.selectedIndex].value != 'MDP'){
		document.getElementById('interfaceRow').style.visibility = 'visible';
		if(document.myform.orientation.options[document.myform.orientation.selectedIndex].value == 1){
			document.getElementById('locationRow').style.visibility = 'visible';
		}
	}
}
function formCheck(){
	if(document.myform.series.options[document.myform.series.selectedIndex].value == ' '){
		document.myform.modelNumber.value = '';
		document.myform.go.style.visibility = 'hidden';
		document.myform.spec.style.visibility = 'hidden';
		document.myform.voltage.length = 1;
		document.myform.voltage.selectedIndex = 0;
		document.myform.current.length = 1;
		document.myform.current.selectedIndex = 0;
		document.myform.plugType.length = 1;
		document.myform.plugType.selectedIndex = 0;
		document.myform.config.length = 1;
	}
	else if(document.myform.voltage.options[document.myform.voltage.selectedIndex].value == ' '){
		document.myform.modelNumber.value = '';
		document.myform.go.style.visibility = 'hidden';
		document.myform.spec.style.visibility = 'hidden';
		document.myform.current.length = 1;
		document.myform.current.selectedIndex = 0;
		document.myform.plugType.length = 1;
		document.myform.plugType.selectedIndex = 0;
		document.myform.config.length = 1;
	}
	else if(document.myform.current.options[document.myform.current.selectedIndex].value == ' '){
		document.myform.modelNumber.value = '';
		document.myform.go.style.visibility = 'hidden';
		document.myform.spec.style.visibility = 'hidden';
		document.myform.plugType.length = 1;
		document.myform.plugType.selectedIndex = 0;
		document.myform.config.length = 1;
	}
	else if(document.myform.plugType.options[document.myform.plugType.selectedIndex].value == ' '){
		document.myform.modelNumber.value = '';
		document.myform.go.style.visibility = 'hidden';
		document.myform.spec.style.visibility = 'hidden';
		document.myform.config.length = 1;
	}
	else if(document.myform.config.options[document.myform.config.selectedIndex].value == ' '){
		document.myform.modelNumber.value = '';
		document.myform.go.style.visibility = 'hidden';
		document.myform.spec.style.visibility = 'hidden';
	}
	else if(document.myform.config.options.length > 1  && document.myform.config.options[document.myform.config.selectedIndex].value != ' '){
				document.myform.go.style.visibility='visible';
	}
}
function genSpecSheet(modelNumber, series, voltage, current, plugType, orientation, outletControl, config, controlModule){
	if(document.myform.locking.checked){
		var locking = 1;
	}else{ var locking = 0;}
	if(document.myform.lowCost.checked){
		var lowCost = 1;
	}else{ var lowCost = 0; }
	var queryString = "&series=" + series + "&locking=" + locking + "&voltage=" + voltage + "&current=" + current + "&plugType=" + plugType + "&orientation=" + orientation + "&outletControl=" + outletControl + "&config=" + config + "&controlModule=" + controlModule + "&lowCost=" + lowCost;
	window.location = "./tcpdf/examples/specSheetGen.php?modelNum=" + modelNumber + queryString;
}
function validateModelNumber(chassis, controller, moduleA, moduleB, moduleC, plugType){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;
			textArray = text.split("*");
			eval(textArray[0]);				
			eval(textArray[1]);
			document.myform.modelNumber.value = textArray[2];
			
		}
	}
	var queryString = "?chassis=" + chassis + "&controller=" + controller + "&moduleA=" + moduleA + "&moduleB=" + moduleB + "&moduleC=" + moduleC + "&plugType=" + plugType;
	document.write.queryString;
	ajaxRequest.open("GET", "modelNumValidator.php" + queryString, true);
	ajaxRequest.send(null); 
}
function setOptions(chosen, selbox) {
	selbox.options.length = 0;
	if (chosen == " ") {
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
	}
	if (chosen == "MDP") { //MDP
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
		selbox.options[selbox.options.length] = new Option('120V','120V');
		selbox.options[selbox.options.length] = new Option('208V','208V');
		selbox.options[selbox.options.length] = new Option('120/208V','120/208V');
		selbox.options[selbox.options.length] = new Option('230V', '230V');
		selbox.options[selbox.options.length] = new Option('120V 3ØY','120V 3 Phase');
		selbox.options[selbox.options.length] = new Option('208V 3ØY','208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('120/208V 3ØY','120/208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('230/400V 3ØY','230/400V 3 Phase');
		document.getElementById('interfaceRow').style.visibility = 'hidden';
		document.getElementById('outletControlRow').style.visibility = 'hidden';
		document.getElementById('lowCostRow').style.visibility = 'hidden';
		document.myform.lowCost.checked = false;
	}
	if (chosen == "MMP") { //MMP
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
		selbox.options[selbox.options.length] = new Option('120V','120V');
		selbox.options[selbox.options.length] = new Option('208V','208V');
		selbox.options[selbox.options.length] = new Option('120/208V','120/208V');
		selbox.options[selbox.options.length] = new Option('230V', '230V');
		selbox.options[selbox.options.length] = new Option('120V 3ØY','120V 3 Phase');
		selbox.options[selbox.options.length] = new Option('208V 3ØY','208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('120/208V 3ØY','120/208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('230/400V 3ØY','230/400V 3 Phase');
		document.getElementById('interfaceRow').style.visibility = 'visible';
		document.getElementById('outletControlRow').style.visibility = 'visible';			
		document.getElementById('lowCostRow').style.visibility = 'hidden';
		document.myform.lowCost.checked = false;
		document.myform.outletControl.selectedIndex = 1;		
	}
	if (chosen == "MRP") { //MRP
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
		selbox.options[selbox.options.length] = new Option('120V','120V');
		selbox.options[selbox.options.length] = new Option('208V','208V');
		selbox.options[selbox.options.length] = new Option('120/208V','120/208V');
		selbox.options[selbox.options.length] = new Option('230V', '230V');
		selbox.options[selbox.options.length] = new Option('120V 3ØY','120V 3 Phase');
		selbox.options[selbox.options.length] = new Option('208V 3ØY','208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('120/208V 3ØY','120/208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('230/400V 3ØY','230/400V 3 Phase');		
		document.getElementById('interfaceRow').style.visibility = 'visible';
		document.getElementById('outletControlRow').style.visibility = 'visible';		
		document.getElementById('lowCostRow').style.visibility = 'hidden';
		document.myform.lowCost.checked = false;
		document.myform.outletControl.selectedIndex = 1;		
	}
	if (chosen == "MSP"){ //MSP
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
		selbox.options[selbox.options.length] = new Option('120V','120V');
		selbox.options[selbox.options.length] = new Option('208V','208V');
		selbox.options[selbox.options.length] = new Option('120/208V','120/208V');
		selbox.options[selbox.options.length] = new Option('230V', '230V');
		selbox.options[selbox.options.length] = new Option('120V 3ØY','120V 3 Phase');
		selbox.options[selbox.options.length] = new Option('208V 3ØY','208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('120/208V 3ØY','120/208V 3 Phase');
		selbox.options[selbox.options.length] = new Option('230/400V 3ØY','230/400V 3 Phase');		
		document.getElementById('interfaceRow').style.visibility = 'visible';
		document.getElementById('outletControlRow').style.visibility = 'hidden';
		document.getElementById('lowCostRow').style.visibility = 'visible';
	}	
}
function setCurrent(voltage){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var text = ajaxRequest.responseText;
			eval(text);
			formCheck();
		}
	}
	var queryString = "?voltage=" + voltage;
	document.write.queryString;
	ajaxRequest.open("GET", "current.php" + queryString, true);
	ajaxRequest.send(null); 
}
function setPlug(voltage,current){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;
			eval(text);
			formCheck();
		}
	}
	var queryString = "?voltage=" + voltage + "&current=" + current;
	document.write.queryString;
	ajaxRequest.open("GET", "plugs.php" + queryString, true);
	ajaxRequest.send(null); 
}
function setConfig(series, voltage, current, outlet, orientation, dispLoc){
	if(document.myform.series.options[document.myform.series.selectedIndex].value != ' ' &&	document.myform.voltage.options[document.myform.voltage.selectedIndex].value != ' ' && document.myform.current.options[document.myform.current.selectedIndex].value != ' ' && document.myform.plugType.options[document.myform.plugType.selectedIndex].value != ' '){
		var ajaxRequest;  // The variable that makes Ajax possible!	
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();	
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					alert("Your browser broke!");
					return false;
				}
			}
		}
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				//var ajaxDisplay = document.getElementById('ajaxDiv');
				//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
				var text = ajaxRequest.responseText;			
				eval(text);
				formCheck();
			
			}
		}
		if(document.myform.locking.checked){
			var locking = 1;
		}else{ var locking = 0;}
		if(document.myform.lowCost.checked){
			var lowCost = 1;
		}else{ var lowCost = 0; }
		var queryString = "?series=" + series + "&voltage=" + voltage + "&current=" + current + "&outlet=" + outlet + "&orientation=" + orientation + "&locking=" + locking + "&lowCost=" + lowCost + "&dispLoc=" + dispLoc;
		document.write.queryString;
		ajaxRequest.open("GET", "modules.php" + queryString, true);
		ajaxRequest.send(null);	
	}
}
function genModelNumber(series, voltage, current, plugType, interFace, orientation, config, location){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;			
			eval(text);
			document.myform.spec.style.visibility='visible';
		}
	}
	if(document.myform.locking.checked){
		var locking = 1;
	}else{ var locking = 0;}
	if(document.myform.lowCost.checked){
		var lowCost = 1;
	}else{ var lowCost = 0; }
	var queryString = "?series=" + series + "&voltage=" + voltage + "&current=" + current + "&plugType=" + plugType + "&interface=" + interFace + "&orientation=" + orientation + "&config=" + config + "&location=" + location + "&lowCost=" + lowCost;
	document.write.queryString;
	ajaxRequest.open("GET", "generator.php" + queryString, true);
	ajaxRequest.send(null);	
}
function addSpecs(modelNum, weight, box){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;			
			eval(text);
		}
	}	
	var queryString = "?modelNum=" + modelNum + "&weight=" + weight + "&box=" + box;
	document.write.queryString;
	ajaxRequest.open("GET", "addSpecs.php" + queryString, true);
	ajaxRequest.send(null);	
}
function getDSNumber(hostCard, numDevices, plugType, output){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;			
			eval(text);
		}
	}
	if(document.myform.series[1].checked){
		var rpc = 1;
	}
	else{ var rpc = 0;}
	var queryString = "?hostCard=" + hostCard + "&numDevices=" + numDevices + "&plugType=" + plugType + "&rpc=" + rpc + "&output=" + output;
	document.write.queryString;
	ajaxRequest.open("GET", "dsGen.php" + queryString, true);
	ajaxRequest.send(null);	
}
function dsSetOptions(selbox){
	selbox.options.length = 0;
	for (var i=0; i < document.myform.series.length; i++){
   		if (document.myform.series[i].checked){
      		var chosen = document.myform.series[i].value;
      	}
   	}
	
	if (chosen == "ds"){
		selbox.options[selbox.options.length] = new Option('-- Select Number of Devices --',' ');
		selbox.options[selbox.options.length] = new Option('4','4');
		selbox.options[selbox.options.length] = new Option('8','8');
		selbox.options[selbox.options.length] = new Option('12','12');
		selbox.options[selbox.options.length] = new Option('16','16');
		selbox.options[selbox.options.length] = new Option('20','20');
		selbox.options[selbox.options.length] = new Option('24','24');
		selbox.options[selbox.options.length] = new Option('28','28');
		selbox.options[selbox.options.length] = new Option('32','32');
		document.getElementById('outputs').style.visibility = 'hidden';
		document.getElementById('spec').style.visibility = 'hidden';
		document.myform.output.length=1;
	}
	if (chosen == "dsrpc"){
		selbox.options[selbox.options.length] = new Option('-- Select Number of Devices --',' ');
		selbox.options[selbox.options.length] = new Option('4','4');
		selbox.options[selbox.options.length] = new Option('8','8');
		selbox.options[selbox.options.length] = new Option('12','12');
		document.getElementById('outputs').style.visibility = 'visible';
		document.myform.output.options.length=0;
		document.myform.output.options[document.myform.output.options.length] = new Option('-- Select Output Options --','N/A');
		document.myform.output.options[document.myform.output.options.length] = new Option('4 - C13','IEC320 C13R');
		document.myform.output.options[document.myform.output.options.length] = new Option('4 - 5-15R','NEMA 5-15R');
		document.myform.output.options[document.myform.output.options.length] = new Option('4 - 5-20R','NEMA 5-20R');
	}
}
function getDSSpec(modelNumber){
	var queryString = "&modelNum=" + modelNumber;
	window.location = "./tcpdf/examples/dsSpecSheetGen.php?modelNum=" + modelNumber + queryString;
}
function getATSNumber(voltage, current, numOutputs, outputType){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;			
			eval(text);
		}
	}
	var queryString = "?voltage=" + voltage + "&current=" + current + "&numOutputs=" + numOutputs + "&outputType=" + outputType;
	document.write.queryString;
	ajaxRequest.open("GET", "atsGen.php" + queryString, true);
	ajaxRequest.send(null);	
}
function setATSoptions(voltage, selbox){
	selbox.options.length = 0;
	if (voltage == " ") {
		selbox.options[selbox.options.length] = new Option('-- Select Voltage --',' ');
	}
	if(voltage == "120"){
		selbox.options[selbox.options.length] = new Option('-- Select Current --',' ');
		selbox.options[selbox.options.length] = new Option('15A','15');
		selbox.options[selbox.options.length] = new Option('20A','20');
		selbox.options[selbox.options.length] = new Option('30A','30');
	}
	if(voltage == "208"){
		selbox.options[selbox.options.length] = new Option('-- Select Current --',' ');
		selbox.options[selbox.options.length] = new Option('10A','10');
		selbox.options[selbox.options.length] = new Option('15A','15');
		selbox.options[selbox.options.length] = new Option('16A','16');
		selbox.options[selbox.options.length] = new Option('20A','20');
		selbox.options[selbox.options.length] = new Option('30A','30');
	}
	if(voltage == "230"){
		selbox.options[selbox.options.length] = new Option('-- Select Current --',' ');
		selbox.options[selbox.options.length] = new Option('10A','10');
		selbox.options[selbox.options.length] = new Option('15A','15');
		selbox.options[selbox.options.length] = new Option('16A','16');
		selbox.options[selbox.options.length] = new Option('20A','20');
		selbox.options[selbox.options.length] = new Option('30A','30');
	}
}
function setATSOutputOptions(voltage, current, numOutputs){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//var ajaxDisplay = document.getElementById('ajaxDiv');
			//ajaxDisplay.innerHTML = ajaxRequest.responsetext; 
			var text = ajaxRequest.responseText;			
			eval(text);
		}
	}
	var queryString = "?voltage=" + voltage + "&current=" + current + "&numOutputs=" + numOutputs;
	document.write.queryString;
	ajaxRequest.open("GET", "atsOutputOptions.php" + queryString, true);
	ajaxRequest.send(null);	
}
function pageHit(page){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	var queryString = "?page=" + page;
	document.write.queryString;
	ajaxRequest.open("GET", "/include/hitCounter.php" + queryString, true);
	ajaxRequest.send(null);	
	
}
