function getHTTPObject()
{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
  		xmlhttp=new XMLHttpRequest()
	// code for IE
	else if (window.ActiveXObject)
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	return xmlhttp;
}

var http = getHTTPObject();

/* adding tour to cart */
function GetTour(mode, tourid, deptdate, adultorg, childorg, seniororg, type, contshp)
{
	//	alert('Coming Soon !!');return false;
	//alert(deptdate);return false;
	/* Code for : Type Sightseeing */
	deptdate = Trim(deptdate);
	if(document.getElementById('fAdult'))
		adultqty = document.getElementById('fAdult').value;
	else
		adultqty = '0';
	
	if(document.getElementById('fChild'))
		childqty = document.getElementById('fChild').value;
	else
		childqty = '0';
	
	if(document.getElementById('fSenior'))
		seniorqty = document.getElementById('fSenior').value;
	else
		seniorqty = '0';
	
	if(document.getElementById('getinfo_senior'))
		seniorinfo = document.getElementById('getinfo_senior').innerHTML;
	else
		seniorinfo = '0';
	
	if(document.getElementById('getinfo_child'))
		childinfo = document.getElementById('getinfo_child').innerHTML;
	else
		childinfo = '0';
		
	if(document.getElementById('getinfo_adult'))
		adultinfo = document.getElementById('getinfo_adult').innerHTML;
	else
		adultinfo = '0';
	/* End Code */
	
	/* Code for Pickup Point */
	if(document.getElementById('selpickup'))
		pickup = document.getElementById('selpickup').value;
	else
		pickup = '0';
	/* end code */
	
	if(type == 'Sightseeing')	//	for sightseeing
		if(document.getElementById('settotamt'))  gettotamt = document.getElementById('settotamt').innerHTML;  else	 gettotamt = '0';
	else if(type == 'Private')	//	for private
	
		if(document.getElementById('settotamt_private'))  gettotamt = document.getElementById('settotamt_private').innerHTML;  else	 gettotamt = '0';
	
	else	//	for walking
		if(document.getElementById('settotamt_walking'))  gettotamt = document.getElementById('settotamt_walking').innerHTML;  else	 gettotamt = '0';
	
	AddTour(mode, tourid, deptdate, pickup, adultqty, childqty, seniorqty, remove_currency_price(adultorg), remove_currency_price(childorg), remove_currency_price(seniororg), type, seniorinfo, childinfo, adultinfo, contshp, remove_currency_price(gettotamt))
}
function AddTour(mode, tourid, deptdate, pickup,  adultqty, childqty, seniorqty , adultorg, childorg, seniororg, type, seniorinfo, childinfo, adultinfo, contshp, gettotamt)
{	
	var errormsg = '';
	var getatt = '';
	
	/* Code for Departure date */
	if(deptdate == '<i>None</i>' || deptdate == '<I>None</I>')
		errormsg += '* Please Select Departure Date<br>';
	/* end code */
	
	
	
	if(pickup == '' )
		errormsg += '* Please Pick Up Point<br>';
	
	
	/* Code for mange tour question */
	var que_cnt = document.getElementById('tottourquestion').value;
	if(que_cnt > 0)
	{
		var getqueans = '';
		for(var m = 0; m < que_cnt; m++)
		{
			//	alert(document.getElementById('question_'+m).value);
			if(document.getElementById('answer_'+m).value == '')
				errormsg += '* Please Enter Information for '+document.getElementById('question_'+m).value+'<br>';
			else
				getqueans += document.getElementById('question_'+m).value+' : '+document.getElementById('answer_'+m).value+'#@#';
		}
	}
	else
		var getqueans = 'notset';
	/* End code */
	
	/* code for manage qty - Sightseeing, private, walking */
	if(type == 'Sightseeing')	//	for sightseeing
	{
		if( (adultqty == '0' || adultqty =='') && ( childqty == '0' || childqty == '') && ( seniorqty == '0' || seniorqty == ''))  errormsg += '* Please Enter At Least one qty';
		gettotamt = gettotamt;
	}
	else if(type == 'Private')	//	for private
	{
		var x=0;
		for(i=0;i < document.frmbooking.elements.length;i++)
		{
			if(document.frmbooking.elements[i].name == 'person' && document.frmbooking.elements[i].checked == true)
			{
				x++;
				getatt = document.frmbooking.elements[i].value;
			}
		}
		if(x < 1)  errormsg += '* Please Select At Least option';
	}
	else if(type == 'Walking')	//	for walking
	{
		var x=0;
		for(i=0;i < document.frmbooking.elements.length;i++)
		{
			if(document.frmbooking.elements[i].name == 'walking' && document.frmbooking.elements[i].checked == true) 
			{
				x++;
				getatt = document.frmbooking.elements[i].value;
			}
		}
		if(x < 1)  errormsg += '* Please Select At Least option';
	}
	/* end code */
	/* For tour schedule */
	var schedule = '';
	/*
  if(totschedule > 0)
	{
    for(i=0;i<totschedule;i++)
    {
      if(document.getElementById('schedule_'+i).checked == true)
      {
        schedule = document.getElementById('schedule_'+i).value;
      }
    }
  }
  */
  /* End code */
	if(errormsg  != '')
	{
		document.getElementById('getinform').innerHTML = errormsg;
		TB_show("Booking Tour","#TB_inline?height=200&width=500&inlineId=bookingtouralert","");
		return false;
	}
	
	//	ajax file - for tour section
	var url = ajax_url + "ajax_tourshoppingcart.php";
	url = url + "?tourid="+ escape(tourid)+"&type="+ escape(type)+"&deptdate="+escape(deptdate)+"&pickup="+escape(pickup)+"&mode="+escape(mode)+"&adultqty="+adultqty+"&childqty="+childqty+"&seniorqty="+escape(seniorqty)+"&adultorg="+escape(adultorg)+"&childorg="+childorg+"&seniororg="+seniororg+"&seniorinfo="+seniorinfo+"&childinfo="+childinfo+"&adultinfo="+adultinfo+"&contshp="+contshp+"&settotamt="+gettotamt+"&getattribute="+getatt+"&getqueans="+encode64(getqueans)+"&schedule="+escape(schedule);
	
	//alert(url);return false;
	
	 http.open("GET", url, true);
     http.onreadystatechange = getCartDataAdd;
     http.send(null);
}
function getCartDataAdd()
{
	if (http.readyState == 4)
	{
   		var xmlDocument = http.responseXML;
//		alert(http.responseText);return false;
		var set_key  = xmlDocument.getElementsByTagName('set_key').item(0).firstChild.data;
//		alert(set_key);return false;

		if(set_key == 'yes')
			TB_show("Add to Cart","#TB_inline?height=100&width=450&inlineId=reduceqty_message","");	//	Need to change
		else
			TB_show("Add to Cart","#TB_inline?height=100&width=450&inlineId=cart_message","");
		return false;
	}
}

function removeone(id, val, att)
{
  //  alert(1);return false;
	document.frmcart.cartmode.value = "RemoveOne";
	document.frmcart.tourid.value = id;
	document.frmcart.tourattsel.value = att;
	
	document.frmcart.submit();
}
function removeonetransfer(id, val, att)
{
	document.frmcart.cartmode.value = "RemoveOneTransfer";
	document.frmcart.transferid.value = id;
	document.frmcart.transferattsel.value = att;
	
	document.frmcart.submit();
}
function removeonehotel(id, val, att)
{
	document.frmcart.cartmode.value = "RemoveOneHotel";
	document.frmcart.searchid.value = id;
	document.frmcart.hotelattsel.value = att;
	
	document.frmcart.submit();
}

function continue_shopping()
{
	document.getElementById("cart_message").style.display = 'none';
	return false;
}
function view_cart()
{
	window.location = site_url + 'ShoppingCart/';
	return false;
}
function continueshopping(url)
{
	if(url != '')
		window.location = url;
	else
		window.location = site_url + 'Hotels';
}
function removeall()
{
	document.frmcart.cartmode.value = "RemoveAll";
	document.frmcart.submit();
}
function removealltransfer()
{
	document.frmcart.cartmode.value = "RemoveAllTransfer";
	document.frmcart.submit();
}

function gotocheckout()
{
	window.location = site_url + 'Billing-Shipping/';
	return false;
}

function gotoquickcheckout()
{
	window.location = site_url+'Billing-Shipping/QuickCheckout';
	return false;
}
