// JavaScript Document
$(function() {
	$("#exactOption").click(function(){
		switchView('#exact');
	});
	$("#weekendsOption").click(function(){
		switchView('#weekendsArea');
	});
	$("#availCalOption").click(function(){
		switchView('#availCal');
	}
	);
	$("#destCalOption").click(function(){
		switchView('#destCal');
	}
	);
		   //$.datepicker.setDefaults( {buttonImage: '/include/eresmodule/global/calendarIcon.gif', buttonImageOnly: true,showOn: 'both' ,numberOfMonths: 2,minDate:0}  )
		   	$("#checkOut1,#checkIn1").datepicker( {buttonImage: '/include/eresmodule/global/calendarIcon.gif', buttonImageOnly: true,showOn: 'both' ,numberOfMonths: 2,minDate:0}  );
			$("#checkOut1").datepicker({minDate:+1});
			$("#checkIn1").datepicker(
									  {onClose: function(dateText, inst) {
										  var newDate=new Date(dateText);
										  var newDatePlusOne=new Date(newDate);
										  var maxDate1=new Date(newDate);
										  maxDate1.setDate(newDate.getDate()+11);
										  newDatePlusOne.setDate(newDate.getDate()+1);
										  var newDatePlusOneVal= newDatePlusOne.getMonth()+1+"/"+newDatePlusOne.getDate()+"/"+newDatePlusOne.getFullYear();
										  $("#checkOut1").val(newDatePlusOneVal);
										  $("#checkOut1").datepicker('destroy'); 
										  $("#checkOut1").datepicker({minDate:newDatePlusOne,maxDate:maxDate1}); 
										  }
										  }
									  );
	//Mouseover effects for Buttons
    $("#calTool, #trainTool").hover(
      function() {
		  $("#"+$(this).attr("id")+"BigVersion").show();
          
      },
      function() {
          $("#"+$(this).attr("id")+"BigVersion").hide();
      }
    );
	function submitMakeResForm() {
		/*if(GetCookie("userSessionCookie") == "true") {
			var trNumber = GetCookieValue("accountId");
			if (trNumber &amp;&amp; trNumber != '') {
				document.CheckAvailabilityForm.primaryTRNumber.value = trNumber;
				document.CheckAvailabilityForm.loggedIn.value = 'Y';
			}
		}*/
		//set check in date
		var ciDate = $("#checkIn1").val();
		var ciVals = ciDate.split("/");
		$("#arrivalMonth").val(ciVals[0]);
		$("#arrivalDay").val(ciVals[1]);
		$("#arrivalYear").val(ciVals[2]);
		
		//set check out date
		var coDate = $("#checkOut1").val();
		var coVals = coDate.split("/");
		if (coVals[0].length == 1)
		{
			$("#departureMonth").val("0" + coVals[0]);
		}
		else
		{
			$("#departureMonth").val(coVals[0]);
		}
		if (coVals[1].length == 1)
		{
			$("#departureDay").val("0" + coVals[1]);
		}
		else
		{
			$("#departureDay").val(coVals[1]);
		}
		
		$("#departureYear").val(coVals[2]);
		$("#makeResForm").submit();
	}
	function submitWeekendForm() {
		//set days of weekend thing
		var startDay = $("#wkndCheckIn").val();
		var endDay = $("#wkndCheckOut").val();
		var differenceOfDays = endDay - startDay;
		$("#weekends").val(startDay+"|"+differenceOfDays);
		$("#checkWeekendForm").submit();
	}
	$("#normalBtn").click(function(){
		 submitMakeResForm();
		 });
	$("#weekendBtn").click(function(){
		 submitWeekendForm();
		 });
	
});
function switchView(divID) 
	{
		$("#weekendsArea").hide();
		$("#availCal").hide();
		$("#destCal").hide();
		$("#exact").hide();
		$(divID).show();
	}
	
	function showPreview(divID)
	{
		$(divID).show();
	}
	
	function hidePreview(divID)
	{
		$(divID).hide();
	}

	

