/******************************************************************************
 * File name:hotelcommon.js
 * Description: This file contains all the validation and javascript functions
 *				related to Hotel UI
 *******************************************************************************/
var IE = document.all?true:false
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
//document.onmousemove = getMouseXY;
//var tempX = 0;
//var tempY = 0; 
var mapViewwindow;
var loadimages=new Array();
 /***********************************************************************
 * Function Name : showpopup
 * Description   : To display popup for checkin checout dates
 * Arguments     : None
 * Return values : popup window
 ***********************************************************************/
function showpopup(){
	document.getElementById('detailspopup').style.display='';
	var details='<div class="mainblock" style="z-index:1003;"><table width="190" border="0" cellspacing="0" cellpadding="0"><tr><td></td><td colspan="2" class="topbg"><table width="180" border="0" align="right" cellpadding="0" cellspacing="0"><tr><td width="15">&nbsp;</td><td width="151" class="number">Booking Details </td><td width="24"><a href=javascript:closepopup();><img src="/images/xhotelv2/closesign.gif" border="0" width="14" height="25" /></a></td></tr></table></td></tr><tr><td width="21" align="right" valign="top" style="padding-top:30px"><img src="/images/xhotelv2/popuparrow.gif" width="20" height="25" /></td><td width="6" style="background-color:#ffffff;"><img src="/images/xhotelv2/leftline.gif" width="1" height="131" /></td><td width="185" class="leftright"><form name="hotelDetails" method="get" style="margin:0px;"><table width="100%" height="131" border="0" align="left" cellpadding="0" cellspacing="0" style="background-color:#ffffff;"><tr><td width="35%" class="bodytext">Check-in</td><td align="left" width="14%"><select id="chiDate" name="chiDate" size="1"><option value="">dd</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select></td><td align="left"><select id="chiMonthYear" name="chiMonthYear"><option value="">mm/yy</option><option value="03/2008">March 08</option><option value="04/2008">April 08</option><option value="05/2008">May 08</option><option value="06/2008">June 08</option><option value="07/2008">July 08</option><option value="03/2008">Mar 08</option><option value="04/2008">Apr 08</option><option value="05/2008">May 08</option><option value="08/2008">Aug 08</option><option value="09/2008">Sept 08</option><option value="10/2008">Oct 08</option><option value="11/2008">Nov 08</option><option value="10/2008">Oct 08</option><option value="10/2008">Nov 08</option><option value="11/2008">Dec 08</option><option value="12/2008">Sep 08</option></select></td></tr><tr><td class="bodytext">Check-out</td><td align="left" width="14%"><select id="choDate" name="choDate" size="1"><option value="">dd</option><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select></td><td align="left"><select id="choMonthYear" name="choMonthYear"><option value="">mm/yy</option><option value="10/2007">Oct 07</option><option value="11/2007">Nov 07</option><option value="12/2007">Dec 07</option><option value="01/2008">Jan 08</option><option value="02/2008">Feb 08</option><option value="03/2008">Mar 08</option><option value="04/2008">Apr 08</option><option value="05/2008">May 08</option><option value="06/2008">Jun 08</option><option value="07/2008">Jul 08</option><option value="08/2008">Aug 08</option><option value="09/2008">Sep 08</option><option value="10/2008">Oct 08</option><option value="10/2008">Nov 08</option><option value="11/2008">Dec 08</option><option value="12/2008">Sep 08</option></select></td></tr></form><tr><td colspan="3" align="center" class="findflight"><input type="image" src="/images/xhotelv2/findhotel.gif" id="hotelform" onclick=go_detail("hotelDetails"); /></td></tr></table></td></tr><tr><td colspan="3" valign="top"><img src="/images/xhotelv2/bottomline.gif" width="211" height="5" /></td></tr></table></div>';
	document.getElementById('detailspopup').innerHTML=details;
	document.getElementById('detailspopup').style.top=(tempY-250)+'px';
	document.getElementById('detailspopup').style.left=(tempX-230) +'px';
}
 /***********************************************************************
 * Function Name : closepopup
 * Description   :Close the pop up window
 * Arguments     : None
 * Return values : 
 ***********************************************************************/
function closepopup(){
	//document.getElementById('hoteldetailspopup').style.display='none';
	//document.getElementById('overeffect').style.display='none';
	document.getElementById('HADT').style.display='';
	document.getElementById('HCHD').style.display='';
	document.getElementById('HRM').style.display='';	
	document.getElementById('HPR').style.display='';
	document.getElementById('HHN').style.display='';
	document.getElementById('HHT').style.display='';
	
}
/*function getMouseXY(e) {
  if (IE) {
     tempX = event.clientX + document.body.scrollLeft
     tempY = event.clientY + document.body.scrollTop
  } else {
    tempX = e.pageX
    tempY = e.pageY
  }
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  return true
}*/
function go_detail(formName,cinDate,codDate){
	var obDate=document.getElementById(cinDate).value;
	var ibDate=document.getElementById(codDate).value;	
	//call to isValidhotel function of isValidate.js for checkin and checkout date validation
	var isValid=isValidpopup(formName,obDate,ibDate);
	if(isValid==true){		
		//document.getElementById('hoteldetailspopup').style.display='';
		//document.getElementById('HADT').style.display='none';
		//document.getElementById('HCHD').style.display='none';
		//document.getElementById('HRM').style.display='none';
		//document.getElementById('HPR').style.display='none';
		//document.getElementById('HHN').style.display='none';
		//document.getElementById('HHT').style.display='none';		
		
	}else{		
		return false;
	}	
}
function openhoteldetails(){
		document.getElementById('overeffect').style.display='';
		document.getElementById('hoteldetailspopup').style.display='';
}
function hoteldetailsmenu(liName,divName){
        //set the continue booking button
        setContinueBookingButton(divName);
	for(i=1; i<=7; i++){
    	if(document.getElementById('hoteldetail'+i)){
			document.getElementById('hoteldetail'+i).className='';
	      	document.getElementById('detail'+i).style.display='none';
		}      
	}
    document.getElementById(liName).className='onmenu';
    document.getElementById(divName).style.display='';
    if(divName == 'detail5'){
		hotel_details_map();	
	}
   
}
function ShowSection(section){
	  //set the continue booking button
      setContinueBookingButton(section);
	var sectionID=new Array('detail1','detail2','detail3','detail4','detail5','detail6','detail7')
	for(i=0;i<sectionID.length; i++){
	if(document.getElementById(sectionID[i])){
		if(section==sectionID[i]){
			document.getElementById(sectionID[i]).style.display='block';
		if(sectionID[i] == 'detail5'){
			hotel_details_map();	
		}
		}else{
			document.getElementById(sectionID[i]).style.display='none';
		}
	}
  	}
}
function setImage(img,tdId){
    var idArr = new Array('d001img','d002img','d003img','d004img','d005img','d006img','d007img');
	var tdArr = new Array('t001','t002','t003','t004','t005','t006','t007');
	var imgOnArr = new Array('about_hotel_on','rate_details_on','photo_gallery_on','destination_guide_on','map_on','user_review_on','videos_on');
	var imgOffArr = new Array('about_hotel_off','rate_details_off','photo_gallery_off','destination_guide_off','map_off','user_review_off','videos_off');
        var len=idArr.length;
        for (var i=0; i<len; i++){
		if(document.getElementById(idArr[i]) && document.getElementById(tdArr[i])){
          if(idArr[i]==img && tdArr[i]==tdId){
			document.getElementById(idArr[i]).src='/images/xhotelv2/'+imgOnArr[i]+'.gif';
			document.getElementById(tdArr[i]).className='offborder';
			}else{
			document.getElementById(idArr[i]).src='/images/xhotelv2/'+imgOffArr[i]+'.gif';
			document.getElementById(tdArr[i]).className='onborder';
			}
		}
        }
}
/***********************************************************************
 * Function name:findcity
 * Description: To open the poup up window for city list
 * Arguments: 
 * Return values:popup window
 ***********************************************************************/
function findcity()
{
	hideselect();
	document.documentElement.style.overflow = "";
	document.getElementById('overeffect').style.display='';
	cities_beginning_with('A');
	document.getElementById('findcitycontainer').style.display='';
	//var findCityUrl='/Hotelv2/components/findcity.html?invalid='+invalid;
	//Window.open is removed as per new changes 31st may 2008
	//window.open(findCityUrl,'popup','scrollbars=1,width=600,height=620,top=50,left=200');
	//var CityListObj;
	//cityListWindow=dhtmlmodal.open(CityListObj, 'iframe', findCityUrl, 'Find City', 'width=795,height=550,left=200,center=1,resize=0,scrolling=1');
}
/***********************************************************************
 * Function name:closefindcity
 * Description: To close the poup up window for city list
 * Arguments: 
 * Return values:popup window
 ***********************************************************************/
function closefindcity()
{
	showselect();
	document.getElementById('overeffect').style.display='none';
	document.getElementById('findcitycontainer').style.display='none';
}


/***********************************************************************
 * Function Name : GetXmlHttpObject
 * Description   : To create the xmlHttp request object used for ajax
 * Arguments     : None
 * Return values : None
 ***********************************************************************/
function GetXmlHttpObject()
{
    var objXMLHttp=null

    if(window.XMLHttpRequest) {
       try {
             objXMLHttp = new XMLHttpRequest();
           } catch(e) {
             objXMLHttp = false;
           }
    } else if(window.ActiveXObject) {
       try {
             objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
           } catch(e) {
             objXMLHttp = false;
           }
    }
    return objXMLHttp;
}
/***********************************************************************
 * Function Name : validate_city_name
 * Description   : Validate the city name
 * Arguments     : City
 * Return values : 1 or 0
 ***********************************************************************/
function validate_city_name(City){
	var NoArray = "0123456789^*$/\\-_=%@!~`;:#&+|{[]}";
	for(i = 0; i < City.length; i++){
		var c = City.charAt(i);
		if(NoArray.indexOf(c)!= -1){
			return 0;
			}else{
				continue;
		}
	}
	return 1;
}
/***********************************************************************
 * Function Name :preloadimages
 * Description   :preload the images 
 * Arguments     : 
 * Return values : 
 ***********************************************************************/
function preloadimages(){
	for(i=0;i<preloadimages.arguments.length;i++){
		loadimages[i]=new Image();
		loadimages[i].src=preloadimages.arguments[i];
	}
}	
//Enter path of images to be preloaded inside parenthesis. Extend list as desired.
preloadimages(
			
			);

/***********************************************************************
 * Function Name :hoteldesp
 * Description   :open the popup for hotel description 
 * Arguments     : 
 * Return values : 
 ***********************************************************************/
 function hoteldesp(hotelName,hotelDescription)
 {
	 document.getElementById('hoteldesppopup').style.display='';
	document.getElementById("hotelName").innerHTML=hotelName;
	document.getElementById("hotelDescription").innerHTML=unescape(hotelDescription);
 }

 function hoteldespclose()
 {
	 document.getElementById('hoteldesppopup').style.display='none';
 }

  function advanceSearch(divId)
 {
	divId = document.getElementById(divId);

   if (divId.style.display == 'none')
	 {
      divId.style.display = 'block';
	  document.getElementById('plus').style.display='none';
	  document.getElementById('minus').style.display='';
	//document.getElementById('searchbutton').style.display='';
	//document.getElementById('advancesearchbutton').style.display='none';
	//document.getElementById('orangebar1').style.display='none';
	//document.getElementById('orangebar2').style.display='';
	 }
   else{
      divId.style.display = 'none';
	  document.getElementById('plus').style.display='';
	  document.getElementById('minus').style.display='none';
   //document.getElementById('searchbutton').style.display='none';
	//document.getElementById('advancesearchbutton').style.display='';
	//document.getElementById('orangebar1').style.display='';
	//document.getElementById('orangebar2').style.display='none';
   }
 }
/***********************************************************************
 * Function Name :hideselect and showselect
 * Description   :When popup open hide all select box thats on page
 * Arguments     : 
 * Return values : 
 ***********************************************************************/
function hideselect(){
	 document.body.className='hideselectbox';
	 //document.body.scroll = 'no';
	if (IE) {
	document.documentElement.style.overflow = "hidden";
	}
 }
function showselect(){
	 document.body.className='';
	 //document.body.scroll = '';
	 if (IE) {
	document.documentElement.style.overflow = "";
	 }
	if(document.getElementById('adzonediv')){
		document.getElementById('adzonediv').style.display='';
	}
 }
 /***********************************************************************
 * Function Name :submitForm
 * Description   :check the terms and conditions checkbox on review page
 * Arguments     : 
 * Return values : 
 ***********************************************************************/
 function submitForm(){
	if(!document.paxDetailForm.tc.checked){
        	alert('Please check the terms and conditions')
                return false;
      	}else{
        	return true;
       	}
 }


/***********************************************************************
 * Function Name : comma_formatted
 * Description   : this function will do the formating of the price to display. 
 * Arguments     : amount
 * Return values : Formated price.
 ***********************************************************************/
function comma_formatted(amount){
	var delimiter = ","; // replace comma if desired
    var d = '';
    var i = Math.round(amount);
    if(isNaN(i)) { return ''; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];	
	if(n.length>2){
		var nn=n.substr(n.length-3);
		a.unshift(nn);
		n=n.substr(0,n.length-3);
		while(n.length > 2)
		{
			var nn = n.substr(n.length-2);
			a.unshift(nn);
			n = n.substr(0,n.length-2);
		}
	}
    if(n.length > 0) { a.unshift(n); }
    n = a.join(delimiter);
    if(d.length < 1) { amount = n; }
    else { amount = n + '.' + d; }
    amount = minus + amount;
    return amount;
}



/*******************************************************************************
 * Function Name : display_yatra_rating
 * Description   : This function is used to get yatra rating image string
                                        according to rating value
 * Arguments     : rating,color
 * Return values : string containing image string
 ********************************************************************************/
function  display_yatra_rating(rating,color){
	var index1;
	var index2;	
	var ratingStr="";
	var flag=false;
	var halfStar="";
	
	switch(color){
		case 'blue' :
			var halfStarImage="\"/images/xhotelv2/star_yellow_half.gif\" border=\"0\" ";
			var fullStarImage="\"/images/xhotelv2/star_yellow.gif\" border=\"0\" ";
			var greyStarImage="\"/images/xhotelv2/star_grey.gif\" border=\"0\" ";
			break;
		case 'orange' :
			var halfStarImage="\"/images/xhotelv2/star_yellow_half.gif\" border=\"0\" ";
			var fullStarImage="\"/images/xhotelv2/star_yellow.gif\" border=\"0\" ";
			var greyStarImage="\"/images/xhotelv2/star_grey.gif\" border=\"0\" ";
			break;
	}
	if(rating=='NA'|| rating == null || rating == '' || rating == 'N/A' || rating =='na' || rating == 'undef'){
		/*for(var i=0;i<5 ;i++){
			ratingStr += "<img src="+greyStarImage+" alt='Govt Rating - Not Available' title='Govt Rating - Not Available' />";
		}*/
		ratingStr = "Not Rated";	
	 return ratingStr;
   	}
   var rating=rating.toString();
   var ratings=rating.split(".");
   index1=ratings[0];
   if(ratings[1]){
	   index2=5-ratings[0]-1;
	   halfStar+="<img src="+halfStarImage+" alt='Govt Rating - "+rating+"' title='Govt Rating - "+rating+"' />";
	   flag=true;
	}else{
		index2=5-ratings[0];
   }
   for(var i=0;i<index1;i++){
	   ratingStr+="<img src="+fullStarImage+" alt='Govt Rating - "+rating+"' title='Govt Rating - "+rating+"' />";
	}
	if(flag){
		ratingStr+=halfStar;
	}
	//for(var i=0;i< index2 ;i++){
		//ratingStr+="<img src="+greyStarImage+" alt='Yatra Rating - "+rating+"' title='Yatra Rating - "+rating+"' />";
   //}
   return ratingStr;
}

/*******************************************************************************
 * Function Name : displayTab
 * Description   : This function is used to open respective tab in hotel details
 *				   popup based on proviede tab name
 * Arguments     : Tab name
 * Return values : None
 ********************************************************************************/
function displayTab(tabName){
      
	switch(tabName){
    	case 'About Hotel': 
				ShowSection('detail1');
				setImage('d001img','t001');
                break;
        case 'Destination Guide':
				ShowSection('detail2');
				setImage('d004img','t004');
                break;
        case 'Rate Details':
				ShowSection('detail3');
				setImage('d002img','t002');
                break;
        case 'User Reviews':
				ShowSection('detail4');
				setImage('d006img','t006');
                break;
        case 'Map':
				ShowSection('detail5');
				setImage('d005img','t005');
                break;
        case 'Photos':
				ShowSection('detail6');
				setImage('d003img','t003');
                break;
        case 'Videos':
				ShowSection('detail7');
				setImage('d007img','t007');
                break;
    }
}
/***********************************************************************************
 * Function Name :setContinueBookingButton
 * Description   :To set the continuebooking button
 * Arguments     :divName
 * Return values :
 ***********************************************************************************/ 
function setContinueBookingButton(divName){
if(document.getElementById('hotelnameheaderight')){
  if(divName=="detail3"){
	document.getElementById("hotelnameheaderight").innerHTML="<img src=\"/images/xhotelv2/spacer.gif\" border=\"0\" height=\"1\" />";
  }else{
        document.getElementById("hotelnameheaderight").innerHTML="<a href=\"javascript:ShowSection('detail3');setImage('d002img','t002');\"><img src=\"/images/xhotelv2/btn_book_now.gif\" border=\"0\"/></a>";
  }
}
}
/*******************************************************************************
 * Function Name : open_hoteldetails_popup
 * Description   : This function is use to open hotel detail dhtml popup
 * Arguments     : formname
 * Return values : 
 ********************************************************************************/
function open_hoteldetails_popup(formName,searchId, hotelId, tabName){
	if(formName != ''){	
		var hotelCode = document.forms[""+formName].hotel_code.value;
		var ciDate = document.forms[""+formName].cidate.value;
		var coDate = document.forms[""+formName].codate.value;
	    var room  = document.forms[""+formName].room.value;       
	    var url = '/Hotelv2/waitpages/waitpage_hoteldetails.html?queryXdist=true&hotel_code='+hotelCode;
	    url = url+'&cidate='+ciDate+'&codate='+coDate+'&room='+room+'&tabName='+tabName;
	    var adt1, adt2, adt3, adt4, chdroom1, chdroom2, chdroom3, chdroom4;
		var adt1_chdage1, adt1_chdage2, adt2_chdage1, adt2_chdage2;
		var adt3_chdage1,adt3_chdage2, adt4_chdage1, adt4_chdage2;
        
		// Get guest details for room1 
		adt1 = document.forms[""+formName].adt1.value; 
		chdroom1 = document.forms[""+formName].chdroom1.value;
		if(chdroom1 > 0){
			adt1_chdage1 = document.forms[""+formName].adt1_chdage1.value;
			adt1_chdage2 = document.forms[""+formName].adt1_chdage2.value;
		}
	
		// Get guest details for room2 
		adt2 = document.forms[""+formName].adt2.value;
        chdroom2 = document.forms[""+formName].chdroom2.value;
        if(chdroom2 > 0){
            adt2_chdage1 = document.forms[""+formName].adt2_chdage1.value;
            adt2_chdage2 = document.forms[""+formName].adt2_chdage2.value;
        }
		
		// Get guest details for room3
        adt3 = document.forms[""+formName].adt3.value;
        chdroom3 = document.forms[""+formName].chdroom3.value;
        if(chdroom3 > 0){
            adt3_chdage1 = document.forms[""+formName].adt3_chdage1.value;
            adt3_chdage2 = document.forms[""+formName].adt3_chdage2.value;
        }

        // Get guest details for room4
        adt4 = document.forms[""+formName].adt4.value;
        chdroom4 = document.forms[""+formName].chdroom4.value;
        if(chdroom4 > 0){
            adt4_chdage1 = document.forms[""+formName].adt4_chdage1.value;
            adt4_chdage2 = document.forms[""+formName].adt4_chdage2.value;
        }
  
		url = url+'&adt1='+adt1+'&chdroom1='+chdroom1+'&adt1_chdage1='+adt1_chdage1+'&adt1_chdage2='+adt1_chdage2;
		url = url+'&adt2='+adt2+'&chdroom2='+chdroom2+'&adt2_chdage1='+adt2_chdage1+'&adt2_chdage2='+adt2_chdage2;
		
		url = url+'&adt3='+adt3+'&chdroom3='+chdroom3+'&adt3_chdage1='+adt3_chdage1+'&adt3_chdage2='+adt3_chdage2;	
		url = url+'&adt4='+adt4+'&chdroom4='+chdroom4+'&adt4_chdage1='+adt4_chdage1+'&adt4_chdage2='+adt4_chdage2;
		url =url+'&random='+Math.random();
    	/*for(var roomCnt=1; roomCnt<=room;roomCnt++){
			var adtField = "adt"+roomCnt;
			var chdCntField = "chdroom"+roomCnt;
		    var chdAge1Field = "adt"+roomCnt+"_chdage1";
            var chdAge2Field = "adt"+roomCnt+"_chdage2";
            alert(adtField1);
			var adtCnt = document.forms[""+formName].adtField.value;
    		var chdCnt = document.forms[""+formName].chdCntField.value;
            if(chdCnt > 0){
			 chdAge1 = document.forms[""+formName].chdAge1Field.value;
			 chdAge2 = document.forms[""+formName].chdAge2Field.value;
			}
    		url = url+'&'+adtField+'='+adtCnt+'&'+chdCntField+'='+chdCnt;
	        url = url+'&'+chdAge1Field+'='+chdAge1+'&'+chdAge2Field+'='+chdAge2;
		}
       	   url = url+'&random='+Math.random();
		url= url+'&adt1='+
		   alert(url);*/
		if(formName=='popupform1'){
			closessh();
		}else if(formName=='popupform2'){
			closessh_c();
		}else if(formName=='popupform3'){
			close_chform();
		}else if(formName=='videotourform'){
			close_vtform();
		}
	}
    else{
	 	var url = 'waitpages/waitpage_hoteldetails.html?queryXdist=false&hotelId='+hotelId+'&searchId='+searchId+'&pageName=userReview';
        url = url+'&tabName='+tabName+'&random='+Math.random();  
    }
	var hotelDhtmlWindowObj='hotelDetailPopUp_'+Math.random();
	hotelDetailsWindow=dhtmlmodal.open(hotelDhtmlWindowObj, 'iframe', url, 'Yatra Hotels', 'width=814,height=550,left=200,center=1,resize=0,scrolling=0');
	//To hide the select boxes
	hideselect();
	if(document.getElementById('adzonediv')){
		document.getElementById('adzonediv').style.display='none';
	}
	hotelDetailsWindow.onclose=function(){					
		return window.confirm("Close this window?")
	}

	return false;
}

/*******************************************************************************
 * Function Name : SetupAdultChildDiv and SetupChildAges
 * Description   : This function is use to more room options and age of children
 * Arguments     : 
 * Return values : 
 ********************************************************************************/

function SetupAdultChildDiv(formName)
{
var obj = document.getElementById('NumberOfRooms_Numbers');
if(obj.options[obj.selectedIndex].text>1){
	document.getElementById('Room1Lable').style.display="block";
	}else{
		document.getElementById('Room1Lable').style.display="none";
	}
		var childlist = new Array(4);
		childlist[0] = document.getElementById('Child1_Numbers');
		childlist[1] = document.getElementById('Child2_Numbers');
		childlist[2] = document.getElementById('Child3_Numbers');
		childlist[3] = document.getElementById('Child4_Numbers');
    	for (var x = 1; x <= 4; x++){
			if(x <= obj.options[obj.selectedIndex].text)
				{
				ResetValuesHotel(formName)
					document.getElementById('AdultChildDiv'+x).style.display="block";
					SetupChildAges(childlist[x-1],x)
				}else{
					document.getElementById('AdultChildDiv'+x).style.display="none";
					document.getElementById('ChildAgesControlDiv'+x).style.display="none";
					}
			}
			document.getElementById('ChildAgeMessage').style.display="none";
			for (var x = 1; x <= 4; x++){
				if(childlist[x-1].selectedIndex >0 && document.getElementById('AdultChildDiv'+x).style.display=="block"){
					document.getElementById('ChildAgeMessage').style.display="block";
					}
				}
	}
	function ResetValuesHotel(formName)
	{
		var obj = document.getElementById('NumberOfRooms_Numbers');
		if(formName=='hotelform'){
		if(obj.options[obj.selectedIndex].text==1){
			document.hotelform.chdroom2.value="0";
			document.hotelform.chdroom3.value="0";
			document.hotelform.chdroom4.value="0";
			document.hotelform.adt2.value="1";
			document.hotelform.adt3.value="1";
			document.hotelform.adt4.value="1";
			document.hotelform.adt2_chdage1.value="";
			document.hotelform.adt2_chdage2.value="";
			document.hotelform.adt3_chdage1.value="";
			document.hotelform.adt3_chdage2.value="";
			document.hotelform.adt4_chdage1.value="";
			document.hotelform.adt4_chdage2.value="";
		}
		if(obj.options[obj.selectedIndex].text==2){
			document.hotelform.chdroom3.value="0";
			document.hotelform.chdroom4.value="0";	
			document.hotelform.adt3.value="1";
			document.hotelform.adt4.value="1";
			document.hotelform.adt3_chdage1.value="";
			document.hotelform.adt3_chdage2.value="";
			document.hotelform.adt4_chdage1.value="";
			document.hotelform.adt4_chdage2.value="";
		}
		if(obj.options[obj.selectedIndex].text==3){
				document.hotelform.chdroom4.value="0";
				document.hotelform.adt4.value="1";
				document.hotelform.adt4_chdage1.value="";
				document.hotelform.adt4_chdage2.value="";
		}
	}else if(formName=='modifysearchform'){
		if(obj.options[obj.selectedIndex].text==1){
			document.modifysearchform.chdroom2.value="0";
			document.modifysearchform.chdroom3.value="0";
			document.modifysearchform.chdroom4.value="0";
			document.modifysearchform.adt2.value="1";
			document.modifysearchform.adt3.value="1";
			document.modifysearchform.adt4.value="1";
			document.modifysearchform.adt2_chdage1.value="";
			document.modifysearchform.adt2_chdage2.value="";
			document.modifysearchform.adt3_chdage1.value="";
			document.modifysearchform.adt3_chdage2.value="";
			document.modifysearchform.adt4_chdage1.value="";
			document.modifysearchform.adt4_chdage2.value="";
		}
		if(obj.options[obj.selectedIndex].text==2){
			document.modifysearchform.chdroom3.value="0";
			document.modifysearchform.chdroom4.value="0";
			document.modifysearchform.adt3.value="1";
			document.modifysearchform.adt4.value="1";
			document.modifysearchform.adt3_chdage1.value="";
			document.modifysearchform.adt3_chdage2.value="";
			document.modifysearchform.adt4_chdage1.value="";
			document.modifysearchform.adt4_chdage2.value="";
		}
		if(obj.options[obj.selectedIndex].text==3){
				document.modifysearchform.chdroom4.value="0";
				document.modifysearchform.adt4.value="1";
				document.modifysearchform.adt4_chdage1.value="";
				document.modifysearchform.adt4_chdage2.value="";
		}
	}
	}
	function SetupChildAges(element, room)
	{
		for (var x = 1; x <= 2; x++){
			if(x <= element.options[element.selectedIndex].text){
				document.getElementById('ChildAge'+room+''+x).style.display="block";
			}else{
				document.getElementById('ChildAge'+room+''+x).style.display="none";
				}
		}
		if(element.options[element.selectedIndex].text>0){
				document.getElementById('ChildAgesControlDiv'+room).style.display="block";
		}else{
				document.getElementById('ChildAgesControlDiv'+room).style.display="none";
		}
					var childlist = new Array(4);
					childlist[0] = document.getElementById('Child1_Numbers');
					childlist[1] = document.getElementById('Child2_Numbers');
					childlist[2] = document.getElementById('Child3_Numbers');
					childlist[3] = document.getElementById('Child4_Numbers');
					document.getElementById('ChildAgeMessage').style.display="none";
			for (var x = 1; x <= 4; x++){
				if(childlist[x-1].selectedIndex >0 && document.getElementById('AdultChildDiv'+x).style.display=="block")	{
					document.getElementById('ChildAgeMessage').style.display="block";
				}
			}
		}

function shod()
{
	document.getElementById('Child1_Numbers').style.display='none';
	document.getElementById('Child2_Numbers').style.display='none';
	document.getElementById('Child3_Numbers').style.display='none';
	document.getElementById('Adult1_Numbers').style.display='none';
}
function shodpopup()
{
	document.getElementById('Child1_Popup').style.display='none';
	//document.getElementById('Child2_Popup').style.display='none';
	//document.getElementById('Child3_Popup').style.display='none';
	//document.getElementById('Child4_Popup').style.display='none';
	document.getElementById('Child1_PopupCY').style.display='none';
	//document.getElementById('Child2_PopupCY').style.display='none';
	//document.getElementById('Child3_PopupCY').style.display='none';
	//document.getElementById('Child4_PopupCY').style.display='none';
	//document.getElementById('Child1_PopupCH').style.display='none';
	//document.getElementById('Child2_PopupCH').style.display='none';
	//document.getElementById('Child3_PopupCH').style.display='none';
	//document.getElementById('Child4_PopupCH').style.display='none';
	document.getElementById('Child1_PopupMap').style.display='none';
	document.getElementById('Child2_PopupMap').style.display='none';
	document.getElementById('Child3_PopupMap').style.display='none';
	document.getElementById('Child4_PopupMap').style.display='none';
}
/*******************************************************************************
 * Function Name : uppercase_firstletter
 * Description   : To upper case the first character of each word in a string
 * Arguments     : str
 * Return values : string with upper case of firstcharacter of each word.
 ********************************************************************************/
function uppercase_firstletter(str) {
   // split string on spaces  
  var arrStr = str.split(" ");
   var strOut =''; 
   for (i=0;i<arrStr.length;i++)
   {
       // split string
       firstChar = arrStr[i].substring(0,1);
       remainChar = arrStr[i].substring(1);

       // convert case
       firstChar = firstChar.toUpperCase(); 
       remainChar = remainChar.toLowerCase();

       strOut += firstChar + remainChar + ' ';
   }
   // return string, but drop the last space
   return strOut.substring(0, strOut.length - 1);
}
/*******************************************************************************
 * Function Name : goback
 * Description   : back to previous page
 * Arguments     : 
 * Return values : 
 ********************************************************************************/
function goback(){
	history.go(-1);		
}
/*******************************************************************************
 * Function Name : Trim
 * Description   : trim the spaces
 * Arguments     : fld
 * Return values : 
 ********************************************************************************/
function Trim(fld)
{
        while(''+fld.charAt(0)==' ')
                fld=fld.substring(1,fld.length);
        while(''+fld.charAt(fld.length-1)==' ')
                fld=fld.substring(0,fld.length-1);
        while(''+fld.charCodeAt(0)==13 || ''+fld.charCodeAt(0)==10)
                fld=fld.substring(1,fld.length);
        while(''+fld.charCodeAt(fld.length-1)==13 || ''+fld.charCodeAt(fld.length-1)==10)
                fld=fld.substring(0,fld.length-1);
        return fld;
}
/*******************************************************************************
 * Function Name : open_mapview_popup
 * Description   : This function is use to open map dhtml popup
 * Arguments     : formname
 * Return values : 
 ********************************************************************************/
function open_mapview_popup(formName){
      	if(formName != ''){  
	    
		var ciDate = document.forms[""+formName].cidate.value;
		var coDate = document.forms[""+formName].codate.value;
		var room  = document.forms[""+formName].room.value;
        var cityName=document.forms[""+formName].city_name.value;
		
		var adt1, adt2, adt3, adt4, chdroom1, chdroom2, chdroom3, chdroom4;
		var adt1_chdage1, adt1_chdage2, adt2_chdage1, adt2_chdage2;
		var adt3_chdage1,adt3_chdage2, adt4_chdage1, adt4_chdage2;
		var dhtmlWindowObj='CityMap_'+Math.random();
        url="waitpages/waitpage_mapviewpopup.html?randomid="+Math.random()+"&cityname="+cityName;		
		url = url+'&cidate='+ciDate+'&codate='+coDate+'&room='+room;
		//Get guest details for room1 
		adt1 = document.forms[""+formName].adt1.value; 
		chdroom1 = document.forms[""+formName].chdroom1.value;
		if(chdroom1 > 0){
			adt1_chdage1 = document.forms[""+formName].adt1_chdage1.value;
			adt1_chdage2 = document.forms[""+formName].adt1_chdage2.value;
		}

		// Get guest details for room2 
		adt2 = document.forms[""+formName].adt2.value;
		chdroom2 = document.forms[""+formName].chdroom2.value;
		if(chdroom2 > 0){
			adt2_chdage1 = document.forms[""+formName].adt2_chdage1.value;
			adt2_chdage2 = document.forms[""+formName].adt2_chdage2.value;
		}

		// Get guest details for room3
		adt3 = document.forms[""+formName].adt3.value;
		chdroom3 = document.forms[""+formName].chdroom3.value;
		if(chdroom3 > 0){
			adt3_chdage1 = document.forms[""+formName].adt3_chdage1.value;
			adt3_chdage2 = document.forms[""+formName].adt3_chdage2.value;
        	}
		//Get guest details for room4
        	adt4 = document.forms[""+formName].adt4.value;
        	chdroom4 = document.forms[""+formName].chdroom4.value;
        	if(chdroom4 > 0){
            		adt4_chdage1 = document.forms[""+formName].adt4_chdage1.value;
            		adt4_chdage2 = document.forms[""+formName].adt4_chdage2.value;
        	}        	
		url = url+'&adt1='+adt1+'&chdroom1='+chdroom1+'&adt1_chdage1='+adt1_chdage1+'&adt1_chdage2='+adt1_chdage2;
              if(room>1)
			url = url+'&adt2='+adt2+'&chdroom2='+chdroom2+'&adt2_chdage1='+adt2_chdage1+'&adt2_chdage2='+adt2_chdage2;
		if(room>2)
			url = url+'&adt3='+adt3+'&chdroom3='+chdroom3+'&adt3_chdage1='+adt3_chdage1+'&adt3_chdage2='+adt3_chdage2;
              if(room>3)	
			url = url+'&adt4='+adt4+'&chdroom4='+chdroom4+'&adt4_chdage1='+adt4_chdage1+'&adt4_chdage2='+adt4_chdage2;
		closessh_map();
                mapviewWindow=dhtmlmodal.open(dhtmlWindowObj, 'iframe', url, 'Yatra Hotels', 'width=810,height=530,left=200,center=1,resize=0,scrolling=0');
		//To hide the select boxes
		hideselect(); 
	if(document.getElementById('adzonediv')){
		document.getElementById('adzonediv').style.display='none';
	}
	}	
	return false;
}
function rating_info(){
	window.open('/HOTEL/hotel/govtratings.html','popup','scrollbars=0,width=370,height=160,top=150,left=400');

}

function show_circle(){
        hideselect();
        document.getElementById('overeffect').style.display="";
        document.getElementById('flashdiv').style.display="";
}

//Functions added for PEGASUS full room name popup
function getTop(obj)
{
	if ('string' == typeof obj)
	obj = document.getElementById(obj);
	var y = 0;
	while (obj != null)
	{
	y += obj.offsetTop;
	obj = obj.offsetParent;
	}
	return y;
}

function fullnameClick(evt,roomId,roomName)
			{
			var Div=document.getElementById('fullroomName');
			Div.style.display='block';
			Div.style.top=getTop(roomId) +260+'px';
			document.getElementById('fullroomName').innerHTML=uppercase_firstletter(roomName);
			}
function fullnameCloseOut()
			{
				document.getElementById('fullroomName').style.display='none'
			}

/*******************************************************************************
 * Function Name : user_review_rating
 * Description   : This function is used to get raahi rating image string
                                        according to rating value
 * Arguments     : rating,color
 * Return values : string containing image string
 ********************************************************************************/
function  user_review_rating(rating,color){
	rating = Math.round(rating);
	var ratingStr="";
	
	switch(color){
		case 'yellow' :
			var fullStarImage="\"/images/xhotelv2/yellow_star_on.gif\" border=\"0\" ";
			var blankStarImage="\"/images/xhotelv2/yellow_star_off.gif\" border=\"0\" ";
			break;
		case 'green' :
			var fullStarImage="\"/images/xhotelv2/green_star_on.gif\" border=\"0\" ";
			var blankStarImage="\"/images/xhotelv2/green_star_off.gif\" border=\"0\" ";
			break;
	}
   for(var i=0;i<rating;i++){
	   ratingStr+="<img src="+fullStarImage+" border='0' />";
	}
   //return ratingStr;
   for(var i=rating;i<5 ;i++){
			ratingStr += "<img src="+blankStarImage+" border='0' />";
		}	
	 return ratingStr;
}
