var net = new Object();
net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;

net.ContentLoader=function(url, onload, fid, onerror)
{
	this.fid=fid;
	this.url=url;
	this.req=null;
	this.onload=onload;
	this.onerror=(onerror)?onerror:this.defaultError;
	this.loadXMLDoc(url);
}
net.ContentLoader.prototype=
{
	loadXMLDoc:function(url)
	{
		if(window.XMLHttpRequest)
		{
			this.req=new XMLHttpRequest();
		}else if(window.ActiveXObject)
		{
			this.req=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(this.req)
		{
			try
			{
				var loader=this;
				this.req.onreadystatechange=function()
				{
					loader.onReadyState.call(loader);
				}
				this.req.open('GET', url, true);
				this.req.send(null);
			}catch(err)
			{
				this.onerror.call(this);
			}
		}
	},
	onReadyState:function()
	{
		var req=this.req;
		var ready=req.readyState;
		//alert(ready);
		if(ready==net.READY_STATE_COMPLETE)
		{
			var httpStatus=req.status;
			if(httpStatus==200||httpStatus==0)
			{
				this.onload.call(this);
			}else
			{
				this.onerror.call(this);
			}
		}
	},
	defaultError:function()
	{
		alert("Error fretching data!"+"\n\nreadyState: "+this.req.readyState+
		"\nstatus: "+this.re.status+"\nheaders: "+this.req.getAllResponseHeaders());
	}
}





function parseprice()
{
	var pr=parseInt(this.req.responseText);
	var price=0, num;
	var i;
        for (i=0; i<document.forms['f'].y2.length; i++)
            if (document.forms['f'].y2[i].checked)
                break;
	price=parseInt(document.forms['f'].y2[i].value);
	num=i;
	
	//pr=pr+Math.round(pr*33/100);
	
	price+=pr+Math.round(pr*33/100);
	
	for (i=0; i<document.forms['f'].l1.length; i++)
            if (document.forms['f'].l1[i].checked)
                break;
    if(num!=0)
		price-=pr*parseInt(document.forms['f'].l1[i].value)/100;
	for (i=0; i<document.forms['f'].x1.length; i++)
            if (document.forms['f'].x1[i].checked)
                break;
    price+=parseInt(document.forms['f'].x1[i].value);
    
    for (i=0; i<document.forms['f'].x2.length; i++)
            if (document.forms['f'].x2[i].checked)
                break;
    price+=parseInt(document.forms['f'].x2[i].value);
	
     for (i=0; i<document.forms['f'].x3.length; i++)
            if (document.forms['f'].x3[i].checked)
                break;
    price+=parseInt(document.forms['f'].x3[i].value);
    
     
	
	if(document.forms['f'].xx5.checked)
	{
		var el=document.getElementById('res1');
		el.innerHTML=price+'$';
	}

}

function load_price(city, air)
{

	var obj_map=new net.ContentLoader("/includes/price.php?city="+city+'&air='+air,parseprice, 1);
	obj_map=null;
	
}
