// JavaScript Document
//====================================================================================================
//	File Name		:	twoweek.js
//----------------------------------------------------------------------------------------------------
//	Purpose			:	Client side validation in JavaScript.

//
//====================================================================================================

//====================================================================================================
//	Function Name	:	Form_Submit()
//	Purpose			:	This function will executed when user submits a form. It checks validity of
//						every field in the form.
//
//	Parameters		:	frm  - form name
//	Return			:	true or false

//----------------------------------------------------------------------------------------------------



function Check_ava(day,month,year,day_out,month_out,year_out,cday11,cmonth11,cyear11,Check_Var,Wrong_Date)//,hotel_msg,room_msg)
{
	
	with(document.frmweek)
	{
		
		if(day<10)
		{
			day="0"+day;
		}
		if(day_out<10)
		{
			day_out="0"+day_out;
		}
		if(cday1<10)
		{
			cday1="0"+cday1;
		}
		checkin_date=day+"-"+month+"-"+year;
		checkout_date=day_out+"-"+month_out+"-"+year_out;
		select_date=cday11+"-"+cmonth11+"-"+cyear11;//cday1+"-"+cmonth1+"-"+cyear1;
		
		dt1=getDateObject(checkin_date,"-");
		dt2=getDateObject(checkout_date,"-");
		dt3=getDateObject(select_date,"-");
		/*alert(checkin_date);
		alert(checkout_date);
		alert(select_date);*/
		//alert(dt1==dt2);
		var one_day=1000*60*60*24;

		//alert("value : "  +Check_Var);
		var diff=Math.ceil((dt2.getTime()-dt1.getTime())/(one_day));
		//alert(checkin_date);
		//alert(checkout_date);
		//alert('date sel '+select_date);
		/*alert("date : " + dt1);
		alert("date : " + dt2);
		alert("date : " + dt3);*/
		if(noperson.value!='')
		{
			if(!allDigits(noperson.value))
				{
					alert(L_no_of_adult_valid.value);
					noperson.focus();
					noperson.select();
					return false;
				}
		}
		if(child.value!='')
		{
			if(!allDigits(child.value))
				{
					alert(L_no_of_child_valid.value);
					child.focus();
					child.select();
					return false;
				}
		}
		if(roomno.value!='')
		{
			if(!allDigits(roomno.value))
				{
					alert(L_no_of_room_valid.value);
					roomno.focus();
					roomno.select();
					return false;
				}
		}
		
		if(dt1>dt2)
		{		
			//alert(L_Proper_Arrival_Date);
			alert(Check_Var);
			//alert("greater");
			return false;
		}
		else if(checkin_date==checkout_date)
		{	
			//alert(L_Proper_Arrival_Date);
			alert(Check_Var);
			//alert("equal");
			return false;
		}
		/*else if(diff > 14)
		{		
			//alert(Wrong_Date_Range);
			alert(Wrong_Date);
			return false;
		}*/
		else if(dt1<dt3)
		{
			//alert(L_Proper_Arrival_Date);
			alert(Check_Var);
			return false;
		}
		
		else
		{	
			Submit.value = "Check Availability";
			flag=Show_Room(day+'-'+month+"-"+year,day_out+"-"+month_out+"-"+year_out,Check_Var,Wrong_Date);
		}
	}
}



function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cDate=dateString.substring(0,curPos);
	
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			cMonth=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);	
	return dtObject;
}

function Show_Room(Adate,Ddate,Check_Var,Wrong_Date)
{
	Stamp = new Date();
	with(document.frmweek)
	{
		var cdate="",cyear,cmonth="";
		var fulldate="";
		cmonth=Stamp.getMonth()+1;
		cdate=Stamp.getDate();
		if(cmonth<10)
		{
			cmonth="0"+cmonth;
		}
		if(cdate<10)
		{
			cdate="0"+cdate;
		}
		fulldate=cdate+"-"+cmonth+"-"+Stamp.getFullYear();
		dt1=getDateObject(Adate,"-");
		dt2=getDateObject(fulldate,"-");
		dt3=getDateObject(Ddate,"-");
		if(dt1<dt2)
		{		
			//alert(L_Proper_Arrival_Date);
			alert(Check_Var);
			return false;
		}
		else if(dt1>dt3)
		{
			//alert(L_Proper_Arrival_Date);
			alert(Check_Var);
			return false;
		}
		else
		{
			Action.value="Show_Room";
			action='twoweek_search.php';
			submit();
		}
	}
	

}


function calculate_amount(frm,amt)
{
		with(frm)
		{
			//alert("ff");
			if(CardType.value=='MasterCard' || CardType.value=='VisaCard')
				{
					//var totalamt=(1.75/100)*parseInt(amt);
					var totalamt=((parseFloat(amt)*1.75)/100);
					//alert(totalamt);
					
					var finalamt=parseFloat(amt)+parseFloat(totalamt);
					//alert(finalamt);									 
					total_cardpayable_Amount.value=finalamt;
					cardamount.value=totalamt;
					total_cardpayable_amount.value=currdefault.value+finalamt;
					
				}
			else if(CardType.value=='AmExCard' || CardType.value=='DinersClubCard')	
				{
					//var totalamt=(3.25/100)*parseInt(amt);
					var totalamt=((parseFloat(amt)*3.25)/100);
					var finalamt=parseFloat(amt)+parseFloat(totalamt);
					//alert(finalamt);									 
					total_cardpayable_Amount.value=finalamt;
					cardamount.value=totalamt;
					total_cardpayable_amount.value=currdefault.value+finalamt;
				}
		}
}

function Submit_Form_Check(frm,i)
{
	var flag='yes';
	 var flag1='yes';
	  var flag11='yes';
	 var flag2='no';
	 var NoRoom = 0;
	 var AvailableRoom = 0;
	 var errmsg='';
	 //alert(i);
	 //return false;
	with(document.frmroom)
	{	
		//alert("ff"+document.all['no_of_room[]'].length);
		
		if(document.all['no_of_room[]'].length)
	  	{
		//for(i=0 ; i<document.all['no_room[]'].length ; i++)
		//{
		/* alert("if");
		 alert(i);
		 alert("val " + document.all['no_of_room[]'][i].value);
		 alert("adult" + document.all['extra_adult[]'][i].value);
		 alert("child" + document.all['extra_child[]'][i].value);*/
		 
		  if(document.all['no_of_room[]'][i].value!='')
		  {
		   flag='no';
		   if(document.all['extra_adult[]'][i].value=='')
		   {
			flag11='no';   
			errmsg=L_Valid_Adult.value+':' +document.all['room_name[]'][i].value;
		   }
		   if(document.all['extra_child[]'][i].value=='')
		   {
   			flag11='no';   
		   	errmsg=L_Valid_Child.value+ ':'+document.all['room_name[]'][i].value;
			
		   }
		  }
		//}
	  }
	  else
	  {
		  //alert("else");
		 //alert(document.all['extra_adult[]'][i].value);
		 if(document.all['no_of_room[]'].value!='')
		  flag='no';
		  if(document.all['extra_adult[]'].value=='')
		   {
			flag11='no';   
			errmsg=L_Valid_Adult.value;
		   }
		   if(document.all['extra_child[]'].value=='')
		   {
   			flag11='no';   
		   	errmsg=L_Valid_Child.value;
		   }
	  }
	  
		 //alert(flag+i);
		//alert("flag "  +flag11);
		if(flag=='yes')
		 {
		   alert(L_Empty_Room.value);
		   
			return false;
		 }
		  if(flag11=='no')
		 {
		   alert(errmsg);
			return false;
		 }
	 	
		
		/****	Checking Of Integer Value ****/
	 if(document.all['no_of_room[]'].length)
	  {
	  /* for(i=0 ; i<document.all['no_room[]'].length ; i++)
		{*/
		if((!allDigits(document.all['no_of_room[]'][i].value) || document.all['no_of_room[]'][i].value==0) && document.all['no_of_room[]'][i].value!='')
		 {
		  flag2='yes';
		  var Integer_Value=L_Valid_Room.value;
		 }
		 if((!allDigits(document.all['extra_adult[]'][i].value) || document.all['extra_adult[]'][i].value==0) && document.all['extra_adult[]'][i].value!='')
		 {
		  flag2='yes';
		  var Integer_Value=L_Valid_Adult.value;
		 
		 }
		 if((!allDigits(document.all['extra_child[]'][i].value))  && document.all['extra_child[]'][i].value!='')
		 {
		  flag2='yes';
		 var Integer_Value=L_Valid_Child.value;
		 }
	 //  }
	 }
	else
	{
	   if((!allDigits(document.all['no_of_room[]'].value) || document.all['no_of_room[]'].value==0) && document.all['no_of_room[]'].value!='')
	   {
		 flag2='yes';
		  var Integer_Value=L_Valid_Room.value;
	   }
	   if((!allDigits(document.all['extra_adult[]'].value) || document.all['extra_adult[]'].value==0) && document.all['extra_adult[]'].value!='')
	   {
	     flag2='yes';
		   var Integer_Value=L_Valid_Adult.value;
	   }
	   if((!allDigits(document.all['extra_child[]'].value)) && document.all['extra_child[]'].value!='')
	   {
	  	flag2='yes';
		var Integer_Value=L_Valid_Child.value;
	   }
	}
	if(flag2=='yes') 
	 {
	  alert(Integer_Value);
	  return false;
	 }
  
	/****	Checking Of Extra Room	****/
	
	/****	Checking Of Extra Room	****/
   if(flag=='no' && flag2=='no')
   {	
			 // alert("ggg");
			 if(document.all['no_of_room[]'].length)
			  {	
					
					 //alert("if");
					 NoRoom = document.all['no_of_room[]'][i].value;
					 AvailableRoom = document.all['room_inventory[]'][i].value;
					// alert("ava"+AvailableRoom);
					// alert("noroom"+NoRoom);
					 if(parseInt(AvailableRoom) < parseInt(NoRoom))
					 { 
					  flag1='no';
					 }
					//}
			  }
			 else
			  {
					 NoRoom = document.all['no_of_room[]'].value;
					 AvailableRoom = document.all['room_inventory[]'].value;
					 if(parseInt(AvailableRoom) < parseInt(NoRoom))
					 { 
					  flag1='no';
					 }
			  }
			//alert('FLag1'+flag1);
			if(document.all['no_of_room[]'].length)
			 {
				if(flag1=='no')
				{
				// alert(Unavailable_Room+document.all['room_name[]'][i].value);
				alert("Maximum "+ AvailableRoom +" Available "+document.all['room_name[]'][i].value+" "+"Room.");
				document.all['no_of_room[]'][i].focus();
				document.all['no_of_room[]'][i].select();
				
				 return false;
				}
			 }
			else
			{
			   if(flag1=='no')
			   {
				// alert(Unavailable_Room+document.all['room_name[]'].value);
				 alert("Maximum "+ AvailableRoom +" Available "+document.all['room_name[]'].value+" "+"Room.");
				 document.all['no_of_room[]'].focus();
				 document.all['no_of_room[]'].select();
				 return false;
			   }
			 }
    }
	
	
	flag3='yes';
	flag4='yes';
	//For Base Extra Adutl & Child Checking
	//alert(document.getElementById('no_of_room[]').length);
	//return false;
	if(document.all['no_of_room[]'].length)
			  {	
					
					// alert("if");
					 extraadult = parseInt(NoRoom) * parseInt(document.all['extra_adult_base[]'][i].value);
					 extrachild = parseInt(NoRoom) * parseInt(document.all['extra_child_base[]'][i].value);
					
					 if(parseInt(document.all['extra_adult[]'][i].value) > parseInt(extraadult))
					 { 
					  // alert("wrong");
					  flag3='no';
					 }
					 if(parseInt(document.all['extra_child[]'][i].value) > parseInt(extrachild))
					 { 
					  flag4='no';
					 }
					 // return false;
					 
					//}
			  }
			 else
			 {
				  	 extraadult = parseInt(NoRoom) * parseInt(document.all['extra_adult_base[]'].value);
					 extrachild = parseInt(NoRoom) * parseInt(document.all['extra_child_base[]'].value);
					
					 if(parseInt(document.all['extra_adult[]'].value) > parseInt(extraadult))
					 { 
					  // alert("wrong");
					  flag3='no';
					 }
					 if(parseInt(document.all['extra_child[]'].value) > parseInt(extrachild))
					 { 
					  flag4='no';
					 }
			 }
	
		if(document.all['no_of_room[]'].length)
			 {
				if(flag3=='no')
				{
				 alert(L_Valid_Adult_Max.value);
				 document.all['extra_adult[]'][i].focus();
				 document.all['extra_adult[]'][i].select();
				 return false;
				}
				if(flag4=='no')
			   {
				 alert(L_Valid_Child_Max.value);
				 document.all['extra_child[]'][i].focus();
				 document.all['extra_child[]'][i].select();
				 return false;
			   }
			 }
		else
			{
				if(flag3=='no')
				{
				 alert(L_Valid_Adult_Max.value);
				 document.all['extra_adult[]'].focus();
				 document.all['extra_adult[]'].select();
				 return false;
				}
				if(flag4=='no')
			   {
				 alert(L_Valid_Child_Max.value);
				 document.all['extra_child[]'].focus();
				 document.all['extra_child[]'].select();
				 return false;
			   }	
			}

		//For Other Charges
		var c=0;
		if(ChargeId.value!='')
		{
			var data=ChargeId.value;
			var arrdata=data.split(",");
			var i2;
			var regex = /^[0-9]*$/;
			//alert(data);
			for(i2=0; i2< arrdata.length-1 ;i2++)
				{
					var t="c_"+ arrdata[i2];
					var a=eval(t + ".value");
					if(a!='')
					{
						if(!regex.test(a))
						{
							alert(L_Valid_Charge.value);
							eval(t+".focus()");
							eval(t+".select()");
							c++;
							return false;
							
						}
					}//if
				}
				if(c!=0)
					return false;
		}
		
	Action.value="Request";
	//alert(i);
	//return false;
	rowno.value=i;
	submit();
	//Action.value="Reservation";
	
	return true;
	}
}

function allDigits(str)
{
	
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;
	var strLen = str.length;
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	return result;
}

function adddate(day,month,year,frm,cval2)
{
	with(frm)
	{
	
	day   = parseInt(day) + 1;
	var monthc=month;
	
	if(cval2=='M' || cval2=='Y' || cval2=='D')
		month = monthc-1;
	else	
		month = monthc-1;
		
	newDate = new Date ( year, month, day );
	year  = newDate.getFullYear();
    
	if(cval2=='M' || cval2=='Y' || cval2=='D')
		month = newDate.getMonth()+1;
	else
		month = newDate.getMonth()+1;
	
    month = (month<10)?'0'+month:month;
    day   = newDate.getDate();
    formattedDate = month + '/' + day + '/' + year;
	
	daylist_out.value=day;
	monthlist_out.value=month;
	yearlist_out.value=year;
	
	}
	
}
///==============================================================================


function calendarCallback(date, month, year)
{
	if(month <= 9)
	{ month = '0'+month }
	if(date <= 9)
	{ date = '0'+date }
	//date =  year +'-' + month + '-' + date ;
	//document.frmweek.news_date.value = date;
	//document.frmweek.news_date.focus();
	document.frmweek.yearlist.value=year;
	document.frmweek.monthlist.value=month;
	document.frmweek.daylist.value=date;
}

function Check_Validation(frm,hotel_msg,room_msg)
{
	with(frm)
	{
		//alert(hotel_msg);
		if(select_hotel.value==0)
		{
			alert(hotel_msg);
			return false;	
		}
		if(select_room.value==0)
		{
			alert(room_msg);
			return false;	
		}
		base_name.value = select_room.value;
		sub3.value="Search";
		submit();
		return true;	
	}
}
function Form_Submit(frm)
{
	
	with(frm)
	{	
				
		if(!IsEmpty(fname,F_Name_Empty))
		{
			
			return false;
		}
		if(!IsEmpty(lname,L_Name_Empty))
		{
			
			return false;
		}
				
		if(!IsEmpty(address,Address_Empty))
		{
			
			return false;
		}
		
		if(!IsEmpty(city,City_Empty))
		{
			
			return false;
		}
		if(!IsEmpty(state,State_Empty))
		{
			
			return false;
		}
						
		if(!IsEmpty(country,Country_Empty))
		{
			
			return false;
		}
		
		if(!IsEmpty(email,Email_Empty))
		{
			
			return false;
		}
		if(!IsEmail(email,Valid_Email))
		{
		
			return false;
		}
		if(!IsEmpty(confirm_email,CEmail_Empty))
		{
			
			return false;
		}
		if(!IsEmail(confirm_email,CValid_Email))
		{
			
			return false;
		}
		if(email.value != confirm_email.value)
		{
		  alert(Match_Email);
		  confirm_email.focus();
		  return false;
		}		 	
		if(!IsValidInteger(day_phone,Phone_Empty))
		{
			return false;
		}
		if(!frm.condition.checked)
		{
			alert("You must confirm that you have read and agree to Terms & condition and Privacy Policy");
			return false;
		}
									 
	return true;
	}
}

//====================================================================================================
//	Function Name	:	Add_Click()
//	Purpose			:	This function will executed when user submits a form. It checks validity of 
//						every field in the form.
//----------------------------------------------------------------------------------------------------
function Add_Click()
{
	with(document.frmtwoweek)
	{
		Action.value = "Add";
		submit();
	}
}

function Check_Ava_Display(hotelid2)
{
	
	with(document.frmweek)
	{ 
	
		//alert(hotelid);
		//SubmitCheck.value = "Availability";
		//selected_month.value = monthlist.value;
		popupWindowURL("avaibility.php?Action=Avaibility&hotelid="+hotelid2, 'PageContent', 800, 400, false, false, true);
		//popupWindowURL("avaibility.php?room_id="+Room_Id+"&Action=View_Gallary&total="+Total, 'PageContent', 650, 500, false, false, true);
		//submit();
		
	}
}

function Check_ava_month(day,month,year,day_out,month_out,year_out)
{
	
	with(document.frmweek)
	{ 
	
		SubmitCheck.value = "Availability";
		selected_month.value = monthlist.value;
		//popupWindowURL("avaibility.php?room_id="+Room_Id+"&Action=View_Gallary&total="+Total, 'PageContent', 650, 500, false, false, true);
		submit();
		
	}
}

function Show_Room_Ava(Adate)
{
	Stamp = new Date();
	with(document.frmweek)
	{
		var cdate="",cyear,cmonth="";
		var fulldate="";
		cmonth=Stamp.getMonth()+1;
		if(cmonth<10)
		{
			cmonth="0"+cmonth;
		}
		
		if(cdate<10)
		{
			cdate="0"+cdate;
		}
		fulldate=Stamp.getFullYear()+"-"+cmonth+"-"+cdate;
		
		if(Adate<fulldate)
		{		
			alert(L_Proper_Arrival_Date);
		}
		else
		{
			Action.value="Show_Room";
			submit();
		}
	}
}



function Change_Month(Month)
{ 
	 with(document.frmweek)
	 {
		 selected_month.value = Month;
		 submit();
	 } 
}
function Change_Year(Year)
{	
	 with(document.frmweek)
	 {
		  selected_year.value = Year;
		  submit();
	 } 
}
function New_Search()
{
	 with(document.frmweek)
	 {
		Action.value='Reset';
		submit();
	 	
	 }
}

function IsValidInteger(fld,msg)
{
	var regex = /^[0-9]*$/;
	if(!regex.test(fld.value))
	{
		alert(msg);
		fld.focus();
		return false;
	}
	return true;
}

//checking for other charges fields
/*L_Empty_Room,
					L_Valid_Room,
					L_Zero_Room,
					L_Valid_Adult,
					L_Valid_Child,
					L_Valid_Charge*/
function Submit_Form()
{
	with(document.frmothercharge)
	{	
		//alert(L_Empty_Room.value);
		
		var roominventory = parseInt(room_inventory.value);
		var roomrequest = parseInt(no_of_room.value);
		
		if(!IsEmpty(no_of_room,L_Empty_Room.value))
		{
			return false;
		}

		if(!IsValidInteger(no_of_room,L_Valid_Room.value))
		{
			
			return false;
		}

		if(no_of_room.value<=0)
		{
			alert(L_Zero_Room.value);
			no_of_room.focus();
			return false;
		}
		if(roominventory < roomrequest)
		{
			//alert(JM_Max_room+" "+room_inventory.value+" "+JM_Max_room_Avai);
			//"JM_Max_room"	=> "Maximum",
			//"JM_Max_room_Avai"	=>" Room Available."
			alert("Maximum"+" "+room_inventory.value+" "+"Room Available.");
			no_of_room.focus();
			return false;
		}
		if(!IsEmpty(extra_adult,L_Valid_Adult.value))
		{
			return false;
		}
		if(!IsValidInteger(extra_adult,L_Valid_Adult.value))
		{
			return false;
		}
		if(extra_adult.value<=0)
		{
			alert(L_Valid_Adult.value);
			extra_adult.focus();
			return false;
		}
		if(extra_adult.value>2)
		{
			alert(L_Valid_Adult_Max.value);
			extra_adult.focus();
			return false;
		}
		if(!IsEmpty(extra_child,L_Valid_Child.value))
		{
			return false;
		}
		if(!IsValidInteger(extra_child,L_Valid_Child.value))
		{
			return false;
		}
		if(extra_child.value>2)
		{
			alert(L_Valid_Child_Max.value);
			extra_child.focus();
			return false;
		}
		var c=0;
		if(ChargeId.value!='')
		{
			var data=ChargeId.value;
			var arrdata=data.split(",");
			var i;
			var regex = /^[0-9]*$/;
			//alert(data);
			for(i=0; i< arrdata.length-1 ;i++)
				{
					var t="c_"+ arrdata[i];
					var a=eval(t + ".value");
					if(a!='')
					{
						if(!regex.test(a))
						{
							alert(L_Valid_Charge.value);
							eval(t+".focus()");
							eval(t+".select()");
							c++;
							return false;
							
						}
					}//if
				}
				if(c!=0)
					return false;
		}
			
	return true;
	}
}





function Privacy_Click(page_Id)
{
	with(document.frmtwoweek)
	{
		var hotel_id1=hotel_id.value;
		popupWindowURL("document.php?page_id="+page_Id+"&hotel_id="+hotel_id1, 'PageContent', 650, 500, false, false, true);
	}
}

function Terms_Click(page_Id)
{
	with(document.frmtwoweek)
	{
		var hotel_id1=hotel_id.value;
		popupWindowURL("document.php?page_id="+page_Id+"&hotel_id="+hotel_id1, 'PageContent', 650, 500, false, false, true);
	}
}

function View_Gallary(Room_Id,Total)
{
	with(document.frmroom)
	{
		popupWindowURL("gallary.php?room_id="+Room_Id+"&Action=View_Gallary&total="+Total, 'PageContent', 650, 500, false, false, true);
	}
}
function Next_Click()
{
		with(document.frmview)
		{
			action.value="Next";
			submit();
		}
}
function Previous_Click()
{
		with(document.frmview)
		{
			action.value="Previous";
			submit();
		}

}

/*
function base64Decode(str) {
    var c=0, d=0, e=0, f=0, i=0, n=0;
    var input = str.split("");
    var output = "";
    var ptr = 0;
    do {
        f = input[ptr++].charCodeAt(0);
        i = dec64List[f];
        if ( f >= 0 && f < 128 && i != -1 ) {
            if ( n % 4 == 0 ) {
                c = i << 2;
            } else if ( n % 4 == 1 ) {
                c = c | ( i >> 4 );
                d = ( i & 0x0000000F ) << 4;
            } else if ( n % 4 == 2 ) {
                d = d | ( i >> 2 );
                e = ( i & 0x00000003 ) << 6;
            } else {
                e = e | i;
            }
            n++;
            if ( n % 4 == 0 ) {
                output += String.fromCharCode(c) + 
                          String.fromCharCode(d) + 
                          String.fromCharCode(e);
            }
        }
    }
    while (typeof input[ptr] != "undefined");
    output += (n % 4 == 3) ? String.fromCharCode(c) + String.fromCharCode(d) : 
              ((n % 4 == 2) ? String.fromCharCode(c) : "");
    return output;
}*/


/*var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}*/

/*if (document.images)
    {
      preload_image_object2 = new Image();
      // set image url
      image_url2 = new Array();
      image_url2[0] = "../templates/templates/grandharbour_grid/images/25.png";
    //  image_url[1] = "http://localhost/rez/templates/surinpark/images/hide_other_charges.png";
	 // image_url[2] = "http://www.ezeereservation.com/rez/templates/surinpark/images/show_rate_plans.jpg";
     // image_url[3] = "http://www.ezeereservation.com/rez/templates/surinpark/images/hide_rate_plans.jpg";
     
       var i = 0;
       for(i=0; i<1; i++) 
         preload_image_object2.src = image_url2[i];
    }
	*/
function ChangeBackOver(idmain)
{
	//alert(image_url[3]);
	
	if (document.images)
    {
      
	  preload_image_object2 = new Image();
      // set image url
      image_url2 = new Array();
      image_url2[3] = "http://www.ezeereservation.com/rez/templates/grandharbour_grid/images/25.png";
     
       var j = 0;
       for(j=3; j<=3; j++) 
         preload_image_object2.src = image_url2[j];
    }
	//alert(image_url2[3]);
	for(var i=0;i<=13;i++)
	{
		//alert("gfhgfh"+ image_url2[3]);
		var t=idmain+"_"+i+'_id';
		/*document.getElementById(t).style.background='#B3B1B1';
		document.getElementById(t).style.MozOpacity='1';
		document.getElementById(t).style.filter='alpha(opacity=100)';*/
		document.getElementById(t).style.backgroundImage='url('+image_url2[3]+')';//'url(../templates/grandharbour_grid/images/25.png)';
		
	}
	var room=idmain+"_rtype";
	document.getElementById(room).style.backgroundImage='url('+image_url2[3]+')';
	/*document.getElementById(room).style.background='#B3B1B1';
	document.getElementById(room).style.opacity='1';
	document.getElementById(room).style.filter='alpha(opacity=100)';*/
}

function ChangeBackOut(idmain)
{
	//alert(id2);
	for(i=0;i<=13;i++)
	{
		//alert("gfhgfh");
		var t=idmain+"_"+i+'_id';
		//alert(document.getElementById(t));
		document.getElementById(t).style.backgroundImage='';
	}
	var room=idmain+"_rtype";
	document.getElementById(room).style.backgroundImage='';
}

/*
function ChangeBackOut()
{
	//alert(id2);
	for(i=0;i<=13;i++)
	{
		//alert("gfhgfh");
		var t=i+'_id';
		document.getElementById(t).class='room_typebg';
	}
}*/
