$(document).ready(function(){
	$("form").validate();
	$("input,textarea").focus(function(){
		$(this).addClass("focus");
	});
	$("input,textarea").blur(function(){
		$(this).removeClass("focus");
	});
	$("input,textarea,button").mouseover(function(){
		$(this).addClass("on");
	});
	$("input,textarea,button").mouseout(function(){
		$(this).removeClass("on");
	});
	jumpTo=function(whereTo){
		top.location.href="#"+whereTo;
	}
	changeReq=function(){
		var current,other;
		switch($(".newOrChg").attr("checked")){
			case true:current="new";other="chg";break;
			default:current="chg";other="new";break;
		}
		$("."+current+"Res").addClass("required");
		$("."+other+"Res").removeClass("required");
		$("#"+current+"Info .req").show();
		$("#"+other+"Info .req,#"+other+"Info label.error").hide();
	}
	changeReq();
	checkDateTime=function(){
		var isNew=$(".newOrChg").attr("checked");
		if(isNew){
			noc="new";
		}else{
			noc="chg";
		}
		var month=parseInt($("#"+noc+"ResDateM").val(),10);
		var day=parseInt($("#"+noc+"ResDateD").val(),10);
		var year=parseInt($("#"+noc+"ResDateY").val(),10);
		if(isNaN(month)||isNaN(day)||isNaN(year)){
			month=99;day=99;year=9999;
		}
		var timeStr="";
		var dateStr=month+"a"+day+"a"+year;
		var hour=parseInt($("#pickUpH").val(),10);
		var minute=$("#pickUpM").val();
		if(isNew){
			if(isNaN(hour)||minute==""){
				hour=99;minute=99;
			}
			if(hour>12||minute.length!=2||parseInt(minute,10)>59){
				alert("Please enter a valid 12 hour time format.");
			}
			var ampm;
			if($("#pickUpAMPM").attr("checked")==true){
				ampm="AM";
			}else{
				ampm="PM";
			}
			timeStr="&t="+hour+"a"+minute+"a"+"00b"+ampm;
		}
		$.post("/milwaukeeLimousineReservation2.asp?d="+dateStr+timeStr,function(get){
			if(get=="NaD"){
				alert("Please enter a valid date.");
			}else if(get<2880&&get>=0){
				alert("Your reservation is less than 48 hours. Please contact a reservation specialist at 414-761-8095.");	
			}else if(get<0){
				alert("Please enter a date in the future.");
			}else{
				$("#reservationForm").submit();
			}
		});
	}
	bldProTog=function(bool){
		switch($("#bldPro").attr("checked")){
			case true:$("#bldProTxt").show();break;
			default:$("#bldProTxt").hide();break;
		}
	}
	bldProTog();
	formReset=function(){
		document.forms[0].reset();
	}
});
