var totalMonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var itemTop, itemLeft ;
var obj1;
var jb_PageLoad = true;
var valdate, js_curday, js_curmonth, js_curyear, js_book_from, js_book_to;
bname = navigator.appName;
bver = parseInt(navigator.appVersion);

function MM_goToURL() { //v3.0
  
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  document.form_bhrc.action = args[1];
  document.form_bhrc.submit();  
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function JF_open_pop(url)
{
	if(!jb_PageLoad)
	{
		wf = 'toolbar=no,location=no,directories=no,top=0,left=0,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=500,height=400';
		win = window.open(url,'winUsrUpd',wf);
	}
}

function Jf_SelHotel()
{	
	document.form_bhrc.Hid_Str_Rating.value="";
	document.form_bhrc.action = document.form_bhrc.ComeFrom.value;  
	document.form_bhrc.submit();
}

function fn_dv_splrate(n,flg_splrt)
{
	if(flg_splrt=='Y')
	{ 
		var temp="dv_splrate"+n;
 		var obj=eval('document.getElementById("'+ temp +'")');
		obj.style.cursor="hand";
		obj.style.color="#2f4f4f";
	}
}

function fn_dv_splrate_mout(n)
{
	var temp="dv_splrate"+n;
	var obj=eval('document.getElementById("'+ temp +'")');
	obj.style.color="brown";
}

function deActivate(layerName,temp)
{
	var obj ;
	if(browser_type=='Netscape')
	{
		MM_showHideLayers_header(layerName,'','hide');
		if (temp)
		{
			var obj_temp;
			obj_temp = MM_findObj_header(temp);
			obj_temp.style.cursor="hand";
			obj_temp.style.color="brown";
		}			
	}
	else
	{
		obj  = eval(layerName);
		obj.style.visibility = 'hidden';

		if (temp)
		{
			temp.style.cursor="hand";
			temp.style.color="brown";
		}
	}	
	return;
}

function EnterContent(layerName, TTitle,obj, rate_obj)
{	
    var obj_tip, obj_rate, top;
        
    TContent = eval(obj).value;
	TContent=TContent.replace("*","'");
	ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="148">'+
	'<tr><td><font color=white size=-1 face="Arial">'+TContent+'</font></td></tr>'+
	'</table>';
	if(browser_type=='Netscape')
	{
		obj_tip = MM_findObj_header(layerName) ;
		if (obj_tip !=null)
		{
			obj_tip.innerHTML = ContentInfo ;
			/*top = JF_GetTop(rate_obj);
			obj_tip.style.top = top ;
			obj_tip.style.left = 250 ;*/
			obj_tip.style.top = yMousePos ;
			obj_tip.style.left = xMousePos ;			
			MM_showHideLayers_header('ToolTip','','show');
		}
	}
	else
	{
		ToolTip.innerHTML = ContentInfo;
		ToolTip.style.left = document.body.scrollLeft + eval(window.event.clientX);
		ToolTip.style.top = document.body.scrollTop + window.event.clientY
		ToolTip.style.visibility = 'visible';
	}
	return;
}


function EnterContenttest(layerName, TTitle,obj, rate_obj)
{	


    var obj_tip, obj_rate, top;
     
    TContent = eval(obj).value;
	TContent=TContent.replace("*","'");
	ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0">'+
	'<tr><td><font color=white size=-1 face="Arial">'+TContent+'</font></td></tr>'+
	'</table>';
	if(browser_type=='Netscape')
	{
		obj_tip = MM_findObj_header(layerName) ;
		if (obj_tip !=null)
		{
			obj_tip.innerHTML = ContentInfo ;
			/*top = JF_GetTop(rate_obj);
			obj_tip.style.top = top ;
			obj_tip.style.left = 250 ;*/
			obj_tip.style.top = yMousePos ;
			obj_tip.style.left = xMousePos ;			
			MM_showHideLayers_header('ToolTip','','show');
		}
	}
	else
	{
		ToolTip.innerHTML = ContentInfo;
		ToolTip.style.left = document.body.scrollLeft + eval(window.event.clientX);
		ToolTip.style.top = document.body.scrollTop + window.event.clientY
		ToolTip.style.visibility = 'visible';
	}
	return;
}


function JF_ChkValidDate(DD,MM,YYYY,flg)
{	
	
	ji_err = 0;
	
	js_val=MM;
	
	if (!(js_val == '$-$-$')) 
	{	
		if (js_val.substring(0,1) == '$') 
			{ji_err = -1;}
		if (js_val.indexOf('$') > 0) 
			{ji_err = -1;}
			
		if (ji_err == 0) 
		{
			
			js_day = DD;
			js_day=""+DD;
			
			js_mnth_year = YYYY;
			js_mnth_year=MM+"-"+YYYY;
			
			js_val=js_day;
			
			while ( js_val.substring(0,1) == '0')
			js_val = js_val.substring(1, js_val.length);
			ji_day = parseInt( js_val ) ;
			if(js_mnth_year.substring(0,1) == '0')
				js_mnth_year = js_mnth_year.substring(1, js_mnth_year.length);
			
			js_val=js_mnth_year;
			
			js_val_splt = js_val.split('-');
			ji_mnth = parseInt( js_val_splt[0]) ;
			ji_year = parseInt( js_val_splt[1] ) ;
			
		}
		var ret_val;
		if ( (ji_err == 0) && ( (ji_mnth == 4) || (ji_mnth == 6) || (ji_mnth == 9) || (ji_mnth == 11) ) && (ji_day > 30) ) 
		{
			ji_err = -1;
			ret_val="30";
		}
			if ( (ji_err == 0) && (ji_mnth == 2) ){if ( ( ( (ji_year % 4) == 0 ) && ( (ji_year % 100) != 0 ) ) || ( ji_year % 400 == 0 ) )
			{
				if (ji_day > 29) 
				{
					ji_err = -1;
					ret_val="29";
				}
			}
			else
			{
				if (ji_day > 28)
				{
					ji_err = -1;
					ret_val="28";
				}
			}
		}
	}
	
	if (ji_err == -1) 
	{
		if(flg=='Y')
		{	
			js_err = as_label + ' is not a valid date.';
			JF_ErrHandle(document.form_bhrc.Sel_Day, as_label, js_err);
			return;
		}
		else
		{
			 
			return ret_val;
		}
	}
	return true;
}

function Jf_SetDateVal()
{
	js_dd_cal=document.form_bhrc.Sel_Day.value;
	var mm_yy=document.form_bhrc.Sel_month_year.value;
	mm_yy_split=mm_yy.split("-");
	js_mm_cal=mm_yy_split[0];
	js_yy_cal=mm_yy_split[1];
	document.form_bhrc.Sel_Day1.value = js_dd_cal + '-' + js_mm_cal + '-' + js_yy_cal;
	document.form_bhrc.Sel_Day1_dd.value = js_dd_cal;
	document.form_bhrc.Sel_Day1_mm_yy.value = js_mm_cal + '-' +js_yy_cal;
}

function EnterContentBook(layerName, TTitle, obj_bk)
{	
	var obj_tip ;	
	   
    //TContent = eval(obj).value;
	//TContent=TContent.replace("*","'");
	TContent="Click here to view/book rates applicable for your Check-in and Check-out date."
	ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="148">'+
	'<tr><td><font color=white size=-1 face="Arial">'+TContent+'</font></td></tr>'+
	'</table>';
	if(browser_type=='Netscape')
	{
		obj_tip = MM_findObj_header(layerName) ;
		if (obj_tip !=null)
		{
			obj_tip.innerHTML = ContentInfo ;
			/*top = JF_GetTop(obj_bk);
			obj_tip.style.top = top ;
			obj_tip.style.left = 750 ;*/
			obj_tip.style.top = yMousePos ;
			obj_tip.style.left = xMousePos ;

			MM_showHideLayers_header('ToolTip','','show');
		}			
	}
	else
	{
		ToolTip.innerHTML = ContentInfo;
		ToolTip.style.left = document.body.scrollLeft + eval(window.event.clientX);
		ToolTip.style.top = document.body.scrollTop + window.event.clientY
		ToolTip.style.visibility = 'visible';
	}	
	return;
		
}

function EnterContentRT(layerName, TTitle,obj,num, obj_rt)
{	



	var temp ;
    TContent = obj;
	TContent=TContent.replace("*","'");
		
	var TContent_obj=TContent.split("<br>");
	if(browser_type=='Netscape')
	{
		temp="dv_rmtype"+num;
		/*ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="148">'+
		'<tr><td valign=top align=left><font color=white size=-1 face=Arial>'+TContent_obj[0]+'</font></td><td valign=top align=right><a style=cursor:pointer;cursor:hand;; onclick=javacript:deActivate("'+layerName+'","'+temp+'"); title="Click here to close window pop up"><font color=white size=-1 face="Arial"><u><b>Close</b></u></font></a></td></tr>'+
		'<tr><td colspan="2"><font color=white size=-1 face="Arial">'+TContent_obj[1]+'</font></td></tr>'+
		'</table>';*/
		
		ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="200">'+
		'<tr><td><font color=white size=-1 face="Arial">'+TContent_obj[0]+'</font></td><td align="right"><a style=cursor:pointer;cursor:hand;; onclick=javacript:deActivate("'+layerName+'","'+temp+'"); title="Click here to close window pop up"><font color=white size=-1 face="Arial"><u><b>Close</b></u></font></a></TD></tr>'+
		'<tr><td colspan="2"><font color=white size=-1 face="Arial">'+TContent_obj[1]+'</font></td></tr>'+
		'</table>';		
		
	
		obj_tip = MM_findObj_header(layerName) ;
		if (obj_tip !=null)
		{
			obj_tip.innerHTML = ContentInfo ;
			/*top = JF_GetTop(obj_rt);
			obj_tip.style.top = top ;
			obj_tip.style.left = 650 ;*/
			obj_tip.style.top = yMousePos ;
			obj_tip.style.left = xMousePos ;			
			MM_showHideLayers_header('ToolTip','','show');
		}		
	}	
	else
	{	
		temp="dv_rmtype"+num;
		/*ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="148">'+
		'<tr><td valign="top" align="left" noWrap><font color=white size=-1 face="Arial">'+TContent_obj[0]+'</font></td><td noWrap valign="top" align="right"><a style="cursor:hand;" onclick="javacript:deActivate('+layerName+','+temp+');" title="Click here to close window pop up"><font color=white size=-1 face="Arial"><u><b>Close</b></u></font></a></td></tr>'+
				
				
		'<tr><td colspan="2" nowrap><font color=white size=-1 face="Arial">'+TContent_obj[1]+'</font></td></tr>'+
		'</table>';*/
		ContentInfo = '<table border="0" cellpadding="4" bgcolor="#B10004" cellspacing="0" width="200">'+
		'<tr><td><font color=white size=-1 face="Arial">'+TContent_obj[0]+'</font></td><td align="right"><a style="cursor:hand;" onclick="javacript:deActivate('+layerName+','+temp+');" title="Click here to close window pop up"><font color=white size=-1 face="Arial"><u><b>Close</b></u></font></a></TD></tr>'+
		'<tr><td colspan="2"><font color=white size=-1 face="Arial">'+TContent_obj[1]+'</font></td></tr>'+
		'</table>';
		ToolTip.innerHTML = ContentInfo;
		ToolTip.style.left = document.body.scrollLeft + eval(window.event.clientX);
		ToolTip.style.top = document.body.scrollTop + window.event.clientY
		ToolTip.style.visibility = 'visible';
	}

	var obj=eval('document.getElementById("'+ temp +'")');	
	if (obj)
	{
		obj.style.cursor="hand";
		obj.style.color="#2f4f4f";
	}
	
	return;
}

function fn_dv_rmtype_mout(n)
{
	var temp="dv_rmtype"+n;
	var obj=eval('document.getElementById("'+ temp +'")');
	obj.style.cursor="hand";
	obj.style.color="brown";
}


/****************************************************************************
        
        Constructor:
        -----------------
        var objCalendar = new suycCalendar([month(Int)], [year(Int)])
        ________________________________________________________________________
        
        Method Selectors:
        -------------------------
        BuildCalendar           - Renders a new calendar with a default of current month.
        goToCurrent             - Renders the calendar to the current month.
        toggleCalendar ( int )  - int = number of months to toggle by.
        show                     - sets the visibility of the Canvass to visible
        hide                      - sets the visibility of the Canvass to not visible
        moveTo                 - accepts x,y as pixels moves the canvass to that position
        bindToElement           - Not yet implemented.
        
        Properties Exposed:
        ---------------------------
        hasEvents   (type: Boolean) - if true then interface raises events.
        posX          allows the user to set the left location (the number of pixels from the left edge of the browser window). 
        posY          allows the user to set the top location (the number of pixels from the top edge of the browser window). 
        
        Notes:
        ---------
        If hasEvents is set to True then you need to implement the following event handlers:
            - clickhandler (d,m,y)   - receives the event thrown by the user clicking on a day/date
            - toggleCalendar (i)      - receives the event thrown by the user clicking on << or >>
            - toggleCurrent ()        - receives the event thrown by the user clicking on [ Today ]
            
        Calendar also exposes the following CSS classes:
            - clickable               : refers to the <<, [ TODAY ], and >> navigation controls at the base of the calendar
            - calendar_normal    : the normal state of a calendar date 
            - calendar_clickable  : the onMouseOver state of a calendar date
            - TR.monthsheader  : the row that contains the abbreviated Day names near the top of the calendar
            - TD.monthsheader : the individual cells contained by the aforementioned row

*****************************************************************************/



/****************************************************************************
        BEGINNING OF CLASS
*****************************************************************************/
function suycCalendar(m,y)
{
    
    if (typeof(_calendar_prototype_called) == 'undefined')
    {
        _calendar_prototype_called = true ;
        
        // Object methods
        this.BuildCalendar = _create ;
        this.createCanvass = _createCanvass ;
        this.showCalendar = _showCalendar ;
        this.goToCurrent = _goToCurrent ;
        this.goTo = _goTo ;
        this.toggleCalendar = _toggleCalendar ;
        this.moveTo = _positionCanvass ;
        this.hide = _hide ;
        this.show = _show ;
        this.init = _init ;
    }
    
        // Object properties
        this.name = 'default' ;
        this.rowBGColor = 'palegoldenrod' ;
        this.currentDay = 0 ;
        this.currentMonth = 0 ;
        this.currentYear = 0 ;
        this.visible = false ;
        this.posX = 10 ;
        this.posY = 10 ;
        this.isIE4 = '';
        this.isNav4 = '' ;
        this.valdate= 0 ;
        
        // If you set hasEvents fo FALSE then the calendar face is dumbed out.
        this.hasEvents = true ;
        
        this.canvass = '' ; // The DIV || LAYER that we display the calendar on.
        this.bindToElement = '' ;  // Bind to an ELEMENT on the page.
    
    // Array of day names
    this.days = new Array("Sunday", "Monday", "Tuesday", "Wednesday","Thursday", 
                                   "Friday", "Saturday");
    // Array of month names
    this.months = new Array("January", "February", "March", "April", "May","June", "July", 
                                        "August", "September", "October", "November", "December");
    // Array of total days in each month
    this.totalDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    
    // Call the Initialize() event.
    this.init(m,y) ;
}

function JF_AddDate(d,n)
{
	var jl_M1=31,jl_M3=31,jl_M4=30,jl_M5=31,jl_M6=30,jl_M7=31,jl_M8=31,jl_M9=30,jl_M10=31,jl_M11=30,jl_M12=31;
	var js_Mon1='Jan',js_Mon2='Feb',js_Mon3='Mar',js_Mon4='Apr',js_Mon5='May',js_Mon6='Jun',js_Mon7='Jul',js_Mon8='Aug',js_Mon9='Sep',js_Mon10='Oct',js_Mon11='Nov',js_Mon12='Dec';
	var jl_M2=JF_LeapYearfun(d.getFullYear());
	if (jl_M2==29)
	{
	js_NoOfDays=parseInt(d.getFullYear())*366;
	}
	else
	js_NoOfDays=parseInt(d.getFullYear())*365;	
	for(jl_i=1;jl_i<d.getMonth()+1;jl_i++)
		js_NoOfDays=js_NoOfDays+parseInt(eval("jl_M"+jl_i));	
		
	js_NoOfDays=js_NoOfDays+parseInt(d.getDate())+parseInt(n);
	
	if (jl_M2==29)
	{
	
		js_y=parseInt(js_NoOfDays/366);		
		js_totm=parseInt(js_NoOfDays%366);
	}
	else
	{
		
		js_y=parseInt(js_NoOfDays/365);		
		js_totm=parseInt(js_NoOfDays%365);
	}
	
	for(jl_i=1;jl_i<13;jl_i++)
	{
		if (js_totm<parseInt(eval("jl_M"+jl_i)))
			break;
		js_totm=js_totm-parseInt(eval("jl_M"+jl_i));
	}
	if(js_totm==0)
		if (jl_i==1)
			var jd_date='Dec 31, '+js_y;
		else    
			var jd_date=eval("js_Mon"+parseInt(jl_i-1))+' '+parseInt(eval("jl_M"+parseInt(jl_i-1))) +', '+js_y;
	else 
		var jd_date=eval("js_Mon"+parseInt(jl_i))+' '+js_totm+', '+js_y;
	jd_ResDate=new Date(jd_date);
	return (jd_ResDate);
}
function JF_DateDiff(d1,d2)
{
	/*var jl_M1=31,jl_M3=31,jl_M4=30,jl_M5=31,jl_M6=30,jl_M7=31,jl_M8=31,jl_M9=30,jl_M10=31,jl_M11=30,jl_M12=31;
	var jl_M2=JF_LeapYearfun(d1.getFullYear());
	js_NoOfFromDays=parseInt(d1.getFullYear()-1)*365;
	for(jl_i=1;jl_i<parseInt(d1.getMonth()+1);jl_i++)
		js_NoOfFromDays=js_NoOfFromDays+parseInt(eval("jl_M"+jl_i));
	js_NoOfFromDays=js_NoOfFromDays+parseInt(d1.getDate());
	
	
	jl_M2=JF_LeapYearfun(d2.getFullYear());
	js_NoOfToDays=parseInt(d2.getFullYear()-1)*365;
	for(jl_i=1;jl_i<parseInt(d2.getMonth()+1);jl_i++)
		js_NoOfToDays=js_NoOfToDays+parseInt(eval("jl_M"+jl_i));

	js_NoOfToDays=js_NoOfToDays+parseInt(d2.getDate());
	return (parseInt(js_NoOfToDays)-parseInt(js_NoOfFromDays));

    var difference = d2.getTime() - d1.getTime();
    var daysDifference = Math.floor(difference/1000/60/60/24);
	return daysDifference;
*/	

  var s1, t1, s2, t2;
  var MinMilli = 1000 * 60;
  var HrMilli = MinMilli * 60;
  var DyMilli = HrMilli * 24;
  t1 = d1.getTime();
  s1 = Math.round(t1 / DyMilli);	//return no. of days since 1st Jan 1970
  
  t2 = d2.getTime();
  s2 = Math.round(t2 / DyMilli);	//return no. of days since 1st Jan 1970
  
  return(s2-s1);

}


function JF_LeapYearfun(y)
{
if ((y % 4)==0 && (y % 1000)!=0 && (y % 400)!=0)
	return (29);
else
	return (28);
}

function setnonights(calid, chkValid)
{
	var js_mm_cal,js_yy_cal, totalDays, td, tm
	var jl_M1='JAN',jl_M2='FEB',jl_M3='MAR',jl_M4='APR',jl_M5='MAY',jl_M6='JUN',jl_M7='JUL',jl_M8='AUG',jl_M9='SEP',jl_M10='OCT',jl_M11='NOV',jl_M12='DEC';

	totalMonthDays[1] = 28;
	js_dd_cal=document.form_bhrc.Sel_Day.value;
	mm_yy=document.form_bhrc.Sel_month_year.value;
	mm_yy_split=mm_yy.split("-");
	tm = mm_yy_split[0];
	js_mm_cal=parseFloat(tm);
	js_yy_cal=mm_yy_split[1];
	js_monthname=eval("jl_M"+js_mm_cal);
		
	if (js_yy_cal % 4 == 0 && (js_yy_cal % 100 != 0 || js_yy_cal % 400 == 0)) 
	{
		totalMonthDays[1] = 29 ;
	}
    
	if(parseInt(js_dd_cal)>totalMonthDays[js_mm_cal-1])
	{
		document.form_bhrc.Sel_Day.selectedIndex = totalMonthDays[parseInt(js_mm_cal-1)]-1;
		document.form_bhrc.Sel_Day_bottom.selectedIndex = totalMonthDays[parseInt(js_mm_cal-1)]-1;
		js_dd_cal = totalMonthDays[js_mm_cal-1];
	}
		
	js_from_dt=js_monthname +" " + js_dd_cal +"," + js_yy_cal;
	if (js_dd_cal.length<2) 
		js_dd_cal="0"+js_dd_cal ;
	if (tm.length<2) 
		tm="0"+tm ;
						
	document.form_bhrc.dtDatefrom.value=js_dd_cal+"-"+tm+"-"+js_yy_cal;

	js_dd_cal1=document.form_bhrc.Sel_Right_Day.value;
	mm_yy1=document.form_bhrc.Sel_Right_month_year.value;
	mm_yy_split1=mm_yy1.split("-");
	tm=mm_yy_split1[0];
	js_mm_cal1=parseFloat(tm);
	js_yy_cal1=mm_yy_split1[1];
	js_monthname1=eval("jl_M"+js_mm_cal1);
		
	if (js_yy_cal1 % 4 == 0 && (js_yy_cal1 % 100 != 0 || js_yy_cal1 % 400 == 0)) {
		totalMonthDays[1] = 29 ;
	}
	if(parseInt(js_dd_cal1)>totalMonthDays[js_mm_cal1-1])
	{
		document.form_bhrc.Sel_Right_Day.selectedIndex = totalMonthDays[parseInt(js_mm_cal1-1)]-1;
		document.form_bhrc.Sel_Right_Day_bottom.selectedIndex = totalMonthDays[parseInt(js_mm_cal1-1)]-1;
		js_dd_cal1 = totalMonthDays[js_mm_cal1-1];
	}		
		
	js_to_dt=js_monthname1 +" " + js_dd_cal1 +"," + js_yy_cal1;
	if (js_dd_cal1.length<2) 
		js_dd_cal1="0"+js_dd_cal1 ;
	if (tm.length<2) 
		tm="0"+tm ;
						
	document.form_bhrc.dtDateto.value=js_dd_cal1+"-"+tm+"-"+js_yy_cal1;	
		
	js_f_dt=new Date(js_from_dt);	
	js_t_dt=new Date(js_to_dt);	
	jd_today=JF_DateDiff(js_f_dt,js_t_dt);
		
	//alert(js_f_dt);
	//alert(jd_today);
	
	if (parseInt(jd_today) <1)
	{	
		if (chkValid == 'Y')
		{
			alert('Check-out(departure) date should be greater than Check-in(arrival) date.');
			document.form_bhrc.Sel_Right_Day.focus();
			return false;
		}
		
		jd_today="1";
		if (calid==1 || calid==3)
			changetodate();
	}

	HTMLstr="<b class='month'><font color='#b10004'>"+jd_today+"</font></b>";
	if (parseFloat(jd_today)>1)
		HTMLstr+="<font class='month'><font color='#000080'>&nbsp;Nights</font></font>";
	else
		HTMLstr+="<font class='month'><font color='#000080'>&nbsp;Night</font></font>";
	document.form_bhrc.sle_nights.value=jd_today;
	document.getElementById("roomtype_cnt").innerHTML=HTMLstr;
	document.getElementById("roomtype_cnt_bottom").innerHTML=HTMLstr;
	
	return true;
}

function changetodate()
{
	var jl_M1='JAN',jl_M2='FEB',jl_M3='MAR',jl_M4='APR',jl_M5='MAY',jl_M6='JUN',jl_M7='JUL',jl_M8='AUG',jl_M9='SEP',jl_M10='OCT',jl_M11='NOV',jl_M12='DEC';
	
	js_dd_cal1=document.form_bhrc.Sel_Day.value;
	mm_yy1=document.form_bhrc.Sel_month_year.value;
	mm_yy_split1=mm_yy1.split("-");
	tm=mm_yy_split1[0];
	js_mm_cal1=parseFloat(tm);
	js_yy_cal1=mm_yy_split1[1];
	js_monthname1=eval("jl_M"+js_mm_cal1);

	js_from_dt=js_monthname1 +" " + js_dd_cal1 +"," + js_yy_cal1;

	js_from_dt=new Date(js_from_dt);
		
	js_date=JF_AddDate(js_from_dt,1);
		
	DD=js_date.getDate();
	d = new String(DD) ;
	MM=parseFloat(js_date.getMonth())+1;
	MM=""+MM;
	if(MM.length==1)
		MM="0"+MM;
	YYYY=js_date.getFullYear();
		
	if(DD=="31" && MM=="12")
		YYYY=parseFloat(YYYY)-1;
		
	document.form_bhrc.Sel_Right_Day.selectedIndex = (DD-1);	
	document.form_bhrc.Sel_Right_Day_bottom.selectedIndex = (DD-1);	
			
	js_mon_year = MM+"-"+YYYY;
	for (i=0; i< document.form_bhrc.Sel_Right_month_year.options.length; i++)
	{
		if (document.form_bhrc.Sel_Right_month_year.options[i].value == js_mon_year)
		{
			pos = i ;
			break ;
		}
	}
	document.form_bhrc.Sel_Right_month_year.selectedIndex = pos ;
	document.form_bhrc.Sel_Right_month_year_bottom.selectedIndex = pos ;
	
	if (d.length<2)
		d = "0"+d ;
	document.form_bhrc.dtDateto.value = d+"-"+MM+"-"+YYYY ;
}

function jf_change_monthyear(calid)
{
	if (obj1!=null)
		calClose();
	var f=document.form_bhrc;
	switch (calid)
	{
		case 1:
			f.Sel_Day_bottom.selectedIndex = f.Sel_Day.selectedIndex;
			f.Sel_month_year_bottom.selectedIndex = f.Sel_month_year.selectedIndex;
			break;
		case 2:
			f.Sel_Right_Day_bottom.selectedIndex = f.Sel_Right_Day.selectedIndex;
			f.Sel_Right_month_year_bottom.selectedIndex = f.Sel_Right_month_year.selectedIndex;
			break;
		case 3:
			f.Sel_Day.selectedIndex = f.Sel_Day_bottom.selectedIndex;
			f.Sel_month_year.selectedIndex = f.Sel_month_year_bottom.selectedIndex;
			break;
		case 4:
			f.Sel_Right_Day.selectedIndex = f.Sel_Right_Day_bottom.selectedIndex;
			f.Sel_Right_month_year.selectedIndex = f.Sel_Right_month_year_bottom.selectedIndex;		
			break;
	}
	setnonights(calid);
}

function _show()
// This function displays the objects canvass.
{
    /*if(this.isNav4)
    {
        this.canvass.visibility = 'show' ;
        this.canvass.left = this.posX ;
        this.canvass.top = this.posY ;   
    } else {*/
        this.canvass.style.visibility = 'visible' ;
        this.canvass.style.left = this.posX ;
        this.canvass.style.top = this.posY ;
    //}
    
    
    this.visible = true ; 
}

function _hide()
// This function hides the objects canvass.
{
    /*if(this.isNav4)
    {
        this.canvass.visibility = 'hide' ;   
    } else {*/
        this.canvass.style.visibility = 'hidden' ;
   // }
    this.visible = false ;
}

function _init(m,y)
{
    if (parseInt(navigator.appVersion.charAt(0)) >= 4)
    // Browser check.
    {
        this.isNav4 = (navigator.appName == "Netscape") ? true : false ;
        this.isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false ;
    }
    
    // Populate the current Day|Month|Year properties
    var obj = new Date();
    this.currentDay = obj.getDate();
    this.currentMonth = obj.getMonth() + 1;
    this.currentYear = (obj.getFullYear() < 1000) ? obj.getFullYear() + 1900 : obj.getFullYear();
    
    /* 
        The constructor optionally accepts m && y parameters
        if none are supplied, the calendar defaults to the current
        month 
    */
    this.month = m || this.currentMonth ;
    this.year = y || this.currentYear ;
    
    // Create the canvass that we will be displaying the calendar on
    this.createCanvass() ;
    obj = null ;
  
}

function _createCanvass()
{
    
    // Create canvass for NN4+
    /*if (this.isNav4) 
    { 
        this.canvass = new Layer(200) ;
        this.canvass.left = this.posX ;
        this.canvass.top = this.posY ;
    }
    
    // Create canvass for IE4+
    if (this.isIE4)
    { */
		var objDiv ;
		if (this.isNav4)
		{
			objDiv = document.createElement("div") ;
			objDiv.style.position = "absolute" ;
		}
		else if(navigator.appName == "Opera")
		{
			objDiv = document.createElement("div") ;
			objDiv.style.position = "absolute" ;
		}	
		else
			objDiv = document.createElement("<DIV STYLE='position: absolute; left: 50; top: 50;'>") ;
        document.body.appendChild (objDiv) ;
        this.canvass = objDiv ;
        this.canvass.style.left = this.posX ;
        this.canvass.style.top = this.posY ;
    //}
}

function _positionCanvass(x,y)
{
    // if either x || y were not supplied, default to the current settings.
    if(x==null || y==null) { x=this.posX; y=this.posY ; return ;}
    
    if( isNaN(x) || isNaN(y) )
    {
        alert('You can only enter numbers for the x/y co-ordinates') ;
        return ;
    }
    
    // apply the new settings for NN
    /*if (this.isNav4) 
    { 
        this.canvass.left = this.posX = x ;
        this.canvass.top = this.posY = y ;
    }
    
    // apply the new settings for NN
    if (this.isIE4)
    {*/ 
        this.canvass.style.left = this.posX = x ;
        this.canvass.style.top = this.posY = y ;
    //}
    
}

function _goToCurrent()
{
    
    this.year = this.currentYear ;
    this.month = this.currentMonth ;
    this.BuildCalendar() ;
}
function _goTo(mon, year)
{
    this.year = year ;
    this.month = mon ;
}
function _toggleCalendar(n)
{
    var currentMonth = this.month ;
    var currentYear = this.year ;
    
    if((currentMonth + n) == 0)
    { 
        this.year = currentYear-1 ; 
        this.month = 12 ; 
    }
    else if((currentMonth + n) == 13)
    { 
        this.year = currentYear+1 ; 
        this.month = 1 ; 
    }
    else
    {
        this.month = currentMonth + n ;
    }
    // Leap year correction
    if (this.year % 4 == 0 && (this.year % 100 != 0 || this.year % 400 == 0)) {
    	this.totalDays[1] = 29 ;
    }

    this.currentYear = this.year ;
    this.currentMonth = this.month ;
    
    this.BuildCalendar() ;
}
function MM_preloadImages() 
{	//v3.0
	var d=document; 
	if(d.images)
	{ 
			if(!d.MM_p) 
				d.MM_p=new Array();
    
			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
			for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0)
				{ 
					d.MM_p[j]=new Image; 
					d.MM_p[j++].src=a[i];
				}
	}
}

//for  rating  Bar start -DINESH




//RAting BAr end


// Create and Display Calendar.
function _create()
{
    // Counters to count rows and days, String to store calendar output.
    var rowCount = 0 ;
    var numRows = 0 ;
    var vald, valm, valy, valtemp ;
    var sOut = new String() ;
    var tday, tmonth, tyear;
    
    // Leap year correction
    if (this.year % 4 == 0 && (this.year % 100 != 0 || this.year % 400 == 0)) {
    	this.totalDays[1] = 29 ;
    }
    
    var obj = new Date(this.year, this.month-1, 1);
    var firstDayOfMonth = obj.getDay();
    obj.setDate(31);
    var lastDayOfMonth = obj.getDay();
    var bgDay;
    obj = null ;

    if (this.currentDay > this.totalDays[this.month-1])
		bgDay = this.totalDays[this.month-1];
	else
		bgDay = this.currentDay ;
		
	//valdate format = yyyymmdd
	vald = this.valdate%100 ;
	valtemp = parseInt(this.valdate/100) ;
	valm = valtemp%100 ;
	valy = parseInt(valtemp/100) ;
	
	if(this.month==valm && this.year==valy)
	{
		if(bgDay<vald)
			bgDay = vald ;	
	}
    
    sOut = ""
    
	if(this.isNav4)
	{
		sOut += "<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000>" ;
		sOut += "<tr><td>" ;
	}    
    
    
    sOut += "<table border=0 cellpadding=0 cellspacing=0 class=calCalendar>" ;
    /*  Write the TABLE header (month/year) */
    sOut += "<tr CLASS='calTitleBar' height='27'>"
    sOut += "<td colspan=2 align=left >" ;
    sOut += "<A HREF=\"javascript:  ;\" onClick='toggleCalendar(-1) ; return false ;' CLASS='calMonth' TITLE='Previous Month' /><img src='images/newcal1.gif' border='0' width='18' height='18'></A>" ;
    sOut += "</td>" ;
    sOut += "<td colspan=3 align=center CLASS='calTitleBar' bgcolor='#b10004'>&nbsp;<b>" + this.months[this.month-1].substring(0,3) + " " + this.year + "</b></td>" ;
    sOut += "<td colspan=2 align=right>" ;
    sOut += "<A HREF=\"javascript:  ;\" onClick='toggleCalendar(1) ; return false ;' CLASS='calMonth' TITLE='Next Month' /><img src='images/newcal2.gif' border='0' width='18' height='18'></A>" ;
    sOut += "</td>" ;   
    sOut += "</tr>" ;

    /*  Write the abbreviated day names */
    sOut += "<tr class='calMonthsheader' height='20'>" ;
    for (x=0; x<7; x++) {
        sOut += "<td class='calMonthsheader' align='center'>" + this.days[x].substring(0,1) + "</td>" ;
    }
    sOut += "</tr>" ;
    
    sOut += "<tr class='calMonthsheader'>" ;
    sOut += "<td class='calMonthsheader' align='center' colspan='7'><img src='images/newcal3.gif'></td>" ;
    sOut += "</tr>" ;
    
    /* Start of BODY */
    sOut += "<tr  class='bodyMain' height='20'>" ;
    numRows++ ;
    
    for (x=1; x<=firstDayOfMonth; x++) {
        /* pad the blank days at the beginning of the month. */
        rowCount++;
        sOut += "<td><span style='font-size: smaller'>&nbsp;</span></td>" ;
    }
    
    /* Increment the current date */
    this.dayCount=1;
    tyear = new String(this.year) ;
    tmonth = new String(this.month) ;
    if (tmonth.length<2) 
		tmonth = "0" + tmonth ;

    while (this.dayCount <= this.totalDays[this.month-1]){
    	/* Display new row after each 7 day block.  */
    	if (rowCount % 7 == 0)
    	{
    	    sOut += "</tr>\n<tr  class='bodyMain' height='20'>" ;
    	    numRows++ ;
    	}

        /* Insert the Date. */
        tday = new String(this.dayCount) ;
        if (tday.length<2)
			tday = "0" + tday ;
			
		if (parseFloat(tyear + tmonth + tday) <this.valdate) 
		{
			sOut += "<td align=center CLASS='calNonClickable'>" + this.dayCount + "</td>" ;
        }
        else
        {
			if (bgDay == this.dayCount)
				sOut += "<td align=center bgcolor = '#b10004' CLASS='calClickable'><A HREF=\"javascript:  ;\""
			else
				sOut += "<td align=center CLASS='calClickable'><A HREF=\"javascript:  ;\""

			if (this.hasEvents) sOut += " onClick='clickhandler(" + this.dayCount + "," + this.month + "," + this.year + ") ;'" ;
			if (bgDay == this.dayCount)
				sOut += " CLASS='calClickable'><FONT color='#FFFFFF'>" + this.dayCount + "</FONT></A>"  
			else
				sOut += " CLASS='calClickable'>" + this.dayCount + "</A>"  
			sOut += "</td>" ;        
        }
        this.dayCount++ ;
        rowCount++ ;
    }

    while (rowCount % 7 != 0) {
        /* pad the blank days at the end of the month. */
        rowCount++ ;
        sOut += "<td><span style='font-size: smaller'>&nbsp;</span></td>" ;
    }
    sOut += "</tr>" ;
    // End of BODY
    
    // Write the Calendar Navigator.
    if(this.hasEvents) {
        sOut += "<tr height='20'>" ;
        sOut += "<td colspan=7 align=center>" ;
        sOut += "<A HREF=\"javascript:  ;\" onClick='calClose() ; return false ;' TITLE='Close' CLASS='calClickable'>Close</A>" ;
        sOut += "</td>" ;
        sOut += "</tr>" ;
    }
    
    sOut += "</table>" ;
    
    if(this.isNav4)
	{
		sOut += "</td></tr></table>" ;
	}
    
    // Render the calendar
    this.showCalendar (sOut) ;
}

function _showCalendar (s)
{
    /*if(this.isNav4)
    {
        this.canvass.document.open() ;
        this.canvass.document.writeln(s) ;
        this.canvass.document.close() ;
    } else {*/
        this.canvass.innerHTML = s ;
    //}
    this.show() ;
}

function produceCalendar (bindToFld, imgid) {

	var jf_seldate, ja_dt, top;
	var jf_dt=eval("document.form_bhrc."+ bindToFld);
	jf_seldate = jf_dt.value;
	ja_dt = jf_seldate.split("-");

    if(typeof(obj1) != 'object') obj1 = new suycCalendar() ;

    obj1.bindToElement = bindToFld ;

	obj1.goTo(parseFloat(ja_dt[1]), parseFloat(ja_dt[2])) ;
	obj1.currentDay = parseFloat(ja_dt[0]);
	obj1.currentMonth = parseFloat(ja_dt[1]);
	obj1.currentYear = parseFloat(ja_dt[2]);

	
	if (imgid=="cal_image1" || imgid=="cal_image3")
		obj1.valdate = js_book_from;
	else
		obj1.valdate = js_book_to;
		
    obj1.BuildCalendar() ;
   
	if(navigator.appName=="Netscape")
	{
		top = JF_DIsplay_IFrame(imgid);
		/*if (imgid=='cal_image1' || imgid=='cal_image3')
		{
			obj1.moveTo(200, top) ;
		}
		else
		{
			obj1.moveTo(400, top) ;			
		}*/
		obj1.moveTo(xMousePos, top) ;
	}
	else
	{
		top = JF_DIsplay_IFrame(imgid);
		obj1.moveTo(document.body.scrollLeft+event.clientX, top) ;
	}
}

function positionCalendar(f) {

    if(typeof(obj1) != 'object') produceCalendar () ;

    if( isNaN(x) || isNaN(y) )
    {
        alert('You can only enter numbers for the x/y co-ordinates') ;
        return ;
    } else {
        obj1.moveTo(x,y)
    }

}

function clickhandler (d,m,y) {
	var td, tm;
	td = new String(d);
	tm = new String(obj1.month);
	if (td.length<2)
		td = "0" + td ;
	if (tm.length<2)
		tm = "0" + tm ;

    var objFld = eval("document.form_bhrc." + obj1.bindToElement) ;
    
    // Update our form field.
    objFld.value = td + '-' + tm + '-' + y ;
    // hide the calendar object.
    obj1.hide() ;
    
    updateDates(obj1, d, m, y) ;
    
}

function updateDates(obj, d, m, y)
{
	var js_mon_year, i, pos=0;
	if(obj.bindToElement=="dtDatefrom")
	{
		document.form_bhrc.Sel_Day.selectedIndex = d-1;
		document.form_bhrc.Sel_Day_bottom.selectedIndex = d-1;
		js_mon_year=new String(m);
		if (js_mon_year.length<2) 
			js_mon_year = "0"+js_mon_year;
			
		js_mon_year += "-"+y;
		for (i=0; i< document.form_bhrc.Sel_month_year.options.length; i++)
		{
			if (document.form_bhrc.Sel_month_year.options[i].value == js_mon_year)
			{
				pos = i ;
				break ;
			}
		}
		document.form_bhrc.Sel_month_year.selectedIndex = pos ;
		document.form_bhrc.Sel_month_year_bottom.selectedIndex = pos ;
		setnonights(1);
	}
	else
	{
		document.form_bhrc.Sel_Right_Day.selectedIndex = d-1;
		document.form_bhrc.Sel_Right_Day_bottom.selectedIndex = d-1;
		js_mon_year=new String(m);
		if (js_mon_year.length<2) 
			js_mon_year = "0"+js_mon_year;
			
		js_mon_year += "-"+y;
		for (i=0; i< document.form_bhrc.Sel_Right_month_year.options.length; i++)
		{
			if (document.form_bhrc.Sel_Right_month_year.options[i].value == js_mon_year)
			{
				pos = i ;
				break ;
			}
		}
		document.form_bhrc.Sel_Right_month_year.selectedIndex = pos ;
		document.form_bhrc.Sel_Right_month_year_bottom.selectedIndex = pos ;		
		setnonights(2);
	}
}

function toggleCalendar (i) {

    var currentMonth = obj1.month ;
    var currentYear = obj1.year ;
    var tyear, tmonth;
    var sfday, sfmonth, sfyear, sfrom;
    var stday, stmonth, styear, sto;
        
    sfyear = new String(js_curyear) ;
    sfmonth = new String(js_curmonth) ;
    if (sfmonth.length<2) 
		sfmonth = "0" + sfmonth ;
	sfrom = parseFloat(sfyear+sfmonth) ;

	if(obj1.bindToElement == "dtDateto")
		sto = parseFloat(new String(js_curyear+1)+sfmonth) ;
	else
	{
		var stemp = parseFloat(sfmonth)-1 ;
		if ( stemp == 0)
			sfmonth = "12"
		else
			sfmonth= new String(stemp) ;
		if (sfmonth.length<2) 
			sfmonth = "0" + sfmonth ;			

		sto = parseFloat(new String(js_curyear+1)+sfmonth) ; 
	}
	
	tyear = currentYear;
	tmonth = currentMonth;
			    
    if((currentMonth + i) == 0)
    { 
        tyear = currentYear-1 ; 
        tmonth = 12 ; 
    }
    else if((currentMonth + i) == 13)
    { 
        tyear = currentYear+1 ; 
        tmonth = 1 ; 
    }
    else
    {
        tmonth = currentMonth + i ;
    }

    styear = new String(tyear) ;
    stmonth = new String(tmonth) ;
    if (stmonth.length<2) 
		stmonth = "0" + stmonth ;

    if(parseFloat(styear+stmonth)>=sfrom && parseFloat(styear+stmonth)<=sto)
    {
		obj1.toggleCalendar(i) ;
		
		if (obj1.currentDay > obj1.totalDays[obj1.month-1])
			bgDay = obj1.totalDays[obj1.month-1];
		else
			bgDay = obj1.currentDay ;		

		//valdate format = yyyymmdd
		vald = obj1.valdate%100 ;
		valtemp = parseInt(obj1.valdate/100) ;
		valm = valtemp%100 ;
		valy = parseInt(valtemp/100) ;
	
		if(obj1.month==valm && obj1.year==valy)
		{
			if(bgDay<vald)
				bgDay = vald ;	
		}		
			
		updateDates(obj1, bgDay, obj1.month, obj1.year)
	}
}

function toggleCurrent () {

    obj1.goToCurrent() ;
}

function calClose () {
    obj1.hide() ;
}

/****************************************************************************
        END OF CLASS
*****************************************************************************/