var xmlHttp;
var TMIloader=HIDstatus=maxwidth=maxheight='';
function getdata(fname,lname,c_phone,s_phone,email,street,city,sel_state,zip,rdo_homei) {
	showdivs();
	HIDstatus='';
	xmlHttp =GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Browser does not support Http Request");
		return;
	}
	var url = "/placeorder.php";
	url=url+"?fname="+fname+"&lname="+lname+"&c_phone="+c_phone+"&s_phone="+s_phone+"&email="+email+"&street="+street+"&city="+city+"&sel_state="+sel_state+"&zip="+zip+"&rdo_homei="+rdo_homei;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open ("POST", url, true);
	xmlHttp.send (null);
}
function stateChanged () {
	if(xmlHttp.readyState<4) {
		CURelement=document.getElementById("loader");
		CURelement.style.display="block";
		CURelement.style.left=(parseInt(maxwidth/2)-(parseInt(CURelement.offsetWidth)/2))+"px";
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		document.getElementById("loader").style.display="none";
		$arr_text=xmlHttp.responseText.split("<>");
		if($arr_text[0]=='success') {
			//$('#message_success').load('msg_secure.html');
			//document.getElementById("message_success").style.display="block";
			document.frm_address.reset();
			resetAll();
			setTimeout(function(){window.location.href="lead_success.php";},500);
		} else {
			//$('#message_failed').load('msg_secure3.php');
			$('#message_failed').html('<iframe src="msg_secure3.php" frameborder=0 border=0 width="450" height="750">');
			document.getElementById("message_failed").style.display="block";
		}
		HIDstatus='ok';
		$('html,body').animate({scrollTop: 0}, 1000);
	}
}
function GetXmlHttpObject() {
	var objxmlHttp=null;
	try {
		objxmlHttp=new XMLHttpRequest();
	} catch (e) {
		try {
			objxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
			  objxmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				objxmlHttp =null;
			}
		}
	}
	return objxmlHttp;
}
function showdivs() {
	maxheight=parseInt(document.body.offsetHeight)+parseInt(document.body.scrollHeight);
	maxwidth=parseInt(document.body.offsetWidth)+parseInt(document.body.scrollWidth);
	maxheight=maxheight/2;
	maxwidth=maxwidth/2;
	document.getElementById("hider").style.height=maxheight+"px";
	document.getElementById("hider").style.width=maxwidth+"px";
	document.getElementById("hider").style.display="block";
	document.getElementById("sel_state").style.display="none";
}
function resetAll() {
	if(HIDstatus=='ok') {
		document.getElementById("message_success").style.display="none";
		document.getElementById("message_failed").style.display="none";
		$("#hider").fadeOut("slow",function () {
			document.getElementById("sel_state").style.display="";
		});
	}
}
var FXpos='';
if(navigator.appName.indexOf('Internet')==-1) {
	FXpos="fixed";
} else {
	FXpos="absolute";
}
document.write('<div id="loader" style="display:none;position:'+FXpos+'"><img src="adt-images/loadingAnimation.gif" border="0" alt="" /></div>');
document.write('<div id="hider" style="display:none" onclick="javascript:resetAll();"></div><div id="message_success" style="display:none"></div><div id="message_failed" style="display:none"></div>');
$(document).ready(function () {
	//$('#message_success').load('msg_secure.html');
	//$('#message_failed').load('msg_secure3.php');
});