				// Global variable for calendar control
				var posObj;
				var toWhichTxt=null;
				var isOverCalendarDiv=false;
				var setTimeOutVar=null;
				var carServicesName=null;
				var carServicesID=null;
				var dptWeekDay=null;
				var rtnWeekDay=null;
				var totalDays=null;
				var RID=null;
				var ISGOTOSUBMIT=false;
				var isFromQuickQuoteCalculateTotal=false;
				/////////////////////////////////////////////////
				// Start of Calendar control
				function getMyEventSenderXY(obj,top,left)
				{
					if(obj.tagName.toUpperCase()=="BODY")
					{ 
						posObj=new Object();
						posObj.top=top;
						posObj.left=left;
						return ;
					}
					else
					{
						top=parseInt(obj.offsetTop)+top;
						left=parseInt(obj.offsetLeft)+left;
						if(obj.parentNode!=null)
						{
							getMyEventSenderXY(obj.offsetParent,top,left);
						}
					}
				     
				}
				function quickQuoteBookingDisplayCalendar(sender,toTxt,src,width,height)
				{
				    setTimeOutVar=true;
					var quickQuotePopUpContainer=document.getElementById("quickQuotequickQuotePopUpContainer");
					ifr=document.getElementById("quickQuoteCalender");
					if(quickQuotePopUpContainer)
					{
					    quickQuotePopUpContainer.style.top=posObj.top+"px";
					    quickQuotePopUpContainer.style.left=posObj.left+"px";
						if(quickQuotePopUpContainer.style.display.toUpperCase()=="BLOCK")
						{ 
						   quickQuotePopUpContainer.style.display="none";
						   
						}
						else
						{
						   toWhichTxt=toTxt;
						   if(sender.id=="imgBtnReturn"){
							src=src+"?mode=return";
						   }
						   document.getElementById("quickQuoteCalender").src=src;
						   quickQuotePopUpContainer.style.display="block";
						}
						if(height!=undefined)
						{
						  quickQuotePopUpContainer.style.height=(height+20)+"px";
						  ifr.style.height=height+"px";
						}
						else
						{
						  
							try
							{
								quickQuotePopUpContainer.style.removeAttribute("height");
								ifr.style.removeAttribute("height");
							}
							catch(err)
							{
								quickQuotePopUpContainer.style.height="";
								ifr.style.height="";
							}
						}
						
						if(width!=undefined)
						{
						  quickQuotePopUpContainer.style.width=width+"px";
						}
						else
						{
							try
							{
								quickQuotePopUpContainer.style.removeAttribute("width");
							}
							catch(err)
							{
								quickQuotePopUpContainer.style.width="";
							}
						}
					}	   
				}
				function quickQuoteCloseCalendar()
				{
					var quickQuotePopUpContainer=document.getElementById("quickQuotequickQuotePopUpContainer");
					if(setTimeOutVar==false){
						quickQuotePopUpContainer.style.display="none";
					}
				}
				function quickQuoteSetSelectedDate(Date,DayOfWeek)
				{
				   
				   if(Date=="wrongDate")
				   {
					    if(toWhichTxt=="txtDptDate")
					    {
							//alert("Departure date has already passed.Please select a valid date");
							alert("The date you have selected has already passed. Please choose a current date.");
						}
						else
						{
							//alert("Return date has already passed. Please select a valid date");
							alert("The date you have selected has already passed. Please choose a current date.");
						}
						return;
				   }
				   if(toWhichTxt!=null)
				   {
				        
						var DptDate=document.getElementById(toWhichTxt);
						if(toWhichTxt=="txtDptDate"){dptWeekDay=DayOfWeek;}else{rtnWeekDay=DayOfWeek;}
						DptDate.value=Date;
						var txtQuote=document.getElementById("txtCalParkQuote"); 
						txtQuote.value="";
						document.getElementById("txtCalTotalQuote").value="";
						quickQuoteCloseCalendar();
					}
				}
				//End of calendar control
				/////////////////////////////////////////////////////////////////////////////////////
				
				
				
				
				
				//Global variable for Rate calculation
			    //Cap infomation
			    var isCapPeriod=false;
				var CapValue=null;
				var CapStardDate=null;
				var CapEndDate=null;
				
				//Period Rate infomation
				var PeriodRate=null;
				 
				//Default Rate informaiton
				var DefaultRateValue=null;
				var DefaultRateValueDuration=null
				var DefaultRateValueAfterDuration=null
				var DptDateMemory=null;
				var RtnDateMemory=null;
				//First day value;
				var FirstDayValue=null;
				
				function checkhoursandminute()
				{
					var dptHourobj = document.getElementById("SltDptHour");
					var dptMinuteobj = document.getElementById("SltDptMinute");
					var rtnHourobj = document.getElementById("SltRtnHour");    
					var rtnMinuteobj =document.getElementById("SltRtnMinute");
					var dptHour=parseInt(dptHourobj.options[dptHourobj.selectedIndex].value);
					var dptMinute=parseInt(dptMinuteobj.options[dptMinuteobj.selectedIndex].value);
					var rtnHour=parseInt(rtnHourobj.options[rtnHourobj.selectedIndex].value);
					var rtnMinute=parseInt(rtnMinuteobj.options[rtnMinuteobj.selectedIndex].value);
					//alert(dptHour+"  "+dptMinute+"  "+rtnHour+" "+rtnMinute);
					if(dptHour>rtnHour)
					{
						alert("Return time should not be before your departure time. Please amend");
						return false;
					}
					if(dptHour==rtnHour)
					{
						if(rtnMinute<=dptMinute)
						{
							alert("Return time should not be before your departure time. Please amend");
							return false
						}
					}
					return true;
					
				}
				function quickQuoteInitializeCalculateMyQuote()
				{
					var DptDate=document.getElementById("txtDptDate");
					var RtnDate=document.getElementById("txtRtnDate");
					
					if(DptDate.value.length<1)
					{
						alert("Please select your departure date");
						return;
					}
					if(RtnDate.value.length<1){
						alert("Please select your return date");
						return;
					}
					//alert(DptDate.value==RtnDate.value)
					if(DptDate.value==RtnDate.value)
					{
						if(checkhoursandminute()==false)
						{
							return;
						}
					}
					DptDateMemory=DptDate.value;
					RtnDateMemory=RtnDate.value;
					var URLPara="StartDate="+DptDate.value+"&EndDate="+RtnDate.value+""; 
					if(CapValue!=null && CapStardDate!=null && CapEndDate!=null)
					{
						URLPara+="&CapStartDate="+CapStardDate+"&CapEndDate="+CapEndDate;
					}					 
					document.getElementById("quickQuoteBookingHelper").src=quickQuoteBookingHelperScriptSrc+"?"+URLPara;
					//alert(document.getElementById("quickQuoteBookingHelper").src)
				}
				function quickQuoteStartCalculateMyQuote(Days)
				{
					if(Days=="")
					{
						alert("Not input founded");
						return false;
					}
					else if(Days=="EndDateTooShort")
					{
						alert("The date you have selected has already passed. Please choose a current date.");
						return false;
					}
					else if(Days=="EarlierThanToday")
					{
						alert("Either departure date or return date has already passed. Please select a valid date.");
						return false;
					}
					else if (Days=="OnlineBookingDisabled")
					{
						alert("Sorry the car park is full on one or all of the dates you have selected.\n\nTo avoid disappointment in the future please book well in advance of your departure date. Thank you.");
						return;
					}
					else
					{
						var txtQuote=document.getElementById("txtCalParkQuote"); 
						txtQuote.value=Days;
						document.getElementById("txtCalTotalQuote").value="";
						if(isFromQuickQuoteCalculateTotal)
						{
							QuickQuoteCalculateTotal();
						}
						if(ISGOTOSUBMIT)
						{
							QuickQuoteBookingMakeReservation();
						}	
					}
					
				}
				function quickQuoteStartCalculateMyQuote90(Days)
				{  
					if(Days=="")
					{
						alert("Not input founded");
						return;
					}
					else if(Days=="EndDateTooShort")
					{
						alert("The Return day can not bofore departure day");
						return;
					}
					else
					{   
					    totalDays=Days;
					    var txtQuote=document.getElementById("txtCalParkQuote"); 
						var quoateValue;
						//User only stay one day
						if(Days=="1")
						{
						   
							if(FirstDayValue!=null)
							{
							  quoateValue=FirstDayValue;
							 
							}
						}
						//User style more than one day
						else
						{
						    // if the client get period rate schema
						    if(PeriodRate!=null && PeriodRate.length>0)
						    {
								
								quoateValue=quickQuoteStartCalculatePeriodRate(Days);
						    }
						    // the client got not period rate schema
						    else
						    {
								// if the client got discount duration
								if(DefaultRateValueDuration!=null)
								{
								    DefaultRateValueDuration=parseInt(DefaultRateValueDuration);
									// Days not meet client duration requirment
									if(Days<DefaultRateValueDuration)
									{
										quoateValue=DefaultRateValue*Days;
									}
									else
									{
										var discountDay=Days-DefaultRateValueDuration;
										
										quoateValue=discountDay*DefaultRateValueAfterDuration+DefaultRateValue*DefaultRateValueDuration;
									}
								}
								// client event has not discount schema
								// then apply rate value
								else
								{
								         quoateValue=quoateValue=DefaultRateValue*Days;
								}
						    }
						}
						
						if(isCapPeriod)
						{ 
							if(quoateValue>CapValue)
							{
								txtQuote.value=CapValue;
								return;
							}
						}
						txtQuote.value=quoateValue;
						document.getElementById("txtCalTotalQuote").value="";
					}
				}
				function quickQuoteStartCalculatePeriodRate(Days){
				 
					var i;
					var quoteValue=0;
					var rate;
					for(i=0;i<PeriodRate.length;i++){
						rate=PeriodRate[i];
						   
							var rateDayspan;
							if(rate.SpanEndDay!=null){
							  rateDayspan=rate.SpanEndDay-rate.SpanStardDay+1;
							  if(Days>rateDayspan)
							  {
								quoteValue+=rate.RateValue*rateDayspan;
							    Days=Days-rateDayspan;	
							  }
							  else
							  {
							    quoteValue+=rate.RateValue*Days;
							    break;
							  }
							}
							else
							{
							   quoteValue+=rate.RateValue*Days;
							}
					}
					
					return quoteValue;
				}
				
				//  QuickQuoteCarWashServiceGetDivHeight get the actual height of customcontent_quickquote_booking_services.aspx
				function QuickQuoteCarWashSetDivHeight(trueHeight)
				{
				    
				    var ifr=document.getElementById("quickQuotequickQuotePopUpContainer");
					ifr.style.height=(trueHeight+50)+"px";
					ifr=document.getElementById("quickQuoteCalender");
					ifr.style.height=(trueHeight+30)+"px";					
				}
				//Set the car wash cost
				function QuickQuoteSelectCarWash(serviceName,serviceCost,servicesID)
				{
				    if(serviceCost=="0"){carServicesID=null; carServicesName=null;}
				    else{carServicesID=servicesID;carServicesName=serviceName;}
					document.getElementById("txtCalCarWashQuote").value=serviceCost;
					setTimeOutVar=false;
					document.getElementById("txtCalTotalQuote").value="";
					quickQuoteCloseCalendar();
					//QuickQuoteCalculateTotal();
				}
				function QuickQuoteCalculateTotal()
				{
					ISGOTOSUBMIT=false;
					 
					var parkQuote=document.getElementById("txtCalParkQuote").value;
					var washQuote=document.getElementById("txtCalCarWashQuote").value;
					var totalValue;
					//var DptDate=document.getElementById("txtDptDate").value;
					//var RtnDate=document.getElementById("txtRtnDate").value;
					if(parkQuote.length<1)
					{
						isFromQuickQuoteCalculateTotal=true; quickQuoteInitializeCalculateMyQuote();
						return;
					}
					if(washQuote.length>0)
					{
						totalValue=parseFloat(parkQuote)+parseFloat(washQuote);
					}
					else
					{
						totalValue=parkQuote;
					}
					document.getElementById("txtCalTotalQuote").value=totalValue;
				}
				//document.body.onclick=function()
				//{
				//	quickQuoteCloseCalendar();
				//}
				function QuickQuoteBookingMakeReservation()
				{ 
					  var URLPara;
					 var dptDate=QuickParkBookingGetValue("txtDptDate","T");
						 if(dptDate==false){ return;}
						 URLPara="dptDate="+dptDate;
						 
					 var rtnDate=QuickParkBookingGetValue("txtRtnDate","T");
						 if(rtnDate==false){ return;}  
						 URLPara+="&rtnDate="+rtnDate;
						 
					 var dptHour = QuickParkBookingGetValue("SltDptHour","S");
					     if(dptHour==false){ return;}
					     URLPara+="&dptHour="+dptHour;
					     
					 var dptMinute = QuickParkBookingGetValue("SltDptMinute","S");
					     
					     if(dptMinute!="00" && dptMinute==false){return;}
					     URLPara+="&dptMinute="+dptMinute;
					     
					 var rtnHour = QuickParkBookingGetValue("SltRtnHour","S");
					     if(rtnHour==false){ return;}
					     URLPara+="&rtnHour="+rtnHour;
					     
					 var rtnMinute = QuickParkBookingGetValue("SltRtnMinute","S");
					     if(rtnMinute==false && rtnMinute!="00"){return;}
					     URLPara+="&rtnMinute="+rtnMinute;
					 var carParkQuote=QuickParkBookingGetValue("txtCalParkQuote","T");
					     if(carParkQuote==false || carParkQuote==""){ISGOTOSUBMIT=true;if(quickQuoteInitializeCalculateMyQuote()==false){return;}return;}
					     URLPara+="&carParkQuote="+carParkQuote;
					 //check the customer has selected car wash services
					 var hasService=document.getElementById("txtCalCarWashQuote");
					 if(carServicesID!=null && hasService.value.length>0 && parseInt(hasService.value)>0 )
					 {
							URLPara+="&svcName="+carServicesName;
						    URLPara+="&svcCost="+hasService.value;
						    URLPara+="&svcID="+carServicesID;
					 }  
					 	 
					var	totalQuote=QuickParkBookingGetValue("txtCalTotalQuote","T");
					   
					    URLPara+="&totalQuote="+totalQuote;
					    URLPara+="&dptWeekDay="+dptWeekDay;
					    URLPara+="&rtnWeekDay="+rtnWeekDay;
					    URLPara+="&totalDays="+totalDays;
					    URLPara+="&ReturnURL="+document.location.href;
					    URLPara+="&RID="+RID;
					   
					    document.location.href=makeReservationScriptSrc+"?"+URLPara;
				}
				function QuickParkBookingGetValue(id,type)
				{
				    var result=false;
				    var obj=document.getElementById(id);
				    if(obj)
				    {
						if(type=="S")
						{
						      result=obj.options[obj.selectedIndex].text;
						}
						else if(type=="T")
						{
							  result=obj.value;
						}
						
				    }
				    return result;
					
				}