var RESERVprocessingURL = "/g2_script/g2_script_reservation.php";
var CUSTOMERprocessingURL = "/g2_script/g2_script_customer.php";
var USERprocessingURL = "/g2_script/g2_script_user.php";
function login()
{
	var postdata = "username=" + document.frmlogin.username.value + "&password=" + document.frmlogin.password.value + "&pro=login";
	doprocessPost(postdata, "" + USERprocessingURL, 'login');
	//alert("here");
}

function redirect($page)
{
	window.location = '/search';
}

function onchange_country()
{
	window.location = '/?G2COUNTRY=' + document.getElementById('G2COUNTRY').value;
}

function timeDifference(startDate,endDate)
{
date1 = startDate;
date2 = endDate;

laterdate = date1.split("-");
laterY=laterdate[0];
laterM=laterdate[1];
laterD=laterdate[2];

earlierdate = date2.split("-");
earlierY=earlierdate[0];
earlierM=earlierdate[1];
earlierD=earlierdate[2];

var laterdate = new Date(laterY,laterM,laterD);
var earlierdate = new Date(earlierY,earlierM,earlierD);

var difference = laterdate.getTime() - earlierdate.getTime();
var daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60);
difference -= hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60);
difference -= minutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000);

return daysDifference;

}

function daysInMonth(iMonth, iYear)
{
        return 32 - new Date(iYear, iMonth, 32).getDate();
}



function onclick_boomaroom()
{
	
	if((document.getElementById('dt1').style.display == '') && (document.getElementById('dt2').style.display == ''))
	{

		var checkin = document.getElementById("txtdt1").value;
		var checkout = document.getElementById("txtdt2").value;
		daytoday =  document.frmsearch.daysstart.value;
		//alert(timeDifference(checkin, checkout));	
		if(checkin == checkout)
		{
			alert("You cannot proceed.\nPlease check your date.");		
		}
		else
		{
			if(timeDifference(checkin, checkout) <= 0)
			{
				if(timeDifference(daytoday, checkin) <= 0)	
				{
					window.location = '/searchdisplay/?G2COUNTRY=' + document.getElementById('G2COUNTRY').value + '&G2CITY=' + document.getElementById('G2CITY').value + '&G2SHOW28=1&G2CHECKIN=' + checkin + '&G2CHECKOUT=' + checkout + '&G2SHOWDATE=1' ;
				}
				else
				{
					alert("You cannot proceed.\nPlease check your date.");
				}
			}
			else
			{
				alert("You cannot proceed.\nPlease check your date.");
			}
		}
	}
	else
	{
		window.location = '/searchdisplay/?G2COUNTRY=' + document.getElementById('G2COUNTRY').value + '&G2CITY=' + document.getElementById('G2CITY').value + '&G2SHOW28=1&G2CHECKIN=' + document.frmsearch.daysstart.value + '&G2CHECKOUT=' + document.frmsearch.daysend.value + '&G2SHOWDATE=0';
	}
	
}


function cidchange()
{
	
	for (var i=0; i < document.frmsearch.cid.length; i++) 
	{
		if (document.frmsearch.cod[i].value == document.frmsearch.cid.value) 
		{
			if(i != document.frmsearch.cid.length -1)
			{
				document.frmsearch.cod[i + 1].selected = true;
			}
			else
			{
				document.frmsearch.cod[1].selected = true;	
			}
		}
	}
}

function cimchange()
{
	for (var i=0; i < document.frmsearch.cim.length; i++) 
	{
		if (document.frmsearch.com[i].value == document.frmsearch.cim.value) 
		{
			daytoday =  document.frmsearch.daysstart.value.split("-");
			//alert(daytoday);
			if(daysInMonth(document.frmsearch.cim.value-1, daytoday[0]) <= document.frmsearch.cid.value)
			{
				//alert(document.frmsearch.cim.value);
				if(document.frmsearch.cim.value == "12")
				{
					document.frmsearch.com[1].selected = true;
					for(var i1=0; i1<document.frmsearch.coy.length; i1++)
					{
						//alert(document.frmsearch.coy.options[i1].text);
						if (document.frmsearch.coy.options[i1].text == daytoday[0])
				                {
                               			
							document.frmsearch.ciy[i1].selected = true;
							document.frmsearch.coy[i1+1].selected = true;
                				}
						else
						{
	                                                //document.frmsearch.ciy[i1].selected = true;
                                                        //document.frmsearch.coy[i1].selected = true;

						}

					}
				}
				else
				{
					document.frmsearch.com[i+1].selected = true;
					for(var i1=0; i1<document.frmsearch.coy.length; i1++)
                                        {
                                                //alert(document.frmsearch.coy.options[i1].text);
                                                if (document.frmsearch.coy[i1].value == document.frmsearch.ciy.value)
                                                {
                            
                                                        //document.frmsearch.ciy[i1].selected = true;
                                                        document.frmsearch.coy[i1].selected = true;
                                                }
                                                else
                                                {
                                                        //document.frmsearch.ciy[i1].selected = true;
                                                        //document.frmsearch.coy[i1].selected = true;
 
                                                }
         
                                        }

				}
			}
			else
			{
				document.frmsearch.com[i].selected = true;
			}
		}
	}
}

function ciychange()
{
	for (var i=0; i < document.frmsearch.ciy.length; i++) 
	{
		if (document.frmsearch.coy[i].value == document.frmsearch.ciy.value) 
		{
				document.frmsearch.coy[i].selected = true;
		}
	}
}

function showdt(id)
{
	if(id == "1")
	{
		document.getElementById('dt1').style.display = '';	
		document.getElementById('dt2').style.display = '';
		document.getElementById('txtdt1').select();	
	}
	else if(id == "0")
	{
		document.getElementById('dt1').style.display = 'none';	
		document.getElementById('dt2').style.display = 'none';	
	}
}

function textselect(id)
{
	document.getElementById(id).select();
}

function onclick_hotel(hotelname, hcode)
{
	window.location = "/g2p_aal/" + document.getElementById('G2PARAMS').value + "&G2HOTELNAME=" + hotelname + "&G2HCODE=" + hcode;
}


function transferdisable(chid)
{
	//alert(chid);
	if(document.getElementById(chid).checked == true)
	{
		for(i=1;i<=2;i++)
		{
			for(i1=0;i1<14;i1++)
			{
				genid = "cb_0_"+i1+"_"+i;
				if(chid != genid)
				{
					document.getElementById(genid).disabled = true;
				}
			}
		}
	}
	else
	{
                for(i=1;i<=2;i++)
                {
                        for(i1=0;i1<14;i1++)
                        {
                                genid = "cb_0_"+i1+"_"+i;
                                //if(chid != genid)
                                //{
                                        document.getElementById(genid).disabled = false;
                                //}
                        }
                }

	}
}

function daysInMonth(iMonth, iYear)
{
        return 32 - new Date(iYear, iMonth, 32).getDate();
}


function reserve()
{
	//document.frmreserve.roomcount.value
	var xmlstr = "";
	xmlstr = "<summaryreserves>\n";
	var checkout = "";
	var roomamount = 0;
	var checkcounter = 0;
        var transferW = 0;
        var transferN = 0;
        var rname_ = "";
        var mrname = "";
	var origcost = 0;
	for(i=0;i<document.frmreserve.roomcount.value; i++)
	{
		numberofroom = document.getElementById("numberofrm_" + i).innerHTML.replace("<input>", "")
		roomcode = document.getElementById("rmcode_" + i).value;
		

		for(i2=1; i2<=2; i2++)
		{
			for(i1=0;i1<14;i1++)
			{
				if(document.getElementById("cb_" + i + "_" + i1 + "_" + i2).checked == true)
				{
					if(checkbox(i, i1 - 1, i2) == false)
					{
						rname_ = document.getElementById("rname__" + i).value
				                //alert(rname_);
				                mrname = rname_.match("Transfer");
				                if(mrname==null)
				                {
				                       transferN++;
				                }
				                else
				                {
				                       transferW++;
				                }

						
						arrR = document.getElementById("cb_" + i + "_" + i1 + "_" + i2).value.split("|");
						//roomamount = (roomamount + parseInt(arrR[1]));
						//alert(arrR[1]);
						xmlstr += "\t<summaryreserve>\n";
						xmlstr += "\t\t<rcode>" + roomcode + "</rcode>\n" +					  
							  "\t\t<checkin>" + arrR[0] + "</checkin>\n" +
							  "\t\t<rcount>1</rcount>\n";
							checkcounter ++;  	
						for(i3=i1;i3<14;i3++)
						{
							if(document.getElementById("cb_" + i + "_" + i3 + "_" + i2).checked == true)
							{
								try
								{
									arrR = document.getElementById("cb_" + i + "_" + (i3) + "_" + i2).value.split("|");
									checkout = arrR[3];
									roomamount = (roomamount + parseInt(arrR[1]));
									origcost = (origcost + parseInt(arrR[2]));
								}
								catch(e)
								{
									arrR = document.getElementById("cb_" + i + "_0_" + (i2 + 1)).value.split("|");
									checkout = arrR[3];
									roomamount =(roomamount + parseInt(arrR[1]));
									origcost = (origcost + parseInt(arrR[2]));

								}
							}
							else
							{
								break;
							}
						}
			
						if(checkout == "")
						{
							try
							{
								arrR = document.getElementById("cb_" + i + "_" + (i1+1) + "_" + i2).value.split("|");
								checkout = arrR[3];
								roomamount = (roomamount + parseInt(arrR[1]));
								origcost = (origcost + parseInt(arrR[2]));

							}
							catch(e)
							{
								arrR = document.getElementById("cb_" + i + "_0_" + (i2 + 1)).value.split("|");
								checkout = arrR[3];
								roomamount = (roomamount + parseInt(arrR[1]));
								origcost = (origcost + parseInt(arrR[2]));
							}
						}				
						xmlstr += "\t\t<ramount>" + roomamount + "</ramount>\n";
						xmlstr += "\t\t<checkout>" + checkout +  "</checkout>\n";	
						xmlstr += "\t\t<breakfast>" + document.getElementById("breakfast").value + "</breakfast>";
						xmlstr += "\t\t<extraperson>" + document.getElementById("extraperson").value + "</extraperson>";
						//arrR = document.getElementById("cb_" + i + "_0_" + (i2 + 1)).value.split("|");
						xmlstr += "\t\t<origcost>" + origcost + "</origcost>";
						xmlstr += "\t</summaryreserve>\n";
						roomamount = 0;
						origcost = 0;
					}
					i1 = i3;
				}
			}
		}
	}
	

		
	
	xmlstr += "</summaryreserves>\n";
		
	if(checkcounter != 0)
	{
		if((transferW==1) && (transferN==0))
                {
                       alert("Your booking cannot process. not allow to book trasfer only");
                }
                else
                {
			var postdata = "xmlstr=" + reservdetail();
			doprocessPost(postdata, RESERVprocessingURL, 'temproomorderdetails');
		
			postdata = "xmlstr=" + xmlstr + "&data=" + document.getElementById("data").value;
			doprocessPost(postdata, RESERVprocessingURL, 'temproomordersummary');
		}
	}
	else
	{
		alert("Please select the dates you wish to book.");
	}
	//document.getElementById("txtxml").value = xmlstr;
	//alert(xmlstr);
}

function validateDate(date)
{
	$arrdate = date.split("-");

	
}

function intformat(intnum)
{
        if(parseInt(intnum) < 10)
        {
                return "0" + intnum;
        }
        else
        {
                return intnum;
        }
}


function recalculate()
{
		var xmlstr = "";
		xmlstr = "<summaryreserves>\n";
		var checkout = "";
		var totalamount = 0;
		for(i=0;i<document.frmcustomer.count.value;i++)
		{
			var amount = document.getElementById("ramount_" + i).value;
			var count = document.getElementById("combo_" + i).value;
			
			var bool_breakfast = document.getElementById("cmbbreakfast_" + i).checked;
			var daycount_  = document.getElementById("rdaycount_" + i).value;
			if(document.getElementById("cmbbreakfast_" + i).checked==true)
			{
				//var bfadult = count * (document.getElementById("chadult_" + i).value * document.getElementById("breakfast").value);
				//var bfextraperson = count * (document.getElementById("chextraperson_" + i).value  * document.getElementById("breakfast").value);
				//document.getElementById("breakfast").value);
				
					var extraperson = count * (document.getElementById("chextraperson_" + i).value * document.getElementById("extraperson").value) * daycount_;
				
					var subtotal = (amount * count + extraperson) - document.getElementById("breakfast").value * daycount_ * count;
					document.getElementById("td_" + i).innerHTML = "<b>US$" + subtotal + "</b>";
			}
			else
			{
				var pos = document.getElementById("rname_" + i).value.match("Transfer");
                                //alert(document.getElementById("rname_" + i).value);
                                if(pos!=null)
                                {
                                        var atransfer = document.getElementById("chadult_" + i).value * amount;
                                        var ctransfer = document.getElementById("chchilren_" + i).value * amount;
                                        var subtotal = atransfer + ctransfer;
                                        document.getElementById("td_" + i).innerHTML = "<b>US$" + subtotal + "</b>";
                                        //alert(subtotal);

                                }
                                else
                                {
				var extraperson = count * (document.getElementById("chextraperson_" + i).value * document.getElementById("extraperson").value) * daycount_;
				var subtotal = (amount * count + extraperson);
				document.getElementById("td_" + i).innerHTML = "<b>US$" + subtotal + "</b>";
				}
			}
			

			totalamount = totalamount + subtotal;
			
			xmlstr += "<summaryreserve>\n" ;
			xmlstr += "\t<rcode>" + document.getElementById("rcode_" + i).value + "</rcode>\n";
			xmlstr += "\t<checkin>" + document.getElementById("rcheckin_" + i).value + "</checkin>\n";
			xmlstr += "\t<checkout>" + document.getElementById("rcheckout_" + i).value + "</checkout>\n";
			xmlstr += "\t<rcount>" + document.getElementById("combo_" + i).value + "</rcount>\n";
			xmlstr += "\t<ramount>" + document.getElementById("ramount_" + i).value + "</ramount>\n";
			xmlstr += "\t<ramountsub>" + subtotal + "</ramountsub>\n";
			xmlstr += "\t<adultacount>" + document.getElementById("chadult_" + i).value + "</adultacount>\n";
			xmlstr += "\t<childrenacount>" + document.getElementById("chchilren_" + i).value + "</childrenacount>\n";
			xmlstr += "\t<extraperson>" + document.getElementById("chextraperson_" + i).value + "</extraperson>";
			xmlstr += "\t<breakfast>" + bool_breakfast + "</breakfast>";
			xmlstr += "\t<origcost>" + document.getElementById("origcost_" + i).value + "</origcost>";
			xmlstr += "</summaryreserve>\n";
			//chextraperson_
			
			
		}
		//alert(xmlstr);
		document.getElementById("tdtotalamount").innerHTML = "<b>Total Amount: US$" + totalamount + "</b>";
		xmlstr += "</summaryreserves>";
		var postdata = "xmlstr=" + xmlstr;
		doprocessPost(postdata, RESERVprocessingURL, 'temproomordersummary_');
		//document.frmcustomer.txtxml.value = xmlstr;
}




function reservdetail()
{
var xmlstr = "";
	xmlstr = "<reservedetails>\n";
	var checkout = "";
	for(i=0;i<document.frmreserve.roomcount.value; i++)
	{
		numberofroom = document.getElementById("numberofrm_" + i).innerHTML.replace("<input>", "")
		roomcode = document.getElementById("rmcode_" + i).value;
		for(i2=1; i2<=2; i2++)
		{
			for(i1=0;i1<14;i1++)
			{
				if(document.getElementById("cb_" + i + "_" + i1 + "_" + i2).checked == true)
				{
						arrR = document.getElementById("cb_" + i + "_" + i1 + "_" + i2).value.split("|");
						xmlstr += "\t<reservedetail>\n";
						xmlstr += "\t\t<rcode>" + roomcode + "</rcode>\n" +					  
							  "\t\t<rdate>" + arrR[0] + "</rdate>\n" +
							  "\t\t<rcount>1</rcount>";	
						xmlstr += "\t\t<ramount>" + arrR[1]+ "</ramount>\n";	
						xmlstr += "\t</reservedetail>\n";
				}
			}
		}
	}
	xmlstr += "</reservedetails>\n";
		//doprocessPost(postdata, RESERVprocessingURL, 'temproomorderdetails');
	//document.getElementById("txtxml").value = xmlstr;
	return xmlstr;
}

function checkbox(i, i1, i2)
{
	if(i1 > 0)
	{
		if(document.getElementById("cb_" + i + "_" + i1 + "_" + i2).checked == true)
		{
			return true;
		}
		else
		{
			return false;	
		}
	}
	else
	{
		return false;	
	}
}

function boxchecker(i, i1 ,i2)
{
	for(i3=i1 +1;i3<14;i3++)
	{
		if(document.getElementById("cb_" + i + "_" + i3 + "_" + i2).checked == true)
		{
			return true;
		}
		else
		{
			
		}
	}
}

function customerinfo()
{
	var xmlstr = "";
	recalculate();
	if(customerinfovalidation()!=1)
	{
	xmlstr = "\t<firstname>" + document.frmcustomer.cfirstname.value + "</firstname>\n" + 
			 "\t<lastname>" + document.frmcustomer.clastname.value + "</lastname>\n" +
			 "\t<middlename>" + document.frmcustomer.cmiddlename.value + "</middlename>\n" + 
			 "\t<address1>" + document.frmcustomer.caddress1.value + "</address1>\n" +
			 "\t<address2>" + document.frmcustomer.caddress2.value + "</address2>\n" + 
			 "\t<city>" + document.frmcustomer.ccity.value + "</city>\n" +
			 "\t<state>" + document.frmcustomer.cstate.value + "</state>\n" +
			 "\t<zip>" + document.frmcustomer.zip.value + "</zip>\n" +
			 "\t<country>" + document.frmcustomer.ccountry.value + "</country>\n" +
			 "\t<email>" + document.frmcustomer.cemail.value + "</email>\n" + 
			 "\t<mobile>" + document.frmcustomer.cmobile.value + "</mobile>\n" +
			 "\t<phone>" + document.frmcustomer.ctelephone.value + "</phone>\n" +
			 "\t<fax>" + document.frmcustomer.cfax.value + "</fax>\n" +
			 "\t<arrivaltime>" + document.frmcustomer.selarrival.value + "</arrivaltime>\n";
			 
	var postdata = "xmlstr=" + xmlstr  + "";
	doprocessPost(postdata, RESERVprocessingURL, 'tempcustomerinfo');		 
	}
}

function customerinfovalidation()
{
	if(document.getElementById('selarrival').value == "Select Arrival Time")
	{
		alert("Please select your arrival time.");
		return 1;
	}
	if(document.frmcustomer.cfirstname.value == "")	
	{
		document.frmcustomer.cfirstname.focus();
		alert("Invalid first name field. Please check first name field.");
		return 1;
	}
	else if(document.frmcustomer.clastname.value == "")
	{
		document.frmcustomer.clastname.focus();
		alert("Invalid last name field. Please check last name field.");
		return 1;
	}
	
	else if(document.frmcustomer.caddress1.value =="")
	{
		document.frmcustomer.caddress1.focus();
		alert("Invalid address 1 field. Please check address 1 field");
		return 1;
	}
	
	else if(document.frmcustomer.ccity.value == "")
	{
		document.frmcustomer.ccity.focus();
		alert("Invalid city field. Please check city field");
		return 1;
	}
	else if(document.frmcustomer.cstate.value == "")
	{
		document.frmcustomer.cstate.focus();
		alert("Invalid state field. Please check state field");
		return 1;
	}
	else if(document.frmcustomer.ccountry.value == "")
	{
		document.frmcustomer.ccountry.focus();
		alert("Invalid country field. Please select your country");
		return 1;
	}
	else if(document.frmcustomer.cemail.value == "")
	{
		document.frmcustomer.cemail.focus();
		alert("Invalid email address field. Please check email address field");
		return 1;
	}
	else if(document.frmcustomer.cemail.value != document.frmcustomer.cemail2.value)
	{
		document.frmcustomer.cemail.focus();
		alert("Email address mismatch. Please check your email address fields");
		return 1;
	}
	
	else if(document.frmcustomer.ctelephone.value == "")
	{
		document.frmcustomer.ctelephone.focus();
		alert("Invalid telephone field. Please check telephone field");
		return 1;
	}
	
	else
	{
		return 0;	
	}
	
	
}

function clientReservation()
{
	if(document.frmconfirm.iagree.checked == true)
	{
		
		
		document.getElementById('viewbuttons').style.display = 'none';
		document.getElementById('showloading').style.display = '';
		doprocessPost("", RESERVprocessingURL, 'clientReservation');
	}
	else
	{
		alert("Please Check I Agree");	
	}
}
function doprocessPost(postdata, file, pro)
{
	var url = file + "?func=" + pro;
	var params = postdata;
	

	var xmlhttp;
	xmlhttp=null;
	
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
		xmlhttp.open("POST", url, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		//xmlhttp.setRequestHeader("Content-length", params.length);
		//xmlhttp.setRequestHeader("Connection", "close");
		
		xmlhttp.onreadystatechange=function() 
		{
			if (xmlhttp.readyState==4) 
			{
				processResponse(xmlhttp.responseText);
				//alert(xmlhttp.responseText);
				//document.getElementById("response").innerHTML = xmlhttp.responseText;
			}
	 }
 xmlhttp.send(params);
}

function processResponse(strresponse)
{
		
		 var qs = new Querystring(strresponse.replace("\n","").replace("\r", ""));
		 if(qs.get("STATUS") == "1")
		 {
			 alert(qs.get("DESC"));
		 }
		 else if(qs.get("STATUS") == "2")
		 {
			 window.location = qs.get("BASEURL");
		 }
		 else if(qs.get("STATUS") == "3")
		 {
				func3(qs.get("DESC"));
		 }
		 else if(qs.get("STATUS") == "4")
		 {
				window.location = "/" + qs.get("PAGE") + "/" + document.getElementById('G2PARAMS').value;
		 }
		 else
		 {
			 
		 }
		
		
}

function func3(text)
{
	var xmlDoc = null;
	//alert(text);
	var im = 0;
	try //Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
  		xmlDoc.loadXML(text);
		im = 0
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			 //xmlDoc=document.implementation.createDocument("","",null);
			 parser=new DOMParser();
    		 xmlDoc=parser.parseFromString(text,"text/xml");
			 im =1
		}
		catch(e)
		{
		alert(e.message);
		return;
		}
	}	
	//alert("here");
	var count = xmlDoc.getElementsByTagName("city").length;

	var formObj = document.forms['frmsearch'];
    formObj.city.options.length = 0;

	for(var i = 0; i < count; i++)
	{
			if(im==0)
			{
			document.getElementById("city").add(new Option(xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue,xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue));
			}
			else
			{
			document.getElementById("city").appendChild(new Option(xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue,xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue));			
			}
			//document.frmsearch.cityt.add(new Option(xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue,xmlDoc.getElementsByTagName("cityname")[i].childNodes[0].nodeValue);
			
			
	}
}

function Querystring(qs) 
{
	try
	{
		this.params = new Object()
		this.get=Querystring_get
		if (qs == null)
			qs=location.search.substring(1,location.search.length)
		if (qs.length == 0) return
		qs = qs.replace(/\+/g, ' ')
		var args = qs.split('&') 
		for (var i=0;i<args.length;i++)
		{
			
			var value;
			var pair = args[i].split('=')
			var name = unescape(pair[0])
			if (pair.length == 2)
				value = unescape(pair[1]);
			else
				value = name;
			this.params[name] = value;
			
		}
	}
	catch(err)
	{
		window.location.reload();	
	}
}


function showdate(id)
{
        if(id == "1")
        {
                document.getElementById('date1').style.display = '';
                document.getElementById('date2').style.display = 'none';
                for(i=0;i<document.frmreserve.roomcount.value;i++)
                {
                                document.getElementById('panel_l_' + i).style.display = '';
                                document.getElementById('panel_2_' + i).style.display = 'none';
                }
        }
        else if(id == "2")
        {
                document.getElementById('date1').style.display = 'none';
                document.getElementById('date2').style.display = '';
                for(i=0;i<document.frmreserve.roomcount.value;i++)
                {
                                document.getElementById('panel_l_' + i).style.display = 'none';
                                document.getElementById('panel_2_' + i).style.display = '';
                }
        }

}


function Querystring_get(key, default_) {
	if (default_ == null) 
	default_ = null;
	var value=this.params[key]
	if (value==null) 
	value=default_;
	return value
}

function str_replace_(haystack, needle, replacement) {
    var temp = haystack.split(needle);
    return temp.join(replacement);
}
