//

function getValue(id){
	return document.getElementById(id).value;
}
function setValue(id,value){
	document.getElementById(id).value = value;
}

function calcVT(){
	var VF = getValue('iVF');
	var W = getValue('iW');
	var CS = getValue('iCS');
	var L = getValue('iL');
	
	calc("?type=VT&VF="+VF+"&W="+W+"&CS="+CS+"&L="+L);
}

function calcW(){
	var VT = getValue('iVT');
	var VF = getValue('iVF');
	var CS = getValue('iCS');
	var L = getValue('iL');	
	
	calc("?type=W&VT="+VT+"&VF="+VF+"&CS="+CS+"&L="+L);
}


function calcL(){
	var VT = getValue('iVT');
	var VF = getValue('iVF');
	var W =  getValue('iW');
	var CS = getValue('iCS');
	
	calc("?type=L&VT="+VT+"&VF="+VF+"&W="+W+"&CS="+CS);
}

function calcVF(){
	var VT = getValue('iVT');
	var L = getValue('iL');
	var W =  getValue('iW');
	var CS = getValue('iCS');
	
	calc("?type=VF&VT="+VT+"&L="+L+"&W="+W+"&CS="+CS);
}

function calc(queryString){
	req=makeRequest();
	if (req==null){
		msg("Browser does not support HTTP Request");
		return
	} 

	req.onreadystatechange=calc_response;
	
	url = "includes/ajax/calc.php"+queryString;
	req.open("GET",url,true);
	req.send(null);
}

function calc_response(){
	switch (req.readyState) {
		case 1 : 
		break;
		case 4 :
			if (req.status == 200) {
				data = req.responseText;
				if(data != '' && data != ' '){
					data = data.split("|");
					if(data.length == 2){
						feild = data[0];
						value = data[1];
						window.document.getElementById('i'+feild).value = value;
					}
				}
			}
		break;
	}
			
}

function makeRequest(){ 
	var objXMLHttp=null;
	
	if (window.XMLHttpRequest){
	  objXMLHttp=new XMLHttpRequest()
	}else if(window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function clearr(){
	window.document.getElementById('iVF').value ='';
	window.document.getElementById('iW').value = '';
	window.document.getElementById('iCS').selectedIndex = 0;
	window.document.getElementById('iL').value = '';
	window.document.getElementById('iVT').value = '';
}


