

                


                                                                                 
         
	  
	
		//var WordWheel = Class.create({
var WordWheel = function(){}

WordWheel.prototype = { 

	input : {},
	searchValue : "", type : "", dialect : "",
	maxDisplay : 9,
	ie6 : $.browser.msie && $.browser.version=="6.0",
	cachedData : [],
	hiddenInputs : ["HiddenEOAG","AutoFill","searchType","stateCode","countryCode","isServedBy"],
	query : function(location){
		var self = this;
		$.getJSON(htz.config.rootContext+"/reservation/gaq/templates/home/wordwheelRequest.jsp?searchText="+location+"&dialect="+self.dialect,
			function(response){
				if(response.locationList.length>0){
					self.draw(response.locationList);
					self.cachedData[response.searchText]=response.locationList;
					self.searchValue = response.searchText;
				}
				else{
					self.clear();
					self.prepare(null);
				}
			}
		);	
	}
	,
	handle : function(e){
		var self = this;
		var key = (e.charCode) ? e.charCode : ((e.keyCode) ? e.keyCode : ((e.which) ? e.which : 0));
		if(key==13){ self.select(); return; }
		if(key!=37 && key!=38 && key!=39 && key!=40){
			if(self.input.val().length>=3){
				if(self.cachedData[self.input.val()]==undefined) self.query(self.input.val());
				else {
					self.draw(self.cachedData[self.input.val()]);
					self.searchValue = self.input.val();
				}
			}
			else{
				self.clear();
				self.prepare(null);
			}
		}
	},
	shift : function(e){
		var self = this;
		var key = (e.charCode) ? e.charCode : ((e.keyCode) ? e.keyCode : ((e.which) ? e.which : 0));
		if($("#wordWheelResults").length && $("#wordWheelResults").css("visibility")=="visible"){
			if(key==38) self.move(0);				
			if(key==40) self.move(1);
		}
	},
	prepare : function(location){
		var self = this;
		var prefix = "inp"+self.type.charAt(0).toUpperCase()+self.type.substr(1);
		if(location){
			for(var key in location){
				if(key=="preferredOag"){
					if(location[key]!="null") $("#"+self.type+"HiddenEOAG").val(location[key]);
					else $("#"+self.type+"HiddenEOAG").val("");
				}
				if(location[key]!="null") $("#"+prefix+key.charAt(0).toUpperCase()+key.substr(1)).val(location[key]);
				else $("#"+prefix+key.charAt(0).toUpperCase()+key.substr(1)).val("");
			}
			$("#"+prefix+"AutoFill").val("Y");

			if(location.locationTitle!="null") self.input.val(location.locationTitle);
			else self.input.val(location.displayText);
		}
		else {
			for(var i=0; i<self.hiddenInputs.length;i++){
				if(self.hiddenInputs[i]=="HiddenEOAG") $("#"+self.type+"HiddenEOAG").val("");
				else $("#"+prefix+self.hiddenInputs[i].charAt(0).toUpperCase()+self.hiddenInputs[i].substr(1)).val("");
			}
		}
	},
	select : function(){
		var self = this;
		var selected = $("#wordWheelResults .wordWheelSelected");
		var location = null;
		if(selected.length && self.cachedData[self.searchValue]){
			for(var i=0;i<self.cachedData[self.searchValue].length;i++){
				var obj = self.cachedData[self.searchValue][i];
				if(obj.displayText == selected.text()) { 
					location = obj;
					break;
				}
			}
			self.prepare(location);
		}

		self.input.unbind('keyup keydown keypress blur').blur();	
		self.clear();
		setTimeout(function(){ self.set(); },1);
	},
	move : function(direction){
		var self = this;
		var results = $("#wordWheelResults");
		var selected = results.find(".wordWheelSelected");
		self.detach();
		
		if(direction==0){
			if(selected.length && selected.prev()!=null) selected.removeClass("wordWheelSelected").prev().addClass("wordWheelSelected");
			else results.find(":last").addClass("wordWheelSelected");
		}
		if(direction==1){
			if(selected.length && selected.next()!=null) selected.removeClass("wordWheelSelected").next().addClass("wordWheelSelected");			
			else results.find(":first").addClass("wordWheelSelected"); 
		}

		if(results.find(".wordWheelSelected").length) self.input.val(results.find(".wordWheelSelected").attr("name"));
		else self.input.val(self.searchValue);
		
		self.reposition(direction);

		if(self.ie6) setTimeout(function(){ self.attach(); },1);
		else self.attach();
	},
	reposition : function(direction){
		var results = $("#wordWheelResults");
		var selected = results.find(".wordWheelSelected");
		
		if(!selected.length) results.attr("scrollTop",0);
		else {
			if(direction==0){
				if(selected.position().top>=results.height()) results.attr("scrollTop",selected.position().top);
				else if(selected.position().top<0) results.attr("scrollTop",results.attr("scrollTop")-selected.outerHeight()); 
			}
			if(direction==1){
				if(selected.position().top>=results.height()) results.attr("scrollTop",selected.position().top-results.height()+selected.outerHeight()+results.attr("scrollTop"));
			}
		}
	},
	draw : function(list){	
		var self = this;
		var results = $("#wordWheelResults");
		self.clear();
		
		if(!results.length) results = $("<div>").attr("id","wordWheelResults").css("visibility","hidden").appendTo("body");
		
		for(var i=0; i<list.length;i++){
			var obj = list[i];
			$("<div>").text(obj.displayText).attr("name", obj.locationTitle!="null" ? obj.locationTitle : obj.displayText)
				.mouseover(function(){ $("#wordWheelResults .wordWheelSelected").removeClass(); $(this).addClass("wordWheelSelected"); })
				.click(function(){ self.select(); })
				.appendTo(results);
		}
		self.attach();
		
		if(list.length>=self.maxDisplay) results.css("height",results.find(":first").outerHeight()*self.maxDisplay);
		results.css({"top":self.input.offset().top+20,"left":self.input.offset().left,"visibility":"visible"});		

		if(self.ie6){
			if(!$("#wordWheelResultsIFrame").length) $("<iframe>").attr({"id":"wordWheelResultsIFrame","src":"javascript:false;"}).css("visibility","hidden").appendTo("body");
			$("#wordWheelResultsIFrame").css({"height":results.outerHeight(),"width":results.outerWidth(),"top":self.input.offset().top+self.input.outerHeight(),"left":self.input.offset().left,"visibility":"visible"});
		}
	},
	detach : function(){
		var results = $("#wordWheelResults");
		if(results.length) results.unbind().children().unbind();
	},
	attach : function(){
		var self = this;
		var results = $("#wordWheelResults");
		if(results.length){
			if(!$.browser.mozilla){
				results.mouseenter(function(){ self.input.unbind("blur").blur(function(){ self.input.focus(); }); })
					.mouseleave(function(){ self.input.unbind("blur").blur(function(){ self.select(); }); });
			}
			results.mousemove(function(){
				$(this).unbind('mousemove').children().unbind()
					.mouseover(function(){ $("#wordWheelResults .wordWheelSelected").removeClass(); $(this).addClass("wordWheelSelected"); })
					.click(function(){ self.select(); });	
			});			
		}
	},
	clear : function(){
		var self = this;
 		if($("#wordWheelResults").length) $("#wordWheelResults").css({"height":"auto","visibility":"hidden"}).children().remove();
		if(self.ie6 && $("#wordWheelResultsIFrame").length) $("#wordWheelResultsIFrame").css("visibility","hidden");
		self.searchValue = "";				
	},
	set : function(){
		var self = this;
      	self.input.unbind('keyup keydown keypress blur')
      		.keyup(function(event){ self.handle(event); })
       		.keydown(function(event){ self.shift(event); })
       		.keypress(function(event){ return (event.keyCode != 13); })
			.blur(function(){ self.select(); });
	},
	init : function(input){
		var self = this;
		self.input = input;
		self.dialet = htz.config.dialect;
		
		if(self.input.attr("id")=="pickupLocation") self.type = "pickup";
		if(self.input.attr("id")=="dropoffLocation") self.type = "dropoff";

		self.set();
	}
};
//});

		
var Calendar = {
	maxCells : 49, euroTime : false, endDate : false, inputStart : {}, inputEnd : {}, start : {}, end : {}, endHighlighted : false, today : new Date(),
	ie6 : $.browser.msie && $.browser.version=="6.0",	
	show : function(start,useEuroTime){
		this.euroTime = useEuroTime;
		this.start = this.createDate(start.val());
		this.end = this.start;
		this.inputStart = start;
		this.inputEnd = start;
		this.endDate = false;
		this.create(this.start);
	},
	showStart : function(start,end,useEuroTime){
		this.euroTime = useEuroTime;
		this.start = this.createDate(start.val());
		this.end = this.createDate(end.val());
		this.inputStart = start;
		this.inputEnd = end;
		this.endDate = false;
		this.create(this.start);
	},
	showEnd : function(end,start,useEuroTime){
		this.euroTime = useEuroTime;
		this.start = this.createDate(start.val());
		this.end = this.createDate(end.val());
		this.inputStart = end;
		this.inputEnd = start;
		this.endDate = true;
		if(Calendar.compare(this.end,Calendar.today)==1) this.create(this.end);
		else this.create(this.start);
	},
	createDate : function(dateStr){
		if(dateStr.length==0) return this.today;
		else {
			var dateParts = dateStr.split("/");
			return newDate = this.euroTime ? new Date(dateParts[2],dateParts[1]-1,dateParts[0]) : new Date(dateParts[2],dateParts[0]-1,dateParts[1]);
		}
	},
	create : function(input){
		if(!$('#globalCalendar').length) {
			var calendar = $("<div>").attr("id","globalCalendar");
			var monthContainer = $("<div>").attr("class","globalCalendarMonthContainer");
			var monthDivider = $("<div>").attr("id","globalCalendarMonthDivider");
			var monthHeader = $("<div>").attr("class","globalCalendarMonthHeader");
			var closeContainer = $("<div>").attr("id","globalCalendarCloseContainer");
			var closeButton = $("<div>").attr("id","globalCalendarCloseButton").text(htz.calendar.content.closeText);
			var clostImage = $("<div>").attr("id","globalCalendarCloseImage");						
			var monthDays = '<div class="globalCalendarDay">';
			for(var i=0;i<this.maxCells;i++) monthDays += '<div></div>';
			monthDays += '</div>';
			monthDays = $(monthDays);
						
			monthHeader.appendTo(monthContainer);
			monthDays.appendTo(monthContainer);
			monthDivider.appendTo(calendar);
			monthContainer.appendTo(calendar);
			monthContainer.clone().prependTo(calendar);
			clostImage.appendTo(closeContainer);
			closeButton.appendTo(closeContainer);
			closeContainer.appendTo(monthContainer);
			calendar.appendTo("body");
			
			if(this.ie6 && !$("#globalCalendarIFrame").length) $("<iframe>").attr("id","globalCalendarIFrame").attr("src","javascript:false;").hide().appendTo("body");
		}
		$("#globalCalendar").hide();
		this.draw(input);
		this.toggle();		
	},
	draw : function(date){
		var todayMonth = this.today.getMonth();
		var todayYear = this.today.getFullYear();
		var currentMonth = date.getMonth();
		var currentYear = date.getFullYear();

		if(currentMonth==todayMonth && currentYear==todayYear+1) {
			currentYear = currentMonth > 0 ? currentYear : currentYear - 1;			
			currentMonth = currentMonth > 0 ? currentMonth - 1 : currentMonth = 11;
		}

		var nextMonth = currentMonth < 11 ? currentMonth + 1 : 0;
		var nextMonthYear = currentMonth < 11 ? currentYear : currentYear + 1;		
		var previousMonth = currentMonth > 0 ? currentMonth - 1 : 11;
		var previousMonthYear = currentMonth > 0 ? currentYear : currentYear - 1;	
		var monthContainer = $("#globalCalendar .globalCalendarDay");
		var monthHeaderContainer = $("#globalCalendar .globalCalendarMonthHeader");
		$(monthHeaderContainer[0]).children().each(function(){ $(this).remove(); });
		$(monthHeaderContainer[1]).children().each(function(){ $(this).remove(); });		
		$("<div>").attr("class","globalCalendarMonth").text(htz.calendar.monthNames[currentMonth]+" "+currentYear).appendTo(monthHeaderContainer[0]);
		$("<div>").attr("class","globalCalendarMonth").text(htz.calendar.monthNames[nextMonth]+" "+nextMonthYear).appendTo(monthHeaderContainer[1]);
		
		if((currentMonth>todayMonth && todayYear==currentYear) || (currentYear==todayYear+1)){
			var leftArrow = $("<div>").attr("id","globalCalendarLeftArrow");
			leftArrow.appendTo($(monthHeaderContainer[0]));
			leftArrow.click(function(){ Calendar.draw(new Date(previousMonthYear,previousMonth,1)); });				
		}
		if((todayMonth==0 && currentMonth!=11) || (todayMonth!=0 && ((currentMonth<todayMonth-1 && currentYear==todayYear+1) || (currentYear==todayYear)))){
			var rightArrow = $("<div>").attr("id","globalCalendarRightArrow");
			rightArrow.appendTo($(monthHeaderContainer[1]));
			rightArrow.click(function(){ Calendar.draw(new Date(nextMonthYear,nextMonth,1)); });						
		}	

		$("#globalCalendarCloseContainer").unbind().click(function(){ Calendar.toggle(); });	
		this.createDays(currentYear,currentMonth,monthContainer[0]);
		this.createDays(nextMonthYear,nextMonth,monthContainer[1]);
	},
	toggle : function(){
		var cal = $("#globalCalendar");
		if(cal.css("display")=='block') {
			if(this.ie6) $("#globalCalendarIFrame").hide();
			cal.hide();
		}
		else {
			cal.show().css("top",this.inputStart.offset().top+this.inputStart.height()+6).css("left",this.inputStart.offset().left);
			if(this.ie6) $("#globalCalendarIFrame").css({"top":cal.offset().top,"left":cal.offset().left,"height":cal.outerHeight(),"width":cal.outerWidth()}).show();
		}
	},
	createDays : function(year,month,monthContainer){
		var numberOfDays = this.getMonthDays(month,year);
		var leadingDateObj = new Date(year,month,1);
		var leadingDays = leadingDateObj.getDay();
		var days = $(monthContainer).children();
		
		days.slice(0,7).each(function(i){ $(this).text(htz.calendar.dayHeaders[i]).removeClass().addClass("globalCalendarDayCellHeader"); });
		days.slice(7,7+leadingDays).each(function(){ $(this).text("").removeClass().unbind(); });			
		days.slice(7+leadingDays,7+leadingDays+numberOfDays).each(function(day){
			day++;
			var highlight = false;
			
			$(this).text(day).removeClass().unbind();
			if(day<Calendar.today.getDate() && month==Calendar.today.getMonth() && year==Calendar.today.getFullYear()) $(this).addClass("globalCalendarDayPassedCell");
			else {
				if((!Calendar.endDate && day==Calendar.start.getDate() && month==Calendar.start.getMonth() && year==Calendar.start.getFullYear())){
					highlight = true;
				}
				else {
					if(Calendar.endDate && day==Calendar.end.getDate() && month==Calendar.end.getMonth() && year==Calendar.end.getFullYear()){
						highlight = true;
					}
					if(Calendar.endDate && Calendar.inputEnd.val().length!=0 && Calendar.inputStart.val().length==0 && day==Calendar.start.getDate() && month==Calendar.start.getMonth() && year==Calendar.start.getFullYear()){
						highlight = true;
					}
				}
				
				if(highlight) $(this).addClass("globalCalendarDaySelectedCell");
				else {
					$(this).mouseover(function(e){
						$(this).removeClass().addClass("globalCalendarDayHoverCell");
					}).mouseout(function(e){ $(this).removeClass(); });
				}
				
				$(this).click(function(){
					var dateStr = Calendar.euroTime ? Calendar.formatDayMonth($(this).html())+"/"+Calendar.formatDayMonth(month+1)+"/"+year : Calendar.formatDayMonth(month+1)+"/"+Calendar.formatDayMonth($(this).html())+"/"+year;
					if(Calendar.endDate && Calendar.compare(Calendar.createDate(dateStr),Calendar.start)==-1){
						alert(htz.calendar.content.returnBeforePickup);
					}
					else{
						if(!Calendar.endDate && Calendar.inputEnd.val()!="" && Calendar.compare(Calendar.createDate(dateStr),Calendar.end)>=0){
							var newEndDate = day==Calendar.getMonthDays(month,year) && month==Calendar.today.getMonth() && year==Calendar.today.getFullYear()+1 ? new Date(year,month,day) : new Date(new Date(year,month,day).getTime()+86400000);
							var endDateStr = Calendar.euroTime ? Calendar.formatDayMonth(newEndDate.getDate())+"/"+Calendar.formatDayMonth(newEndDate.getMonth()+1)+"/"+newEndDate.getFullYear() : Calendar.formatDayMonth(newEndDate.getMonth()+1)+"/"+Calendar.formatDayMonth(newEndDate.getDate())+"/"+newEndDate.getFullYear();
							Calendar.inputEnd.val(endDateStr);
						}
						Calendar.inputStart.val(dateStr);
						$("#globalCalendarCloseContainer").click();
					}
				});
			}
		});
		days.slice(7+leadingDays+numberOfDays,Calendar.maxCells).text("").removeClass().unbind();
	},	
	formatDayMonth : function(str){
		return str.toString().length==1 ? "0"+str : str;
	},
	monthDays : [31,28,31,30,31,30,31,31,30,31,30,31],
	getMonthDays : function(month,year){
		if(month==1){
			if(new Date(year,1,29).getDate()== 29) return 29;
			else return this.monthDays[month];
		} else return this.monthDays[month];
	},
	compare : function(date1,date2){
		date1 = new Date(date1.getFullYear(),date1.getMonth(),date1.getDate());
		date2 = new Date(date2.getFullYear(),date2.getMonth(),date2.getDate());	
		if(date1.getTime()==date2.getTime()) return 0;
		else {
			if(date1.getTime()<date2.getTime()) return -1;
			else return 1;
		}
	}
}	



	 	
		var Clock = {
	militaryTime : false,
	minutes : [0,15,30,45],
	init : function(pickupHour,pickupMin,dropoffHour,dropoffMin,useMilitaryTime){
		this.militaryTime = useMilitaryTime;
		$("#pickupHourContainer").html(this.drawHour(pickupHour).attr("id","pickupHour").attr("name","pickupHour"));
		$("#pickupMinuteContainer").html(this.drawMin(pickupMin).attr("id","pickupMinute").attr("name","pickupMinute"));
		$("#dropoffHourContainer").html(this.drawHour(dropoffHour).attr("id","dropoffHour").attr("name","dropoffHour"));
		$("#dropoffMinuteContainer").html(this.drawMin(dropoffMin).attr("id","dropoffMinute").attr("name","dropoffMinute"));
	},
	format : function(str){
		return str = str.toString().length==1 ? "0"+str : str;
	},
	drawHour : function(hour){
		var select = $("<select></select>");
		var options = "";
		if(this.militaryTime) {
			for(var i=0;i<24;i++) {
				if(hour==i) options += '<option selected="selected" value="'+i+'">'+this.format(i)+'</option>';
				else options += '<option value="'+i+'">'+this.format(i)+'</option>'; 
			}
		}
		else {
			for(var i=1;i<12;i++) {
				if(hour==i) options += '<option selected="selected" value="'+i+'">'+this.format(i)+' AM</option>';
				else options += '<option value="'+i+'">'+this.format(i)+' AM</option>';
			}

			if(hour==12) options += '<option selected="selected" value="12">12 Noon</option>';
			else options += '<option value="12">12 Noon</option>';

			for(var j=1;j<12;j++) {
				i++;
				if(hour==i) options += '<option selected="selected" value="'+i+'">'+this.format(j)+' PM</option>';
				else options += '<option value="'+i+'">'+this.format(j)+' PM</option>';
			}		
			
			if(hour==0) options += '<option selected="selected" value="0">12 Midnight</option>';
			else options += '<option value="0">12 Midnight</option>';
		}
		$(options).appendTo(select);
		return select;
	},
	drawMin : function(min){
		var select = $("<select></select>");
		var options = "";
		for(var i=0;i<4;i++){
			if(min==this.minutes[i]) options += '<option selected="selected" value="'+this.minutes[i]+'">:'+this.format(this.minutes[i])+'</option>';
			else options += '<option value="'+this.minutes[i]+'">:'+this.format(this.minutes[i])+'</option>';
		}
		$(options).appendTo(select);
		return select;
	}	
}


		
var ToolTip = (function() {

	return {
		
		loserwin:null,
		
		show: function (e) {
	
//			if (this.loserWin) this.loserwin.close()
//			this.loserwin = window.open(e.target.lang, "loserWindow", "location=0,status=0,width=400,height=400" ); 
//			this.loserwin.focus()
//			return;

			if (typeof lightBox != "function") return;
			lightBoxTT = new lightBox()
		  lightBoxTT.reset()
		  lightBoxTT.parms.url = e.target.lang
		  lightBoxTT.parms.screen = 20
		  lightBoxTT.parms.scroll = "false";    
		  lightBoxTT.parms.center = "false";     
		  lightBoxTT.parms.top = e.pageY
		  lightBoxTT.parms.left = e.pageX
		  lightBoxTT.init()    
			lightBoxTT.jspRequest();  
		
		}		
		
	}

})();
	
		var HomePage = (function() {

	var homePageAdsLoad = { cache: true, dataType: 'html', success: function(data) { $('#homePageBannerAdContainer').html(data); }};
	homePageAdsLoad.url = htz.config.rootContext + '/reservation/gaq/templates/home/reservationOnHomepageAds.jsp';
	LazyLoad.queueJS(homePageAdsLoad, 'high');
	
	$(document).ready(function() {
		Clock.init(htz.clock.pickupHour, htz.clock.pickupMin, htz.clock.dropoffHour, htz.clock.dropoffMin, htz.clock.useMilitaryTime);
		
		$("#pickupDay")
			.focus(function(){ $(this).blur(); })
			.click(function(){ Calendar.showStart($(this),$("#dropoffDay"),htz.calendar.flags.militaryClock); });
			
		$("#dropoffDay")
			.focus(function(){ $(this).blur(); })
			.click(function(){ Calendar.showEnd($(this),$("#pickupDay"),htz.calendar.flags.militaryClock); });	
	
		$(".wordWheelInput").each(function(){ 
			new WordWheel().init($(this));
		});
		
		// To handle DnC
		if(htz.homepage.jsflag.isDnCAvailable){
			$("#pickupLocation").keydown(function(){HomePage.setDandCChangedValue('isDeliveryChanged',htz.homepage.jsdata.pkLocation,'Y',$("#pickupLocation")[0]);})
								.change(function(){HomePage.setDandCChangedValue('isDeliveryChanged',htz.homepage.jsdata.pkLocation,'Y',$("#pickupLocation")[0]);});
			
			$("#dropoffLocation").keydown(function(){HomePage.setDandCChangedValue('isCollectChanged',htz.homepage.jsdata.drLocation,'Y',$("#dropoffLocation")[0]);})
								.change(function(){HomePage.setDandCChangedValue('isCollectChanged',htz.homepage.jsdata.drLocation,'Y',$("#dropoffLocation")[0]);});
		}
	

	});
	
	/* Copied the functions to submit home page , will refactor the code/functions after functionality is working. - KM */
	
	validateResLocations = function(){
		if(htz.homepage.jsflag.isDropDownLocation)
			return validateDropDownLocations();
		
		return true;
	};
	
	validateResDates = function(){
		with(document.resForm){
			if($.trim(pickupDay.value).length == 0){
				alert(htz.homepage.jscontent.choosePickDate);
				return false;
			}
			if($.trim(dropoffDay.value).length == 0){
				alert(htz.homepage.jscontent.chooseReturnDate);
				return false;
			}
		}
		return true;
	};
	
	handleFTSSubmit = function(){
		with(document.resForm){
			if($.trim(wasFormSubmitted.value) == 'true'){
				continueButton.value = 'continue'; 
		 		submit();
			}
	    }
 	};

	validateArrivalInformation = function(){
		var formVar = document.resForm;
		
		if(formVar.arrivingInfoRadioButton){
			if(!$.isArray(formVar.arrivingInfoRadioButton) || formVar.arrivingInfoRadioButton[2].checked){
				if($.trim(formVar.selectedAirline.value).length == 0){
					alert(htz.homepage.jscontent.arrivalOptionError);
					return false;
				}
				return true;
			}
		
			if(!formVar.arrivingInfoRadioButton[0].checked && !formVar.arrivingInfoRadioButton[1].checked && !formVar.arrivingInfoRadioButton[2].checked)
			{
				alert(htz.homepage.jscontent.arrivalInfoError);
				return false;
			}
		}
		return true;
	};
	
	determineOverallFormSubmission = function() {
		document.resForm.continueButton.value = 'continue';
		document.resForm.submit()	
	}	
	
	handleServedBy = function() {
		if(!htz.homepage.jsflag.isDropDownLocation){	
			if($('#inpPickupIsServedBy').val() == 'Y') {
				window.open(htz.config.rootContext+'/fts/'+htz.config.dialect+'/fullTextSearchHomepageServedByTab.jsp?oag=' + $('#pickupHiddenEOAG').val() + '&locType=pUp','resWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=350,height=400').focus();
				return false;
			}
			if($('#inpDropoffIsServedBy').val() == 'Y') {
				alert(htz.homepage.jscontent.cannotReturn);
				return false;
			}
		}
		return true;
	};
	
	populateLocation  = function (locationList){
		var pickCountry = $("#pickupCountry");
		var pickLocation = $("#pickupLocation");
		var dropLocation = $("#dropoffLocation");	
		
		pickCountry.attr("disabled", false);
		pickLocation.empty();
		dropLocation.empty();			
		if(locationList.nvplist.length <= 1){		
			locationList.nvplist[0].name = htz.homepage.jscontent.selectAnotherCountry;
		} else {
			locationList.nvplist[0].name = htz.homepage.jscontent.selectALocation;
		}
		
		optionList = "";
		for(i=0; i<locationList.nvplist.length; i++){
			optionList +="<option value='"+locationList.nvplist[i].value+"'>"+locationList.nvplist[i].name+"</option>";
		}
		pickLocation.html(optionList);
		dropLocation.html(optionList);
		
	};
	
	resetSelections = function (){
		$("#pickupCountry").attr("disabled", false);
		$("#pickupLocation").empty().append($('<option>').text(htz.homepage.jscontent.selectCountry).val(""));
		$("#dropoffLocation").empty().append($('<option>').text(htz.homepage.jscontent.selectCountry).val(""));
	};
	
	validateDropDownLocations = function(){
		var pickupCountry = $("#pickupCountry");
		var pickupLocation = $("#pickupLocation");
		var resCheckBox = $("#oneWayTripCheckBox");
		var dropoffLocation = $("#dropoffLocation");	
		
		if(($.trim(pickupCountry.val())).length == 0 || ($.trim(pickupLocation.val())).length == 0){
			if(($.trim(pickupCountry.val())).length == 0){
				alert(htz.homepage.jscontent.selectCountry);
				pickupCountry.focus();
			} else {
				alert(htz.homepage.jscontent.selectPickupLoc);			
				pickupLocation.focus();
			}
			return false;			
		}
		
		if(resCheckBox.attr("checked")){
			if(($.trim(dropoffLocation.val())).length == 0){
				alert(htz.homepage.jscontent.selectDropoffLoc);
				dropoffLocation.focus();
				return false;
			}
		}
	
		return true;
	};
	 
	handleDropDownSubmit = function(){
		with(document.resForm){ 
			pickupHiddenEOAG.value = pickupLocation.value;
			var index = pickupLocation.selectedIndex;
			pickupLocation.options[index].value = pickupLocation.options[index].text;
			
			if(returnAtDifferentLocationCheckbox.checked){
				dropoffHiddenEOAG.value = dropoffLocation.value;
                var index = dropoffLocation.selectedIndex;
				dropoffLocation.options[index].value = dropoffLocation.options[index].text;
			} else 
				dropoffHiddenEOAG.value = "";
		   
		   continueButton.value = 'continue';
		   submit();
	   }		
	};
 	
	return {
		toggleTabs: function(cN) {
			$('#homeResFormTabs').removeClass().addClass(cN);				
		},
		
		openDandC : function (url,isLoginRequired){
			if(!isLoginRequired)
				window.open(url,'resWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=300,height=425').focus();
			else		
				document.location.href = url;			
		},
		
		setDandCChangedValue : function (id, originalLocationValue, flagValue, element){	
			if(element.value != originalLocationValue)
				$("#"+id).val(flagValue);
		    return true;
		},
		
		showOneWayTrip : function (){
			if($('#oneWayTripCheckBox').attr("checked"))
				$('#rtnLocationSec').show();
			else {
				$('#rtnLocationSec').hide();
				$('#inpDropoffIsServedBy').val('');
				$('#dropoffLocation').val('');
				$('#dropoffHiddenEOAG').val('');
			}
		},
		
		openLinkInPopup : function (url, width, height) {
			if(!width) width = 500;
			if(!height) height = 500;
			window.open(url,'resWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height).focus();
		},
		
		handleFormSubmit : function(){
			
			// pickup and dropoff location
			if(!validateResLocations()) return;
			
			// pickup and dropoff dates
			if(!validateResDates()) return;
			
			//arrival information
			if (!validateArrivalInformation()) return;
			
			//served by information
			if(!handleServedBy()) return;
			 
			// submit form
			if(htz.homepage.jsflag.isDropDownLocation){	
				handleDropDownSubmit();
			} else {
				document.resForm.wasFormSubmitted.value = "true";
				handleFTSSubmit();
			}
		},
		
		toggleAffiliations : function(obj){
			if(obj != null && obj.checked) $('#affiliationsSection').show();
			else $('#affiliationsSection').hide();
		},
		
		toggleCorpDependentFields : function (obj) {
			with(document.resForm){
				if(obj.checked) { 
					$('#RQCVITSection').hide(); 
					
					if(!htz.homepage.jsflag.showPCField)
					    $('#PCSection').hide();
					
					if($.trim(cdpField.value).length > 0 && $('#cdpOptions').size() > 0) {
						corporateRate.checked = true;
						officialTravel.checked = true;
						$('#cdpOptions').show();
					}
					corpCustomer.value = "Y";
				} else {
					$('#RQCVITSection').show(); 
					$('#PCSection').show();
					if($('#cdpOptions').size() > 0){
						$('#cdpOptions').hide();
						corporateRate.checked = false;
						officialTravel.checked = false;
					}
					corpCustomer.value = "N";
				}
			}
		},
		
		showCDPOptions : function (){ 
			with(document.resForm){
				var cdpOption = $('#cdpOptions').size() > 0 ? $('#cdpOptions').get(0) : null;
				if(cdpOption == null) return;
				if($.trim(cdpField.value).length > 0){
					if(typeof corpCustCheckBoxFE != "undefined") {
						if(corpCustCheckBoxFE.checked){
							corporateRate.checked = true;
							officialTravel.checked = true;
							cdpOption.style.display = "block";
						}
					} else {
						cdpOption.style.display = "block";
					}
			    } else {
			    	cdpOption.style.display = "none";
			    	if(typeof corporateRate != "undefined")
						corporateRate.checked = false;
					if(typeof officialTravel != "undefined")
						officialTravel.checked = false;
				}
			}
		},
		
		highlightRow : function (element,trId) {
			if($.trim(element.value).length == 0) {
				$("#"+trId).removeClass('homeValidDisctountCode');
			} else {
				$("#"+trId).addClass('homeValidDisctountCode');
			}
		},
		
		showCdpRqWarning : function (){
			with (document.resForm){
				if(corporateRate.checked)
					if(typeInRateQuote.value != "" && !($('#corpCustCheckBoxFE').size() > 0 && $('#corpCustCheckBoxFE').attr("checked")))
						alert(htz.homepage.jscontent.cdprqError);
			}
		},
		
		arrivalRadioButton : function () {
			$("#arrivalDropDownRadio").attr("checked", true);
		},
		
		determineOverallFormSubmission : function (){
			handleFTSSubmit();
		},
		
		findRes : function (x){
			if(typeof(x)=="object")	{ 
				$("#confirmationNumber").val(x.innerHTML)
				$("#confirmationNumber").css(	{ 'color' : 'white' } ) 
				}
	 		document.resModifyForm.submit();
	 	},		 
		
	 	
	 	handlePickCountrySelection : function(url){
			var pickCountry = $("#pickupCountry");
			if(pickCountry.attr("selectedIndex") > 0){
				pickCountry.attr("disabled", true);
				url+="?countrySelection="+pickCountry.val();
				$("#pickupLocation").empty().append($('<option>').text(htz.homepage.jscontent.loadingText).val(""));
				$.getJSON(url , function (data){ populateLocation(data);});
			} else 
			  resetSelections();
		},
		
		reloadDropoffLocation : function(){
			var pickLocation = $("#pickupLocation");
			var dropLocation = $("#dropoffLocation");	
			
			dropLocation.empty();
			pickLocation = pickLocation[0];
			dropLocation = dropLocation[0]; 
			
			if(pickLocation.value != "" && pickLocation.value != null){
				for(i = 0; i < pickLocation.options.length ; i++){
					if(pickLocation.options[i].value != pickLocation.value){
						dropLocation.options[dropLocation.options.length] = new Option(pickLocation.options[i].text,pickLocation.options[i].value);
					}
				}
				if($("#oneWayTripCheckBox").attr("checked")) dropLocation.focus();		
			} else {
				for(i = 0 ; i < pickLocation.options.length ; i++){
					dropLocation.options[i] = new Option(pickLocation.options[i].text,pickLocation.options[i].value);
				}
			}
		}	
		
	}
})();




	
       
                                                                                                                  
                                                                                                  