var xmlHttp;

function GetXmlHttpObject() {
	try	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch(e) {
		// Internet Explorer
		try	{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
}

function setSurveyCharge(objForm, flagSurvey) {	

	var price = objForm.txtPrice.value;
	var surveyType = objForm.lstSurveyType.value;
	
	if (price == "") {
	}
	else{ 
		GetXmlHttpObject();
		url = "productajax.php";
		url = url + "?doAction=SetSurveyCharge&price=" + price + "&surveyType=" + surveyType;

		xmlHttp.onreadystatechange = stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function stateChanged() {
	if(xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {

		strResponseText = xmlHttp.responseText;
		//alert(strResponseText);
		arrResponseText = strResponseText.split("##@##");
		
		var surveyCharge = arrResponseText[0];
		var preSurveyCharge = arrResponseText[1];
		document.getElementById("fee").innerHTML = "&pound;" + surveyCharge;
		document.getElementById("surveyFee").value = surveyCharge;
		if(document.getElementById('chkPre').checked) {
			document.getElementById("preFee").innerHTML = "&pound;" + preSurveyCharge;
			document.getElementById("preSurveyFee").value = preSurveyCharge;
		}
		
	}
}
