// JavaScript Document

$(document).ready(function(){

		//mask click hide mask and reservation box	
		$("#maskHome").click(function(){	
										 
			$("#reservationNameDiv").fadeOut('slow');
			$("#maskHome").fadeOut('slow');
											  
		});
		

		
}); //document ready

function hideMask(){
	
	$("#reservationNameDiv").fadeOut('slow');
	$("#maskHome").fadeOut('slow');
}

//Reservation Validation
function validateReservation(){
	var date1 = document.getElementById("hotelCheckIn") ;	
	var date2 = document.getElementById("hotelCheckOut") ;	
	var roomtype = document.getElementById("idHotelRoomType") ;	
	if ( date1.value == '' ) { alert('Invalid Start Date') ; return false; }
	if ( date2.value == '' ) { alert('Invalid End Date') ; return false; }
	if ( roomtype.value == '--Choose a Room Type--' ) { alert('Choose a room type.') ; return false; }
	
	//lightbox effect for div to ask for Name and Email Address
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		
		//Set heigth and width to mask to fill up the whole screen
		$('#maskHome').css({'width':maskWidth,'height':maskHeight});
			
		//transition effect		
		$('#maskHome').fadeIn(1000);	
		$('#maskHome').fadeTo("slow",0.8);	
		
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
				
		//Set the popup window to center
		$("#reservationNameDiv").css('top',  winH/2-$("#reservationNameDiv").height()/2 + 200);
		$("#reservationNameDiv").css('left', winW/2-$("#reservationNameDiv").width()/2 - 200 )	;
		
		//transition effect
		$("#reservationNameDiv").fadeIn(2000);	
	
	return false;
}

function submitReservation(){
		
	var fullname = document.getElementById("fullName") ;	
	var email = document.getElementById("emailAddress") ;	
	var contact = document.getElementById("contactNo") ;	
	
	if ( fullname.value == '' ) { alert('Name required!') ; return false; }
	if ( email.value == '' ) { alert('Email Address required.') ; return false; }
	if ( contact.value == '' ) { alert('Contact No required.') ; return false; }
	
	if ( $("#emailAddress").val().search("@") == -1 ){ alert("Email is invalid."); return false;}
	
	$("#reservationNameDiv").fadeOut(1000);	
	
	return true;
	
}


