<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=400');");
}
// End -->

function moveForm(){
	var resform = document.getElementById('resForm').innerHTML;
	document.getElementById('resForm').innerHTML = '';
	document.getElementById('resFormContainer').innerHTML = resform;
	$(function() {
	var dates = $('#pickupDate, #returnDate').datepicker({
		duration: jQuery.support.boxModel ? 'normal' : '',
		showOn: 'both',
		showAnim: 'slideDown',
		buttonImage: 'images/icon_calendar.jpg',
		buttonImageOnly: true,
		changeMonth: true,
		numberOfMonths: 2,
		minDate: 0,
		onSelect: function(selectedDate) {
			var option = this.id == "pickupDate" ? "minDate" : "";
			var instance = $(this).data("datepicker");
			
			var pick = $("#pickupDate").val();
			var drop = $("#returnDate").val();
			var pick = new Date(pick);
			var drop = new Date(drop);
			
			if(this.id == 'pickupDate' && pick >= drop){
			var dateString = selectedDate;
			var myDate = new Date(dateString);
			myDate.setDate(myDate.getDate()+1);
			var dateString = (myDate.getMonth()+1) + '/' + myDate.getDate() + '/' + myDate.getFullYear();
			//selectedDate = dateString;
			$("#returnDate").val(dateString);
			}
			
			var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
			dates.not(this).datepicker("option", option, date);
		}
		});
	});
	var puDate = new Date();
	var doDate = new Date();
	puDate.setDate(puDate.getDate()+1);
	doDate.setDate(doDate.getDate()+2);
	var puDate =(puDate.getMonth()+1) + '/' + puDate.getDate() + '/' + puDate.getFullYear();
	var doDate =(doDate.getMonth()+1) + '/' + (doDate.getDate()) + '/' + doDate.getFullYear();
	$("#pickupDate").val(puDate);
	$("#returnDate").val(doDate);
	
	$("#pickupDate").keydown(function() {return false;});
	$("#returnDate").keydown(function() {return false;});
	$("#pickupDate").keypress(function() {return false;});
	$("#returnDate").keypress(function() {return false;});
	promobox();

}
function showHide(checked){
	//alert(checked);
	var resheight = parseFloat(document.getElementById('resFormContainer').style.height);
	if(checked == false){
		document.getElementById('sameLocation').value = false;
		document.getElementById('checkboxValue').value = false;
		document.getElementById('returnLocation').style.display = 'block';
		document.getElementById('resFormContainer').style.height = (resheight + 40) + 'px';
		//alert(document.getElementById('sameLocation').value);
	}
	if(checked == true){
		document.getElementById('sameLocation').value = true;
		document.getElementById('checkboxValue').value = true;
		document.getElementById('returnLocation').style.display = 'none';
		document.getElementById('resFormContainer').style.height = (resheight - 40) + 'px';
		//alert(document.getElementById('sameLocation').value);
	}
}

function showInfo(pos){
	document.getElementById('locationInfo'+pos).style.display = 'block';
}
function hideInfo(pos){
	document.getElementById('locationInfo'+pos).style.display = 'none';
}
function showCouponField(){
	var resheight = parseFloat(document.getElementById('resFormContainer').style.height);
	document.getElementById('resFormContainer').style.height = (resheight + 20) + 'px';
	document.getElementById('couponLink').style.display = 'none';
	document.getElementById('couponField').style.display = 'block';
}

function setLocation(loc){
	document.getElementById('airport_location').value = loc;
	document.getElementById('airport_location').style.background = "#f5f356"
	document.getElementById('airport_location').style.borderTop = "1px #acaeb4 solid";
	document.getElementById('airport_location').style.borderLeft = "1px #dde1e7 solid";
	document.getElementById('airport_location').style.borderRight = "1px #dde1e7 solid";
	document.getElementById('airport_location').style.borderBottom = "2px #f1f4f7 solid";
	document.getElementById('airport_location').onkeyup = function(){
		if(document.getElementById('airport_location').value == ''){
			document.getElementById('airport_location').style.background = "#ffffff";
			
		}
	}
}
function setAWD(){
	var AWDval = document.getElementById('AWD_Field').value;
	if(AWDval != '') document.getElementById('AWD_NUMBER').value = AWDval;
	//if(document.getElementById('pickupKeywordValue').value != '') 
}

setReferrerCookie();

//set the cookie
function setcookie(name,value)
{
	cookiestring=name+"="+escape(value)+";path=/";
    document.cookie=cookiestring;
}

//set the referrer cookie
function setReferrerCookie() {
	var referer =document.referrer;
	if(referer !=null && referer.length > 0)
	{
        setcookie("SEARCH_REFERER",referer);
	}
}

function promobox() {
	if($('.content:first').parent().css('width') == "740px") {
		$('.content:first').parent().css('width', 'auto');
	}
	var loc_ct = $('.nearbyContainer').length;
	$('#resFormContainer').css('float', 'right');
	$('#resFormContainer').css('margin-right', '20px');

	if(loc_ct >= 3 || $('.mainCarImage').length == 1) {
		//USE FULL BANNER
		$('#resFormContainer').after('<div style="float:left; width:708px; padding:20px 20px 10px 20px; text-align:center;"><div style="width:708px"><a href="http://www.avis.com/car-rental/content/small-medium-business.ac?navId=T4M04S01&partnerId=1127" style="text-decoration:none; color:#FFF;"><img style="float:none;"  src="http://www.avis.com/car-rental/html/landing/images/small-business-banner-708x90.gif" alt="Click to check out Avis Corporate Awards Program" title="Click to check out Avis Corporate Awards Program"></a></div></div>');
		$('#banner_promobox_wide').hide();
	} else {
		//USE WIDE BANNER
		$('#resFormContainer').after('<div style="float:left; text-align:center; width:387px; padding:20px 20px 10px 20px; margin-left:20px;"><div style="width:325px; background:#EB2822; margin-left:31px;"><a href="http://www.avis.com/car-rental/content/small-medium-business.ac?navId=T4M04S01&partnerId=1127" style="text-decoration:none; color:#FFF;">Small or Mid-Size Business?<br><img style="float:none;"  src="http://www.avis.com/car-rental/html/landing/images/325x95_CorpAwardsLogoCar_1a.gif" alt="Click to check out Avis Corporate Awards Program" title="Click to check out Avis Corporate Awards Program"><br>Enroll for free to receive special corporate rates.</a></div></div>');
		$('#banner_promobox_full').hide();
	}
}
