//+++++++++++++++++++++++++++++++++++++++++++++
//   AJAX
//   JAVASCRIPT CALLS FOR AJAX
//
//+++++++++++++++++++++++++++++++++++++++++++++
 
function selectProd(){
var selectBox = document.getElementById("prod_select");
var index  = selectBox.selectedIndex ;
var product = selectBox.options[index].value; 
var postValues 	= "product="+product	;
var processFile = "ajax/productInfoForm_1.php"	;
var div_id		= "prod-info-req";
  document.getElementById("prod_select").selectedIndex = index ;        // reset list
pkl_AjaxCall_POST(processFile, postValues, div_id)	;
}//selectProd()

function get_acDrives(called_from){
var selectBox = document.getElementById("select-voltage");
var indexVoltage  = selectBox.selectedIndex ;
var voltage = selectBox.options[indexVoltage].value; 
//alert('VOLTAGE = '+voltage);
var hp =  document.getElementById("input-hp").value ;
//alert('HP = '+hp);
var postValues 	= "voltage="+voltage+"&hp="+hp+"&called_from="+called_from	;
var processFile = "ajax/get_ac_drives.php"	;
var div_id		= "ac-drive-info";
document.getElementById("select-voltage").selectedIndex = indexVoltage;        // reset list
pkl_AjaxCall_POST(processFile, postValues, div_id)	;
}//selectProd()


function populateManufacturerInfo(calledFrom){

if(this.id = "65"){
    //alert( "This is the Comany Link" );
    var coLink = this.id;
   // alert( "Comany Link= "+coLink);
    }

if(document.getElementById("manufacturer")){
	var indexManuf      		= document.getElementById("manufacturer").options.selectedIndex ;
	var manuf_id 		= document.getElementById("manufacturer").options[indexManuf].value    ; 
	var manufName 		= document.getElementById("manufacturer").options[indexManuf].text    ;
}

if(document.getElementById("prodName")){
	var prodName 		= document.getElementById("prodName").value ; 
}
if(document.getElementById("acCalcManuf")){
	var manufName 		= document.getElementById("acCalcManuf").value ; 
}

var postValues 	= "manuf_id="+manuf_id+"&manufName="+manufName+"&prodName="+prodName+"&calledFrom="+calledFrom+"&coLink="+coLink  ;
var processFile 	= "ajax/populateManufacturerInfo.php"	;
var div_id				= "manufacturerInfo";

if(document.getElementById("manufacturer")){
  document.getElementById("manufacturer").selectedIndex = indexManuf  ;        // reset list
}  
pkl_AjaxCall_POST(processFile, postValues, div_id)	;
}//function populateManufacturerInfo

// add post variables here for product details for ac drives 
function getProductDetails(manufName,prodName, meets, costrange,  pid_blocks, digital_inputs, digital_outputs, relay_outputs, line_inductors, swing_choke, line_inductors, drivekey){
var postValues 	= "prodName="+prodName+"&manufName="+manufName+
"&meets="+meets+
"&cost_ranges="+costrange+
"&pid_blocks="+pid_blocks+
"&digital_inputs="+digital_inputs+
"&digital_outputs="+digital_outputs+
"&relay_outputs="+relay_outputs+
"&line_inductors="+line_inductors+
"&swing_choke="+swing_choke+
"&drive_key="+drivekey+
"&line_inductors="+line_inductors;

var processFile = "ajax/product_details.php"	;
var div_id		= "product-details";
 
pkl_AjaxCall_POST(processFile, postValues, div_id)	;
}//selectProd()



//+++++++++++++++++++++++++++++++++++++++++++++
//      ZEMELRECK FUNCTIONS
//+++++++++++++++++++++++++++++++++++++++++++++
 
function pkl_AjaxCall_POST(processFile, postValues, div_id){
 	var XMLHttpRequestObject = false;
  	if (window.XMLHttpRequest) {
				XMLHttpRequestObject = new XMLHttpRequest();
  			} else if (window.ActiveXObject) {
				XMLHttpRequestObject = new 
				ActiveXObject("Microsoft.XMLHTTP");
  			}//if-else
  	if(XMLHttpRequestObject) {
			XMLHttpRequestObject.open("POST", processFile); 
    		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  
			XMLHttpRequestObject.onreadystatechange = function() { 
	  							if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { 
		  							document.getElementById(div_id).innerHTML = XMLHttpRequestObject.responseText;
	  							} //if
						} //function
			XMLHttpRequestObject.send(postValues); 
  		}// if(XMLHttpRequestObject)
  }//function pkl_AjaxCall(processFile, div )