//Booking Validation
function bookingForm() {
	
	var name		= $('#bookername').val();
	var emailId		= $("#emailadd").val();
	var emailReg	= /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var phone		= $('#phone').val();
	var duration	= $("#duration").val();
	var sleep		= $("#sleep").val();
	var bookdate	= $("#bookdate").val();
	var comment		= $('#note').val();
	var	book		= $('#book').val();

	
	if(name == "") {
		inlineMsg('You must fill <strong>Full Name</strong>!', 5);
		return false;
	}
	
	if(emailId == "") {
		inlineMsg('You must fill <strong>Email</strong>!', 5);
		return false;
	}
	
	if(!emailReg.test(emailId)) {
		inlineMsg('Please enter <strong>Valid Email</strong>!', 5);
		return false;
	}

	if(phone == "") {
		inlineMsg('You must fill <strong>Phone Number</strong>!', 5);
		return false;
	}
	
	if(!phone.match('^(0|[1-9][0-9]*)$')){
		inlineMsg('<strong>Phone Number</strong> is not valid!', 5);
		return false;
	}
	
	if(duration == "") {
		inlineMsg('You must select <strong>Duration</strong>!', 5);
		return false;
	}
	
	if(sleep == "") {
		inlineMsg('You must select <strong>Sleep</strong>!', 5);
		return false;
	}
	
	if(bookdate == "") {
		inlineMsg('You must fill <strong>Date</strong>!', 5);
		return false;
	}

		
		$('#loader').fadeIn(200).show();
		var dataString = 'name='+ name + '&emailId=' + emailId + '&phone=' + phone + '&duration=' + duration + '&sleep=' + sleep + '&bookdate=' + bookdate + '&comment=' + comment + '&book=' + book;
		$.ajax({
			type: "POST",
			url: "includes/booking_action.php",
			data: dataString,
			success: function(){
				$('#success').fadeIn(200).show();
				$('#loader').fadeOut(200).hide();
				$('#bookingForm').fadeOut(200).hide();
			}
		});
		
		//return true;
}


//Booking Validation
function contactForm() {
	
	var name		= $('#urname').val();
	var emailId		= $("#uremail").val();
	var emailReg	= /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var phone		= $('#urphone').val();
	var	contact		= $('#contact').val();

	
	if(name == "") {
		alert('You must fill Full Name!');
		return false;
	}
	
	if(emailId == "") {
		alert('You must fill Email!');
		return false;
	}
	
	if(!emailReg.test(emailId)) {
		alert('Please enter Valid Email!');
		return false;
	}

	if(phone == "") {
		alert('You must fill Phone Number!');
		return false;
	}
	
	if(!phone.match('^(0|[1-9][0-9]*)$')){
		alert('Phone Number is not valid!');
		return false;
	}
	
	
		
		$('#loader1').fadeIn(200).show();
		var dataString = 'name='+ name + '&emailId=' + emailId + '&phone=' + phone  + '&contact=' + contact;
		$.ajax({
			type: "POST",
			url: "includes/contact_action.php",
			data: dataString,
			success: function(){
				$('#success1').fadeIn(200).show();
				$('#loader1').fadeOut(200).hide();
				$('#contaceme').fadeOut(200).hide();
			}
		});
		
		//return true;
}



// Error Message
function inlineMsg(Err,interval) {
    var options = {};
    $("#errors").show(
		setTimeout(function() {
    $("#errors").fadeOut(500)}, 3000)
	);
    $("#errorText").html('<span class="ui-icon ui-icon-alert" style="float:left;margin-right:0.3em;"></span><strong>Alert:  </strong>'+ Err);
	
}

