var Ajax = new Object();

Ajax.Request = function(url,id, callbackMethod)
{

	var subcription_total="";
	count=document.getElementsByName("payment_option").length;
	var obj=document.getElementsByName("payment_option");
//alert(obj);
	for(i=0;i<count;i++){
		if(obj[i].checked){
			subcription_total+=obj[i].value;
		}
	}
	var addtioanl_total="";
	count=document.getElementsByName("add_payment_option").length;
	var obj=document.getElementsByName("add_payment_option");
//alert(obj);
	for(i=0;i<count;i++){
		if(obj[i].checked && subcription_total !=''){
			addtioanl_total+=","+obj[i].value;
		}
	}
	if(subcription_total !=''){
		id=subcription_total+addtioanl_total;
	}
	if (id =='')
	{
		return;
	}
	Page.getPageCenterX();

	Ajax.request = Ajax.createRequestObject();
	Ajax.request.onreadystatechange = callbackMethod;
	//alert(url+subcription_total+addtioanl_total);
	/////alert(url+id);
	Ajax.request.open("POST", url+id, true);
	//alert(url+id);
	Ajax.request.send(url);
}
Ajax.Request1 = function(url,id, callbackMethod)
{
	//alert(document.properties);
	
	Page.getPageCenterX();

	Ajax.request = Ajax.createRequestObject();
	Ajax.request.onreadystatechange = callbackMethod;
	//alert(url+subcription_total+addtioanl_total);
	//alert(url+id);
	Ajax.request.open("POST", url+id, true);
	//alert(url+id);
	Ajax.request.send(url);
}
Ajax.Request2 = function(url,id, callbackMethod)
{
	//alert(document.properties);
	if(document.properties!=undefined){
		var startmonth=document.properties.availability_startdate_month.options[document.properties.availability_startdate_month.selectedIndex].value;
		var startday=document.properties.availability_startdate_day.options[document.properties.availability_startdate_day.selectedIndex].value;
		var startyear=document.properties.availability_startdate_year.options[document.properties.availability_startdate_year.selectedIndex].value;
		
		var endmonth=document.properties.availability_enddate_month.options[document.properties.availability_enddate_month.selectedIndex].value;
		var endday=document.properties.availability_enddate_day.options[document.properties.availability_enddate_day.selectedIndex].value;
		var endyear=document.properties.availability_enddate_year.options[document.properties.availability_enddate_year.selectedIndex].value;
		
		var startdate=startyear+"-"+startmonth+"-"+startday;
		var enddate=endyear+"-"+endmonth+"-"+endday;
		//alert(startdate);
		//alert(enddate);
		if( startyear =="" || startmonth =="" || startday ==""){
			window.alert('Please enter a valid Start Dates.');
			return false;
		}
		if( endyear =="" || endmonth =="" || endday ==""){
			window.alert('Please enter a valid End Dates.');
			return false;
		}
		if (!isDate(document.properties.availability_startdate_day.options[document.properties.availability_startdate_day.selectedIndex].value,document.properties.availability_startdate_month.options[document.properties.availability_startdate_month.selectedIndex].value,document.properties.availability_startdate_year.options[document.properties.availability_startdate_year.selectedIndex].value)) {
			window.alert('Please enter a valid Start Dates.');
			return false;
		}
		if (!isDate(document.properties.availability_enddate_day.options[document.properties.availability_enddate_day.selectedIndex].value,document.properties.availability_enddate_month.options[document.properties.availability_enddate_month.selectedIndex].value,document.properties.availability_enddate_year.options[document.properties.availability_enddate_year.selectedIndex].value)) {
			window.alert('Please enter a valid End Date.');
			return false;
		}				
		if (Date.UTC(document.properties.availability_startdate_year.options[document.properties.availability_startdate_year.selectedIndex].value, document.properties.availability_startdate_month.options[document.properties.availability_startdate_month.selectedIndex].value, document.properties.availability_startdate_day.options[document.properties.availability_startdate_day.selectedIndex].value,0,0,0,0) > Date.UTC(document.properties.availability_enddate_year.options[document.properties.availability_enddate_year.selectedIndex].value, document.properties.availability_enddate_month.options[document.properties.availability_enddate_month.selectedIndex].value, document.properties.availability_enddate_day.options[document.properties.availability_enddate_day.selectedIndex].value,0,0,0,0))
	    {
			window.alert('Start Date must come before the End Date.');
			return false;
	    }else{
			id="&startdate="+startdate+"&enddate="+enddate;
		}
	}
	if(document.hotel!=undefined){
		var startmonth=document.hotel.availability_startdate_month.options[document.hotel.availability_startdate_month.selectedIndex].value;
		var startday=document.hotel.availability_startdate_day.options[document.hotel.availability_startdate_day.selectedIndex].value;
		var startyear=document.hotel.availability_startdate_year.options[document.hotel.availability_startdate_year.selectedIndex].value;
		
		var endmonth=document.hotel.availability_enddate_month.options[document.hotel.availability_enddate_month.selectedIndex].value;
		var endday=document.hotel.availability_enddate_day.options[document.hotel.availability_enddate_day.selectedIndex].value;
		var endyear=document.hotel.availability_enddate_year.options[document.hotel.availability_enddate_year.selectedIndex].value;
		
		var startdate=startyear+"-"+startmonth+"-"+startday;
		var enddate=endyear+"-"+endmonth+"-"+endday;
		
			if (!isDate(startday,startmonth,startyear)) {
				window.alert('Please enter a valid Start Date.');
				return false;
			}
			if (!isDate(endday,endmonth,endyear)) {
				window.alert('Please enter a valid End Date.');
				return false;
			}				
			if (Date.UTC(y2k(startyear,startmonth,startday,0,0,0,0)) > Date.UTC(y2k(endyear,endmonth,endday,0,0,0,0)) ){
				window.alert('Start Date must come before the End Date.');
				return false;
			}else{
				id="&startdate="+startdate+"&enddate="+enddate;
			}
		
	}
	Page.getPageCenterX();

	Ajax.request = Ajax.createRequestObject();
	Ajax.request.onreadystatechange = callbackMethod;
	//alert(url+subcription_total+addtioanl_total);
	//alert(url+id);
	Ajax.request.open("POST", url+id, true);
	//alert(url+id);
	Ajax.request.send(url);
}
Ajax.Response = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		document.getElementById('selcity').length = 0;
		document.getElementById('selcity').options[0] = new Option("-- SELECT --","0");
		
		var	response = Ajax.request.responseXML.documentElement;
		
		if(response==null)
		{
			alert('No City Found In This Region.So Please Contact Admin');
			/*document.getElementById('selSubCat').style.display = 'none';
			document.getElementById('subCat').style.display = '';*/
		}else{
			//alert('_data.length');
			var _data = response.getElementsByTagName('category');
			var i
			for ( i = 0 ; i < _data.length ; i ++ )
			{
				document.getElementById('selcity').options[i+1] = new Option(response.getElementsByTagName('fname')[i].firstChild.data,response.getElementsByTagName('id')[i].firstChild.data);	
			}
			/*document.getElementById('selSubCat').style.display = '';
			document.getElementById('subCat').style.display = 'none';*/
		}
	}
}

Ajax.ResponseCountry = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		document.getElementById('selSubCat').length = 0;
		document.getElementById('selSubCat').options[0] = new Option("--Select--","0");
		var	response = Ajax.request.responseXML.documentElement;
		//alert(response);
		
		//if(_data==null)
		
		if(response==null)
		{
			//alert('No City Found In This Region.So Please Contact Admin');
			document.getElementById('selSubCat').style.display = 'none';
			document.getElementById('subCat').style.display = '';
			document.getElementById('subCat').focus();
		}else{
			
			var _data = response.getElementsByTagName('category');
			var i
			
			for ( i = 0 ; i < _data.length ; i ++ )
			{
				document.getElementById('selSubCat').options[i+1] = new Option(response.getElementsByTagName('fname')[i].firstChild.data,response.getElementsByTagName('id')[i].firstChild.data);	
			}
			if(_data.length){
				document.getElementById('selSubCat').style.display = '';
				document.getElementById('subCat').style.display = 'none';
			}else{
				document.getElementById('selSubCat').style.display = 'none';
				document.getElementById('subCat').style.display = '';
				document.getElementById('subCat').focus();
			}
		}
	}
}
Ajax.ResponseTotal = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		var	response = Ajax.request.responseText;
		document.getElementById("sub_total_div").innerHTML =response;
		//toggle1('dynamic_content');
	}
}
Ajax.ResponseCurrency = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		var	response = Ajax.request.responseText;
		document.getElementById("currencyexchange").innerHTML =response;
	}
}
Ajax.ResponseCurrencyHotel = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		var	response = Ajax.request.responseText;
		document.getElementById("currencyExchangeHotel").innerHTML =response;
	}
}
Ajax.ResponseBooking = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		var	response = Ajax.request.responseText;
		//alert(response);
		//response="hai";
		document.getElementById("booking").innerHTML =response;
	}
}
Ajax.ResponseBookingComplete = function ()
{
	
	if(Ajax.CheckReadyState(Ajax.request))
	{		
		var	response = Ajax.request.responseText;
		//alert(response);
		//response="hai";
		document.getElementById("booking_complete").innerHTML =response;
		//alert('Record Delete Successfully!!!');
	}
}
Ajax.createRequestObject = function()
{
	var obj;
	if(window.XMLHttpRequest)
	{
		obj = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		obj = new ActiveXObject("MSXML2.XMLHTTP");
	}
	return obj;
}

Ajax.CheckReadyState = function(obj)
{
	if(obj.readyState < 4) {		
		//document.getElementById('loading').style.top = (Page.top + Page.height/2)-100;
		//document.getElementById('loading').style.left = Page.width/2-75;
		//document.getElementById('loading').style.position = "absolute";
		//document.getElementById('loading').innerHTML = "<table border=0 cellpadding=0 cellspacing=1 width=160 bgcolor=gray><tr><td align=center class=loading height=45 bgcolor=#ffffff><img src='snake_transparent.gif'/>&nbsp&nbspLoading..</td></tr></table>";  
	}
	//if(obj.readyState == 1) { document.getElementById('loading').innerHTML = "Loading..."; }
	//if(obj.readyState == 2) { document.getElementById('loading').innerHTML = "Loading..."; }
	//if(obj.readyState == 3) { document.getElementById('loading').innerHTML = "Loading..."; }	
	if(obj.readyState == 4)
	{
		if(obj.status == 200)
		{
			//document.getElementById('loading').innerHTML = "<table border=0 cellpadding=0 cellspacing=1 width=160 bgcolor=gray><tr><td align=center class=loaded height=45 bgcolor=#ffffff>Data is loaded successfully..</td></tr></table>";
			setTimeout('Page.loadOut()',2000);
			return true;
		}
		else
		{
			//document.getElementById('loading').innerHTML = "HTTP " + obj.status;
		}
	}
}

var Page = new Object();
Page.width;
Page.height;
Page.top;

Page.loadOut = function ()
{
	//document.getElementById('loading').innerHTML ='';	
}
Page.getPageCenterX = function ()
{
		var fWidth;
		var fHeight;		
		//For old IE browsers 
		if(document.all) 
		{ 
		fWidth = document.body.clientWidth; 
		fHeight = document.body.clientHeight; 
		} 
		//For DOM1 browsers 
		else if(document.getElementById &&!document.all)
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 
		} 
		else if(document.getElementById) 
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 		
		} 
		//For Opera 
		else if (is.op) 
		{ 
		fWidth = innerWidth; 
		fHeight = innerHeight; 		
		} 
		//For old Netscape 
		else if (document.layers) 
		{ 
		fWidth = window.innerWidth; 
		fHeight = window.innerHeight; 		
		}
	Page.width = fWidth;
	Page.height = fHeight;
	Page.top = window.document.body.scrollTop;
}



