var prev = 'blank';
function change_class(rrId)
{
 	if(prev != 'blank')
 	{
		document.getElementById(prev).className = '';
	}
	if(prev == 'blank' && rrId != 'rr1')
	{
		document.getElementById('rr1').className = '';
	}
	document.getElementById(rrId).className = 'activenav';
	prev = rrId;
}
function ll(theTable)
{    
	i=1;    
	var linkname = '';
	while(i<=27)
	{
		if(theTable!="r"+i)
		{
			linkname="r"+i;
			if(document.getElementById(linkname)!=null)
				document.getElementById(linkname).style.display = 'none';
		} 
		i++;
	}     
	if (document.getElementById(theTable).style.display == 'none')
	{		
		document.getElementById(theTable).style.display = 'block';
	}
	else
	{
		document.getElementById(theTable).style.display = 'block';
	}
}
// JavaScript Document
function mainSubNav(subnavs)
{
		document.getElementById('bty').style.display='none';
		document.getElementById(subnavs).style.display='block';
}
//


function f_proceed()
{
	/*
	if (IsNumeric(document.getElementById("checkIn").value) == false) 
	{
		alert("Please check - non numeric value in From Date !");
		document.getElementById("checkIn").focus();
		return false;
	}
	if (IsNumeric(document.getElementById("checkOut").value) == false) 
	{
		alert("Please check - non numeric value in To Date !");
		document.getElementById("checkOut").focus();
		return false;
	}
	*/	
	function f_dis()
	{
		document.getElementById('bodyindex').style.visibility = "visible";
		document.getElementById('bodyindex').style.display	= "block";
		document.getElementById('loading').style.visibility = "visible";
		document.getElementById('loading').style.display	= "none";
	}
	showLoad();			
	function IsNumeric(strString)
	//check for valid numeric strings	
	{
		var strValidChars = "0123456789.-/ ";
		var strChar;
		var blnResult = true;
		if (strString.length == 0) return false;
	    //test strString consists of valid characters listed above
		for (i = 0; i < strString.length && blnResult == true; i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
			}
		}
		return blnResult;
	 }				
				
	var cin = document.getElementById("checkIn").value; 
	var cout = document.getElementById("checkOut").value; 
    var tempin = new Array();
    var tempout = new Array();
    tempin = cin.split('/');	
    tempout = cout.split('/');			
	strStartDatein=tempin[0]+"-"+tempin[1]+"-"+tempin[2];		
	strStartDateout=tempout[0]+"-"+tempout[1]+"-"+tempout[2];			                
	strRetin = ac_validate_date(strStartDatein);
	strRetout = ac_validate_date(strStartDateout);	            	            
	if (strRetin.substring(0,1) == ' ')
	{
		f_dis();
		alert("Please select a valid Check In Date")
		document.getElementById("checkIn").focus();
		return false;
	}
	if (strRetout.substring(0,1) == ' ')
	{
		f_dis();
		alert("Please select a valid Check Out Date")
		document.getElementById("checkOut").focus();
		return false;
	}
	function f_makeArray(n)
	{
		this.length = n;
		for( var ai = 1; ai<=n; ai++) this[ai] = 0;
			return this;
	}		

function ac_validate_date(as_date)
{
			ls_months = new f_makeArray(12);			 
			ls_months [1] = 'JAN';ls_months [2] = 'FEB'; ls_months [3] = 'MAR'; ls_months [4] = 'APR'; ls_months [5] = 'MAY'; ls_months [6] = 'JUN'; ls_months [7] = 'JUL'; ls_months [8] = 'AUG'; ls_months [9] = 'SEP'; ls_months [10] = 'OCT'; ls_months [11] = 'NOV'; ls_months [12] = 'DEC'; 
			li_err=1;            
			as_date = f_trim(as_date);
			if (as_date.indexOf(' ',1) > 0)	return (' cannot contain spaces');
			ll_pos1 = as_date.indexOf ('/',1);
			if (ll_pos1 > 0) ll_pos2 = as_date.indexOf('/', ll_pos1+1);
			if (ll_pos1 < 0 || ll_pos2 < 0){
				ll_pos1 = as_date.indexOf ('-',1);
				if (ll_pos1 > 0) ll_pos2 = as_date.indexOf('-', ll_pos1+1);
			}
			if (ll_pos1 < 0 || ll_pos2 < 0) return ' is not a valid date';
			ls_val = as_date.substring ( 0, ll_pos1);
			while ( ls_val.substring(0,1) == '0' ) ls_val = ls_val.substring(1, ls_val.length);
			ll_day = parseInt(ls_val);
			ls_val = as_date.substring ( ll_pos1+1, ll_pos2);
			while ( ls_val.substring(0,1) == '0' ) ls_val = ls_val.substring(1, ls_val.length);
			ll_mon_t = ls_val;
			ls_val = as_date.substring ( ll_pos2+1, as_date.length);
			
			/*while ( ls_val.substring(0,1) == '0' ) ls_val = ls_val.substring(1, ls_val.length);*/
			ll_year = parseInt(ls_val);
			ll_year=Math.abs(ll_year);
				
			if (ll_year < 50) ll_year += 2000; else if (ll_year < 100) ll_year += 1900;
				
			if ( isNaN(ll_day) || isNaN(ll_year)) return ' is not a valid date';
			if (ll_year < 1900 || ll_year > 2079){ return  ' - Please enter year in the range 1900 - 2079';}
			if ( parseInt(ll_mon_t) != ll_mon_t){
				ls_mon = ll_mon_t.toUpperCase();
				for(var di=1;di<=12;di++) if (ls_mon == ls_months[di]) {ll_mon = di; break;}
				if (di > 12) return ' is not a valid date';
			}
			else { ll_mon = ll_mon_t;}
			if (ll_mon > 12 || ll_mon <1 || ll_day > 31 || ll_day < 1) return ' is not a valid date';
			if ((ll_mon == 1 || ll_mon == 3 || ll_mon == 5 || ll_mon == 7 || ll_mon == 8 || ll_mon == 10 || ll_mon == 12) && ll_day > 31) li_err = -1;
			if ((ll_mon == 4 || ll_mon == 6 || ll_mon == 9 || ll_mon == 11) && ll_day > 30) li_err= -1;
			if (ll_mon == 2){
				if ( (  ll_year % 4 == 0  &&  ll_year % 100 != 0 ) || ( ll_year % 400 == 0 ) ){
					if (ll_day > 29)li_err = -1;
				}
				else{
					if (ll_day > 28)li_err = -1;
				}
			}
			if (li_err == -1) return ' is not a valid date'; 
			else {
				ls_final_date = ll_day + '-'+ ls_months[ll_mon] + '-' + ll_year;
				return ls_final_date;
			}			
		}
	
		if (window.document.getElementById("LstDestination").value=="0" || window.document.getElementById("LstDestination").value=="" || window.document.getElementById("LstDestination").value=="Select Destination")
		{
			f_dis();
			alert("Please Select the Destination");
			window.document.getElementById("LstDestination").focus();
			return false
		}
		var f = window.document.frmLocations	
		//inthotelId = (window.document.getElementById("LstProperty").value);			
		if (Date.parse(document.getElementById("checkIn").value) < Date.parse('<%=txtCIJS%>'))
		{
			f_dis();
			alert("Reservation can not be made prior to "+ '<%=txtCIJS%>');
			document.getElementById("checkIn").focus();
			return false;
		} 
		else 
		{
			if(Date.parse(document.getElementById("checkOut").value) <= Date.parse(document.getElementById("checkIn").value))
			{
				f_dis();
				alert("Departure date is prior to Check in date!!! Please re-enter");
				document.getElementById("checkOut").focus();
				return false;
		}  						              
	  }
	}
	//Validations for the Check in and Check out dates
	function f_DateCheck()
	{
		var aD=0,aM=0,aY=0,dD=0,dM=0,dY=0,mD=0,mM=0,mY=0;
		var aadate,dddate;
		//Values Chosen by the user
		aadate=(window.document.getElementById("checkIn").value).split("/");		
		aD=aadate[1];
		aM=aadate[0];
		aY=aadate[2];
		dddate=(window.document.getElementById("checkOut").value).split("/");		
		dD=dddate[1];
		dM=dddate[0];
		dY=dddate[2];
		
		//Minimum Check in Date
		mD=window.document.getElementById("txtArrDay").value;
		mM=window.document.getElementById("txtArrMonth").value;
		mY=window.document.getElementById("txtArrYear").value;		
		aD=aD/1
		aM=aM/1
		aY=aY/1
		
		dD=dD/1
		dM=dM/1
		dY=dY/1
		
		mD=mD/1
		mM=mM/1
		mY=mY/1
		
		//Array for month validations
		arrMonth= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		depMonth= new Array(31,28,31,30,31,30,31,31,30,31,30,31);

				
		//Check for Leap Year
		if (((aY%4)==0)&& ((aY % 100)!=0) || ((aY % 400)==0)){
			arrMonth[1]=29;
			
		}

		if (((dY%4)==0)&& ((dY % 100)!=0) || ((dY % 400)==0)){
			depMonth[1]=29;
		}
		
		
		//Check for the validity of dates.
		if (aD > arrMonth[aM-1]){
			alert("Check in month doesn't have the date requested");
			return false;}

		if (dD > depMonth[dM-1]){
			alert("Check out month doesn't have the date requested");
			return false;}
			
		//Check for the Check out date being prior to Check in date
		
		if (dY<aY)
		{
			alert("Check out Year is prior to Check in Year");
			return false;
		}
		
		//Check for the Check out month being prior to Check in month in the same year
		
		if((dM<aM)&&(dY==aY))
		{
			alert("Check out month is prior to Check in month");
			return false;
		}
		
		//Check for the Check out date being prior to Check in date in the same month and year
		
		if ((dD<aD)&&(dM==aM)&&(dY==aY)){
			alert("Check out date is prior to Check in date");
			return false;
		}
		
		//Check for Check in date being less than minimal Check in date
		arMon= new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
		
		if (((aD<mD)&&(aM<=mM)&&(aY==mM))||((aM<mM)&&(aY==mY))||(aY<mY)){
			alert("Reservation cannot be made prior to "+mD+"-"+arMon[mM-1]+"-"+mY);
			return false;
		}			
		
		if ((aD==dD)&&(aM==dM)&&(aY==dY)){
			alert("Minimum length of stay is one Room Night.");
			return false;
		}
		//All validations over..Submit the page.		
	}	