
var xmlHttp
function showExtraservices(hotel_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=showextraservices&id=" +  hotel_id ;
	xmlHttp.onreadystatechange=extraservices
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function extraservices() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("extra_services_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("extra_services_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}


function  showhoteltitle(hotel_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=showhoteltitle&id=" +  hotel_id
	xmlHttp.onreadystatechange=stateHotel
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateHotel() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			strTemp = xmlHttp.responseText ;
			searchTerm = "@@@@@@@@@@";
			pos = strTemp.search(searchTerm);
			str1 = strTemp.substring(0,pos);
			str2 = strTemp.substr(pos+10);
			document.getElementById("hdiv").innerHTML= str1;
			document.getElementById("extra_services_div").innerHTML = str2;
			
		 } 
		 else
		{
			document.getElementById("hdiv").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function showlocationtitle(location_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=showlocationtitle&id=" + location_id
	xmlHttp.onreadystatechange=stateLocation
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateLocation() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("ldiv").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("ldiv").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function alertTypeAjax(type_id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=showtypetitle&id=" + type_id
	xmlHttp.onreadystatechange=stateType
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateType() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("vdiv").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("vdiv").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function showCompleteAjax(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=completePlan&id=" + id
	xmlHttp.onreadystatechange=stateComplete
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateComplete() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("complete_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("complete_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}



function checkstartdayAjax(startDate)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=checkingStartDate&startDate=" + startDate
	xmlHttp.onreadystatechange=stateChangeStartDate
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChangeStartDate() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("startDateArea").innerHTML=xmlHttp.responseText 
			
		 } 
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function checkdayAjax(startDate,arrivalDate,start_activity)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=checkingdate&startDate=" + startDate + "&arrivalDate=" + arrivalDate + "&start_activity=" + start_activity;
	xmlHttp.onreadystatechange=stateChangeDate
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChangeDate() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("ndate").innerHTML=xmlHttp.responseText 
		
	 } 
	else
	  {
	    document.getElementById("ndate").innerHTML= "<img src='http://muare.vn/forum/images/imgLoading.gif'>"
	  }
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function completetask(id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	

	var user_name = document.getElementById('user_name');
	var user_address = document.getElementById('user_address');
	var user_email = document.getElementById('user_email');
	var user_phone = document.getElementById('user_phone');
	var user_city = document.getElementById('user_city');
	var user_country = document.getElementById('user_country');

	var url="index2.php?option=com_travelagency&view=upload&task=saveinformation&id=" + id + "&user_name=" + user_name.value + "&user_address=" + user_address.value + "&user_email=" + user_email.value + "&user_phone=" + user_phone.value + "&user_city=" + user_city.value + "&user_country=" + user_country.value;
	xmlHttp.onreadystatechange=stateChangeda
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChangeda() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		//document.getElementById("user_information").innerHTML=xmlHttp.responseText 
		location.href='index.php?option=com_travelagency&view=upload&task=reviewAll&id='+ id;
	 } 
	else
	  {
	    document.getElementById("user_information").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
	  }
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function finaltask(id)
{
	finaltask1(id);
}

function finaltask1(id)
{   
	http=GetXmlHttpObject()
	if (http==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var value = '';
	text = document.getElementById('special_request');
	var from = document.getElementById('from');
	var to   = document.getElementById('to');
	var airline = document.getElementById('airline');
	var tranfer_need = document.getElementById('tranfer_need');
	var tranfer_vehicle = document.getElementById('tranfer_vehicle');
	if(from.value!="")
	{
		value += '*bTime of arrival:*/b' ;
		value += from.value;
	}
	if(to.value!="")
	{
		value += " : " + to.value;
		value += '__';
	}
	if(airline.value != null)
	{
		value += '*bAirline,flight number:*/b' ;
		value += airline.value;
		value += '__';

	}
	if(tranfer_need.value !="")
	{
		value += '*bTransfer needed:*/b' ;
		if(tranfer_need.value=='0'){
			value += 'No';
		}else{
			value += 'Yes';
		}
		value += '__';
	}
	if(tranfer_vehicle.value !="")
	{
		value += '*bTransfer/Vehicle type:*/b' ;
		value += tranfer_vehicle.value;
		value += '__';
	}
	value += "*bSpecial request:*/b__";
	value += text.value;
	var url = "index2.php";
	var params = "option=com_travelagency&view=upload&task=step7&special_request=" + value + "&id=" + id;

	http.open("POST", url, true);

	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById("content_travel6").innerHTML=http.responseText 
		}
	}
	http.send(params);
}

function changeStatusValueSpecial(id)
{
	var temp = document.getElementById(id);
	if(temp!=null)
	{
		if(temp.value=='0')
		{
			temp.value = '1';
		}else{
			temp.value = '0';
		}
	}
}

function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}



function chooseHotelAjax(hotel_id,id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	 var tempvalue = '';
	 var tempvalue2 = '';
	// var temp = document.getElementById('extra_services');
	var temp = document.getElementById('customfield_type');
	if(temp!=null){
		if(temp.value=='select')
		{
			var temp2 = document.getElementById('select_extraservices');	

		}else if(temp.value=="checkbox"){
			var temp2 = document.getElementById('checkbox_extraservices_total');
		}else{
			temp2 = document.getElementById('textarea_extraservices');
		}
		tempvalue = temp.value;
		tempvalue2 = temp2.value;
		if((tempvalue!="") && (tempvalue2==""))
		{
			alert("Please choose extra services for this hotel");
			return false;
		}
	}

	//hotel.php
	var hoteltemp = document.getElementById('total_hotelphp');
	var result =  "";
	for(i=0;i<hoteltemp.value;i++)
	{
		temp = document.getElementById('extra_services_hotel_' + i);
		if(temp!=null)
		{
			if(temp.value == 1)
			{
				temp2 = document.getElementById('extra_services_hotel_value_' + i);
				if(temp2!=null)
				{
					result += temp2.value + ",";
				}
			}
		}
	}
	if(result.length>0)
	{
		result = result.substring(0,result.length - 1);
	}
	var url="index2.php?option=com_travelagency&view=upload&task=step6&id=" + id + "&hotel_id=" + hotel_id + "&extra_services=" + tempvalue2 + "&customfield_type=" + tempvalue + "&other_services=" + result;
	xmlHttp.onreadystatechange=stateChanged10
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged10() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("content_travel5").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("content_travel5").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;	
}

function showDetailsOfHotel(id)
{
	showDetailsOfHotelAjax(id);
}

function showDetailsOfHotelAjax(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=view_hotel&id=" + id;
	xmlHttp.onreadystatechange=stateChanged9 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged9() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("hotel_details").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("hotel_details").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}


function gotoStep5Ajax(id,str,start_date)
{
	total_field  = document.getElementById('total_extra_act_field')	;
	if(total_field != null)
	{
		total_field = parseInt(total_field.value);
		var name;
		var value = '';
		var value1 = '';
		if(total_field>0)
		{
			alertvalue = 0;
			namevalue = 0;
			for(i=start_date;i<=total_field;i++)
			{
				temp_i = i;
				name = document.getElementById('extra_act_' + temp_i + '_' + id);
				if(name != null)
				{
					name = name.value;
					namevalue = 1;
				}
				value1 = document.getElementById('extra_act_select_' + temp_i + '_' + id);
				if(value1!=null)
				{
					if(value1.value!="")
					{
						value1 = value1.value;
						value += name + "_";
						value += value1 + "|";
					}else{
						alertvalue = 1;
					}
				}
				value1 = document.getElementById('extra_act_checkbox_total_' + temp_i + '_' + id);
				if(value1!=null)
				{
					if(value1.value!="")
					{
						value1 = value1.value;
						value += name + "_";
						value += value1 + "|";
					}else{
						alertvalue = 1;
					}
				}
				value1 = document.getElementById('extra_act_textrea_' + temp_i + '_' + id);
				if(value1!=null)
				{
					if(value1.value!="")
					{
						value1 = value1.value;
						value += name + "_";
						value += value1 + "|";
					}else{
						alertvalue = 1;
					}
				}
				if((alertvalue==1) && (namevalue ==1)){
					alert("Plese enter extra service for day " + temp_i);
					return false;
				}
			}
			

		}
	}


	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=step5&id=" + id + "&str=" + str + "&value=" + value;
	xmlHttp.onreadystatechange=stateChanged8 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged8() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("content_travel4").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("content_travel4").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}


function loadActDetails(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=view_act&id=" + id;
	xmlHttp.onreadystatechange=stateChanged7 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged7() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("act_type_details").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("act_type_details").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}


function chooselocationTypeAjax(type_id,id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=step4&id=" + id + "&type_id=" + type_id;
	xmlHttp.onreadystatechange=stateChanged6 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged6() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("content_travel3").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("content_travel3").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}







function loadLocationDetails(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=view_location&id=" + id;
	xmlHttp.onreadystatechange=stateChanged5 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged5() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("location_type_details").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("location_type_details").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}






function choosevacationTypeAjax(type_id,vid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=step3&id=" + vid + "&type_id=" + type_id;
	xmlHttp.onreadystatechange=stateChanged4 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged4() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("content_travel2").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("content_travel2").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}






function loadVacationDetails(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=view_type&id=" + id;
	xmlHttp.onreadystatechange=stateChanged2 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged2() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("vacation_type_details").innerHTML=xmlHttp.responseText 
	 } 
	else
		{
		document.getElementById("vacation_type_details").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		}
	}function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function step2(startDate,numguest,arrivalDate,cip,name,start_activity,num_date)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=step2&startDate=" + startDate + "&numguest=" + numguest + "&arrivalDate=" + arrivalDate + "&cip=" + cip + "&name=" + name + "&start_activity=" + start_activity + "&num_date=" + num_date;
	xmlHttp.onreadystatechange=stateChanged3 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function stateChanged3() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("content_travel").innerHTML=xmlHttp.responseText 
	 } 
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}


	var dhtmlgoodies_tooltip = false;
	var dhtmlgoodies_tooltipShadow = false;
	var dhtmlgoodies_shadowSize = 1;
	var dhtmlgoodies_tooltipMaxWidth = 480;
	var dhtmlgoodies_tooltipMinWidth = 200;
	var dhtmlgoodies_iframe = false;
	var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;
	function showTooltip(e,tooltipTxt)
	{
		var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;
	
		if(!dhtmlgoodies_tooltip){
			dhtmlgoodies_tooltip = document.createElement('DIV');
			dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
			dhtmlgoodies_tooltipShadow = document.createElement('DIV');
			dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
			
			document.body.appendChild(dhtmlgoodies_tooltip);
			document.body.appendChild(dhtmlgoodies_tooltipShadow);	
			
			if(tooltip_is_msie){
				dhtmlgoodies_iframe = document.createElement('IFRAME');
				dhtmlgoodies_iframe.frameborder='5';
				dhtmlgoodies_iframe.style.backgroundColor='gray';
				dhtmlgoodies_iframe.src = '#'; 	
				dhtmlgoodies_iframe.style.zIndex = 100;
				dhtmlgoodies_iframe.style.position = 'absolute';
				document.body.appendChild(dhtmlgoodies_iframe);
			}
			
		}
		
		dhtmlgoodies_tooltip.style.display='block';

		dhtmlgoodies_tooltip.style.filter = 'alpha(opacity=100)';
		dhtmlgoodies_tooltip.style.opacity = '1.0';
		dhtmlgoodies_tooltipShadow.style.display='block';
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='block';
		
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		var leftPos = e.clientX + 10;
		
		dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
		dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
		dhtmlgoodies_tooltip.style.left = leftPos + 'px';
		dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';

		
		dhtmlgoodies_tooltipShadow.style.left =  leftPos + dhtmlgoodies_shadowSize + 'px';
		dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
		
		if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
			dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
		}
		
		var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;		
		if(tooltipWidth<dhtmlgoodies_tooltipMinWidth)tooltipWidth = dhtmlgoodies_tooltipMinWidth;
		
		
		dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';		
		
		if((leftPos + tooltipWidth)>bodyWidth){
			dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
			dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
		}
		
		if(tooltip_is_msie){
			dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
			dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
			dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
			dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
		
		}
				
	}
	
	function topvacation()
	{
		var temp = document.getElementById('vacation_name_id');
		var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'>" + temp.value + "</td></tr></table>";
		return str;
	}

	function hideTooltip()
	{
		dhtmlgoodies_tooltip.style.display='none';
		dhtmlgoodies_tooltipShadow.style.display='none';		
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='none';		
	}
	
	function tip(id,link,image)
	{
		var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center><b>" + id + "</b></center></td></tr><tr><td width=100% style='padding:10px;text-align:center;'><img src=" + link +  "/components/com_travelagency/images/" + image + " width=150></td></tr></table>";
		return str;
	}

	function tip2(vc_type,link,id,image1,image2,image3,image4,image5)
	{
		var temp = document.getElementById('tooltip_type_' + id);
		var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center>";
			str += "<b>" + vc_type + "</b></center>";
			str += "</td></tr>";
			str += "<tr><td width=100% style='padding:10px;text-align:center;verticall-align:top' valign=top>";
			if(image1!="")
			{
				str += "<img src=" + link +  "/components/com_travelagency/images/" + image1 + " height=100>";
			}
			if(image2!="")
			{
				str += "<img src=" + link +  "/components/com_travelagency/images/" + image2 + " height=100>";
			}
			if(image3!="")
			{
				str += "<img src=" + link +  "/components/com_travelagency/images/" + image3 + " height=100>";
			}
			if(image4!="")
			{
				str += "<img src=" + link +  "/components/com_travelagency/images/" + image4 + " height=100>";
			}
			if(image5!="")
			{
				str += "<img src=" + link +  "/components/com_travelagency/images/" + image5 + " height=100>";
			}
			str += "</td></tr>";
			str += "<tr><td width='100%' style='color:white;padding-left:20px;'><table cellpadding=0 cellspacing=0 width=100% border='0'><tr><td width=100%>";
			str += temp.value;
			str += "</td></tr></table></td></tr>";
			str += "</table>";

		return str;
	}

	function tipLocation(loc_name,link,image,id)
	{
			var temp = document.getElementById('tooltip_location_' + id);
			var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center>";
			str += "<b>" + loc_name + "</b></center>";
			str += "</td></tr>";
			str += "<tr><td width=100% style='padding:10px;text-align:left;verticall-align:top;color:white;' valign=top><div>";
			if(image!="")
			{
				//str += "<div style='float:left;padding-right:10px;padding-bottom:10px;'<img src=" + link +  "/components/com_travelagency/images/" + image + " height=100></div>";
			}
			str += temp.value;
			str += "</div></td></tr>";
			str += "</table>";
			return str;
	}


	function tipHotel(loc_name,link,image,id)
	{
			var temp = document.getElementById('tooltip_hotel_' + id);
			var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center>";
			str += "<b>" + loc_name + "</b></center>";
			str += "</td></tr>";
			str += "<tr><td width=100% style='padding:10px;text-align:left;verticall-align:top;color:white;' valign=top><div>";
			if(image!="")
			{
				//str += "<div style='float:left;padding-right:10px;padding-bottom:10px;'<img src=" + link +  "/components/com_travelagency/images/" + image + " height=100></div>";
			}
			str += temp.value;
			str += "</div></td></tr>";
			str += "</table>";
			return str;
	}


	function addservices(i)
	{
		var temp = document.getElementById('extra_services');
		var str = temp.value;
		str += "_" + i;
		temp.value = str;
	}

	function tipAct(activity,link,image,id)
	{
		    var temp = document.getElementById('tooltip_act_' + id);

			var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center>";
			str += "<b>" + activity + "</b></center>";
			str += "</td></tr>";
			str += "<tr><td width=100% style='padding:10px;text-align:left;verticall-align:top;color:white;' valign=top><div>";
			str += temp.value;
			str += "</div></td></tr>";
			str += "</table>";
			return str;
	}

	function tip1(desc)
	{
		var str = "<table cellpadding=0 cellspacing=0 width=100%><tr><td style='color:white;'><center><b>" + desc + "</b></center></td></tr></table>";
		return str;
	}

	function IsNumeric(sText)

	{
	   var ValidChars = "0123456789";
	   var IsNumber=true;
	   var Char;

	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
		  { 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) 
			 {
			 IsNumber = false;
			 }
		  }
	   return IsNumber;
	   
	   }

	function passStep1()
	{
		var startDate = document.getElementById('startDate');
		var arrivalDate = document.getElementById('arrivalDate');
		var start_activity = document.getElementById('start_activity');
		var vacation_name = document.getElementById('vacation_name');
		var numguest = document.getElementById('numguest');
		var num_date  = document.getElementById('num_date');

		var number = IsNumeric(numguest.value);

	
		if(vacation_name.value=="")
		{
			alert("Please enter the vacation title");
		}
		else if(startDate.value=="")
		{
			alert("Please choose the departure date");
		}
		else if(arrivalDate.value=="")
		{
			alert("Please choose arrival date");
		}
		else if(numguest.value=="")
		{
			alert("Please enter the number of guests");
		}
		else if(number==false)
		{
			alert("The number of guests must be number character");
		}
		else
		{
			var cip = document.getElementById('cip');
			startDateTemp = startDate.value;
			startYear = startDateTemp.substring(0,4);
			monthYear = startDateTemp.substring(5,7);
			monthYear = parseInt(monthYear);
			dayYear   = startDateTemp.substring(9,11);
			dayYear   = parseInt(dayYear);
			startDateObj = new Date(startYear,monthYear,dayYear);
			currentDate = new Date();

			if(startDateObj < currentDate)
			{
				alert("The departure date cannot before today");
			}
			else{
				
				step2(startDate.value,numguest.value,arrivalDate.value,cip.value,vacation_name.value,start_activity.value,num_date.value);			
			}

			//step2(startDate.value,numguest.value,numday.value,cip.value);		
		}
		
		
	}
	function showDetailsOfVacationType(id)
	{
		loadVacationDetails(id);
	}
	function chooseVacationType(type_id,vid)
	{
		var temp = document.getElementById('type_temp');
		if(temp.value=="")
		{
			alert("Please choose one vacation type");
		}
		else
		{

			choosevacationTypeAjax(temp.value,vid);
		}
	}
	function chooseVacationTypeForTemp(type_id,vid)
	{
		var temp = document.getElementById('type_temp');
		
		temp.value = type_id;
		alertTypeAjax(type_id);
		//choosevacationTypeAjax(type_id,vid);
	}
	function showDetailsOfLocation(id)
	{
		loadLocationDetails(id);
	}
	function chooseLocationForTemp(location_id,vid)
	{
		var temp = document.getElementById('location_temp');
		temp.value=location_id;
		//chooselocationTypeAjax(type_id,vid);
		showlocationtitle(location_id);
	}
	function chooseLocation(location_id,vid)
	{
		var temp = document.getElementById('location_temp');
		if(temp.value=="")
		{
			alert("Please choose location");
		}
		else
		{
			location_id = temp.value;
			chooselocationTypeAjax(location_id,vid);
		}
	}
	function showDetailsOfAct(id)
	{
		loadActDetails(id);
	}
	function gotoStep5(count_day,id,start_date,start_activity)
	{
			var str = '';
			var bo = 1;
			var temp1;
			if(start_activity==0)
			{
				start = 1;
			}else{
				start = 0;
			}
			for(i=start;i<count_day;i++){
				startdate = i + 1;
				temp = id + "_" + startdate;
				temp = document.getElementById(temp);
				if(temp!=null)
				{
					if(temp.value!="")
					{
						str += ":" + startdate + "_" + temp.value;
					}
					else
					{
						temp1 = document.getElementById('td_act_' + id + '_' + i);
						if(temp1!=null)
						{
							temp1.style.background = "red";
							//alert(temp1);
						}
						bo = 0;
					}
				}
				
			}

			//tra ve str
			if(bo==1)
			{
				str = str.substring(1,str.length);
				gotoStep5Ajax(id,str,start_date);
			}
			else{
				alert("All fields must be filled");
			}
	}
	function chooseHotelForTemp(hotel_id,id)	
	{
		var temp = document.getElementById('hotel_temp');
		temp.value =  hotel_id;
		showhoteltitle(hotel_id);
		//chooseHotelAjax(hotel_id,id);
	}
	function chooseHotel(hotel_id,id)	
	{
		var temp = document.getElementById('hotel_temp');
		if(temp.value=="")
		{
			alert("Please choose hotel");
		}
		else
		{
			hotel_id = temp.value;
			chooseHotelAjax(hotel_id,id);
		}
	}
	function changeStatusValue(id)
	{
		var temp = document.getElementById(id);
		if(temp.value==0)
		{
			temp.value = 1;
		}else{
			temp.value = 0;
		}

	}

	function showDetailsOfCat(cat_id,id)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }

		//var url="index.php?option=com_travelagency&view=upload&task=saveinformation&id=" + id + "&user_name=" + user_name.value + "&user_address=" + user_address.value + "&user_email=" + user_email.value + "&user_phone=" + user_phone.value + "&user_city=" + user_city.value + "&user_country=" + user_country.value;
		var url = "index2.php?option=com_travelagency&view=upload&task=step5&id=" + id + "&cat_id=" + cat_id;
		xmlHttp.onreadystatechange=stateChangeda1
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		}
		function stateChangeda1() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("content_travel5").innerHTML=xmlHttp.responseText 
			//location.href='index.php?option=com_travelagency&view=upload&task=reviewAll&id='+ id;
		 } 
		else
		  {
			document.getElementById("content_travel5").innerHTML= "<img src='http://www.keia.com/images/loading.gif'>"
		  }
		}
		function GetXmlHttpObject()
		{
		var xmlHttp=null;
		try
		 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
		 }
		catch (e)
		 {
		 //Internet Explorer
		 try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		 }
		return xmlHttp;
	}



function gotoprevious(id,itemid)
{
	var temp = document.getElementById('goback');
	if(temp.value!="")
	{
		location.href='index.php?option=com_travelagency&view=upload&task=' + temp.value + '&id=' + id + '&Itemid=' + itemid;
	}
}

function verifyEmail(){
var status = false;     
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
     if (document.myform.email1.value.search(emailRegEx) == -1) {
          alert("Please enter a valid email address.");
     }
     else if (document.myform.email1.value != document.myform.email2.value) {
          alert("Email addresses do not match.  Please retype them to make sure they are the same.");
     }
     else {
          alert("Woohoo!  The email address is in the correct format and they are the same.");
          status = true;
     }
     return status;
}

function checkingSubmitForm()
{
	var title = document.getElementById('user_title');
	var first_name  = document.getElementById('user_first_name');
	var last_name  = document.getElementById('user_name');
	var user_address  = document.getElementById('user_address');
	var user_city  = document.getElementById('user_city');
	var user_country  = document.getElementById('user_country');
	var user_email  = document.getElementById('user_email');
	var user_phone  = document.getElementById('user_phone');
	var term1 = document.getElementById('term1');
	var term2 = document.getElementById('term2');
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if(title.value=="")
	{
		alert("Please choose title");
	}
	else if(first_name.value=="")
	{
		alert("Please enter your first name");
	}
	else if(last_name.value=="")
	{
		alert("Please enter your last name");
	}
	else if(user_address.value == "")
	{
		alert("Please enter your address");
	}
	else if(user_city.value == "")
	{
		alert('Please enter your city name');
	}
	else if(user_country.value == "")
	{
		alert("Please choose your country");
	}
	else if(user_email.value=="")
	{
		alert("Please enter your email address");
	}
	else if(user_email.value.search(emailRegEx) == -1)
	{
		alert("Please enter the valid email address");
	}
	else if(term1.value==0)
	{
		alert("You must agree with term and condition");
	}
	else if(term2.value==0)
	{
		alert("You must agree with visas");
	}
	else
	{
		document.adminForm.submit();
	}
}
function changeImage(image,id)
{
	var temp = document.getElementById('addservices');
	if(temp!=null)
	{
		temp.src='components/com_travelagency/images/' + image;
	}
}


function showExtraActExtraServices(count_day,id)
{
	var str = '';
	var bo = 1;
	var temp1;
	for(i=0;i<count_day;i++){
		temp = id + "_" + i;
		temp = document.getElementById(temp);
		if(temp!=null)
		{
			if(temp.value!="")
			{
				str += ":" + temp.value;
			}
			else
			{
				temp1 = document.getElementById('td_act_' + id + '_' + i);
				if(temp1!=null)
				{
					temp1.style.background = "red";
				}
				bo = 0;
			}
		}
	}
	if(bo==1)
	{
		str = str.substring(1,str.length);
		showExtraservicesAct(id,str);
	}
	else{
		alert("All fields must be filled");
	}
}
function showExtraservicesAct(hotel_id,str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	
	var url="index2.php?option=com_travelagency&view=upload&task=showextraservicesAct&id=" +  hotel_id + "&str=" + str;
	xmlHttp.onreadystatechange=extraservicesAct
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function extraservicesAct() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("showextraservicesAct_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("showextraservicesAct_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
function changeCheckboxActValue(i1,id,k,count)
{
	var name = "extra_act_checkbox_" + i1 + "_" + id + "_" + k;
	var temp = document.getElementById(name);
	if(temp!=null){		
		if(temp.value==0){
			temp.value = 1;
		}else{
			temp.value = 0;
		}
	}
	var temp1 = "extra_act_checkbox_total_" + i1 + "_" + id;
	var temp1  = document.getElementById(temp1);
	var value  = temp1.value;
	var temp2;
	var total_services_str='';
	for(i=0;i<count;i++){
		name  = "extra_act_checkbox_" + i1 + "_" + id + "_" + i;
		value = "extra_act_checkbox_value_" + i1 + "_" + id + "_" + i;
		temp  = document.getElementById(name);
		if(temp!=null){
			if(temp.value==1){
				temp2 = document.getElementById(value);
				if(temp2!=null){
					total_services_str += "," + temp2.value;
				}
			}
		}
	}
	total_services_str = total_services_str.substr(1,total_services_str.length);
	temp1.value = total_services_str;
}
function updateExtraFieldValue(id,count)
{
	var temp   = document.getElementById(id);
	if(temp!=null){		
		if(temp.value==0){
			temp.value = 1;
		}else{
			temp.value = 0;
		}
	}
	var temp1  = document.getElementById('checkbox_extraservices_total');
	var value  = temp1.value;
	var temp2;
	var total_services_str = '';
	for(i=0;i<count;i++){
		temp = document.getElementById('checkbox_extraservices_' + i);
		if(temp!=null){
			if(temp.value==1){
				temp2 = document.getElementById('checkbox_extraservices_value_' + i);
				if(temp2!=null){
					total_services_str += "__" + temp2.value;
				}
			}
		}
	}
	
	temp1.value = total_services_str;
}

function showActExtrafields(id,day)
{

	var temp = document.getElementById(id + '_' + day);

	if(temp!=null)
	{
		if(temp.value!="")
		{
			showActExtrafieldsAjax(id,day,temp.value);
		}
	}
}
function showActExtrafieldsAjax(id,day,value)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_travelagency&view=upload&task=showextraservicesActEach&id=" +  id +"&day=" + day + "&act=" + value;

	xmlHttp.onreadystatechange=extraservicesAct
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	xmlHttp.div_id = day;
	}
	function extraservicesAct() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 

			document.getElementById("extraservices_act_" + xmlHttp.div_id).innerHTML=xmlHttp.responseText 
			
		 } 
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}
