//Ajax function

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function showUser(str,id)
{ 

if(document.getElementById('txtShow'+id).style.display == 'none'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('txtShow'+id).innerHTML = oXML.responseText;};
	
	document.getElementById('txtShow').style.display = 'inline'; 
	document.getElementById('txtShow').innerHTML = "<img src='images/loading.gif' />";
	myConn.connect("main_pg.php", "GET", "?qid2="+str, include_terminado);
	
	}
	else
	{
		
		
		document.getElementById('txtShow'+id).style.display = 'none'; 
		
	}

}


function showBooking(id)
{
	if(document.getElementById('booking'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('book'+id).innerHTML = oXML.responseText;};
	document.getElementById('btnBooking'+id).value = 'Hide Booking'; 
	document.getElementById('booking'+id).className = 'reveal'; 
	document.getElementById('book'+id).innerHTML = "<img src='images/loading.gif' />";
	myConn.connect("booking.php", "GET", "id="+id, include_terminado);
	
	}
	else
	{
		
		
		document.getElementById('booking'+id).className = 'hidden'; 
		document.getElementById('book'+id).innerHTML = "";
		document.getElementById('btnBooking'+id).value = 'Show Booking';
	}
}


function checkEmail()
{
	
	//alert(document.getElementById('email').value);
	
	
	var myConn = new XHConn();
	var email;
	email = document.getElementById('email').value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ 
	if(oXML.responseText == '1'){
	document.getElementById('email').style.background='red';
	document.getElementById('email').style.color='white';
	document.getElementById('err').innerHTML = '<font color=red>Email all ready exist in database</font>';
	document.getElementById('submit').disabled = true;
	}
	else
	{
	document.getElementById('email').style.background='white';
	document.getElementById('email').style.color='black';
	document.getElementById('err').innerHTML = '';
	document.getElementById('submit').disabled = false;
	}
	};
	myConn.connect("checkemail.php", "GET", "email="+email, include_terminado);
	
	
	
}

function checkCode(addHotel)

{
	
	var myConn = new XHConn();
	var user;

	user = document.addHotel.txthotelcode.value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

	var include_terminado = function (oXML){ 
	//alert(oXML.responseText);
	if(oXML.responseText == 1){
		
	document.getElementById('txthotelcode').style.background='red';

	document.getElementById('txthotelcode').style.color='white';

	document.getElementById('err').innerHTML = '<font color=red size=1>Hotel Code already exists, Please Choose different!</font>';

	
	document.getElementById('err').className = 'reveal';

	document.addHotel.txthotelcode.focus();
	document.getElementById('submit').disabled = true;

   	document.addHotel.txthotelcode.focus();

	}

	else

	{

	document.getElementById('txthotelcode').style.background='white';

	document.getElementById('txthotelcode').style.color='black';
    /////document.addHotel.txthotelcode.toUpperCase();
	document.getElementById('err').className = 'hidden';
	document.getElementById('err').innerHTML = '';

	document.getElementById('submit').disabled = false;

	}

	};

	myConn.connect("chkcode.php", "GET", "hcode="+user, include_terminado);
}

function checkAgntCode(addFrm)
{

	var myConn = new XHConn();
	var user;

	user = document.addFrm.txtagentcode.value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

	var include_terminado = function (oXML){ 
	//alert(oXML.responseText);
	if(oXML.responseText == 1){
		
	document.getElementById('txtagentcode').style.background='red';
	document.getElementById('txtagentcode').style.color='white';
	document.getElementById('err').innerHTML = '<font color=red size=1>Agent Code already exists, Please Choose different!</font>';
	document.getElementById('err').className = 'reveal';
	document.addFrm.txtagentcode.focus();
	document.getElementById('submit').disabled = true;
   	document.addFrm.txtagentcode.focus();
	}
	else
	{
	document.getElementById('txtagentcode').style.background='white';
	document.getElementById('txtagentcode').style.color='black';
    /////document.addHotel.txthotelcode.toUpperCase();
	document.getElementById('err').className = 'hidden';
    document.getElementById('err').innerHTML = '';
	document.getElementById('submit').disabled = false;
	}

	};

	myConn.connect("chkcode.php", "GET", "acode="+user, include_terminado);
}

function checkEmpCode(addEmp)
{

	var myConn = new XHConn();
	var user;

	user=document.addEmp.txtempcode.value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

	var include_terminado = function (oXML){ 
	//alert(oXML.responseText);
	if(oXML.responseText == 1){
		
	document.getElementById('txtempcode').style.background='red';
	document.getElementById('txtempcode').style.color='white';
	document.getElementById('err').innerHTML = '<font color=red size=1>Employee Code already exists, Please Choose different!</font>';
	document.getElementById('err').className = 'reveal';
	document.addEmp.txtempcode.focus();
	document.getElementById('submit').disabled = true;
   	document.addEmp.txtempcode.focus();
	}
	else
	{
	document.getElementById('txtempcode').style.background='white';
	document.getElementById('txtempcode').style.color='black';
    /////document.addHotel.txthotelcode.toUpperCase();
	document.getElementById('err').className = 'hidden';
    document.getElementById('err').innerHTML = '';
	document.getElementById('submit').disabled = false;
	}

	};

	myConn.connect("chkcode.php", "GET", "ecode="+user, include_terminado);
}
function signUp()
{

}
function showTestimonial(id)
{
	if(document.getElementById('booking'+id).className == 'hidden'){

	document.getElementById('btnBooking'+id).value = 'Hide Testimonial'; 
	document.getElementById('booking'+id).className = 'reveal'; 
	
	}
	else
	{
		document.getElementById('btnBooking'+id).value = 'Show Testimonial';
		document.getElementById('booking'+id).className = 'hidden'; 
		
	}
}
function showeventdetails(id)
{
	if(document.getElementById('event'+id).className == 'hidden'){

	document.getElementById('imgevent'+id).value = 'Hide Testimonial'; 
	document.getElementById('event'+id).className = 'reveal'; 
	
	}
	else
	{
		document.getElementById('imgevent'+id).value = 'Show Testimonial';
		document.getElementById('event'+id).className = 'hidden'; 
		
	}
}
function AgentDetails(id)
{
	if(document.getElementById('agent'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('agnt'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agent'+id).className = 'reveal'; 
	document.getElementById('agnt'+id).innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("agentdet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agent'+id).className = 'hidden'; 
		document.getElementById('agnt'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}
function EmpDetails(id)
{
	if(document.getElementById('agent'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('agnt'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agent'+id).className = 'reveal'; 
	document.getElementById('agnt'+id).innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("empdet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agent'+id).className = 'hidden'; 
		document.getElementById('agnt'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}

function ClientDetails(id)
{
	if(document.getElementById('agent'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('agnt'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agent'+id).className = 'reveal'; 
	document.getElementById('agnt'+id).innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("clientdet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agent'+id).className = 'hidden'; 
		document.getElementById('agnt'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}

function PkgDetails(id)
{
	//alert(id);
	if(document.getElementById('agent'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('agnt'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agent'+id).className = 'reveal'; 
	document.getElementById('agnt'+id).innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("packagedet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agent'+id).className = 'hidden'; 
		document.getElementById('agnt'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}

function HotelPkgDetails(id)
{
	if(document.getElementById('agent'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('agnt'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agent'+id).className = 'reveal'; 
	document.getElementById('agnt'+id).innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("hotelpackagedet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agent'+id).className = 'hidden'; 
		document.getElementById('agnt'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}


function HotelDetails(addPkg)
{
	var hid=document.addPkg.txthotelcode.value;
	var ht=hid.split(":");
	var id=ht[0];
	document.addPkg.hdnCode.value=ht[1];
	
	if(document.getElementById('htldet').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('htldet').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('htldet').style.display="inline"; 
	document.getElementById('htldet').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("hoteldet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('htldet').style.display="none"; 
		document.getElementById('htldet').innerHTML = "";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}


function getClient(frmtravel)
{
	
	var myConn = new XHConn();
	var cid=document.frmtravel.clientcode.value;
	//alert(cid);
	if(document.getElementById('htldet').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('htldet').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('htldet').style.display="inline"; 
	document.getElementById('htldet').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("clientdet2.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('htldet').style.display="none"; 
		document.getElementById('htldet').innerHTML = "";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}

function getAgent(frmtravel)
{
	
	var myConn = new XHConn();
	var cid=document.frmtravel.agntcode.value;
	//alert(cid);
	if(document.getElementById('agdet').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('agdet').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('agdet').style.display="inline"; 
	document.getElementById('agdet').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("agentdet2.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('agdet').style.display="none"; 
		document.getElementById('agdet').innerHTML = "";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}
function getEmp(frmtravel)
{
	
	var myConn = new XHConn();
	var cid=document.frmtravel.empcode.value;
	//alert(cid);
	if(document.getElementById('empdet').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('empdet').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('empdet').style.display="inline"; 
	document.getElementById('empdet').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("empdet2.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('empdet').style.display="none"; 
		document.getElementById('empdet').innerHTML = "";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
}
function chooseHotel(frmDeal)
{
	//alert("HELLO");
	//alert(document.getElementById('hotelcode').value);
	var myConn = new XHConn();
	var cont=document.frmDeal;
	var hotel;
	hotel = cont.hotelcode.value;
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ 
	//alert(oXML.responseText);
	var hoteldetail=oXML.responseText;
	var hoteldet=hoteldetail.split("*");
	cont.txthotel.value=hoteldet[0];
	cont.txthoteladd.value=hoteldet[1];
	
	};
	myConn.connect("chkhotel.php", "GET", "hotel="+hotel, include_terminado);
	
}
function getHotel(frmtravel,id)
{
	
	//alert(id);
	//alert(document.frmtravel["txthotelcode" + id].value);
	var myConn = new XHConn();
	var cont=document.frmtravel["txthotelcode" + id];
	var hotelcd = cont.value;
	//alert(hotelcd);
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var hoteldetail=oXML.responseText;
	var x;
	
	    var htarr=hoteldetail.split("==");
		document.frmtravel["txthotelplace" + id].value=htarr[0];
		var htrms=htarr[1].split("@");
       
	   for (x in htrms){
		  // alert(htrms[x]);
		   document.frmtravel["roomtype" + id].options[x]=new Option(htrms[x],htrms[x]);
		   
	   }

		
		//document.getElementById("dht").innerHTML=hoteldetail;
	};
	myConn.connect("gethotel.php", "GET", "hotel="+hotelcd, include_terminado);
	
}


function getHotelRate(frmtravel,id)
{
	
	//alert(id);
	//alert(document.frmtravel["txthotelcode" + id].value);
	
	var frm=document.frmtravel.rmno.value;
	var myConn = new XHConn();
	var cont=document.frmtravel["txthotelcode" + id];
	var hotelcd = cont.value;
	
	var rt=document.frmtravel["roomtype" + id];
	var hoteltype = rt.value;
	var noofrm=document.frmtravel["hotelrooms" + id];
	var noofexbed=document.frmtravel["hotelexbed" + id];
	var htrm = noofrm.value;
	var hexbd = noofexbed.value;
	var gdamt=0;
	//alert(hoteltype);
	document.frmtravel["purchasecurrency" + id].style.color='red';
	document.frmtravel["purchasecurrency" + id].value="Loading...";
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var hotelamt=oXML.responseText;
	document.frmtravel["billcurrency" + id].style.color='black';
	document.frmtravel["billcurrency" + id].value=hotelamt;
	
	document.frmtravel["purchasecurrency" + id].value=hotelamt;
	//var gamt=eval(document.frmtravel["billcurrency" + id].value);
	//gamt+=eval(gamt);
	document.frmtravel.txtGrandpurchase.style.color='red';
	
	for(var iht=1;iht<=frm;iht++){
		//alert("billcurrency"+iht);
		if(document.frmtravel["billcurrency" + iht].value==""){
			continue;}
		
		gdamt+=eval(document.frmtravel["billcurrency" + iht].value);
		}
		
		//gdamt+=eval(document.frmtravel["billcurrency" + i].value);}
	document.frmtravel.txtGrandpurchase.value=gdamt;
	document.frmtravel.txtGrandbill.value=gdamt;
	document.frmtravel.txttotal.value=gdamt;
		
	};
	myConn.connect("gethotelrate.php", "GET", "hotel="+hotelcd+"&htrm="+hoteltype+"&rmno="+htrm+"&exbed="+hexbd, include_terminado);
	
}
function ChangeRate(frmtravel)
{
	
	var frm=document.frmtravel.rmno.value;
	//alert(frm);
	var gdbillamt=0;
	
	for(var iiht=1;iiht<=frm;iiht++){
		//alert("billcurrency"+iht);
		if(document.frmtravel["billcurrency" + iiht].value==""){
			continue;}
		
		gdbillamt+=eval(document.frmtravel["billcurrency" + iiht].value);
		}
		
		//gdamt+=eval(document.frmtravel["billcurrency" + i].value);}
	
	document.frmtravel.txtGrandbill.value=gdbillamt;
		
	
}
function getlist(frmtravel)
{
	
	var myConn = new XHConn();
	var cid=document.frmtravel.rmno.value;
	
//alert(cid);
	if(document.getElementById('tdtravellist').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('tdtravellist').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('tdtravellist').style.display="inline"; 
	document.getElementById('tdtravellist').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("travelfrm.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('tdtravellist').style.display="none"; 
		document.getElementById('tdtravellist').innerHTML = "";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
	
}

function getHotelRm(addHotel)
{
	
	var myConn = new XHConn();
	var cid=document.addHotel.noofrm.value;
	
//alert(cid);
	if(document.getElementById('tdrmlist').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('tdrmlist').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('tdrmlist').style.display="inline"; 
	//document.getElementById('frmAddNew').style.display="inline"; 
	document.getElementById('tdrmlist').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("hotelrmfrm.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('tdrmlist').style.display="none"; 
		document.getElementById('tdrmlist').innerHTML = "";
		///document.getElementById('frmAddNew').style.display="none";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
	
}

function getHotelExRm(addHotelex)
{
	
	var myConn = new XHConn();
	var cid=document.addHotelex.noofrm.value;
	
//alert(cid);
	if(document.getElementById('tdrmlist').style.display="none"){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	
	var include_terminado = function (oXML){ document.getElementById('tdrmlist').innerHTML = oXML.responseText;};
	
	//document.getElementById('imgPro'+id).src = 'images/close2.jpg'; 
	document.getElementById('tdrmlist').style.display="inline"; 
	document.getElementById('frmAddNew').style.display="inline"; 
	document.getElementById('tdrmlist').innerHTML = "<img src='images/ajaxloading10.gif' />";
	myConn.connect("hotelrmfrm.php", "GET", "clid="+cid, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('tdrmlist').style.display="none"; 
		document.getElementById('tdrmlist').innerHTML = "";
		document.getElementById('frmAddNew').style.display="none";
		//document.getElementById('imgPro'+id).src = 'images/view_more.gif';
	}
	
}

////////   PACKAGE DETAILS                 /////////////////////////

function getCity(frmPkg)
{
	
	//alert("adfasfdafs");
	//alert(document.frmtravel["txthotelcode" + id].value);
	
	var myConn = new XHConn();
	var cont=document.frmPkg["country"];
	var concity=document.frmPkg["city"];
	var country = cont.value;
	
	//alert(country);
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var hoteldetail=oXML.responseText;
	var x=0;
	
	    var htarr=hoteldetail.split("@");
		
       //alert(htarr);
	   var numcity=htarr.length-1;
	   
	   document.frmPkg["city"].options.length=0;
	   document.frmPkg["city"].options[0]=new Option("-----All-----","");
	   //alert(numcity);
	   
	   if(numcity >=1){
		   
		  				   for(i=0;i<numcity;i++){
						   document.frmPkg["city"].options[i+1]=new Option(htarr[i],htarr[i]);}
								
						}
		 
		//alert(hoteldetail);
		//document.getElementById("dht").innerHTML=hoteldetail;
	};
	myConn.connect("getcity.php", "GET", "country="+country, include_terminado);
	
}



function getLocation(frmPkg)
{
	var myConnloc = new XHConn();
	
	var con=document.frmPkg["city"];
	var concity = con.value;
	if(concity==""){
	alert("Please Re-Select Country");return false;}
	//alert(country);
	if (!myConnloc) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var hoteldetail=oXML.responseText;
	var x=0;
	
	    var htarr=hoteldetail.split("@");
		//document.frmPkg["city"].value=htarr[0];
		//var htrms=htarr[1].split("@");
      // alert(htarr);
	   var numcity=htarr.length-1;
	   document.frmPkg["location"].options.length=0;
	   document.frmPkg["location"].options[0]=new Option("-----All-----","");
	   //alert(numcity);
	   
	   if(numcity >=1){
		   
		  
						   for(i=0;i<numcity;i++){
						   document.frmPkg["location"].options[i+1]=new Option(htarr[i],htarr[i]);}
								
						}
		
	};
	myConnloc.connect("getLocation.php", "GET", "city="+concity, include_terminado);
	
}

function getTourCountry(frmtourPkg)
{
	
	var myConn = new XHConn();
	var region=document.frmtourPkg["pkg_region"];
	//var concity=document.frmPkg["city"];
	var reg = region.value;
	
	//alert(country);
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var condetail=oXML.responseText;
	var x=0;
	
	    var htarr=condetail.split("@");
		
       //alert(htarr);
	   var numcity=htarr.length-1;
	   
	   document.frmtourPkg["country"].options.length=0;
	   document.frmtourPkg["country"].options[0]=new Option("---------All---------","");
	   //alert(numcity);
	   
	   if(numcity >=1){
		   
		  				   for(i=0;i<numcity;i++){
						   document.frmtourPkg["country"].options[i+1]=new Option(htarr[i],htarr[i]);}
								
						}
		 
		//alert(hoteldetail);
		//document.getElementById("dht").innerHTML=hoteldetail;
	};
	myConn.connect("getcity.php", "GET", "region="+reg, include_terminado);
	
}



function getTourLocation(frmtourPkg)
{
	var myConnloc = new XHConn();
	
	var con=document.frmtourPkg["city"];
	var concity = con.value;
	
	//alert(country);
	if (!myConnloc) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ 
	var hoteldetail=oXML.responseText;
	var x=0;
	
	    var htarr=hoteldetail.split("@");
		//document.frmPkg["city"].value=htarr[0];
		//var htrms=htarr[1].split("@");
      // alert(htarr);
	   var numcity=htarr.length-1;
	   document.frmtourPkg["location"].options.length=0;
	   document.frmtourPkg["location"].options[0]=new Option("-----All-----","");
	   //alert(numcity);
	   
	   if(numcity >=1){
		   
		  
						   for(i=0;i<numcity;i++){
						   document.frmtourPkg["location"].options[i+1]=new Option(htarr[i],htarr[i]);}
								
						}
		
	};
	myConnloc.connect("getLocation.php", "GET", "tcity="+concity, include_terminado);
	
}

function getpic111(pic,id){
	

var myConn = new XHConn();
var img = document.images['imgPkg'+id]; 

document.getElementById('divpkg'+id).innerHTML = "<img name="+img+" src='images/loading.gif' />";
if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
var include_terminado = function (oXML){ 

	
	};
//img.src = pic;
document.getElementById('divpkg'+id).innerHTML ="";	
document.getElementById('divpkg'+id).innerHTML = "<img name="+img+" src='"+pic+"' />";	


}

function GalleryDetails(id)
{
	if(document.getElementById('property'+id).className == 'hidden'){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var include_terminado = function (oXML){ document.getElementById('prop'+id).innerHTML = oXML.responseText;};
	document.getElementById('imgPro'+id).src = 'images/delete.gif'; 
	document.getElementById('property'+id).className = 'reveal'; 
	document.getElementById('prop'+id).innerHTML = "<img src='images/loading.gif' />";
	myConn.connect("GalleryDet.php", "GET", "id="+id, include_terminado);
	//alert("PROPERTY DETAILS");
	return false;
	}
	else
	{
		document.getElementById('property'+id).className = 'hidden'; 
		document.getElementById('prop'+id).innerHTML = "";
		document.getElementById('imgPro'+id).src = 'images/button_quick_find.gif';
	}
}

function deleteMultipl()
{
	
	if(confirm("Do you Really want to Delete?")==true)
	{

		//CheckIsSelected();
		
		document.location.href="property.php";
		return true;
	}
   else
   return false;
	
}
function deleteMultipleGallery()
{
	
	if(confirm("Do you Really want to Delete?")==true)
	{

		//CheckIsSelected();
		
		document.location.href="gallery.php?action=view";
		return true;
	}
   else
   return false;
	
}
function deleteeventMultipl()
{
	
	if(confirm("Do you Really want to Delete?")==true)
	{

		//CheckIsSelected();
		
		document.location.href="event.php";
		return true;
	}
   else
   return false;
	
}
function CheckIsSelected()
{
        var chkobj=document.form1.chk;
		var blSelected = false;
        
		for(i=0;i<chkobj.length;i++)
			{
				if(chkobj[i].checked)
				{ 
						blSelected = true;
						break;
				}
				
			}
		
		if(!blSelected)
        {
          	alert('Please Select at least One Record!');
            return false
        }
		else
		{
			
			return true;
		}
}
var form='form1' //Give the form name here

function SetChecked(val,chkName) {
dml=document.forms[form];
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if (dml.elements[i].name==chkName) {
dml.elements[i].checked=val;
}
}
}

function checkBox(){
return confirm('All records will be deleted');
}


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
    if (theAction == "over" || theAction == "click") {
        theRow.style.cursor='pointer';
    } else {
        theRow.style.cursor='default';
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function ChangeImage(param)
{
	var img_array = param.split('@');
	var img_id_array = img_array[1].split('#');
	var img = document.getElementById('bigImage'); 
	var a = document.getElementById('bimg'); 
	img.src = "../propertyimages/"+img_array[0];
	a.href = "javascript:popupWindow('popup_image.php?imgID="+img_id_array[0]+"@"+img_id_array[1]+"')";
	
}

//Booking details showing using AJAX
function showBookingOld(id)
{
document.getElementById('booking'+id).className = 'reveal'; 
alert(id);
}

function open_win(id)
{
window.open("proImg.php?uid="+id,"_blank","scrollbars=yes,width=400,height=420")
}
function open_win2(id)
{
window.open("view_proimg.php?uid="+id,"_blank","scrollbars=no,width=430,height=420")
}

function open_editImgwin(id,imid)
{
window.open("edit_img.php?uid="+id+"&imd="+imid,"_blank","scrollbars=yes,width=400,height=300")
}

function open_addPrice(id)
{
window.open("price.php?pid="+id,"_blank","scrollbars=yes,width=500,height=250")
}

function edit_price(pid,id)
{
window.open("editprice.php?pid="+id+"&id="+pid,"_blank","scrollbars=yes,width=500,height=250")
}

function delete_price(id)
{
if(confirm('The price will be deleted!'))
{
window.open("delete_price.php?id="+id,"_blank","scrollbars=yes,width=400,height=50")
}
}


function close_addPrice()
{
window.opener.location.reload();
self.close();
}



function open_editImgwinGall(id,imid)
{
window.open("edit_imgGall.php?uid="+id+"&imd="+imid,"_blank","scrollbars=yes,width=400,height=300")
}
function chk_imgtype()
{
var extPos=document.reg.upldimg.value.indexOf(".");
var strimg=(document.reg.upldimg.value).substr(extPos+1);
//alert(strimg);
if(document.reg.upldimg.value==""){
alert("Please Select the image");
document.reg.upldimg.focus();
return false;}
var strimg2=strimg.toLowerCase();

if((strimg2!="gif")&&(strimg2!="png")&&(strimg2!="jpg")){
alert("Please Select Only Gif, Jpg or Png Format");
document.reg.upldimg.focus();
return false;}

}

function chk_add_imgtype()
{
var extPos=document.reg.upld_proimg.value.indexOf(".");
var strimg=(document.reg.upld_proimg.value).substr(extPos+1);
//alert(strimg);
if(document.reg.upld_proimg.value==""){
alert("Please Select the image");
document.reg.upld_proimg.focus();
return false;}
if((strimg!="gif")&&(strimg!="png")&&(strimg!="jpg")){
alert("Please Select Only Gif, Jpg or Png Format");
document.reg.upld_proimg.focus();
return false;}

}

function selectAll(){
if(document.form1.chkSel.checked==false){
		DeSelectAll();
}
else
{
selectAllNew();
}
}

function selectAllNew()
{
for(i=0;i<document.form1.elements.length;i++){
if(document.form1.elements[i].type=="checkbox"){
document.form1.elements[i].checked = true;
}
}
}

function DeSelectAll(){
for(i=0;i<document.form1.elements.length;i++){
if(document.form1.elements[i].type=="checkbox"){
document.form1.elements[i].checked = false;
}
}
}


/////////////////////////////////////////////IMAGE GALLERY//////

function selectAllimg(){
if(document.iview.chkSel.checked==false){
		DeSelectAllimg();
}
else
{
selectAllNewimg();
}
}

function selectAllNewimg()
{
for(i=0;i<document.iview.elements.length;i++){
if(document.iview.elements[i].type=="checkbox"){
document.iview.elements[i].checked = true;
}
}
}

function DeSelectAllimg(){
for(i=0;i<document.iview.elements.length;i++){
if(document.iview.elements[i].type=="checkbox"){
document.iview.elements[i].checked = false;
}
}
}


function calAmt(frmtravel){
var famt=document.frmtravel.txtfinalamt;
var gamt=document.frmtravel.txtgst;
var lsamt=document.frmtravel.txtlumsum;

famt.value=(eval(lsamt.value)+(eval(lsamt.value)*eval(gamt.value)/100));
}

function calAmt2(frmtravel){
var vamt=document.frmtravel.txtvehiclebillamt;
var billamt=document.frmtravel.txtGrandbill;
var ttamt=document.frmtravel.txttotalamt;

ttamt.value=eval(eval(vamt.value)+eval(billamt.value));
}


function showVehicle()
{
var elem = document.getElementById('vhc');
elem.style.display="inline";
}
function HideVehicle()
{
var elem = document.getElementById('vhc');
elem.style.display="none";
}
function open_rt(hcd){
	window.open("htl_rates.php?id="+hcd,"_blank","scrollbars=yes,width=900,height=370")
}
function open_price(pid){
window.open("chkpkgprices.php?pid="+pid,"_blank","scrollbars=yes,width=400,height=200")
}

function open_htlpkgs(pid){
window.open("chkhotelpkgs.php?pid="+pid,"_blank","scrollbars=yes,width=700,height=600")
}
