//function paymentdisplayvalidation()
//{
	//var action='display';
	//xajax_billingfunction(xajax.getFormValues('paymentformnew'),action);
	//return true;
//}
function showpayment()
{
document.getElementById('billingaddressdiv').className='show';
document.getElementById('paymentdiv').className='show';
document.getElementById('customerinfo').className='show';
document.getElementById('Passengertype[]').focus();
}
function paymentvalidation()
{
	
	
	
	var form = document.paymentformnew;
	
	var adult=(form.adult.value);
	//alert (adult);
	if(adult>1)
	{
		for(i=0;i<adult;i++)
		{
			var fname=trim(form["Firstname[]"][i].value);
			
			if(fname=='')
			{	
				alert("Please enter first name of Adult " + (i+1));
				form["Firstname[]"][i].focus();
			    return false;
			}
           	else
	    	{	
				count=fname.length;
				if (count <= 1)
				{	
					alert("Sorry, First name should have more than one character");
					form["Firstname[]"][i].focus();
                      return (false);
				}
				else if (count > 50)
				{	
					alert("Sorry, currently we do not accept more than 50 characters for First name. \n If your first name exceeds 50 characters, please send us an e-mail with\n your requirements to support@atyourprice.in we will revert to you at the earliest");
					form["Firstname[]"][i].focus();
                      return (false);
				}
				
		     }
			var lname=trim(form["Lastname[]"][i].value);
			if(lname=='')
			{	alert("Please enter last name of Adult " + (i+1));
				form["Lastname[]"][i].focus();
				return false;
			}
		}
	}
	if(adult==1)
	{
		fname=trim(form["Firstname[]"].value);
		
		if(fname=='')
		{
	 		alert("Please enter First name of Adult " );
			form["Firstname[]"].focus();
			return false;
		}
		else
		{
			count=fname.length;
			if (count <= 1)
			{
				alert("First name should have more than one character.");
				form["Firstname[]"].focus();
                return (false);
			}
			else if (count > 50)
			{	
				alert("Sorry, currently we do not accept more than 50 characters for First name. \n If your first name exceeds 50 characters, please send us an e-mail with\n your requirements to support@atyourprice.in we will revert to you at the earliest");
				form["Firstname[]"].focus();
				return (false);
			}
		}
		lname=trim(form["Lastname[]"].value);
		if(lname=='')
		{
  			alert("Please enter  Last name of the Adult.");
			form["Lastname[]"].focus();
	 		return false; 
		}
	} 

	
	
	var baddrone = document.getElementById('firstname').value;
   	var baddrtwo = document.getElementById('lastname').value;
   	//var baddrthree=document.paymentformnew.Baddress3.value;	  	
   	var badd1 = document.getElementById('address1').value;
   	var bcity = document.getElementById('city').value;
	var bstate = document.getElementById('state').value;
    var bcountry = document.getElementById('country').value;
    var bpincode = document.getElementById('pincode').value;
	var bmobile = document.getElementById('mobileno').value;
   //	var bareacode=document.paymentformnew.Bareacode.value;
    var bphone = document.getElementById('phoneno').value;
	var bemail = document.getElementById('emailidpayment').value;
 	
	baddrone=trim(baddrone);
	baddrtwo=trim(baddrtwo);
	//baddrthree=trim(baddrthree);
	bcity=trim(bcity);
	bemail=trim(bemail);

	if(baddrone=='')
	{
 		alert("Enter the first name field");
		document.getElementById('firstname').focus();
 		return false;
 	}
	else if (baddrone.length > 50) 
	{	
 		alert("Sorry, Currently we do not accept more than 50 characters for first name field.");
		document.getElementById('firstname').value='';
		document.getElementById('firstname').focus();
 		return false;	
	}
	
	if(baddrtwo=='')
	{
 		alert("Enter the last name field");
		document.getElementById('lastname').focus();
 		return false;
 	}
	else if (baddrtwo.length > 50)
	{
		alert("Last name field length should be less than 51 characters");
		document.getElementById('lastname').value='';
		document.getElementById('lastname').focus();
		return false;				
	}
	if(badd1=='')
	{
 		alert("Enter the Address 1 field");
		document.getElementById('address1').focus();
 		return false;
 	}
	else if (badd1.length > 50)
	{
		alert("Address 1 field length should be less than 51 characters");
		document.getElementById('address1').value='';
		document.getElementById('address1').focus();
		return false;				
	}
	if(bcity=='')
	{
		alert("Please enter the city in which you live");
		document.getElementById('city').focus();
		return false;
	}
	else if(bcity.length >30 )
	{
		alert("Please enter a valid city name");
		document.getElementById('city').focus();
		document.getElementById('city').value='';
		return false;
	}
	
	if(bstate=='')
	{
		alert("Please enter the state in which you live");
		document.getElementById('state').focus();
	 	return false;
 	}
	else if(bstate.length >30 )
	{
			 alert("Please enter a valid state name");
			 document.getElementById('state').value='';
			 document.getElementById('state').focus();
			
			return false;
	}
	
	if(bcountry=='')
	{
		alert("Please enter the country in which you live");
		document.getElementById('country').focus();
 		return false;
	}
	else if(bcountry.length >30 )
	{
			alert("Please enter a valid country name");
			document.getElementById('country').focus();
			document.getElementById('country').value='';
			return false;
	}
	
	if(bpincode=='')
	{
		alert("Please enter a pincode of your place.");
		document.getElementById('pincode').focus();
		return false;
	}
	else if(bpincode.length > 9)
	{
		alert("Please enter a valid pincode");
		document.getElementById('pincode').focus();
		document.getElementById('pincode').value='';
		return false;
	}
	
	if(bmobile=='')
	{
		alert("Please enter your mobile number.  Ensure that you given us correct mobile number, \n so that we will be able to contact you when it is necessary.");
		document.getElementById('mobileno').focus();
		return false;
	}
	else if(bmobile.length < 10 || bmobile.length >12)
	{
		alert("Sorry, you have provided incorrect mobile number. Please provide your correct mobile number with 10 numeric characters");
		document.getElementById('mobileno').focus();
		document.getElementById('mobileno').value="";
		
		return false;
	}
	
	if(bphone=='')
	{
		alert("Please enter your land line phone number with STD code");
		document.getElementById('phoneno').focus();
		return false;
	}
	else if(bphone.length > 12)
	{
		alert("Please enter a valid land line phone number with STD code.");
		document.getElementById('phoneno').focus();
		document.getElementById('phoneno').value="";
		return false;
	}
	
	if(bemail=='')
	{
 		alert("Enter your e-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		document.getElementById('emailidpayment').focus();
 		return false;
	}
	else if(emailval(document.getElementById('emailidpayment').value)==false)
	{
		document.getElementById('emailidpayment').value=''
		document.getElementById('emailidpayment').focus();
		return false;
	}
	
	if(document.getElementById('Cardno1').value == '')
	{
		alert("Please enter the first four digit credit card numbers");
		document.getElementById('Cardno1').focus();
		return false;
	}
	else if(document.getElementById('Cardno1').value.length < 4)
	{
		alert("Please enter the correct first four digit credit card numbers");
		document.getElementById('Cardno1').focus();
		return false;
	}
	
	if(document.getElementById('Cardno2').value == '')
	{
		alert("Please enter the second four digit credit card numbers");
		document.getElementById('Cardno2').focus();
		return false;
	}
	else if(document.getElementById('Cardno2').value.length < 4)
	{
		alert("Please enter the correct second four digit credit card numbers");
		document.getElementById('Cardno2').focus();
		return false;
	}
	
	if(document.getElementById('Cardno3').value == '')
	{
		alert("Please enter the third four digit credit card numbers");
		document.getElementById('Cardno3').focus();
		return false;
	}
	else if(document.getElementById('Cardno3').value.length < 4)
	{
		alert("Please enter the correct third four digit credit card numbers");
		document.getElementById('Cardno3').focus();
		return false;
	}
	
	if(document.getElementById('Cardno4').value == '')
	{
		alert("Please enter the last four digit credit card numbers");
		document.getElementById('Cardno4').focus();
		return false;
	}
	else if(document.getElementById('Cardno4').value.length < 4)
	{
		alert("Please enter the correct last four digit credit card numbers");
		document.getElementById('Cardno4').focus();
		return false;
	}
	
	if(document.getElementById('Expmonth').value == '')
	{
		alert("Please select card expiry month ");
		document.getElementById('Expmonth').focus();
		return false;
	}
	
	if(document.getElementById('Expyear').value == '')
	{
		alert("Please select card expiry year ");
		document.getElementById('Expyear').focus();
		return false;
	}
	
	if(document.getElementById('Cvv').value == '')
	{
		alert("Please enter your card CVV number ");
		document.getElementById('Cvv').focus();
		return false;
	}
	
	if(document.getElementById('Cardholder').value == '')
	{
		alert("Please enter name of the card holder ");
		document.getElementById('Cardholder').focus();
		return false;
	}
		
	
	var searchid=document.getElementById('search_id').value;
	var hotelid=document.getElementById('selectedhotelid').value;
	var tariffid=document.getElementById('selectedtarriffid').value;
	var action='insert';
	var tarifftype=document.getElementById('tarifftype').value;
	var hotel_search_mode=document.getElementById('hotel_search_mode').value;
    var amount_total = document.getElementById('totalamount').value; 
	if(usercheck())
	{
		
		//alert('sdfsdsf');
		xajax_billingfunction(xajax.getFormValues('paymentformnew'),action,searchid,hotelid,tariffid,tarifftype,amount_total,hotel_search_mode);
		document.getElementById('paymenttext').innerHTML="Please Wait..."; 
	 	document.getElementById('paymentbutton').disabled=true; 
	 }
	 
	 
}

function gotocard2(value)
{
	if(value.length>=4)
	{
		document.getElementById('Cardno2').focus();
	}
}
function gotocard3(value)
{
	if(value.length>=4)
	{
		document.getElementById('Cardno3').focus();
	}
}
function gotocard4(value)
{
	
	if(value.length>=4)
	{
		document.getElementById('Cardno4').focus();
	}
}
function gotoselect(value)
{
	
	if(value.length>=4)
	{
		document.getElementById('Expmonth').focus();
	}
}



function gotocardname(value)
{
	
	if(value.length>=4)
	{
		document.getElementById('Cardholder').focus();
	}
}


function emailval(emailid)
{
	
	//var emailid=document.getElementById("emailid").value;
	//alert(emailid);
	var at="@";
	var dot=".";
	var lat=emailid.indexOf(at);
	var lemailid=emailid.length;
	var ldot=emailid.indexOf(dot);
	

	if(emailid=="")
	{
		alert("Please enter your correct email address.");
	}

	if(emailid.length > 0) 
	{

		if (lat==-1 || lat==0 || lat==lemailid)
		{
		   	alert("Please enter your correct email address.");
		   	emailid = "";
		   	
		   	return false;
		}
		if (ldot==-1 || ldot==0 || ldot==lemailid)
		{
		    	alert("Please enter your correct email address.");
			 emailid = "";
		   	 
		    	return false;
		}
		if (emailid.indexOf(at,(lat+1))!=-1)
		{
		   	alert("Please enter your correct email address.");
			emailid = "";
		    	
		    	return false;
		}

		if (emailid.substring(lat-1,lat)==dot || emailid.substring(lat+1,lat+2)==dot)
		{
		    	alert("Please enter your correct email address.");
			emailid = "";
		    	
		    	return false;
		}

		if (emailid.indexOf(dot,(lat+2))==-1)
		{
		    	alert("Please enter your correct email address.");
			 emailid = "";
		    	
		    	return false;
		}

		if (emailid.indexOf(" ")!=-1)
		{
		    	alert("Please enter your correct email address.");
	         	emailid = "";
		    	
			return false;
		}

		if(ldot+1 == lemailid )
		{
			alert("Please enter your correct email address.");
	        emailid = "";
		    	
			return false;
		}
		return true;
	}
}