﻿/*

To Do:
1) Add date range from and to restriction - i.e. forward only from today or from ##/##/#### to ##/##/#### only...
2) Add time option to output - i.e. ##/##/#### 12:00:00 AM/PM - maybe add default time value as well

*/ 

//var today = new Date();
//alert(today)
//today.setDate(today.getDate() + 16); 

//    var dateNowRPFC	 = today.getDate()
//    var monthNowRPFC = today.getMonth()
//    var yearNowRPFC	 = today.getYear()


    var allowbackRPFC='0';
    var length;
    var todayStringF = "Today is"
      var typeRPFC=""
    var ctlEndRPFCDateRPFC="01/01/1970"
    var formatRPFC="mm/dd/yyyy"    
    var iCalWidth = 155
    var iCalHeight = 135
    var	fixedX = -1 // x position (-1 if to appear below control)
    var	fixedY = -1 // y position (-1 if to appear below control)
    var startAt = 0 // 0 - sunday ; 1 - monday
    var showWeekNumber = 0	// 0 - don't show; 1 - show
    var showToday = 1		// 0 - don't show; 1 - show
     var imgDirRPFC = RelativePathNewRPFC()+"controls/calendar/"		// directory for images ... e.g. var imgDirRPFC="/img/"
    var bShowFullDayName = false //whether to display T or Tue on day headings
     
    //UI vars for control messages
    var gotoString = "Go To Current Month"
    var todayString = "Today is"
    
    var weekString = "Wk"
   //    var scrollLeftMessage = "Click to scroll to previous month. Hold mouse button to scroll automatically."
   //    var scrollRightMessage = "Click to scroll to next month. Hold mouse button to scroll automatically."
    var scrollLeftMessage = "Click to scroll to the previous month. Hold the mouse button to scroll automatically."
    var scrollRightMessage = "Click to scroll to the next month.  Hold the mouse button to scroll automatically."
    var selectMonthRPFCMessage = "Click to select a month."
    var selectYearRPFCMessage = "Click to select a year."
    var selectDateMessage = " " // do not replace [date], it will be replaced by date.

    //vars related to whether data was selected and what each data point selected was
    var crossobjRPFC="", crossMonthObjRPFC, crossYearObjRPFC;
    var crossYearObjRPFC;
    var monthSelectedRPFC, yearSelectedRPFC, dateSelectedRPFC, omonthSelectedRPFC, oyearSelectedRPFC, odateSelectedRPFC;
    var monthConstructedRPFC, yearConstructedRPFC, intervalID1RPFC, intervalID2RPFC, timeoutID1RPFC, timeoutID2RPFC;
    var ctlNow, dateFormat, nStartingYear;

    //form elements to place selected date(s) into
    var ctlToPlaceValueRPFC, ctlToRPFCPlaceEndDateValueRPFC;

    var bPageLoadedRPFC=false
    
    var ie=document.all //check to see browser type
    var dom=getObj

    var ns4=document.layers
    var today =	new	Date()
    var dateNowRPFC	 = today.getDate()
    var monthNowRPFC = today.getMonth()
    var yearNowRPFC	 = today.getYear()
    var imgsrcRPFC = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
    var img	= new Array()
    var Language="";

    var bShow = false;
    var objName;
    var noOfYears;

	var forwardallowRPFC= '0';
	var backallowRPFC= '0';
	
	var langTypeRPFC;
	
   	var startendtypeRPFC;
   	var DateFlageRPFC=0;
   	var dec= 0;
   	var CalendarTypeRPFC=2;// 1 for single Calendar and 2 for double
   	var dateIsSelectedRPFC= false;
  	var monthActualRPFC = '0';
  	
    var cutdateNowRPFC="";
    var cutmonthNowRPFC="";
    var cutyearNowRPFC="";
    
    var ctlStartRPFC ="";
    var ctlEndRPFC="";
  	var calPositionRPFC='0' ;
  	var ctlToRPFC ;
  	
  	var CalendarNumber;
  	
/* hides <select> and <applet> objects (for IE only) */
var dom=getObj

  function getObj(objID) 
	{
	    if (document.getElementById)
	    {
	        if (document.getElementById(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        
	        return document.getElementById(objID)
	    }
	    else if (document.all)
	    {
	        if (document.all(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        
	        return document.all[objID];
	    }
	    else if (document.layers)
	    {
	        if (document.layers(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        	    
	        return document.layers[objID];
	    }
	}
	
	function setcalPositionRPFC(pos)
	{
	calPositionRPFC =  pos;	
	return calPositionRPFC;
	}
	
  	 function RelativePathNewRPFC()
{

     var url = self.location.href;
 
    url = url.toLowerCase();
    var path = '';    
    var local = 'localhost/';   
    var live  = 'chateaugranville.com';
    
    if(url.lastIndexOf(local) > 1)
        path = "http://localhost/BestWesternChateaGranville/";  
    else if(url.lastIndexOf(live) > 1)
        path = "http://www.chateaugranville.com/";         
    
    return path;
}
	//* call in popUpCalendarUser()
// Find the element's offsetTop and offsetLeft relative to the BODY tag.
function hideElementRPFC( elmID, overDiv ){  
    if(ie){
        for( i = 0; i < document.all.tags( elmID ).length; i++ ){
            obj = document.all.tags( elmID )[i];
            if( !obj || !obj.offsetParent ){
                continue ;
            }
        objLeft   = obj.offsetLeft;
        objTop    = obj.offsetTop;
        objParent = obj.offsetParent;

        while( objParent.tagName.toUpperCase() != "BODY" ){
            objLeft  += objParent.offsetLeft;
            objTop   += objParent.offsetTop;
            objParent = objParent.offsetParent;
        }


        objHeight = obj.offsetHeight;
        objWidth = obj.offsetWidth;
        if (overDiv !=null){
            if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
            else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
            else if( overDiv.offsetTop >= ( objTop + objHeight ));
            else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
            else{
                obj.style.visibility = "hidden";	           
            }
        }
      }
    }
    
}     
 /*
    * unhides <select> and <applet> objects (for IE only)
    */
    //* call in hideCalendar()
function showElementRPFC( elmID ){
    if( ie ){
        for( i = 0; i < document.all.tags( elmID ).length; i++ ){
            obj = document.all.tags( elmID )[i];
            if( !obj || !obj.offsetParent ){
                 continue;
            }
        obj.style.visibility = "";
        }
}

}
// * get day month year and description
// * call in addHoliday ()
	function HolidayRec (d, m, y, desc){
		this.d = d
		this.m = m
		this.y = y
		this.desc = desc
	}

	var HolidaysCounter = 0
	var Holidays = new Array()
    // * add holidays get day,month,year and description
	function addHoliday (d, m, y, desc){
		Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )
	}

	//write div containing calendar and place holders for cal header and calendar contentRPFC
	if (dom)// dom=documnet.getElementId
	        {
		for	(i=0;i<imgsrcRPFC.length;i++){
			img[i] = new Image
			img[i].src= imgDirRPFC + imgsrcRPFC[i]
		}
if(CalendarTypeRPFC==2)
{
    	document.write ("<div onclick='bShow=true' id='calendarRPFC' class='div-styleRPFC'>")
    	document.write("<table width=310 cellpadding=0  cellspacing=0 class='table-styleRPFC' height=" + iCalHeight + "  >")
    	document.write("<tr class='title-background-styleRPFC'><td height=13>")
    	document.write("<table cellpadding=0   cellspacing=0 width=100%><tr><td class='title-styleRPFC' height=13 valign=top>")
    	document.write("<span id='captionRPFC'></span></td><td align=right width=15>")
    	document.write(" ")
    	document.write(" </a></td></tr></table></td>")
    	document.write("<td class=divisionlineRPFC  height=13 align=right >")
    	document.write("<table cellpadding=0  cellspacing=0  width=146><tr><td class='title-styleRPFC' height=13 valign=top>")
    	document.write("<span id='caption1RPFC'></span></td><td align=right width=15><a onclick=javascript:hideCalendarRPFC();>")     	                                                                    
    	document.write("<img src='"+imgDirRPFC+"close.gif' width='15' id='closeimg' height='13' border='0'")
    	document.write(" alt='Close the calendar'></a></td></tr></table></td>")
    	document.write("</tr><tr>")

    	
    	document.write("<td  class='body-styleRPFC' valign=top><span id='contentRPFC'></span></td><td  class='body-styleRPFC' valign=top style='border-left:solid 1px #184453;'><span id='content1RPFC'></span></td></tr>")

      }
      else
      {
        document.write ("<div onclick='bShow=true' id='calendarRPFC' class='div-styleRPFC'>")
    	document.write("<table width="+ iCalWidth + " cellpadding=1 cellspacing=0  class='table-styleRPFC' height=" + iCalHeight + ">")
    	document.write("<tr class='title-background-styleRPFC'><td height=13>")
    	document.write("<table cellpadding=0  cellspacing=0 width=100%><tr><td class='title-styleRPFC' height=13 valign=top>")
    	document.write("<span id='captionRPFC'></span></td><td align=right width=15><a href='javascript:hideCalendarRPFC()'>")
    	document.write("<img src='"+imgDirRPFC+"close.gif' width='15' id='closeimg' height='13' border='0'")
    	document.write(" alt='Close the Calendar'></a></td></tr></table></td></tr><tr><td class='body-styleRPFC'")
    	document.write(" valign=top><span id='contentRPFC'></span></td></tr>")
      }
      
      if(CalendarTypeRPFC==2)
      {
          if (showToday==1){
			document.write ("<tr class='today-styleRPFC'><td><span id='lblTodayRPFC' class='body-styleRPFC'></span></td><td class=divisionlineRPFC ><span id='lblTodayRPFC1' class='body-styleRPFC'></span></td></tr>")

		 }
      }
      else
      {
      
		if (showToday==1){
			document.write ("<tr class='today-styleRPFC'><td><span id='lblTodayRPFC' class='body-styleRPFC'></span></td></tr>")
		}
	}
		
			
		document.write ("</table></div><div id='selectMonthRPFC' class='div-styleRPFC' style=\"width:58px\">")
		document.write("</div><div id='selectYearRPFC' class='div-styleRPFC'></div>");
	}
	

    var	monthNameRPFC =	new	Array("January","February","March","April","May","June","July","August","September","October","November","December")
	var	monthNameRPFC2 = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC")
		
	if (startAt==0){
		if (bShowFullDayName == false){
			dayNameRPFC = new Array	("S","M","T","W","T","F","S")
		}
		else{
			dayNameRPFC = new Array	("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
		} 
	}
	else{	
		if (bShowFullDayName == false){
			dayNameRPFC = new Array	("M","T","W","T","F","S","S")
		}
		else{
			dayNameRPFC = new Array	("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
		}
	}

	function swapImageRPFC(srcImg, destImg){
        if (ie){

            if(backallowRPFC=='1' && srcImg=='changeLeft'  )
                {
                getObj(srcImg).setAttribute("src",imgDirRPFC + 'left2.gif')
                }
            else if(yearSelectedRPFC != yearNowRPFC && monthActualRPFC == monthNowRPFC && srcImg=='changeRight' && destImg=='right1.gif' )
                {
                    getObj(srcImg).setAttribute("src",imgDirRPFC + 'right2.gif')
                }
            else
             {
             getObj(srcImg).setAttribute("src",imgDirRPFC + destImg)
             }
       }
    }
// * set header of  calender
// * call in popUpCalendarUser()
	function initRPFC(){
   
    	if (yearNowRPFC < 200)
			   yearNowRPFC += 1900;
		if (!ns4){	  
	
		
			crossobjRPFC=(dom)?getObj("calendarRPFC").style : ie? document.all.calendar : document.calendar
			hideCalendarRPFC()
			
            crossMonthObjRPFC=(dom)?getObj("selectMonthRPFC").style : ie? document.all.selectMonthRPFC	: document.selectMonthRPFC
            crossYearObjRPFC=(dom)?getObj("selectYearRPFC").style : ie? document.all.selectYearRPFC : document.selectYearRPFC

			monthConstructedRPFC=false;
			yearConstructedRPFC=false;


			if (showToday==1){
				if (bShowFullDayName == false){
					var sToday = monthNameRPFC[parseFloat(monthNowRPFC)].substring(0,3) + " " +  dateNowRPFC +  " " + yearNowRPFC
			
				}
				else{ 
					var sToday = dayNameRPFC[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", " + dateNowRPFC + " " + monthNameRPFC[parseFloat(monthNowRPFC)].substring(0,3) + "	" +	yearNowRPFC
				}	
							
				//getObj("lblTodayRPFC").innerHTML =	todayString + " <a class='today-styleRPFC' onmousemove='window.status=\""+gotoString+"\"' onmouseout='window.status=\"\"' title='"+gotoString+"' href='javascript:monthSelectedRPFC=monthNowRPFC;yearSelectedRPFC=yearNowRPFC;constructCalendar();'>" +	sToday + "</a>"
				getObj("lblTodayRPFC").innerHTML =	todayString + " <a class='today-styleRPFC'  onmouseout='window.status=\"\"' title='"+gotoString+"' onmouseover=javascript:window.status=\"\";return true;>" +	sToday + "</a>"
				 //<a class='"+sStyleRPFC+"' style='cursor:pointer;' title=\"" + sHint + "\" onclick=javascript:flagefirstRPFC();closeCalendarRPFC();   onmouseout=window.status =\"\";return true; onmouseover=javascript:dateSelectedRPFC="+datePointerRPFC+";window.status=\"\";return true;>" + datePointerRPFC + "</a>
				if(CalendarTypeRPFC==2)
				{
				    getObj("lblTodayRPFC1").innerHTML =	todayString + " <a class='today-styleRPFC'  onmouseout='window.status=\"\"' title='"+gotoString+"' onmouseover=javascript:window.status=\"\";return true;>" +	sToday + "</a>"
				}
			}
				
	
			///*make calendar header fixed width so that header does not "flop" around			
				
		sHTMLRPFCCalHeadRPFC =" <table cellpadding=0 cellspacing=0 ><tr>"			
        sHTMLRPFCCalHeadRPFC+=" <td id='spanLeft' height=13 width=10 valign=top class='title-control-normal-styleRPFC'"
        
        sHTMLRPFCCalHeadRPFC+=" onmouseover='swapImageRPFC(\"changeLeft\",\"left2.gif\");this.className=\"title-control-select-styleRPFC\";window.status=\""
        sHTMLRPFCCalHeadRPFC+=" "+scrollLeftMessage+"\"' title=\""+scrollLeftMessage+"\" onclick='javascript:decMonthRPFC()'"
        
        sHTMLRPFCCalHeadRPFC+=" onmouseout='clearInterval(intervalID1RPFC);swapImageRPFC(\"changeLeft\",\"left1.gif\");"
        sHTMLRPFCCalHeadRPFC+=" this.className=\"title-control-normal-styleRPFC\";window.status=\"\"' "
        sHTMLRPFCCalHeadRPFC+=" onmousedown='clearTimeout(timeoutID1RPFC);timeoutID1RPFC=setTimeout(\"StartdecMonthRPFCRPFC()\",500)' "
        sHTMLRPFCCalHeadRPFC+=" onmouseup='clearTimeout(timeoutID1RPFC);clearInterval(intervalID1RPFC)'>"
        
        if(startendtypeRPFC=='startDateRPFC')
        {
            sHTMLRPFCCalHeadRPFC+=" <img id='changeLeft' src='"+imgDirRPFC+"left1.gif' width=10 height=11 border=0></td>"
        }
        else
        {
            sHTMLRPFCCalHeadRPFC+=" <img id='changeLeft' src='"+imgDirRPFC+"left2.gif' width=10 height=11 border=0></td>"
        }
        
        sHTMLRPFCCalHeadRPFC+=" <td id='spanRight' height=13 width=10 valign=top class='title-control-normal-styleRPFC'"
        sHTMLRPFCCalHeadRPFC+=" onmouseover='swapImageRPFC(\"changeRight\",\"right2.gif\");this.className=\"title-control-select-styleRPFC\";"
        sHTMLRPFCCalHeadRPFC+="window.status=\""+scrollRightMessage+"\"' title=\""+scrollRightMessage+"\" "
        sHTMLRPFCCalHeadRPFC+="onmouseout='clearInterval(intervalID1RPFC);swapImageRPFC(\"changeRight\",\"right1.gif\");"
        sHTMLRPFCCalHeadRPFC+="this.className=\"title-control-normal-styleRPFC\";window.status=\"\"' "
        sHTMLRPFCCalHeadRPFC+="onclick='incMonthRPFC()' onmousedown='clearTimeout(timeoutID1RPFC);"
        sHTMLRPFCCalHeadRPFC+="timeoutID1RPFC=setTimeout(\"StartincMonthRPFC()\",500)' onmouseup='clearTimeout(timeoutID1RPFC);"
        sHTMLRPFCCalHeadRPFC+="clearInterval(intervalID1RPFC)'><img id='changeRight' src='"+imgDirRPFC+"right1.gif'"
        sHTMLRPFCCalHeadRPFC+=" width=10 height=11 border=0></td>"
        sHTMLRPFCCalHeadRPFC+=" <td id='spanMonthRPFC' height=13 width=70 valign=top class='title-control-normal-styleRPFC'"
        sHTMLRPFCCalHeadRPFC+=" onmouseover='swapImageRPFC(\"changeMonth\",\"drop2.gif\");"
        sHTMLRPFCCalHeadRPFC+="this.className=\"title-control-select-styleRPFC\";window.status=\""+selectMonthRPFCMessage+"\"'"
        sHTMLRPFCCalHeadRPFC+=" title=\""+selectMonthRPFCMessage+"\" onmouseout='swapImageRPFC(\"changeMonth\",\"drop1.gif\");"
        sHTMLRPFCCalHeadRPFC+="this.className=\"title-control-normal-styleRPFC\";window.status=\"\"' onclick='popUpMonthRPFC()'></td>"
        sHTMLRPFCCalHeadRPFC+=" <td id='spanYearRPFC' height=13 valign=top class='title-control-normal-styleRPFC' "
        sHTMLRPFCCalHeadRPFC+="onmouseover='swapImageRPFC(\"changeYear\",\"drop2.gif\");this.className=\"title-control-select-styleRPFC\"; "
        sHTMLRPFCCalHeadRPFC+="window.status=\""+selectYearRPFCMessage+"\"' title=\""+selectYearRPFCMessage+"\" "
        sHTMLRPFCCalHeadRPFC+="onmouseout='swapImageRPFC(\"changeYear\",\"drop1.gif\");this.className=\"title-control-normal-styleRPFC\";"
        sHTMLRPFCCalHeadRPFC+="window.status=\"\"'	onclick='popUpYearRPFC()'></td>"
        sHTMLRPFCCalHeadRPFC+=" </tr></table>"
			//*/
	    getObj("captionRPFC").innerHTML  =	sHTMLRPFCCalHeadRPFC
		//**************for double calendar********
		if(CalendarTypeRPFC==2)	
		{
	    sHTMLRPFCCalHeadRPFC1 =" <table cellpadding=0 cellspacing=0><tr>"			
        sHTMLRPFCCalHeadRPFC1+=" <td "
        sHTMLRPFCCalHeadRPFC1+=" "
        sHTMLRPFCCalHeadRPFC1+=" <td id='spanRight' "
        sHTMLRPFCCalHeadRPFC1+=" ></td>"
        sHTMLRPFCCalHeadRPFC1+=" <td id='spanMonth1RPFC' height=13 width=70 valign=top class='title-control-normal-style1RPFC'"
        sHTMLRPFCCalHeadRPFC1+=" ></td>"
        sHTMLRPFCCalHeadRPFC1+=" <td id='spanYear1RPFC' height=13 valign=top class='title-control-normal-style1RPFC' "
        sHTMLRPFCCalHeadRPFC1+=" ></td>"
        sHTMLRPFCCalHeadRPFC1+=" </tr></table>"
		
		getObj("caption1RPFC").innerHTML  =	sHTMLRPFCCalHeadRPFC1
		}
		//********************************************
			bPageLoadedRPFC=true ;
		}
	}

			hideCalendarRPFC()
function hideCalendarRPFC(){
    crossobjRPFC.visibility="hidden" ;
    if (crossMonthObjRPFC != null){
         crossMonthObjRPFC.visibility="hidden";
    }
    if (crossYearObjRPFC !=	null){
         crossYearObjRPFC.visibility="hidden";
    }
    
    if(iframeObj2)iframeObj2.style.display = 'none';
    
    showElementRPFC( 'SELECT' );
    showElementRPFC( 'APPLET' );
    
}
// * call in constructDate()
function padZero(num){
	return (num	< 10)? '0' + num : num ;
}

//controls formatting of date
//* call in closeCalendarRPFC(),ChDate(),constructCalendar (), 
function constructDate(d,m,y){
   
	sTmp = dateFormat ;
	sTmp = sTmp.replace	("dd","<e>");
	sTmp = sTmp.replace	("d","<d>");
	sTmp = sTmp.replace	("<e>",padZero(d));
	sTmp = sTmp.replace	("<d>",d);	
	sTmp = sTmp.replace	("mmm","<o>");
	sTmp = sTmp.replace	("mm","<n>");
	sTmp = sTmp.replace	("m","<m>");
	sTmp = sTmp.replace	("<m>",m+1)	;	
	sTmp = sTmp.replace	("<n>",padZero(m+1));	
	sTmp = sTmp.replace	("<o>",monthNameRPFC2[m]);	
	sTmp = sTmp.replace ("yyyy",y);
	//return sTmp.replace ("yyyy",y) //original code
	return sTmp.replace ("yy",padZero(y%100));	
}

//handles setting of actual dat value in form field
// *call in constructCalendar()
function closeCalendarRPFC(){
    try{	
    var	sTmp;
    hideCalendarRPFC();
    if(CalendarTypeRPFC==2)
    {
        if(DateFlageRPFC==1)
        {
            if(monthSelectedRPFC==11){
                monthSelectedRPFC=0
                yearSelectedRPFC=yearSelectedRPFC+1
            }
            else{
             monthSelectedRPFC=monthSelectedRPFC+1
            }
        }
    }

  
  
        
        /// getObj("ctl00_cphContent_grdEvent_ctl0"+CalNoPre+"_txtMeetingEndDate").value

    ctlToPlaceValueRPFC.value =	constructDate(dateSelectedRPFC,monthSelectedRPFC,yearSelectedRPFC)
   
   
    if(getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumber+"_txtMeetingStartDate")!=null)
    {
         var CalendarNumberNew = parseFloat(CalendarNumber)+1;
         if(CalendarNumberNew<10)
          CalendarNumberNew="0"+CalendarNumberNew;
            if(getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate")!=null && getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate").value!="") 
            {
            
            
                    var initDateArray = getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumber+"_txtMeetingEndDate").value.split("/");                  
                    var endDateArray = getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate").value.split("/"); // assuming strEnd is the end date
                  
                    var endIsBigger = false;

                    if (endDateArray[2] > initDateArray[2]) { // If the end year is greater than the initial year
                    endIsBigger = true;
                    } else if ((endDateArray[2] == initDateArray[2]) && (endDateArray[1] > initDateArray[1])) { // If the end month is greater than the initial month and the year is the same
                    endIsBigger = true;
                    } else if ((endDateArray[2] == initDateArray[2]) && (endDateArray[1] == initDateArray[1]) && (endDateArray[0] > initDateArray[0])) { // If the end day of month is greater than the initial day of month and the month and year are the same
                    endIsBigger = true;
                    }
                   
                    if(endIsBigger==false)
                    {
                      // code for +1 date for next calendar 

                                var d = new Date(getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumber+"_txtMeetingEndDate").value);
                               
                                d.setDate(d.getDate()+1);
                               
                                var newDate =d.getMonth()+1+"/"+d.getDate()+"/"+d.getFullYear();
                                var dateString=newDate;    	    
                                var dateString_array=dateString.split("/");
                                var newDateMoLength=dateString_array[0].length;
                                var newDateDaLength=dateString_array[1].length;
                                var newDateYeLength=dateString_array[2].length;
                                var newDateD=d.getDate();
                                if(newDateDaLength==1)
                                {
                                newDateD= "0"+newDateD;
                                }
                                var newDateM=d.getMonth();
                                newDateM=parseFloat(newDateM)+1;
                                if(newDateMoLength==1)
                                {
                                newDateM= "0"+newDateM;
                                }
                                var newDateY=d.getFullYear();
                                var newDateD =newDateM+"/"+newDateD+"/"+newDateY;
                          
                                getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingStartDate").value=newDateD;
                                getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate").value=newDateD;
                                
                          
                               
                                var hdnCountval = getObj("hdnCount").value;
                                CalendarNumberNext = parseFloat(CalendarNumberNew);
                                if(CalendarNumberNext<10)
                                  CalendarNumberNext="0"+CalendarNumberNext;
                                for( p=parseFloat(CalendarNumberNext);p<=hdnCountval;p++)
                                {                              
                                     
                                          CalendarNumberNext = parseFloat(CalendarNumberNew) +1;
                                          if(CalendarNumberNext<10)
                                          CalendarNumberNext="0"+CalendarNumberNext;
                                
                                        var initDateArray = getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate").value.split("/");                                    
                                        var endDateArray = getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNext+"_txtMeetingEndDate").value.split("/"); // assuming strEnd is the end date
                                       
                                        
                                        var endIsBigger = false;

                                        if (endDateArray[2] > initDateArray[2]) { // If the end year is greater than the initial year
                                        endIsBigger = true;
                                        } else if ((endDateArray[2] == initDateArray[2]) && (endDateArray[1] > initDateArray[1])) { // If the end month is greater than the initial month and the year is the same
                                        endIsBigger = true;
                                        } else if ((endDateArray[2] == initDateArray[2]) && (endDateArray[1] == initDateArray[1]) && (endDateArray[0] > initDateArray[0])) { // If the end day of month is greater than the initial day of month and the month and year are the same
                                        endIsBigger = true;
                                        }
                                      
                                        if(endIsBigger==false)
                                        {
                                        
                                                var d = new Date(getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNew+"_txtMeetingEndDate").value);
                                               // alert(d)
                                                d.setDate(d.getDate()+1);
                                               // alert(d)
                                                var newDate =d.getMonth()+1+"/"+d.getDate()+"/"+d.getFullYear();
                                                var dateString=newDate;    	    
                                                var dateString_array=dateString.split("/");
                                                var newDateMoLength=dateString_array[0].length;
                                                var newDateDaLength=dateString_array[1].length;
                                                var newDateYeLength=dateString_array[2].length;
                                                var newDateD=d.getDate();
                                                if(newDateDaLength==1)
                                                {
                                                newDateD= "0"+newDateD;
                                                }
                                                var newDateM=d.getMonth();
                                                newDateM=parseFloat(newDateM)+1;
                                                if(newDateMoLength==1)
                                                {
                                                newDateM= "0"+newDateM;
                                                }
                                                var newDateY=d.getFullYear();
                                                var newDateD =newDateM+"/"+newDateD+"/"+newDateY;
                                                //alert(CalendarNumberNew)
                                                getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNext+"_txtMeetingStartDate").value=newDateD;
                                                getObj("ctl00_cphContent_grdEvent_ctl"+CalendarNumberNext+"_txtMeetingEndDate").value=newDateD;
                                         
                                        }
                                     
                                         CalendarNumberNew++;
                                         if(CalendarNumberNew<10)
                                           CalendarNumberNew="0"+CalendarNumberNew;
                                         
                                        //CalendarNumberNext++;
                                }
                              
                        
                    }
                        
            
            
            
             // alert(getObj("ctl00_cphContent_grdEvent_ctl0"+CalendarNumberNew+"_txtMeetingEndDate").value);
            }
    
    
    }
//Naresh
    //alert(ctlToRPFCPlaceValueRPFC.value)
    
    
    ////////////////////////////////////////////////////////////////////////
       if(startendtypeRPFC=="startdate")
           {
              
             if( getObj(ctlToRPFC).value!="")
             {
              dtStartDate = new Date(ctlToPlaceValueRPFC.value); 
              dtEndDate = new Date(getObj(ctlToRPFC).value); 
              if (dtEndDate.getTime() < dtStartDate.getTime())
              {
             getObj(ctlToRPFC).value = ctlToPlaceValueRPFC.value;
              }
             }
             else
             {
              getObj(ctlToRPFC).value = ctlToPlaceValueRPFC.value;
             }
          }
          else
          {
              cutdateNowRPFC=dateSelectedRPFC;
              cutmonthNowRPFC=monthSelectedRPFC;
              cutyearNowRPFC=yearSelectedRPFC;          
          }
    
    ////////////////////////////////
    
    }
    catch(er){
         alert(er);
    }  		
}


function setCheckInValueRPFC(controlValue)
{
    var chin=controlValue;
    var chin_array=chin.split("/")
    var Imlength=chin_array[0].length;
    var Idlength=chin_array[1].length;
    var Iylength=chin_array[2].length;
    
    var monthSubStr=chin_array[0];
    
    if(valueFormat=="0")
    {
        monthSubStr=chin_array[0].substring(0,1);
        if(monthSubStr=="0")
        {
            monthSubStr=chin_array[0].substring(1,2);
        }
        else
        {
            monthSubStr=chin_array[0]
        }
         monthSubStr--;
       
         if(monthSubStr<10)
            monthSubStr="0"+monthSubStr;
    }
        
        var monthyear = chin_array[2]+ monthSubStr;
        var dayValue=chin_array[1];
        if(dayValue.substring(0,1)=="0")
            dayValue=dayValue.substring(1,2);
       
        getObj("arrivalMonthYear").value=monthyear;
        fillArrivalDate();
        getObj("arrivalDay").value=dayValue;
        fillDepartureMonth();	
	    fillDepartureDate();
	    fillTextBox();
        
}

function setCheckOutValueRPFC(controlValue)
{
    var chin=controlValue;
    var chin_array=chin.split("/")
    var Imlength=chin_array[0].length;
    var Idlength=chin_array[1].length;
    var Iylength=chin_array[2].length;
    
    var monthSubStr=chin_array[0];
    if(valueFormat=="0")
    {
        monthSubStr=chin_array[0].substring(0,1);
        if(monthSubStr=="0")
        {
            monthSubStr=chin_array[0].substring(1,2);
        }
        else
        {
            monthSubStr=chin_array[0]
        }
         monthSubStr--;
       
         if(monthSubStr<10)
            monthSubStr="0"+monthSubStr;
    }
        
        var monthyear = chin_array[2]+ monthSubStr;
        
        var dayValue=chin_array[1];
        if(dayValue.substring(0,1)=="0")
            dayValue=dayValue.substring(1,2);
            
        getObj("departureMonthYear").value=monthyear;
        fillDepartureDate();
        getObj("departureDay").value=dayValue;
        fillTextBox();
}


	
	/*** Start actual calendar code which builds string of calendar contentRPFC***/
     // * get the date and return number of week
     // * call in constructCalender()
function WeekNbr(today){
	
    Year = takeYear(today);
    Month = today.getMonth();
    Day = today.getDate();
    now = Date.UTC(Year,Month,Day+1,0,0,0);
    var Firstday = new Date();
    Firstday.setYear(Year);
    Firstday.setMonth(0);
    Firstday.setDate(1);
    then = Date.UTC(Year,0,1,0,0,0);
    var Compensation = Firstday.getDay();
    if (Compensation > 3) Compensation -= 4;
    else Compensation += 3;
    NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
    return NumberOfWeek;
}
//* return year
   //* call in weekNbr
function takeYear(theDate){
    x = theDate.getFullYear();
    var y = x % 100;
    y += (y < 38) ? 2000 : 1900;
    return y;
}

	//builds string containing HTML table that is calender


//* 
//* call in closeCalendarRPFC()
function setExpDate(iID){
    if(iID.substring(iID.length - 3,iID.length) == "Enr"){
	    var ArrayOfDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	    tb = iID.substring(0,iID.length - 3) + "Exp"
	    obj = getObj(iID)
	    dt =obj.value;
	    mm = dt.substring(0,2)
	    dd = dt.substring(3,5)
	    yy = parseInt(dt.substring(6,10))
	    yy = yy + parseInt(noOfYears)
	    obj = getObj(tb);
	    obj.value= mm + "/" + dd + "/" + yy
     }	
}
	
function getDays(GivenYear){
	if((GivenYear % 4 == 0 && GivenYear % 100 !=0 ) || (GivenYear % 100 == 0 && GivenYear % 400 ==0 ))
		return 29;
	else
	  return 28;
}	

function OpenNewWin(url){
	if(url.length > 3){
		if(url.substring(0,4) == "http")
		newWin = window.open(url);
    	else{
			newWin = window.open("http://" + url);
		 }
	 }
	else{
	  newWin = window.open(url);
    }
 }
		
function popUpCalendarAdmin(ctl,ctl2,startend,ctlFrom,Pos,CalNo)
{
 if(CalNo<10)
 {
 CalNo= "0"+CalNo;
 }
CalendarNumber=CalNo;
    if(CalNo!=2)
    {
        CalNoPre= parseFloat(CalNo)-1;
        if(CalNoPre<10)
        CalNoPre="0"+CalNoPre; 
        if(getObj("ctl00_cphContent_grdEvent_ctl"+CalNoPre+"_txtMeetingEndDate").value=="")
        {
        return false;
        }

        var d = new Date(getObj("ctl00_cphContent_grdEvent_ctl"+CalNoPre+"_txtMeetingEndDate").value);
        d.setDate(d.getDate()+1);

        var newDate =d.getMonth()+1+"/"+d.getDate()+"/"+d.getFullYear();

        var dateString=newDate;    	    
        var dateString_array=dateString.split("/");

        var newDateMoLength=dateString_array[0].length;
        var newDateDaLength=dateString_array[1].length;
        var newDateYeLength=dateString_array[2].length;
                
        var newDateD=d.getDate();
        if(newDateDaLength==1)
        {
        newDateD= "0"+newDateD;
        }
         
        var newDateM=d.getMonth();
        newDateM=parseFloat(newDateM)+1;
            if(newDateMoLength==1)
             {
             newDateM= "0"+newDateM;
             }
        var newDateY=d.getFullYear();
        var newDateD =newDateM+"/"+newDateD+"/"+newDateY;
        getObj("ctl00_cphContent_grdEvent_ctl"+CalNo+"_txtMeetingStartDate").value=newDateD;
    }


 

    ctlStartRPFC =ctl2;    
//    if(ctlFrom !=null)
//     {
//       ctlEndRPFC=ctlFrom;
//     }

     allowbackRPFC!='0';  
    startendtypeRPFC=startend; 
    
    if(startendtypeRPFC=="startdate")
    { 
     ctlToRPFC=ctlFrom;
    }
    else
    { 
      
        if(ctlFrom !=null)
        {
            ctlEndRPFC=ctlFrom;
        }
        if(ctlFrom!=undefined)
        {
            if(getObj(ctlFrom).value==""){
            // alert('Please select Start Date');
            return false;
        }
        }
    }
    
     

 
    

   imgDirRPFC =RelativePathNewRPFC()+"controls/calendar/"
     getObj("closeimg").src=imgDirRPFC+"close.gif"
     var	leftpos=0
     var	toppos=0
    

  initRPFC();
     
    if(bPageLoadedRPFC)
    {
    if ( crossobjRPFC.visibility ==	"hidden" )
    {
	    ctlToPlaceValueRPFC	= getObj(ctl2)
	    dateFormat=formatRPFC;
        formatChar = " ";
		aFormat	= dateFormat.split(formatChar);
		
		if (aFormat.length<3)
		{
		   formatChar = "/";
		   aFormat	= dateFormat.split(formatChar);
		   
		   if (aFormat.length<3)
		   {
             formatChar = ".";
			 aFormat	= dateFormat.split(formatChar);
			 if (aFormat.length<3)
			 {
			    formatChar = "-";
				aFormat	= dateFormat.split(formatChar);
			    if (aFormat.length<3)
			    {
				   formatChar="";
				}
			 }
		   }
	 }

	tokensChanged =	0;
	if ( formatChar	!= "" ){
		// use user's date
		aData =	getObj(ctl2).value.split(formatChar);
		
        for	(i=0;i<3;i++){
		  if ((aFormat[i]=="d") || (aFormat[i]=="dd")){
					dateSelectedRPFC = parseInt(aData[i], 10);
					tokensChanged ++;
		  }
		  else if	((aFormat[i]=="m") || (aFormat[i]=="mm")){
				monthSelectedRPFC =	parseInt(aData[i], 10) - 1;
				tokensChanged ++;
			}
		  else if	(aFormat[i]=="yyyy"){
				yearSelectedRPFC = parseInt(aData[i], 10);
				tokensChanged ++;
			}
		  else if	(aFormat[i]=="mmm"){
			  for	(j=0; j<12;	j++){
				if (aData[i]==monthNameRPFC[j]){
					monthSelectedRPFC=j;
					tokensChanged ++;
				 }
			   }
		}
	}
  }
  

  
    if ((tokensChanged!=3)||isNaN(dateSelectedRPFC)||isNaN(monthSelectedRPFC)||isNaN(yearSelectedRPFC)) {
			
			dateSelectedRPFC = dateNowRPFC;
			monthSelectedRPFC =	monthNowRPFC;
			yearSelectedRPFC = yearNowRPFC;
    }
            odateSelectedRPFC=dateSelectedRPFC;
			omonthSelectedRPFC=monthSelectedRPFC;
			oyearSelectedRPFC=yearSelectedRPFC;

		aTag = ctl
	   var browserName = ""; 
             var ua = navigator.userAgent.toLowerCase(); 
            if ( ua.indexOf( "opera" ) != -1 )
            { 
                browserName = "opera"; 
            } 
            else if ( ua.indexOf( "msie" ) != -1 )
            { 
             
                browserName = "msie"; 
            }
            else if ( ua.indexOf( "safari" ) != -1 )
            { 
                browserName = "safari"; 
            }
            else if ( ua.indexOf( "mozilla" ) != -1 )
            { 
                if ( ua.indexOf( "firefox" ) != -1 )
                { 
                    browserName = "firefox"; 
                }
                else
                { 
                    browserName = "mozilla"; 
                } 
            } 
                 
             
        if(browserName == "msie")
	     {
		    do 
		    {
               	      
			    aTag = aTag.offsetParent;
			   try
			    {
			        leftpos	+= aTag.offsetLeft;
			        toppos += aTag.offsetTop;  //alert(aTag.tagName);
			    }catch(er){}
		    } 
		    
		    while(aTag!=null && aTag.tagName!="HTML");
		 } 
		 else 
		 {
		    do {
		        	 
			    aTag = aTag.offsetParent;
			    leftpos	+= aTag.offsetLeft;
			    toppos += aTag.offsetTop;  //alert(aTag.tagName);
		    } while(aTag.tagName!="BODY");
		 }
	
		 if(Pos=='res')
                {
                    var oPosLeft = (fixedX==-1 ? ctl.offsetLeft	+ leftpos-120 :	fixedX) + "px";
                    var oPosTop = (fixedY==-1 ?	ctl.offsetTop +	toppos + ctl.offsetHeight +	2 :	fixedY) + "px";
                }
              else  if(Pos=='rpf')
                {
                    var oPosLeft = (fixedX==-1 ? ctl.offsetLeft	+ leftpos :	fixedX) + "px";
                    var oPosTop = (fixedY==-1 ?	ctl.offsetTop +	toppos + ctl.offsetHeight +	2 :	fixedY) + "px";
                }
                else
                {
                    var oPosLeft = (fixedX==-1 ? ctl.offsetLeft	+ leftpos :	fixedX) + "px";
                    var oPosTop = (fixedY==-1 ?	ctl.offsetTop +	toppos + ctl.offsetHeight +	2 :	fixedY) + "px";
                }
       
            
		
		  
		 if(calPositionRPFC==1)
		  {
		  
		  crossobjRPFC.left =	426;
		  crossobjRPFC.top = oPosTop;
		  }
		  else if(calPositionRPFC==2)
		  {
		  crossobjRPFC.left =	600;
		  crossobjRPFC.top = oPosTop;
		  }
		  else
		  {
             
                    crossobjRPFC.left =	oPosLeft;
                    crossobjRPFC.top = oPosTop;
               
		  }
		  
		   if(startendtypeRPFC=="startdate")
           {
//              
//             if( getObj(ctlToRPFC).value!="")
//             {
//             alert( getObj(ctlToRPFC).value)
//             
//             }
//             else
//             {          
               cutdateNowRPFC=dateNowRPFC;
               cutyearNowRPFC=yearNowRPFC;
               cutmonthNowRPFC=monthNowRPFC;
             //}
           }   

           if(startendtypeRPFC!="startdate")
           {     
        
             cutmonthNowRPFC = getObj(ctlEndRPFC).value.substring(0,2);
              cutdateNowRPFC = getObj(ctlEndRPFC).value.substring(3,5);
              cutyearNowRPFC = getObj(ctlEndRPFC).value.substring(6,10);
           
//              cutmonthNowRPFC = getObj("ctl00_cphContent_txtFrom").value.substring(0,2);
//              cutdateNowRPFC = getObj("ctl00_cphContent_txtFrom").value.substring(3,5);
//              cutyearNowRPFC = getObj("ctl00_cphContent_txtFrom").value.substring(6,10);
              monthSelectedRPFC = parseFloat(cutmonthNowRPFC)-1;
              yearSelectedRPFC=cutyearNowRPFC;
            }
         
   		  constructCalendarRPFC ();	
   		  
	      crossobjRPFC.visibility=(dom||ie)? "visible" : "show"
		  bShow = true;
			
		}
	}
	else{
		
		initRPFC();
	}
}	
//handles click on Enter Key to hide calendar
document.onkeypress = function hidecal1 () { 
	if (event.keyCode==27) 
	 {
		hideCalendar();
	 }
}
 //handles click on of document to hide calendar
document.onclick = function hidecal2 () { 		
	if (!bShow)
	 {
		hideCalendar();
	 }
	bShow = false
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
/*** Start Month Pulldown ***/
//* set the interval of given method
function StartdecMonthRPFCRPFC(){
	intervalID1RPFC=setInterval("decMonthRPFC()",80);
}
   //* set the interval of given method
function StartincMonthRPFC(){
	intervalID1RPFC=setInterval("incMonthRPFC()",80);
}
  // * if selected month is  last month of year then next month will be first month of next year
  //* call in init()
function incMonthRPFC ()
{

 if ( type== 1 ){
  	   if(forwardallowRPFC == '1'){
  	  
         return  ;
	    }
        monthSelectedRPFC++
       
	    if (monthSelectedRPFC>11){
	        monthSelectedRPFC=0
		    yearSelectedRPFC++
	     } 
	     
     constructCalendarUser()
     
    }
	else {
	
	  
	  monthSelectedRPFC++
	    allowbackRPFC='1';
	    if (monthSelectedRPFC > 11)
	    {
	        monthSelectedRPFC=0		    
		    yearSelectedRPFC=parseFloat(yearSelectedRPFC)+1;
		    cutyearNowRPFC=yearSelectedRPFC;
	    }
	  cutmonthNowRPFC = monthSelectedRPFC;
	  constructCalendarRPFC()	
	  
	}

	  
}


// * if selected month is first month of year then month of last year is last month
// * call in init()
function decMonthRPFC ()
{

    if(typeRPFC == 1){
    
   
        if(backallowRPFC == '1'){
            return  ;
        }
        
        swapImageRPFC('changeLeft','left2.gif');
        swapImageRPFC('changeRight','right1.gif');
        
        monthSelectedRPFC--
        if (monthSelectedRPFC<0) {
            monthSelectedRPFC=11
            yearSelectedRPFC--
        }
                
        constructCalendarUser()
        
    }
    else{
    
    
         if(startendtypeRPFC!="startdate")
         { 
           if(getObj(ctlEndRPFC)!=null)
           {   
                var txtFromMonth = getObj(ctlEndRPFC).value.substring(0,2);
                var txttoMonth = getObj(ctlStartRPFC).value.substring(0,2);    
                var txtFromYear = getObj(ctlEndRPFC).value.substring(6,10);
                var txttoYear = getObj(ctlStartRPFC).value.substring(6,10);
            }
            else
            {
              if(backallowRPFC == '1'){
                    return  ;
              }
            }
         }
         
                  if(backallowRPFC == '1' && parseInt(txtFromMonth) == parseInt(monthSelectedRPFC)+ parseInt(1) && parseInt(txtFromYear)== parseInt(yearSelectedRPFC) )
             {    
             
                 return  ;
             }  
             
              monthSelectedRPFC--
           allowbackRPFC='1';
           if (monthSelectedRPFC<0)
             {
               monthSelectedRPFC=11
               yearSelectedRPFC--
               cutyearNowRPFC=yearSelectedRPFC;
             }
             cutmonthNowRPFC = monthSelectedRPFC; 
                
                if((parseInt(txtFromMonth)-1) == monthSelectedRPFC)
                {
                    cutmonthNowRPFC++;
                }
            constructCalendarRPFC()
    
    }













//    var txtFromMonth = getObj("ctl00_cphContent_txtFrom").value.substring(0,2);
//    var txttoMonth = getObj("ctl00_cphContent_txtTo").value.substring(0,2);
//    
//    var txtFromYear = getObj("ctl00_cphContent_txtFrom").value.substring(6,10);
//    var txttoYear = getObj("ctl00_cphContent_txtTo").value.substring(6,10);

    //Allow back untill month of dateto doesnot reaches till datefrom 
     
//   if(parseInt(txtFromMonth) == parseInt(monthSelectedRPFC)+ parseInt(1) &&  startendtypeRPFC!='startdate')
//     {
//     
//        return ;
//     }
  
   
}


// * call in popUpMonthRPFC() 
function constructMonthRPFC() 
{
    popDownYearRPFC()
 
if(Language=="French")
{   
        var	monthNameRPFC =	new	Array("janvier","f"+String.fromCharCode(233)+"vrierss","mars","avril","mai","juin","juillet","ao"+String.fromCharCode(251)+"t","septembre","octobre","novembre","d"+String.fromCharCode(233)+"cembre")
}
else
{
        var	monthNameRPFC =	new	Array("January","February","March","April","May","June","July","August","September","October","November","December")
}
    if( typeRPFC== 1 ){ 
    
    
         //        cutdateNowRPFC=dateNowRPFC;
//       cutyearNowRPFC=yearNowRPFC;
//       cutmonthNowRPFC=monthNowRPFC;

//alert(yearSelectedRPFC +" a "+ yearNowRPFC)
            sHTMLRPFC =	""
            if(yearSelectedRPFC == yearNowRPFC ){
             for	(i=cutmonthNowRPFC; i<12;	i++){
                sName =	monthNameRPFC[i];
                if(i >= monthSelectedRPFC){
                    if(i == monthSelectedRPFC){
                      sName =	"<B>" +	sName +	"</B>"
                    }

                }
              sHTMLRPFC += "<tr><td id='m" + i + "' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='this.className=\"dropdown-normal-styleRPFC\"' onclick='monthConstructedRPFC=false;monthSelectedRPFC=" + i + ";constructCalendarUser();popDownMonthRPFC();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"

            }
          getObj("selectMonthRPFC").innerHTML = "<table class='dropdown-styleRPFC' cellspacing=0 cellpadding=1 onmouseover='clearTimeout(timeoutID1RPFC)' onmouseout='clearTimeout(timeoutID1RPFC);timeoutID1RPFC=setTimeout(\"\",100);event.cancelBubble=true'>" + sHTMLRPFC + "</table>"

          monthConstructedRPFC=true
        }

        else if(yearSelectedRPFC > yearNowRPFC){
       
            var startMonth=0;
            if(yearSelectedRPFC==cutyearNowRPFC)
                startMonth=parseInt(cutmonthNowRPFC);
          for(i=startMonth; i <= monthNowRPFC;	i++){
             sName =	monthNameRPFC[i];
             if(i == monthSelectedRPFC){
                 sName =	"<B>" +	sName +	"</B>"
             }
            sHTMLRPFC += "<tr><td id='m" + i + "' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='this.className=\"dropdown-normal-styleRPFC\"' onclick='monthConstructedRPFC=false;monthSelectedRPFC=" + i + ";constructCalendarUser();popDownMonthRPFC();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
          }
       getObj("selectMonthRPFC").innerHTML = "<table class='dropdown-styleRPFC' cellspacing=0 cellpadding=1 onmouseover='clearTimeout(timeoutID1RPFC)' onmouseout='clearTimeout(timeoutID1RPFC);timeoutID1RPFC=setTimeout(\"popDownMonthRPFC()\",100);event.cancelBubble=true'>" + sHTMLRPFC + "</table>"
       monthConstructedRPFC=true
    }	
 // }
}	
    else{
        if (!monthConstructedRPFC){
          sHTMLRPFC =	""
          for(i=0; i<12;	i++){
            sName =	monthNameRPFC[i];
            if (i==monthSelectedRPFC){
                sName =	"<B>" +	sName +	"</B>"
            }
            sHTMLRPFC += "<tr><td id='m" + i + "' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='this.className=\"dropdown-normal-styleRPFC\"' onclick='monthConstructedRPFC=false;monthSelectedRPFC=" + i + ";constructCalendarRPFC();popDownMonthRPFC();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
        }
       getObj("selectMonthRPFC").innerHTML = "<table class='dropdown-styleRPFC' cellspacing=0 cellpadding=1 onmouseover='clearTimeout(timeoutID1RPFC)' onmouseout='clearTimeout(timeoutID1RPFC);timeoutID1RPFC=setTimeout(\"popDownMonthRPFC()\",100);event.cancelBubble=true'>" + sHTMLRPFC + "</table>"
       monthConstructedRPFC=true
   }
 }

 
}
// * asign the left & top lenth of popmonth
// * call in init()
function popUpMonthRPFC()
 {
    constructMonthRPFC()
    crossMonthObjRPFC.visibility = (dom||ie)? "visible"	: "show";    
    crossMonthObjRPFC.left = (parseInt(crossobjRPFC.left) + 20) + "px";
    crossMonthObjRPFC.top =	(parseInt(crossobjRPFC.top) + 16) + "px";    
 }

function popDownMonthRPFC(){
crossMonthObjRPFC.visibility= "hidden"
}

/*** END Month Pulldown ***/
/*** Start Year Pulldown ***/
// * increase the year in popdown year in calender
function incYearRPFC()
{  

  if(typeRPFC == 1){
        return; 
    }   
    for	(i=0; i<7; i++){
        newYear	= (i+nStartingYear)+1
        if (newYear==yearSelectedRPFC){ 
            txtYear =	"&nbsp;<B>"	+ newYear +	"</B>&nbsp;"
        }
        else{
            txtYear =	"&nbsp;" + newYear + "&nbsp;" 
        }
        getObj("y"+i).innerHTML = txtYear
    }
    nStartingYear ++;
    bShow=true



 
//    for	(i=0; i<7; i++)
//    {
//         newYear	= (i+parseInt(nStartingYear))+1
//       
//        if (newYear==yearSelectedRPFC){ 
//            txtYear =	"&nbsp;<B>"	+ newYear +	"</B>&nbsp;"
//        }
//        else
//        {
//          
//            txtYear =	"&nbsp;" + newYear + "&nbsp;" 
//        }
//        getObj("y"+i).innerHTML = txtYear
//    }
//   
//    nStartingYear ++;
//    bShow=true
}
  //* decrease the year in popdown year in calender
     
function decYearRPFC()
{   
            if(nStartingYear == cutyearNowRPFC)
                {

                }
             else
                 {
                
                    for	(i=0; i<7; i++)
                        {
                            newYear	= (i+parseInt(nStartingYear))-1 
                            if (newYear==cutyearNowRPFC)
                                { 
                                    txtYear = "&nbsp;<B>"	+ newYear +	"</B>&nbsp;" 
                                }
                            else
                                { 
                                   txtYear = "&nbsp;" + newYear + "&nbsp;" 
                                }   
                            getObj("y"+i).innerHTML = txtYear  
                        }     

                     nStartingYear --;   
                 }      
//     }
    
    bShow=true
}
// * select the given year 


function constructYearRPFC()
 {
       if( typeRPFC== 1 ){

        popDownMonthRPFC()
        sHTMLRPFC =	""
       if (!yearConstructedRPFC){ 
            if ( typeRPFC== 1 ){
            sHTMLRPFC =	"<tr><td align='center' onmouseover='this.className=\"dropdown-select-styleRPFC\"' >	</td></tr>"
            //sHTMLRPFC =	"<tr><td align='center'	onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(intervalID1RPFC);this.className=\"dropdown-normal-style\"' onmousedown='clearInterval(intervalID1RPFC);intervalID1RPFC=setInterval(\"decYearRPFC()\",30)' onmouseup='clearInterval(intervalID1RPFC)'></td></tr>"
            }
            else {
            sHTMLRPFC =	"<tr><td align='center'	onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(intervalID1RPFC);this.className=\"dropdown-normal-styleRPFC\"' onmousedown='clearInterval(intervalID1RPFC);intervalID1RPFC=setInterval(\"decYearRPFC()\",30)' onmouseup='clearInterval(intervalID1RPFC)'>-</td></tr>"
            }
           j =	0
           //nStartingYear =	yearSelectedRPFC-3 
           nStartingYear = parseInt(cutyearNowRPFC);//yearNowRPFC
           //alert(parseInt(cutyearNowRPFC)+" a "+yearNowRPFC)
           
           if(parseInt(cutyearNowRPFC)>yearNowRPFC)
                nEndingYear =parseInt(cutyearNowRPFC);
           else
                nEndingYear =parseInt(cutyearNowRPFC)+1;
                
           //for	(i=(nStartingYear); i<=(yearSelectedRPFC+3); i++) 
           for(i=(nStartingYear); i<=(nEndingYear); i++){
               sName =	i;
               if (i==yearSelectedRPFC){
	               sName =	"<B>" +	sName +	"</B>"
               }
              sHTMLRPFC += "<tr><td id='y" + j + "' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='this.className=\"dropdown-normal-styleRPFC\"' onclick='selectYearRPFC("+j+");event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
              j ++;
           }
        if (type == 1){
        sHTMLRPFC += "<tr><td align='center'> </td></tr>"
        }
        else{
        sHTMLRPFC += "<tr><td align='center' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='clearInterval(intervalID2RPFC);this.className=\"dropdown-normal-styleRPFC\"' onmousedown='clearInterval(intervalID2RPFC);intervalID2RPFC=setInterval(\"incYearRPFC()\",30)'	onmouseup='clearInterval(intervalID2RPFC)'>+</td></tr>"
        }
        getObj("selectYearRPFC").innerHTML	= "<table width=44 class='dropdown-styleRPFC' onmouseover='clearTimeout(timeoutID2RPFC)' onmouseout='clearTimeout(timeoutID2RPFC);timeoutID2RPFC=setTimeout(\"popDownYearRPFC()\",100)' cellspacing=0>"	+ sHTMLRPFC	+ "</table>"
       yearConstructedRPFC	= true
       }
    }
    else {    
 
        popDownMonthRPFC()
        sHTMLRPFC =	""
            if (!yearConstructedRPFC){ 
            sHTMLRPFC =	"<tr><td align='center'	onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='clearInterval(intervalID1RPFC);this.className=\"dropdown-normal-styleRPFC\"' onmousedown='clearInterval(intervalID1RPFC);intervalID1RPFC=setInterval(\"decYearRPFC()\",30)' onmouseup='clearInterval(intervalID1RPFC)'>-</td></tr>"
            j =	0
            nStartingYear = parseFloat(yearSelectedRPFC)
           
                for	(i=nStartingYear; i<=( parseFloat(yearSelectedRPFC)+9); i++){
                sName =	i;
                    if (i==yearSelectedRPFC){
                        sName =	"<B>" +	sName +	"</B>"
                    }
                sHTMLRPFC += "<tr><td id='y" + j + "' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='this.className=\"dropdown-normal-styleRPFC\"' onclick='selectYearRPFC("+j+");event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>"
                j ++;
                }
            sHTMLRPFC += "<tr><td align='center' onmouseover='this.className=\"dropdown-select-styleRPFC\"' onmouseout='clearInterval(intervalID2RPFC);this.className=\"dropdown-normal-styleRPFC\"' onmousedown='clearInterval(intervalID2RPFC);intervalID2RPFC=setInterval(\"incYearRPFC()\",30)'	onmouseup='clearInterval(intervalID2RPFC)'>+</td></tr>"

            getObj("selectYearRPFC").innerHTML	= "<table width=44 class='dropdown-styleRPFC' onmouseover='clearTimeout(timeoutID2RPFC)' onmouseout='clearTimeout(timeoutID2RPFC);timeoutID2RPFC=setTimeout(\"popDownYearRPFC()\",100)' cellspacing=0>"	+ sHTMLRPFC	+ "</table>"
            yearConstructedRPFC	= true
            }
    }
}
// call in constructYear()
    function selectYearRPFC(nYear)
    {
    
     allowbackRPFC='1';
         if ( type== 1 ){
        
            yearSelectedRPFC=parseInt(nYear+nStartingYear);
            yearConstructedRPFC=false;
            constructCalendarUser();
            popDownYearRPFC();
         
         }
         else
         {
        
                if(startendtypeRPFC=='startdate')
                {        
                    yearSelectedRPFC=parseInt(nYear+nStartingYear);
                }
                else
                {           
                    yearSelectedRPFC=parseInt(nYear+parseInt(nStartingYear));
                }
                yearConstructedRPFC=false;
                constructCalendarRPFC();
                popDownYearRPFC();
        }
    
//        allowbackRPFC='1';
//        
//        if(startendtypeRPFC=='startdate')
//        {        
//            yearSelectedRPFC=parseInt(nYear+nStartingYear);
//        }
//        else
//        {           
//            yearSelectedRPFC=parseInt(nYear+parseInt(nStartingYear));
//        }
//        yearConstructedRPFC=false;
//        constructCalendar();
//        popDownYearRPFC();
    }


//* clear the interval time 
function popDownYearRPFC() {
	clearInterval(intervalID1RPFC)
	clearTimeout(timeoutID1RPFC)
	clearInterval(intervalID2RPFC)
	clearTimeout(timeoutID2RPFC)
	crossYearObjRPFC.visibility= "hidden"
}
// * call in init()
function popUpYearRPFC() {
    var	leftOffset;
    constructYearRPFC();

    crossYearObjRPFC.visibility=(dom||ie)?"visible" : "show";
    leftOffset = parseInt(crossobjRPFC.left) + getObj("spanYearRPFC").offsetLeft;
      
    leftOffset += 6
    crossYearObjRPFC.left =	leftOffset +"px";
    crossYearObjRPFC.top = (parseInt(crossobjRPFC.top) +	16) + "px";
}

	/*** END Year Pulldown ***/

///////////////////////////////////////////////////////////////////////////////////////////

function constructCalendarRPFC()
{


        if(Language=="French")
        {   
                var	monthNameRPFC =	new	Array("janvier","f"+String.fromCharCode(233)+"vrierss","mars","avril","mai","juin","juillet","ao"+String.fromCharCode(251)+"t","septembre","octobre","novembre","d"+String.fromCharCode(233)+"cembre")
                todayString=todayStringF;
        }
        else
        {
                var	monthNameRPFC =	new	Array("January","February","March","April","May","June","July","August","September","October","November","December")
        }

       if (showToday==1)
        {
	            if (bShowFullDayName == false)
	            {
		            var sToday = monthNameRPFC[parseFloat(monthNowRPFC)].substring(0,3) + " " +  dateNowRPFC +  " " + yearNowRPFC
	            }
	            else
	            { 
		            var sToday = dayNameRPFC[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", " + dateNowRPFC + " " + monthNameRPFC[parseFloat(monthNowRPFC)].substring(0,3) + "	" +	yearNowRPFC
	            }			
        }
      forwardallowRPFC= '0';
      backallowRPFC= '0';

     if(monthSelectedRPFC != monthNowRPFC)     
        {
            swapImageRPFC('changeLeft','left1.gif','yes')
        }

if(startendtypeRPFC!=null)
{
     if(startendtypeRPFC!="startdate")//open the calnder with respect to the date enter into the text box.
        {  
                           //and diallow the user go back withrespect to dateto 
          //if(getObj("ctl00_cphContent_txtTo").value !="" && allowbackRPFC!='1')
         
          if(getObj(ctlStartRPFC).value !="" && allowbackRPFC!='1')
             {
             
              
                cutmonthNowRPFC = getObj(ctlStartRPFC).value.substring(0,2);
                cutdateNowRPFC = 0; 
                cutyearNowRPFC = getObj(ctlStartRPFC).value.substring(6,10);
              
               // monthSelectedRPFC = parseFloat(cutmonthNowRPFC)-1;               
              
                //yearSelectedRPFC=cutyearNowRPFC;                
             }
                         
        }
       
   }
     
           allowbackRPFC='0';
           var iDateCelWidthRPFC = (iCalWidth/7) - 4
           var dateMessageRPFC
           var	startDateRPFC =	new	Date (yearSelectedRPFC,monthSelectedRPFC,1)
           var	endDateRPFC	= new Date (yearSelectedRPFC,monthSelectedRPFC+1,1);
           endDateRPFC	= new Date (endDateRPFC	- (24*60*60*1000));
           numDaysInMonthRPFC = endDateRPFC.getDate()
           datePointerRPFC	= 0 
           dayPointerRPFC = startDateRPFC.getDay() - startAt  //*var startAt = 0 // 0 - sunday ; 1 - monday
       
           if (dayPointerRPFC<0)
           {
                dayPointerRPFC = 6
           }
             sHTMLRPFC =	"<table	border=0 cellspacing=0 cellpadding=1 width=100%><tr>"

          if (showWeekNumber == 1)
          {
               sHTMLRPFC += "<td width=" + iDateCelWidthRPFC + ">"+ weekString + "</td><td width=1 rowspan=7 class='weeknumber-div-styleRPFC'><img src='"+imgDirRPFC+"divider.gif' width=1></td>"
          }
          for(i=0; i<7; i++)
           {
              sHTMLRPFC += "<td align='right' class='dayheader-styleRPFC' width=" + iDateCelWidthRPFC + ">"+ dayNameRPFC[i]+"</td>"
           }
            sHTMLRPFC +="</tr><tr>"
         if (showWeekNumber == 1)
            {
                sHTMLRPFC += "<td align=right width=" + iDateCelWidthRPFC + ">" + WeekNbr(startDateRPFC) + "</td>"
            }
         for	(var i=1; i<=dayPointerRPFC;i++)
          {
           sHTMLRPFC += "<td width=" + iDateCelWidthRPFC + ">&nbsp;</td>"
          }

  //Start writing cells with dates in them
  for(datePointerRPFC=01; datePointerRPFC<=numDaysInMonthRPFC; datePointerRPFC++ )
  {
       if((datePointerRPFC == numDaysInMonthRPFC) && (( dayPointerRPFC % 7)  == 6 ))
       {
                	
       }
       else
       {
        dayPointerRPFC++;
       }
        sHTMLRPFC += "<td align=right width=" + iDateCelWidthRPFC + ">"
        var sStyleRPFC="normal-day-styleRPFC"; //regular day
       
       if(startendtypeRPFC!="startdate")
       {
     
         if ((datePointerRPFC ==1)&&(monthSelectedRPFC==parseInt(cutmonthNowRPFC)-1)&&(yearSelectedRPFC==cutyearNowRPFC))
         {
     
             backallowRPFC='1';
         }
        
        if(yearSelectedRPFC == cutyearNowRPFC && monthSelectedRPFC == (parseInt(cutmonthNowRPFC)-1))
            {       
         
               backallowRPFC='1';
            }
       }
   	
       if ((datePointerRPFC==cutdateNowRPFC)&&(monthSelectedRPFC==cutmonthNowRPFC)&&(yearSelectedRPFC==cutyearNowRPFC)) 
             {        
              
            if(cutdateNowRPFC==odateSelectedRPFC)
            {
               sStyleRPFC = "current-day-styleRPFC"; 
            }
           else
            {
              sStyleRPFC ="normal-day-styleRPFC";
           }
            } 
          else if	(dayPointerRPFC % 7 == (startAt * -1) +1) 
            { 
             sStyleRPFC = "end-of-weekday-styleRPFC"; 
            }
         else if	(dayPointerRPFC % 7 == 0) 
            { 
                 sStyleRPFC = "end-of-weekday-styleRPFC"; 
            }
     //*  for sunday
   if ((datePointerRPFC==odateSelectedRPFC) &&	(monthSelectedRPFC==omonthSelectedRPFC)	&& (yearSelectedRPFC==oyearSelectedRPFC)){ 
        if(datePointerRPFC != dateNowRPFC)
        {
             sStyleRPFC += " selected-day-styleRPFC"; 
        }
        if	(dayPointerRPFC % 7 == 0) 
        { 
         sStyleRPFC = " selected-day-styleRPFC"; 
       }
     }
    
   if(startendtypeRPFC!=null)
{
    if(startendtypeRPFC!="startdate")
    {
  
     //to reset the values so that all cutted datee will show while again click on calender icon
     if (getObj(ctlStartRPFC).value!='' && getObj(ctlEndRPFC).value!='' && cutdateNowRPFC==0)
       {
           cutmonthNowRPFC = getObj(ctlEndRPFC).value.substring(0,2);
           cutdateNowRPFC =  getObj(ctlEndRPFC).value.substring(3,5);
           cutyearNowRPFC = getObj(ctlEndRPFC).value.substring(6,10);
       }
       
       
     if ((parseInt(datePointerRPFC) < (parseFloat(cutdateNowRPFC))) &&(parseInt(monthSelectedRPFC)==parseInt(cutmonthNowRPFC-1))&&(parseInt(yearSelectedRPFC)==parseInt(cutyearNowRPFC)))
        { 
    
             sStyleRPFC = "pre-day-styleRPFC"; 
        }

    }
}
 
    sHint = ""
//    for (k=0;k<HolidaysCounter;k++){
//            if ((parseInt(Holidays[k].d)==datePointerRPFC)&&(parseInt(Holidays[k].m)==(monthSelectedRPFC+1)))
//	        {
//	         if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelectedRPFC)&&(parseInt(Holidays[k].y)!=0)))
//	          {
//		         sStyleRPFC += " holiday-style";
//		         sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc
//	          }
//        }
//     }

    var regexp= /\"/g
    sHint=sHint.replace(regexp,"&quot;")
    
    if(startendtypeRPFC!="startdate"){
        if ((parseInt(datePointerRPFC) < (parseFloat(cutdateNowRPFC))) &&(parseInt(monthSelectedRPFC)==parseInt(cutmonthNowRPFC-1))&&(parseInt(yearSelectedRPFC)==parseInt(cutyearNowRPFC)))
        { 
            dateMessageRPFC = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointerRPFC,monthSelectedRPFC,yearSelectedRPFC))+"\"' onmouseout='window.status=\"\"' "
            sHTMLRPFC += "<a class='"+sStyleRPFC+"' "+dateMessageRPFC+" title=\"" + sHint + "\" >&nbsp;" + datePointerRPFC + "&nbsp;</a>"
        }
        else
        {
            dateMessageRPFC = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointerRPFC,monthSelectedRPFC,yearSelectedRPFC))+"\"' onmouseout='window.status=\"\"' "
            sHTMLRPFC += "<a class='"+sStyleRPFC+"' "+dateMessageRPFC+" title=\"" + sHint + "\" href='javascript:dateSelectedRPFC="+datePointerRPFC+";flagefirstRPFC();closeCalendarRPFC();'>&nbsp;" + datePointerRPFC + "&nbsp;</a>"
        }

    }
    else  {
        dateMessageRPFC = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointerRPFC,monthSelectedRPFC,yearSelectedRPFC))+"\"' onmouseout='window.status=\"\"' "
        sHTMLRPFC += "<a class='"+sStyleRPFC+"' "+dateMessageRPFC+" title=\"" + sHint + "\" href='javascript:dateSelectedRPFC="+datePointerRPFC+";flagefirstRPFC();closeCalendarRPFC();'>&nbsp;" + datePointerRPFC + "&nbsp;</a>"
    }



     sHTMLRPFC +=  " "  //this give gap's between Number of dates in calendar.
     if ((dayPointerRPFC+startAt) % 7 == startAt) { 
	    sHTMLRPFC += "</td></tr><tr>" 
        if ((showWeekNumber==1)&&(datePointerRPFC<numDaysInMonthRPFC))
	      {
            sHTMLRPFC += "<td align=right>" + (WeekNbr(new Date(yearSelectedRPFC,monthSelectedRPFC,datePointerRPFC+1))) + "</td>"
	      }
     }
  }
        sHTMLRPFC +="</tr></table>"		  
    //write string to calendar contentRPFC placeholder

    getObj("contentRPFC").innerHTML  = sHTMLRPFC 
     //getObj("content1RPFC").innerHTML  = sHTMLRPFC


    getObj("spanMonthRPFC").innerHTML = "&nbsp;" +	monthNameRPFC[parseFloat(monthSelectedRPFC)] + "&nbsp;<IMG id='changeMonth' SRC='"+imgDirRPFC+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
    getObj("spanYearRPFC").innerHTML =	"&nbsp;" + yearSelectedRPFC	+ "&nbsp;<IMG id='changeYear' SRC='"+imgDirRPFC+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
    if(CalendarTypeRPFC==2)
    {
        constructCalendar1RPFC()
    }
}

function constructCalendar1RPFC() {

      monthSelectedRPFC=monthSelectedRPFC+1

      //forwardallowRPFC= '0';
      var iDateCelWidthRPFC = (iCalWidth/7) - 4
      var dateMessageRPFC
      var	startDateRPFC =	new	Date (yearSelectedRPFC,monthSelectedRPFC,1)
      var	endDateRPFC	= new Date (yearSelectedRPFC,monthSelectedRPFC+1,1);
      endDateRPFC	= new Date (endDateRPFC	- (24*60*60*1000));
      numDaysInMonthRPFC = endDateRPFC.getDate()
      datePointerRPFC	= 0
      //dd=0;      
          
   dayPointerRPFC = startDateRPFC.getDay() - startAt  //*var startAt = 0 // 0 - sunday ; 1 - monday
   if (dayPointerRPFC<0){
    dayPointerRPFC = 6
   }
   sHTMLRPFC =	"<table	border=0 cellspacing=0 cellpadding=1 width=100%><tr>"
   if (showWeekNumber == 1){
     sHTMLRPFC += "<td width=" + iDateCelWidthRPFC + ">"+ weekString + "</td><td width=1 rowspan=7 class='weeknumber-div-styleRPFC'><img src='"+imgDirRPFC+"divider.gif' width=1></td>"
   }
   for(i=0; i<7; i++){
      sHTMLRPFC += "<td align='right' class='dayheader-styleRPFC' width=" + iDateCelWidthRPFC + ">"+ dayNameRPFC[i]+"</td>"
   }
   sHTMLRPFC +="</tr><tr>"
  if (showWeekNumber == 1){
     sHTMLRPFC += "<td align=right width=" + iDateCelWidthRPFC + ">" + WeekNbr(startDateRPFC) + "</td>"
  }
  for	(var i=1; i<=dayPointerRPFC;i++){
   sHTMLRPFC += "<td width=" + iDateCelWidthRPFC + ">&nbsp;</td>"
  }
  //Start writing cells with dates in them
  for(datePointerRPFC=1; datePointerRPFC<=numDaysInMonthRPFC; datePointerRPFC++ ){
   if((datePointerRPFC == numDaysInMonthRPFC) && (( dayPointerRPFC % 7)  == 6 )){
            	
    }
   else{
    dayPointerRPFC++;
    }
    sHTMLRPFC += "<td align=right width=" + iDateCelWidthRPFC + ">"
    var sStyleRPFC="normal-day-styleRPFC calOver"; //regular day
    
   if ((datePointerRPFC==dateNowRPFC)&&(monthSelectedRPFC==monthNowRPFC)&&(yearSelectedRPFC==yearNowRPFC)) { 
         sStyleRPFC = "current-day-styleRPFC"; 
    } 
   else if	(dayPointerRPFC % 7 == (startAt * -1) +1) { 
         sStyleRPFC = "end-of-weekday-styleRPFC"; 
    }
    else if	(dayPointerRPFC % 7 == 0) { 
         sStyleRPFC = "end-of-weekday-styleRPFC"; 
    }
     //*  for sunday

  if ((datePointerRPFC==odateSelectedRPFC) &&	(monthSelectedRPFC==omonthSelectedRPFC)	&& (yearSelectedRPFC==oyearSelectedRPFC)){ 
        sStyleRPFC += " selected-day-styleRPFC"; 
     }
     
    sHint = ""
    for (k=0;k<HolidaysCounter;k++){
            if ((parseInt(Holidays[k].d)==datePointerRPFC)&&(parseInt(Holidays[k].m)==(monthSelectedRPFC+1)))
	        {
	         if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelectedRPFC)&&(parseInt(Holidays[k].y)!=0)))
	          {
		         sStyleRPFC += " holiday-style";
		         sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc
	          }
        }
     }

    var regexp= /\"/g
    sHint=sHint.replace(regexp,"&quot;")

    
  
         dateMessageRPFC = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointerRPFC,monthSelectedRPFC,yearSelectedRPFC))+"\"' onmouseout='window.status=\"\"' "
         sHTMLRPFC += "<a class='"+sStyleRPFC+"' "+dateMessageRPFC+" title=\"" + sHint + "\" href='javascript:dateSelectedRPFC="+datePointerRPFC+";flageSecondRPFC();closeCalendarRPFC();'>&nbsp;" + datePointerRPFC + "&nbsp;</a>"
      

     sHTMLRPFC +=  " "  //this give gap's between Number of dates in calendar.
     if ((dayPointerRPFC+startAt) % 7 == startAt) { 
	    sHTMLRPFC += "</td></tr><tr>" 
        if ((showWeekNumber==1)&&(datePointerRPFC<numDaysInMonthRPFC))
	      {
            sHTMLRPFC += "<td align=right>" + (WeekNbr(new Date(yearSelectedRPFC,monthSelectedRPFC,datePointerRPFC+1))) + "</td>"
	      }
     }
  }
        sHTMLRPFC +="</tr></table>"		  
    //write string to calendar contentRPFC placeholder

     getObj("content1RPFC").innerHTML  = sHTMLRPFC 

      
     if(monthSelectedRPFC==12)
     {         
        monthSelectedRPFC=0
        yearSelectedRPFC=yearSelectedRPFC++
        getObj("spanMonth1RPFC").innerHTML = "&nbsp;" +	monthNameRPFC[parseFloat(monthSelectedRPFC)] + "&nbsp;"
        getObj("spanYear1RPFC").innerHTML =	"&nbsp;" + yearSelectedRPFC	+ "&nbsp;"
        monthSelectedRPFC=12
        yearSelectedRPFC=yearSelectedRPFC--
     }      
     else{
  
        getObj("spanMonth1RPFC").innerHTML = "&nbsp;" +	monthNameRPFC[parseFloat(monthSelectedRPFC)] + "&nbsp;"
        getObj("spanYear1RPFC").innerHTML =	"&nbsp;" + yearSelectedRPFC	+ "&nbsp;"
        }
        
       
    if((monthSelectedRPFC==0) )
     {
        monthSelectedRPFC=11
        //yearSelectedRPFC=yearSelectedRPFC-1
      }
     else
     {
        monthSelectedRPFC=monthSelectedRPFC-1;
     }
       monthActualRPFC = monthSelectedRPFC + 1 ;  
       
        
 }

function flageSecondRPFC()
{
DateFlageRPFC=1;
}
function flagefirstRPFC()
{
DateFlageRPFC=0;
}




//handles building calendar - this is the function that is called by page controls to do calendar functionality

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////Calendar for Book now//////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function closeCalendarRPFCUser(){

    try{	
        var	sTmp;
        hideCalendar();
       if(typeRPFC=="1"){
//***********************
    if(CalendarTypeRPFC==2)
    {
    if(DateFlageRPFC==1)
    {
        if(monthSelectedRPFC==11){
      
           monthSelectedRPFC=0
           yearSelectedRPFC=yearSelectedRPFC+1
            }
        else{
           monthSelectedRPFC=monthSelectedRPFC+1
            }
    }
    }
 
            ctlToPlaceValueRPFC.value =	constructDate(dateSelectedRPFC,monthSelectedRPFC,yearSelectedRPFC)
          //alert(ctlToRPFCPlaceValueRPFC.value)
             if(ctlToPlaceValueRPFC.name=="txtDateFr")
                setCheckInValueRPFC(ctlToPlaceValueRPFC.value);
            else
                setCheckOutValueRPFC(ctlToPlaceValueRPFC.value);
            

         }
         
        else{
          if(CalendarTypeRPFC==2)
    {
    if(DateFlageRPFC==1)
    {
        if(monthSelectedRPFC==11){
          
            monthSelectedRPFC=0
            yearSelectedRPFC=yearSelectedRPFC+1
            }
        else{
            monthSelectedRPFC=monthSelectedRPFC+1
            }
    }
    }
          ctlToPlaceValueRPFC.value =	constructDate(dateSelectedRPFC,monthSelectedRPFC,yearSelectedRPFC)
        }			
    }
    catch(er){
	    alert(er);
    }  		
}









	
