// JavaScript Document

function subscribenews(){
var data = jQuery("#email").val();
var sessid = jQuery("#sessionid").val();
//alert(sessid);
jQuery.ajax({ 
   type: "POST", 
   url: "utilities.php", 
   data: "op=subscribe&email="+data+"&sessionid="+sessid, 
   success: function(msg){ 
     //alert( "Data Saved: " + msg ); 
	 //alert(data);
	 //$("#tr_payoption").append(msg);
	 jQuery("#notify").html(msg);
   } 
 });

}
function getstatename(){
	$("#state_name").get(0).value = $("#states option:selected").text();
}

function getnumrooms(){
var data = $("#roomt_type").val();
$.ajax({ 
   type: "POST", 
   url: "utilities.php", 
   data: "op=numrooms&roomt_type="+data, 
   success: function(msg){ 
     //alert( "Data Saved: " + msg ); 
	 //alert(data);
	 //$("#tr_payoption").append(msg);
	 $("#num_rooms").html(msg);
   } 
 });

}

function getpackageamount(){
var data = $("#package_sel").val();
$.ajax({ 
   type: "POST", 
   url: "utilities.php", 
   data: "op=pkgamount&package_sel="+data, 
   success: function(msg){ 
     //alert( "Data Saved: " + msg ); 
	 //alert(msg);
	 //$("#tr_payoption").append(msg);
	 $("#pkg_amount").html(msg);
	 $("#pkg_amount_h").get(0).value = msg;
   } 
 });

}

function getroomtypefee(){
var data = $("#roomt_type").val();
var data2 = $("#num_rooms").val();
$.ajax({ 
   type: "POST", 
   url: "utilities.php", 
   data: "op=roomtypefee&roomt_type="+data+"&num_rooms="+data2, 
   success: function(msg){ 
     //alert( "Data Saved: " + msg ); 
	 //alert(msg);
	 //$("#tr_payoption").append(msg);
	 $("#roomfeedisplay").html(msg);
	 $("#roomt_type_fees").get(0).value = msg;
   } 
 });
}

function getmembercatamount(){
var data = $("#member_cat").val();
$.ajax({ 
   type: "POST", 
   url: "utilities.php", 
   data: "op=membercatamount&member_cat="+data, 
   success: function(msg){ 
     //alert( "Data Saved: " + msg ); 
	 //alert(msg);
	 //$("#tr_payoption").append(msg);
	 $("#memcat_amount").html(msg);
	 $("#memcat_amount_h").get(0).value = msg;
   } 
 });
}

function movenext(formurl){
//$("#form1").action = 'reservation_pdetails.php';
/*
$("#form1").validate({ 
  rules: { 
    checkin_date: { 
      required: true, 
      date: true 
    } 
  } 
});
*/
if($("#checkin_date").val()==''){
	$("#error_label").html('This field is required').show();
	$("#checkin_date").focus()
	return false;
}
if($("#checkout_date").val()==''){
	$("#error_label").html('This field is required').show();
	$("#checkout_date").focus()
	return false;
}
if($("#package_sel").val()==''){
	$("#error_label").html('This field is required').show();
	$("#package_sel").focus()
	return false;
}
if($("#roomt_type").val()==''){
	$("#error_label").html('This field is required').show();
	$("#roomt_type").focus()
	return false;
}
if($("#num_rooms").val()==''){
	calldialog();
	$("#error_label").html('This field is required').show();
	return false;
}
if($("#lastname").val()==''){
	$("#error_label").html('This field is required').show();
	$("#lastname").focus()
	return false;
}
if($("#firstname").val()==''){
	$("#error_label").html('This field is required').show();
	$("#firstname").focus()
	return false;
}
if($("#middlename").val()==''){
	$("#error_label").html('This field is required').show();
	$("#middlename").focus()
	return false;
}
if($("#address").val()==''){
	$("#error_label").html('This field is required').show();
	$("#address").focus()
	return false;
}
if($("#city").val()==''){
	$("#error_label").html('This field is required').show();
	return false;
}
if($("#city").val()==''){
	$("#error_label").html('This field is required').show();
	return false;
}if($("#countries").val()==''){
	$("#error_label").html('This field is required').show();
	return false;
}
if($("#email").val()==''){
	$("#error_label").html('This field is required').show();
	return false;
}
if($("#mobile_no").val()==''){
	$("#error_label").html('This field is required').show();
	return false;
}
else {
	$("#form1").attr("action",formurl);
	$("#form1").submit();
}
}

function moveback(formurl){
	$("#form1").attr("action",formurl);
	$("#form1").submit();
}


function checklogin(formurl){
		var data = $("#email").val();
		var data2 = $("#password").val();
		//alert(formurl);
		$.ajax({ 
		   type: "POST", 
		   url: "utilities.php", 
		   data: "op=checklogin&email="+data+"&password="+data2, 
		   success: function(msg){  
			 //alert(msg); 
			 $("#error_label_login").html('logging you in ...').show();
				if(msg!=''){	
					$("#member_data").get(0).value = msg;
					alert($("#member_data").val());
				 $("#form1").attr("action",formurl);
				 $("#form1").submit();
				}
				else{
					$("#error_label_login").html('Invalid email or password').show();
				}
		   } 
		 });
		//alert(data);
}

function doregister(formurl){
if($("#lastname").val()==''){
	$("#error_label").html('Lastname is required').show();
	$("#lastname").focus();
	return false;
}
if($("#firstname").val()==''){
	$("#error_label").html('Firstname is required').show();
	$("#firstname").focus();
	return false;
}
if($("#middlename").val()==''){
	$("#error_label").html('Middlename is required').show();
	$("#middlename").focus();
	return false;
}
if($("#address").val()==''){
	$("#error_label").html('Address is required').show();
	$("#address").focus();
	return false;
}
if($("#city").val()==''){
	$("#error_label").html('City is required').show();
	$("#city").focus();
	return false;
}
if($("#state").val()==''){
	$("#error_label").html('State is required').show();
	$("#state").focus();
	return false;
}if($("#country").val()==''){
	$("#error_label").html('Country is required').show();
	return false;
}
if($("#email_address").val()==''){
	$("#error_label").html('Email address is required').show();
	$("#email_address").focus();
	return false;
}
if($("#sex").val()==''){
	$("#error_label").html('Select your gender').show();
	$("#sex").focus();
	return false;
}
if($("#chosen_password").val()==''){
	$("#error_label").html('Type in your prefered password').show();
	$("#error_label").focus();
	return false;
}
if($("#confirm_password").val()!=$("#chosen_password").val()){
	$("#error_label").html('Password is not the same').show();
	$("#confirm_password").focus();
	return false;
}
else {
	$("#form1").attr("action",formurl);
	$("#form1").submit();
}
}

function calldialog(){
var roomtypeval = 'Sorry there are no available rooms for '+$("#roomt_type option:selected").text();
$("#roomdialog").html(roomtypeval);
$("#roomdialog").dialog();
}

function calldialog_session(){
var data = 'You do not have a valid logon session';
$("#sessiondialog").html(data);
$("#sessiondialog").dialog({                                                           
							width: 600,                        
							modal: true,                        
							close: function(event, ui) {window.location.href = 'membership.php';}                        
							});
//window.location.href = 'membership.php';
}
