function booking(rtype,start_date,end_date,roomname,rate,night,amount,curr,bed,abf,rooms,unique_id){
	var formObj = document.frm_booking;
	formObj.action = "customer_details.php";
	formObj.method = "post";
	
	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = unique_id;
	inputObj.name = "unique_id";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = rtype;
	inputObj.name = "rtype";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = start_date;
	inputObj.name = "start_date";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = end_date;
	inputObj.name = "end_date";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = roomname;
	inputObj.name = "roomname";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = rate;
	inputObj.name = "rate";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = night;
	inputObj.name = "night";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = amount;
	inputObj.name = "amount";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = curr;
	inputObj.name = "curr";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = bed;
	inputObj.name = "bed";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = abf;
	inputObj.name = "abf";
	formObj.appendChild(inputObj);

	var inputObj = document.createElement("input");
	inputObj.type = "hidden";
	inputObj.value = rooms;
	inputObj.name = "rooms";
	formObj.appendChild(inputObj);

	formObj.submit();
}

function swipstep_2(){
	var error;
	var no;
	no = 1; error = "";

	var fname = document.getElementById("fname").value.replace(/^\s*/, '');
	var lname = document.getElementById("lname").value.replace(/^\s*/, '');
	var city = document.getElementById("city").value.replace(/^\s*/, '');
	var state = document.getElementById("state").value.replace(/^\s*/, '');
	var country = document.getElementById("country").value.replace(/^\s*/, '');
	var postal = document.getElementById("postal").value.replace(/^\s*/, '');
	var phone = document.getElementById("phone").value.replace(/^\s*/, '');
	var email = document.getElementById("email").value.replace(/^\s*/, '');
	var confirm_email = document.getElementById("confirm_email").value.replace(/^\s*/, '');
	var nationality = document.getElementById("nationality").selectedIndex;
	
	if(fname==""){error = error + no + " . First Name is require. \n"; no += 1;}
	if(lname==""){error = error + no + " . First Name is require. \n"; no += 1;}
	if(city==""){error = error + no + " . City is require. \n"; no += 1;}
	if(state==""){error = error + no + " . State or Province is require. \n"; no += 1;}
	if(country==""){error = error + no + " . Country is require. \n"; no += 1;}
	if(postal==""){error = error + no + " . Postal Code is require. \n"; no += 1;}
	if(phone==""){error = error + no + " . Phone is require. \n"; no += 1;}
	
	if(email==""){
		error = error + no + " . Email Address is require. \n"; no += 1;
	}else if(email != confirm_email){
		error = error + no + " . Email is'n Match. \n"; no += 1;
	}else if(!isValidEmail(email)){
		error = error + no + " . Invalid Email Address. \n"; no += 1;
	}
	if(nationality==0){error = error + no + " . Nationality is require. \n"; no += 1;}

	if(error != "") alert(error); else document.frm_step2.submit();		
}

function swipstep_3(){
	var error;
	var no;
	no = 1; error = "";

	//var cc_cardtype = document.getElementById("cc_cardtype").selectedIndex;
	//var cardtype = document.getElementById("cc_cardtype").options[cc_cardtype].value;
	var cardtype="";
	for( i = 0; i < document.frm_step3.cc_cardtype.length; i++ )
	{
		if( document.frm_step3.cc_cardtype[i].checked == true )
			cardtype = document.frm_step3.cc_cardtype[i].value;
	}

	var cc_cardname = document.getElementById("cc_cardname").value.replace(/^\s*/, '');
	var cc_cvccode = document.getElementById("cc_cvccode").value.replace(/^\s*/, '');
	var cc_holdername = document.getElementById("cc_holdername").value.replace(/^\s*/, '');
	var cc_expiry_month = document.getElementById("cc_expiry_month").selectedIndex;
	var cc_expiry_year = document.getElementById("cc_expiry_year").selectedIndex;

	var cc_address = document.getElementById("cc_address").value.replace(/^\s*/, '');
	var cc_city = document.getElementById("cc_city").value.replace(/^\s*/, '');
	var cc_state = document.getElementById("cc_state").value.replace(/^\s*/, '');
	var cc_country = document.getElementById("cc_country").value.replace(/^\s*/, '');
	var cc_zipcode = document.getElementById("cc_zipcode").value.replace(/^\s*/, '');
	var agree = document.getElementById("agree");

	if(cardtype==""){error = error + no + " . Card Type is require. \n"; no += 1;}
	
	if(cc_cardname==""){
		error = error + no + " . Credit Card Number is require. \n"; no += 1;
	}else if(!isValidCC (cardtype, cc_cardname)){
		error = error + no + " . Invalid Card Numbers. \n"; no += 1;
	}

	if(cc_cvccode==""){error = error + no + " . Secure Code is require. \n"; no += 1;}
	if(cc_holdername==""){error = error + no + " . Holder Name is require. \n"; no += 1;}
	if(cc_expiry_month==0){error = error + no + " . Expiry Month is require. \n"; no += 1;}
	if(cc_expiry_year==0){error = error + no + " . Expiry Year is require. \n"; no += 1;}

	if(cc_address==""){error = error + no + " . Address is require. \n"; no += 1;}
	if(cc_city==""){error = error + no + " . City is require. \n"; no += 1;}
	if(cc_state==""){error = error + no + " . State is require. \n"; no += 1;}
	if(cc_country==""){error = error + no + " . Country is require. \n"; no += 1;}
	if(cc_zipcode==""){error = error + no + " . Postal Code is require. \n"; no += 1;}
	if(agree.checked == false){error = error + no + " . Agree Policy is require. \n"; no += 1;}

	if(error != "") 
		alert(error); 
	else
		addBooking();		
}

function addBooking(){
	var ajaxRequest;
	
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
		}
	}

	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//document.myForm.time.value = ajaxRequest.responseText;
			document.frm_step3.submit();
		}
	}

	var title = document.getElementById('title').value;
	var fname = document.getElementById('fname').value;
	var mname = document.getElementById('mname').value;
	var lname = document.getElementById('lname').value;
	var other_guest = document.getElementById('other_guest').value;
	var address = document.getElementById('address').value;
	var city = document.getElementById('city').value;
	var state = document.getElementById('state').value;
	var postal = document.getElementById('postal').value;
	var phone = document.getElementById('phone').value;
	var fax = document.getElementById('fax').value;
	var email = document.getElementById('email').value;
	var country = document.getElementById('country').value;
	var nationality = document.getElementById('nationality').value;
	var arrival_time = document.getElementById('arrival_time').value;
	var adult = document.getElementById('adult').value;
	var child = document.getElementById('child').value;
	var child_age = document.getElementById('child_age').value;
	var rooms = document.getElementById('rooms').value;

	var start_date = document.getElementById('start_date').value;
	var end_date = document.getElementById('end_date').value;
	var roomname = document.getElementById('roomname').value;
	var bed = document.getElementById('bed').value;
	var abf = document.getElementById('abf').value;
	var night = document.getElementById('night').value;
	var rate = document.getElementById('rate').value;
	var amount = document.getElementById('amount').value;
	var curr = document.getElementById('curr').value;
	var unique_id = document.getElementById("unique_id").value;
	
	//Credit Card
		var cc_cardtype = document.getElementsByName('cc_cardtype');
		if(cc_cardtype[0].checked){
			var cardtype = cc_cardtype[0].value;
		}else if(cc_cardtype[1].checked){
			var cardtype = cc_cardtype[1].value;
		}

		var cc_cardname = document.getElementById('cc_cardname').value;
		var cc_cvccode = document.getElementById('cc_cvccode').value;
		var cc_holdername = document.getElementById('cc_holdername').value;
		var cc_expiry_month = document.getElementById('cc_expiry_month').options[document.getElementById('cc_expiry_month').selectedIndex].value;
		var cc_expiry_year = document.getElementById('cc_expiry_year').options[document.getElementById('cc_expiry_year').selectedIndex].value;
		var cc_issuing_bank = document.getElementById('cc_issuing_bank').value;
		var cc_address = document.getElementById('cc_address').value;
		var cc_city = document.getElementById('cc_city').value;
		var cc_state = document.getElementById('cc_state').value;
		var cc_country = document.getElementById('cc_country').options[document.getElementById('cc_country').selectedIndex].value;
		var cc_zipcode = document.getElementById('cc_zipcode').value;

	var url = 'addbooking.php';
	var pmeters  = 'title='+title+'&fname='+fname+'&mname='+mname+'&lname='+lname+'&other_guest='+other_guest;
		pmeters += '&address='+address+'&city='+city+'&state='+state+'&postal='+postal+'&phone='+phone+'&fax='+fax;
		pmeters += '&email='+email+'&country='+country+'&nationality='+nationality+'&arrival_time='+arrival_time;
		pmeters += '&adult='+adult+'&child='+child+'&child_age='+child_age+'&rooms='+rooms;
		pmeters += '&start_date='+start_date+'&end_date='+end_date+'&roomname='+roomname+'&night='+night;
		pmeters += '&bed='+bed+'&abf='+abf+'&rate='+rate+'&amount='+amount+'&curr='+curr;

		pmeters += '&cc_cardtype='+cardtype+'&cc_cardname='+cc_cardname+'&cc_cvccode='+cc_cvccode+'&cc_holdername='+cc_holdername;
		pmeters += '&cc_expiry_month='+cc_expiry_month+'&cc_expiry_year='+cc_expiry_year+'&cc_issuing_bank='+cc_issuing_bank;
		pmeters += '&cc_address='+cc_address+'&cc_city='+cc_city+'&cc_state='+cc_state+'&cc_country='+cc_country+'&cc_zipcode='+cc_zipcode+'&unique_id='+unique_id;

	ajaxRequest.open('POST',url,true);

	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", pmeters.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	ajaxRequest.send(pmeters);
}

function validateEmail(strValue){
	var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	return objRegExp.test(strValue);
}

function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
    {
      return false;
    } 
    return true; 
}

function isValidCC (cctype, ccnumber) { 
	// Check for valid credit card type/number 
	var creditCardList = [ 
	   //type      prefix   length 
	   ["amex",    "34",    15], 
	   ["amex",    "37",    15], 
	   ["disc",    "6011",  16], 
	   ["mc",      "51",    16], 
	   ["mc",      "52",    16], 
	   ["mc",      "53",    16], 
	   ["mc",      "54",    16], 
	   ["mc",      "55",    16], 
	   ["visa",    "4",     13], 
	   ["visa",    "4",     16] 
	]; 
   var cc = getdigits (ccnumber); 
   if (luhn (cc)) { 
      for (var i in creditCardList) { 
         if (creditCardList [i][0] == (cctype.toLowerCase ())) { 
            if (cc.indexOf (creditCardList [i][1]) == 0) { 
               if (creditCardList [i][2] == cc.length) { 
                  return true; 
               } 
            } 
         } 
      } 
   } 
   return false; 
}

function getdigits (s) { 
   return s.replace (/[^\d]/g, ""); 
}

function luhn (cc) { 
   var sum = 0; 
   var i; 
  
   for (i = cc.length - 2; i >= 0; i -= 2) { 
      sum += Array (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) [parseInt (cc.charAt (i), 10)]; 
   } 
   for (i = cc.length - 1; i >= 0; i -= 2) { 
      sum += parseInt (cc.charAt (i), 10); 
   } 
   return (sum % 10) == 0; 
}

function NumberCheck(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (!(charCode > 42 && charCode < 80) && charCode!=8)
	return false;				 
}

function openwin( urlpage , width , height , center) {
	xpos=0; ypos=0;
	if ((parseInt(navigator.appVersion) >=4) && (center)) {

		xpos=(screen.width-width)/2;
		ypos=(screen.height-height)/2;

	}
		arg="width="+width+","
		+ "height="+ height + ","
		+ "location=0, "
		+ "menubar=0, "
		+ "resizeable=0, "
		+ "scrollbars=yes,"
		+ "status=0,"
		+ "toolbar=0,"
		+ "screenx=" + xpos + ","
		+ "screeny=" + ypos + ","
		+ "left=" + xpos + ","
		+ "top=" + ypos;

		window.open(urlpage,'newwin',arg);
}