function Ajax() {
	this.createAjaxObj = function() {
		var httprequest=false;
		if (window.XMLHttpRequest){ 
			httprequest=new XMLHttpRequest();
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml');
		}
		else if (window.ActiveXObject){ 
		try {
			httprequest=new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
				httprequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
			}
		}
		return httprequest;
	}

	this.ajaxpack=new Object();
	this.ajaxpack.basedomain="http://"+window.location.hostname;
	this.ajaxpack.ajaxobj=this.createAjaxObj();
	this.ajaxpack.filetype="txt";
	this.ajaxpack.addrandomnumber=0;

	this.getAjaxRequest = function(url, parameters, callbackfunc, filetype){
		this.ajaxpack.ajaxobj=this.createAjaxObj(); 
		var parameters=parameters+"&ajaxcachebust="+new Date().getTime();
		if (this.ajaxpack.ajaxobj){
			this.ajaxpack.filetype=filetype;
			this.ajaxpack.ajaxobj.onreadystatechange=callbackfunc;
			this.ajaxpack.ajaxobj.open('GET', url+"?"+parameters, true);
			this.ajaxpack.ajaxobj.send(null);
		}
	}

	this.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
		this.ajaxpack.ajaxobj=this.createAjaxObj();
		if (this.ajaxpack.ajaxobj){
			this.ajaxpack.filetype=filetype;
			this.ajaxpack.ajaxobj.onreadystatechange = callbackfunc;
			this.ajaxpack.ajaxobj.open('POST', url, true);
			this.ajaxpack.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.ajaxpack.ajaxobj.setRequestHeader("Content-length", parameters.length);
			this.ajaxpack.ajaxobj.setRequestHeader("Connection", "close");
			this.ajaxpack.ajaxobj.send(parameters);
		}
	}	
}
function SendLead() {
	var url = "/app/leads.php"
	var method = "post";
	var ObjAjax =  new Ajax();
	var name = document.getElementById("name");
	var email = document.getElementById("email");
	var phone = document.getElementById("phone");
	var type = document.getElementById("type");
	var price = document.getElementById("price");
	var parameters="name="+name.value+"&email="+email.value+"&phone="+phone.value+"&type="+type.value+"&price="+price.value;
	this.processGetPost = function(){
		var myajax=ObjAjax.ajaxpack.ajaxobj;
		var myfiletype=ObjAjax.ajaxpack.filetype;
		if (myajax.readyState == 4){ 
			if (myajax.status==200 || window.location.href.indexOf("http")==-1){ 
			//alert("Thank you for signing up the form...");
			document.SForm.submit();
			}
		}
	}
	ObjAjax.postAjaxRequest(url, parameters, this.processGetPost, 'txt');
	return;	
}
