refalpha = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
refnum = "0123456789";
refaddr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz., /";
ref="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
function emailcheck(str)
{
	//alert("inside validation");
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1)
	{
		alert("Invalid login id. Please enter your login id");
	   	return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Invalid login id. Please enter your login id");
		return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Invalid login id. Please enter your login id");
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1)
	{
    	alert("Invalid login id. Please enter your login id");
    	return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
	   	alert("Invalid login id. Please enter your login id");
    	return false
	}
	if (str.indexOf(dot,(lat+2))==-1)
	{
    	alert("Invalid login id. Please enter your login id");
	   	return false
	}
	if (str.indexOf(" ")!=-1)
	{
    	alert("Invalid login id. Please enter your login id");
    	return false
	}
	return true;
}

function roundsubmitform()
{
	alert('roundsubmitform');
	document.Mainform.submit();
}

function passenger(pass)
{
	var str = document.loginform.Loginid.value;
	if(document.loginform.Loginid.value=='')
	{
		alert("Please enter your Login ID.");
		return false;
	}
	else
	{
		if(emailcheck(str)==false)
		{
			document.loginform.Loginid.value=''
				document.loginform.Loginid.focus();
			return false;
		}
	}
	if(document.loginform.Userpwd.value=='')
	{
		alert('Please enter your password');
		document.loginform.Userpwd.focus();
		return false;
	}
	if(pass=="request")
	{
		document.loginform.action ="./requestpass.php";
	}
	else
	{
		document.loginform.action ="./searchpass.php";
	}
}

function showonward()
{
	document.getElementById("Bookreturn1show").className = "show";
	document.getElementById("bookonward1show").className = "hide";
}
function showreturn()
{
	document.getElementById("bookonward1show").className = "hide";
	document.getElementById("Bookreturn1show").className = "show";
}

function booking(book)
{
	if(book==2)
	{
		num = document.getElementById("select").value;
		if(num==1)
		{
			alert("Please select the return flight");
			return false;
		}
	}
	document.Bookonward.submit();
}

function Assign(name)
{
	if(name=='')
		return name='';
	else
		return name;
}
		
function Onwardbook(form1)
{
	//alert(form1)
	document.getElementById("select").value = 1;
	document.getElementById("DivBothBook").className = "show";
	document.getElementById("DivOnwardBook").className = "show";
	var airline = document.getElementById('airline_code'+form1).value;
	document.getElementById('Oairline').value = airline;
	var flight_no = document.getElementById('flight_no'+form1).value;
	document.getElementById('Oflight_no').value =flight_no;
	var deptime = document.getElementById('deptime'+form1).value;
	document.getElementById('Odeptime').value = deptime;
	arrtime = document.getElementById('arrtime'+form1).value;
	document.getElementById('Oarrtime').value = arrtime;
	fare_of_flight = document.getElementById('fare_of_flight'+form1).value;
	document.getElementById('Ofare_of_flight').value = fare_of_flight;
	image = document.getElementById('images'+form1).value;
	document.getElementById('Oimage1').value = image;
	//alert(image);
	origin_city = document.getElementById('origin_city').value;
	document.getElementById('Oorigin_city').value = origin_city;
	dest_city = document.getElementById('dest_city').value;
	document.getElementById('Odest_city').value = dest_city;
	depart_date = document.getElementById('depart_date'+form1).value;
	document.getElementById('Odepart_date').value = depart_date;
	adult = document.getElementById('adult').value;
	document.getElementById('Oadult').value =adult;
	bookingclasscode = document.getElementById('bookingclasscode').value;
	document.getElementById('Obookingclasscode').value = bookingclasscode;
	farebasiscode = document.getElementById('farebasiscode').value;
	document.getElementById('Ofarebasiscode').value = farebasiscode;
	emailid = document.getElementById('emailid').value;
	document.getElementById('Oemailid').value = emailid;
	convidhid = document.getElementById('convidhid').value;
	document.getElementById('Oconvidhid').value =convidhid;
	stokenhid = document.getElementById('stokenhid').value;
	document.getElementById('Ostokenhid').value = stokenhid;
	document.getElementById("trips").value = 1;
	document.getElementById("Odate").innerHTML = depart_date;
	document.getElementById("Oflight").innerHTML = flight_no;
	document.getElementById("Ofrom").innerHTML = origin_city;
	document.getElementById("Odeparture").innerHTML = deptime;
	document.getElementById("Oto").innerHTML = dest_city;
	document.getElementById("Oarrival").innerHTML = arrtime;
	document.getElementById("Ofare").innerHTML = fare_of_flight;
	document.getElementById("Oimage").src ="."+image;
}

function Returnbook(form2,showcheck1)
{
	//alert("Return Booking")
	check = document.getElementById("select").value;
	ok = true;
	if(showcheck1!=3)
	{
		if(check==0)
		{
			alert("Please Select Onward Flight First");
			ok=false;
			return false;
		}
		document.getElementById("select").value=2;
		ok=true;			
	}
	if(ok)
	{	
		document.getElementById("DivBothBook").className = "show";
		document.getElementById("DivReturnBook").className = "show";
		airline1 = document.getElementById('airline_code1'+form2).value
		document.getElementById('Rairline').value = airline1;
		flight_no1 = document.getElementById('flight_no1'+form2).value;
		document.getElementById('Rflight_no').value =flight_no1;
		deptime1 = document.getElementById('deptime1'+form2).value;
		document.getElementById('Rdeptime').value = deptime1;
		arrtime1 = document.getElementById('arrtime1'+form2).value;
		document.getElementById('Rarrtime').value = arrtime1;
		fare_of_flight1 = document.getElementById('fare_of_flight1'+form2).value;
		document.getElementById('Rfare_of_flight').value = fare_of_flight1;
		image1 = document.getElementById('image1'+form2).value;
		//alert("image"+image1);
		document.getElementById('Rimage1').value = image1;
		origin_city = document.getElementById('origin_city1').value;
		document.getElementById('Oorigin_city').value = origin_city;
		dest_city = document.getElementById('dest_city1').value;
		document.getElementById('Odest_city').value = dest_city;
		adult = document.getElementById('adult1').value;
		document.getElementById('Oadult').value =adult;
	
		depart_date1 = document.getElementById('depart_date1').value;
		document.getElementById('Rdepart_date').value = depart_date1;
		bookingclasscode1 = document.getElementById('bookingclasscode1').value;
		document.getElementById('Rbookingclasscode').value = bookingclasscode1;
		farebasiscode1 = document.getElementById('farebasiscode1').value;
		document.getElementById('Rfarebasiscode').value = farebasiscode1;

		returndate1 = document.getElementById('returndate1').value;
		document.getElementById('Rreturndate').value = returndate1;
		returnrange1 = document.getElementById('returnrange1').value;
		document.getElementById('Rreturnrange').value = returnrange1;
		
		document.getElementById("trips").value = 2;
		document.getElementById("Rdate").innerHTML = depart_date1;
		document.getElementById("Rflight").innerHTML = flight_no1;
		document.getElementById("Rfrom").innerHTML = dest_city;
		document.getElementById("Rdeparture").innerHTML = deptime1;
		document.getElementById("Rto").innerHTML = origin_city;
		document.getElementById("Rarrival").innerHTML = arrtime1;
		document.getElementById("Rfare").innerHTML = fare_of_flight1;
		document.getElementById("Rimage").src ="."+image1;
		//alert(document.getElementById('Rdest_city').value);
	}
}

function trim(inputString) 
{
	// Removes leading and trailing spaces from the passed string. Also removes
 	// consecutive spaces and replaces it with one space. If something besides
	// a string is passed in (null, custom object, etc.) then return the input.

	if (typeof inputString != "string") 
	{
		 return inputString; 
	}
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ")
	{ // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
    	ch = retValue.substring(0, 1);
   	}
   	ch = retValue.substring(retValue.length-1, retValue.length);
   	while (ch == " ") 
	{ // Check for spaces at the end of the string
    	retValue = retValue.substring(0, retValue.length-1);
    	ch = retValue.substring(retValue.length-1, retValue.length);
   	}
   	while (retValue.indexOf("  ") != -1) 
	{ // Note that there are two spaces in the string - look for multiple spaces within the string
    	retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   	}
   	return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function testingxajax()
{
	//alert('testingxajax');
	xajax_testfile();
	xajax_passengerstore(xajax.getFormValues('passengerform'));
	
}

function PassengerCall(form,type)
{
 	
	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 firstname of a passenger in row " + (i+1));
				form["Firstname[]"][i].focus();
			     return false;
			}
           	else
	    	{	
				count=fname.length;
				/*for(j=0;j<count;j++) //In this loop not allow space between string
		  		{ 	tempchar = fname.substring (j,j+1);
                       if (ref.indexOf (tempchar, 0) == -1)
					{ 	alert("Please Enter Valid Firstname.");
                           return (false); 
					}
                }*/
				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 lastname of a passenger in row" +(i+1));
				form["Lastname[]"][i].focus();
				return false;
			}
			/*else
		   	{	
				count=lname.length;
				for(j=0;j<count;j++)
			  	{	tempchar = lname.substring (j,j+1);
                    if (ref.indexOf (tempchar, 0) == -1)
					{	alert("Please Enter Valid Lastname.");
                        return (false); 
					}
                }
				if (count <= 1)
				{	alert("Lastname should be more than 1 character long.");
                    return (false);
				}else if (count > 50)
				{	alert("Lastname should be less than 50 character.");
                      return (false);
				}
		     }*/
		}
		//xajax_passengerstore(xajax.getFormValues('passengerform'),type);
	}
	if(adult==1)
	{
		fname=trim(form["Firstname[]"].value);
		if(fname=='')
		{
	 		alert("Please enter firstname of the passenger");
			form["Firstname[]"].focus();
			return false;
		}
		else
		{
			
			count=fname.length;
			/*for(i=0;i<count;i++)	
		  	{
	    		tempchar = fname.substring (i,i+1);
                if (ref.indexOf (tempchar, 0) == -1)
				{
					alert("Please Enter Valid Firstname.");
                    return (false); 
				}
            }*/
			if (count <= 1)
			{
				alert("First name should have more than one character, try again");
				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 passenger. If you do not have, enter the initials");
			form["Lastname[]"].focus();
	 		return false; 
		}
		/*else
		{
			
			count=lname.length;
			for(i=0;i<count;i++)
	  		{
    			tempchar = lname.substring(i,i+1);
                if (ref.indexOf (tempchar, 0) == -1)
				{
			  		alert("Please Enter Valid Lastname.");
                    return (false); 
				}
            }
			if (count <= 1)
			{
				alert("Lastname should be more than 1 character long.");
                return (false);
			}else if (count > 50)
			{	alert("Lastname should be less than 50 character.");
				  return (false);
			}
			//xajax_passengerstore(xajax.getFormValues('passengerform'),type);
		}	*/	
	} 
	return true;
}

function DeliveryCalltest(form)
{
	xajax_deliverystore(xajax.getFormValues('deliveryform'));
}

function loadingpage(value,requestid)
{
	

	document.getElementById('Divloadingpage').className="show";
	if(value==1)
	{
		setTimeout('loadinghide('+requestid+')',7000);
	}
	else if(value==0)
	{
		setTimeout('loadingnomoreflights()',7000);
	}
	else
	{
		setTimeout('loadinghideerror()',7000);
	}
}

function showloading()
{
	document.getElementById('Divloadingpage').className="show";
}

function closeloading()
{
	document.getElementById('Divloadingpage').className="hide";
}

function loadinghide(requestid)
{
	//if(requestid > 0)
	//{
		xajax_selectmultiairline(requestid);
	//}
	//else
	//{
		//document.resubmitfarepost.submit();
	//}
	//document.getElementById('Divloadingpage').className="hide";
	//document.location.href = "https://www.atyourprice.in/yourprice/securitypayment.php";
	//document.location.href = "../yourprice/securitypayment.php?requestdate="+requestdate;
	//document.getElementById('DivPaymentdetails').className="show";
}
function loadingnomoreflights()
{
	//alert('loadingnomoreflights');
	//document.getElementById('newabacussearchtpl').className="show";
	//document.getElementById('airlinefilter').className="show";
	
	//document.getElementById('bidagaindiv').className="hide";
	document.getElementById('Divloadingpage').className="hide";
	document.getElementById('Divnomoreflights').className="show";
}
function loadinghideerror()
{
	//alert('loadinghideerror');
	//document.getElementById('newabacussearchtpl').className="show";
	//document.getElementById('airlinefilter').className="show";
	
	//document.getElementById('bidagaindiv').className="show";
	document.getElementById('Divloadingpage').className="hide";
	document.getElementById('Displayalternate').className="show";
	document.getElementById('infodiv').className = "show";
	document.getElementById('altfare').className="show"
}

function entsubimtresubmitquote(evt) 
{
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if ((charCode > 31) && (charCode < 48 || charCode > 57)) 
	{
        return false;
    }
	if( charCode == 13) 
	{
		 if(resubmitquote())
		 {
			return true; 
		 }
		 else
		 {
			return false; 
		 }
	}
    return true;
}

function resubmitquote()
{
	newfare = document.getElementById('requotefare').value;
	reqfare = document.getElementById('alternatefare').value;

	if(newfare=="")
	{
		alert(" Please enter the price you would like to quote.");
		document.getElementById('requotefare').focus();
		return false
	}
	newfare = parseInt(newfare);
	reqfare = parseInt(reqfare);
	if(reqfare >= newfare)
	{
		alert('New fare must be more than  Rs'+reqfare)
		document.getElementById('requotefare').focus();
		document.getElementById('requotefare').select();
		return false;
	}
	document.getElementById('Divloadingpage').className="show";
	requestdate = document.getElementById('sessionrequestdate').value;
	xajax_resubmitquote(newfare,requestdate);
	document.getElementById('Displayalternate').className="hide";
}

function bidagain()
{
	
	newfare = document.getElementById('requotefare').value;
	if(newfare=="")
	{
		alert(" Please enter the price you would like to quote.");
		document.getElementById('requotefare').focus();
		return false;
	}
	document.getElementById('requotefare').value = "";
	document.getElementById('Divloadingpageold').className="hide";
	document.getElementById('bidagaindiv').className="hide";
	document.getElementById('popup').className="hide";
	//document.getElementById('requotefare').value = newfare ;
	

	
	document.getElementById('Divloadingpage').className="show";
	requestdate = document.getElementById('sessionrequestdate').value;
	xajax_resubmitquote(newfare,requestdate);
	document.getElementById('Displayalternate').className="hide";
}
function DeliveryCall(form)
{
	
	if(!PassengerCall(form,''))
	{
			
			return false;
	}
	
	var bmobile=form.Bmobileno.value;
    var bemail=form.Bemailid.value;
	bemail=trim(bemail);
   /*var email=form.Emailid.value;
   	var baddrone=form.Baddress1.value;
   	var baddrtwo=form.Baddress2.value;
   	var baddrthree=form.Baddress3.value;	  	
   	var bcity=form.Bcity.value;
   	var bstate=form.Bstate.value;
	var bcountry=form.Bcountry.value;
    var bphone=form.Bphoneno.value;
    var bpincode=form.Bpincode.value;
	var bareacode=form.Bareacode.value;
	
	email=trim(email);
	baddrone=trim(baddrone);
	baddrtwo=trim(baddrtwo);
	baddrthree=trim(baddrthree);
	bcity=trim(bcity);
	
	

	if(baddrone=='')
	{
 		alert("Enter a valid billing address1.");
		form.Baddress1.focus();
 		return false;
 	}
	else if (baddrone.length > 50) 
	{	
 		alert("Address line length should be less than 51 characters.");
		form.Baddress1.value='';
		form.Baddress1.focus();
 		return false;	
	}
	else
	{
		count=baddrone.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrone.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address1. No special characters like "+tempchar+" are not allowed.");
				form.Baddress1.value='';
				form.Baddress1.focus();
				return (false); 
			}
        }
	}
	if(baddrtwo == '') 
	{
		//alert("address2");
		alert("Enter a valid billing address2.");
		form.Baddress2.focus();
		return false;
	}
	else if (baddrtwo.length > 50)
	{
		alert("Address line length should be less than 51 characters.");
		form.Baddress2.value='';
		form.Baddress2.focus();
		return (false);				
	}
	else
	{
		count=baddrtwo.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrtwo.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address2. No special characters like "+tempchar+" are not  allowed.");
				form.Baddress2.value='';
				form.Baddress2.focus();
				return (false); 
			}
        }
	}
	if(bphone=='')
	{
		alert("Enter billing address phone number.");
		form.Bphoneno.focus();
		return false;
	}
	else
	{
		if(bphone.length > 12)
 	 	{
   			alert("Please enter valid billing address phone number.");
			form.Bphoneno.focus();
			form.Bphoneno.value="";
    		return false;
  		}
  	}
	*/
	if(bmobile.length < 10 || bmobile=='0')
	{
		alert("Sorry, you have provided incorrect mobile number. Please provide your correct mobile number with 10 numeric characters ");
		form.Bmobileno.focus();
		return false;
	}
	else
	{
		if(bmobile.length >13)
 		{
	 		alert("Sorry, you have provided incorrect mobile number. Please provide your correct mobile number with 10 numeric characters");
			form.Bmobileno.focus();
			form.Bmobileno.value="";
			
   		 	return false;
		}
	}
	if(bemail=='')
	{
 		alert("Please enter your email-id");
		form.Bemailid.focus();
 		return false;
	}
	else
	{
		var str=form.Bemailid;
		
		if(EmailCheck(str)==false)
		{
			form.Bemailid.value=''
			form.Bemailid.focus();
			return false;
		}
		//return true	
	}
	/*
	if(bcity=='')
	{
		alert("Enter billing address city.");
		form.Bcity.focus();
		return false;
	}
	else
	{
		count=bcity.length;
		if(count >30 )
		{
			alert("Enter Correct billing address city.");
			form.Bcity.focus();
			form.Bcity.value='';
			return false;
		}
		for(i=0;i<count;i++)
		{
			tempchar = bcity.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing city name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bcity.value='';
				form.Bcity.focus();
				return false; 
			}
        }
	}
	if(bstate=='')
	{
		alert("Enter billing address state.");
		form.Bstate.focus();
	 	return false;
 	}
	else
	{
		count=bstate.length;
		
		if(count >30 )
		{
			alert("Enter Correct billing address State.");
			    form.Bstate.value='';
				form.Bstate.focus();
			
			return false;
		}
		
		for(i=0;i<count;i++)
		{
			tempchar = bstate.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing state name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bstate.value='';
				form.Bstate.focus();
				return false; 
			}
        }
	}
	if(bcountry=='')
	{
		alert("Enter billing address country.");
		form.Bcountry.focus();
 		return false;
	}
	else
	{
		count=bcountry.length;
		if(count >30 )
		{
			alert("Enter Correct billing address Country.");
			form.Bcountry.focus();
			form.Bcountry.value='';
			return false;
		}
		for(i=0;i<count;i++)
		{
			tempchar = bcountry.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing country name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bcountry.value='';
				form.Bcountry.focus();
				return false; 
			}
        }
	}
	if(bpincode=='')
	{
		alert("Enter billing address pincode.");
		form.Bpincode.focus();
		return false;
	}
	else
	{
		if(bpincode.length != 6)
		{
	 		alert("Pincode Should be Six Digit.");
			form.Bpincode.focus();
			form.Bpincode.value='';
			return false;
		}
	}
	if(bareacode=='')
	{
		alert("Enter billing address areacode");
		form.Bareacode.focus();
		return false;
	}
	else
	{
		if(bareacode.length  > 6)
   		{
			alert("Please enter valid billing address areacode.");
			form.Bareacode.focus();
			form.Bareacode.value='';
			return false;
		}
	}
	*/
 	//xajax_passengerstore(xajax.getFormValues('deliveryform'),'insert');
	document.getElementById('Divloadingpage').className ="show";
	document.getElementById('DivDeliveryshow').className="hide";
	return xajax_deliverystore(xajax.getFormValues('deliveryform'));
}
function UpdatePassenger(form)
{
	var addrone=form.Address1.value;
   	var addrtwo=form.Address2.value;
   	var addrthree=form.Address3.value;
    var city=form.City.value;
    var state=form.State.value;
	var country=form.Country.value;
   	var phone=form.Phoneno.value;
    var pincode=form.Pincode.value;
	var mobile=form.Mobileno.value;
   	var areacode=form.Areacode.value;
    var email=form.Emailid.value;
    var baddrone=form.Baddress1.value;
    var baddrtwo=form.Baddress2.value;
    var baddrthree=form.Baddress3.value;	  	
    var bcity=form.Bcity.value;
    var bstate=form.Bstate.value;
	var bcountry=form.Bcountry.value;
   	var bphone=form.Bphoneno.value;
    var bpincode=form.Bpincode.value;
	var bmobile=form.Bmobileno.value;
    var bareacode=form.Bareacode.value;
    var bemail=form.Bemailid.value;
	addrone=trim(addrone);	
	addrtwo=trim(addrtwo);		
	addrthree=trim(addrthree);
	city=trim(city);
	email=trim(email);
	baddrone=trim(baddrone);
	baddrtwo=trim(baddrtwo);
	baddrthree=trim(baddrthree);
	bcity=trim(bcity);
	bemail=trim(bemail);
	if(email=='')
	{
 		alert("Please enter your email-id");
 		return false;
	}
	else
	{
		var str=form.Emailid.value;
		if(emailcheck(str)==false)
		{
			form.Emailid.value=''
			form.Emailid.focus();
			return false;
		}
	}
	if(addrone=='')
	{
		alert("Enter the correct delivery address so that we will be able to send your ticket to this address.");
		return false;
	}
	else if (addrone.length > 50) 
	{	
		alert("Sorry, currently we do not accept more than 50 characters for Address 1.\nIf your Address 1 exceed more than 50 characters, \n please enter the remaining in Address 2.");
		return false;	
	}
	else
	{
		count=addrone.length;
		for(i=0;i<count;i++)
		{
			tempchar = addrone.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please provide valid address1.special characters like "+tempchar+" are not allowed");
				return (false); 
			}
        }
	}
	if((addrtwo!='') && (addrtwo.length <= 50))
	{
		count=addrtwo.length;
		for(i=0;i<count;i++)
		{
			tempchar = addrtwo.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Sorry, our system does not accept special characters like "+tempchar+" ");
				return (false); 
			}
        }
	}
	else if (addrtwo.length > 50)
	{
		alert("Our system does not accept more than 51 characters for the Address field");
		return (false);				
	}
	if((addrthree!='') && (addrthree.length <= 50))
	{
		count=addrthree.length;
		for(i=0;i<count;i++)
		{
			tempchar = addrthree.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid address3.special characters like "+tempchar+" are not allowed");
				return (false); 
			}
        }
	}
	else if (addrthree.length > 50)
	{
		alert("Our system does not accept more than 51 characters for the Address field");
		return (false);				
	}
	if(city=='')
	{
		alert("Please enter the city in which you live");
	
		return false;
	}
	else
	{
		count=city.length;
		for(i=0;i<count;i++)
		{
			tempchar = city.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Sorry, our system does not accept special characters");
				return (false); 
			}
        }
	}
	if(state=='')
 	{
 		alert("Please enter the State in which you live");
	 	return false;
 	}
	if(phone=='')
	{
		alert("Please enter your Land line phone number with STD code");
		return false;
	}
	else
	{
		if(!(phone>9))
 	 	{
   	 		alert("Sorry, you have provided invalid number.\nPlease provide your correct phone number");
   		 	return false;
  		}
	}
	if(areacode=='')
	{
		alert("Please provide your areacode");
		return false;
	}
	else
	{
		if(!(areacode>=0))
       	{
			alert("Please provide a valid areacode");
			return false;
		}
	}		
	if(pincode=='')
	{
		alert("Please enter Pincode of your place");
		return false;
	}
	else
	{
		if(!(pincode>9))
		{
	 		alert("Please provide a valid pin code");
			return false;
		}
	}
	if(baddrone=='')
	{
 		alert("Please provide a valid billing address");
 		return false;
 	}
	else if (baddrone.length > 50) 
	{	
 		alert("Address line length should be less than 51 characters");
 		return false;	
	}
	else
	{
		count=baddrone.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrone.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address1.special characters like "+tempchar+" are not allowed");
				return (false); 
			}
        }
	}
	if((baddrtwo!='') && (baddrtwo.length <= 50))
	{
		count=baddrtwo.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrtwo.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address2. No special characters like "+tempchar+" are not  allowed.");
				return (false); 
			}
        }
	}
	else if (baddrtwo.length > 50)
	{
		alert("Address line length should be less than 51 characters");
		return (false);				
	}
	if((baddrthree!='') && (baddrthree.length <= 50))
	{
		count=baddrthree.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrthree.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address3.Special characters like "+tempchar+" are not allowed.");
				return (false); 
			}
		}
	}
	else if (baddrthree.length > 50)
	{
		alert("Address line length should be less than 51 characters.");
		return (false);				
	}
	if(bcity=='')
	{
		alert("Please enter the City in which you live");
		return false;
 	}
	else
	{
		count=bcity.length;
		for(i=0;i<count;i++)
		{
			tempchar = bcity.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Sorry, our system does not accept  special characters like  "+tempchar+" \n Please provide us correct City name.");
				return (false); 
			}
        }
	}
	if(bstate=='')
 	{
 		alert("Please enter the State in which you live");
	 	return false;
 	}
	if(bphone=='')
	{
 		alert("Please enter STD code with your Land line number");
 		return false;
 	}
 	else
 	{
  		if(!(bphone>9))
  		{
		 	alert("Sorry, Please enter correct Land line number,\n so that we will be able to contact you when it is necessary");
    		return false;
  		}
  	}
	if(bareacode=='')
 	{
		alert("Please supply your areacode");
		return false;
 	}
 	else
 	{
		if(!(bareacode>=0))
     	{
			alert("Please supply a valid areacode");
			return false;
		}
 	}		
	if(bpincode=='')
	{
  		alert("Please enter Pincode of your place.");
  		return false;
 	}
 	else
 	{
  		if(!(bpincode>9))
  		{
 			alert("Please provide a valid pincode");
   			return false;
  		}
 	}
	if(bemail=='')
	{
		alert("Please enter your e-mail id ");
		return false;
	}
	else
	{
		var str=form.Bemailid.value;
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1)
		{
		   	alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
			return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
			alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
			return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		   	alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		   	return false
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
		   	alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		   	return false
		}
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		   	alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		   	return false
		}
		if (str.indexOf(dot,(lat+2))==-1)
		{
		   	alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		   	return false
		}
		if (str.indexOf(" ")!=-1)
		{
		   alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		   	return false
		}
		//return true	
	}
	//alert("Update Passenger");
	xajax_updatepassenger(xajax.getFormValues('passengerform'));
}
function UpdateDelivery(form)
{
	if(!PassengerCall(form,''))
	{
			
			return false;
	}
	/*
	var email=form.Emailid.value;
   	var baddrone=form.Baddress1.value;
   	var baddrtwo=form.Baddress2.value;
   	var baddrthree=form.Baddress3.value;	  	
   	var bcity=form.Bcity.value;
   	var bstate=form.Bstate.value;
	var bcountry=form.Bcountry.value;
    var bphone=form.Bphoneno.value;
    var bpincode=form.Bpincode.value;
	
   	var bareacode=form.Bareacode.value;
	email=trim(email);
	baddrone=trim(baddrone);
	baddrtwo=trim(baddrtwo);
	baddrthree=trim(baddrthree);
	bcity=trim(bcity);
	*/
	var bmobile=form.Bmobileno.value;
    var bemail=form.Bemailid.value;
	bemail=trim(bemail);
/*
	if(baddrone=='')
	{
 		alert("Enter a valid billing address1.");
		form.Baddress1.focus();
 		return false;
 	}
	else if (baddrone.length > 50) 
	{	
 		alert("Address line length should be less than 51 characters.");
		form.Baddress1.value='';
		form.Baddress1.focus();
 		return false;	
	}
	else
	{
		count=baddrone.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrone.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address1. No special characters like "+tempchar+" are not allowed.");
				form.Baddress1.value='';
				form.Baddress1.focus();
				return (false); 
			}
        }
	}
	if(baddrtwo == '') 
	{
		//alert("address2");
		alert("Enter a valid billing address2.");
		form.Baddress2.focus();
		return false;
	}
	else if (baddrtwo.length > 50)
	{
		alert("Address line length should be less than 51 characters.");
		form.Baddress2.value='';
		form.Baddress2.focus();
		return (false);				
	}
	else
	{
		count=baddrtwo.length;
		for(i=0;i<count;i++)
		{
			tempchar = baddrtwo.substring (i,i+1);
			if (refaddr.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing address2. No special characters like "+tempchar+" are not  allowed.");
				form.Baddress2.value='';
				form.Baddress2.focus();
				return (false); 
			}
        }
	}
	if(bphone=='')
	{
		alert("Enter billing address phone number.");
		form.Bphoneno.focus();
		return false;
	}
	else
	{
		if(bphone.length > 12)
 	 	{
   			alert("Please enter valid billing address phone number.");
			form.Bphoneno.focus();
			form.Bphoneno.value="";
    		return false;
  		}
  	}
	*/
	if(bmobile.length < 10 || bmobile=='0')
	{
		alert("Sorry, you have provided incorrect mobile number.\n Please provide your correct mobile number with 10 numeric characters");
		form.Bmobileno.focus();
		return false;
	}
	else
	{
		if(bmobile.length >13)
 		{
	 		alert("Sorry, you have provided incorrect mobile number.\n Please provide your correct mobile number with 10 numeric characters");
			form.Bmobileno.focus();
			form.Bmobileno.value="";
			
   		 	return false;
		}
	}
	if(bemail=='')
	{
 		alert("Please enter your mobile number.  Ensure that you given us correct mobile number,  so that we will be able to contact you when it is necessary. ");
		form.Bemailid.focus();
 		return false;
	}
	else
	{
		var str=form.Bemailid.value;
		if(emailcheck(str)==false)
		{
			form.Bemailid.value=''
			form.Bemailid.focus();
			return false;
		}
		//return true	
	}
	/*
	if(bcity=='')
	{
		alert("Enter billing address city.");
		form.Bcity.focus();
		return false;
	}
	else
	{
		count=bcity.length;
		if(count >30 )
		{
			alert("Enter Correct billing address city.");
			form.Bcity.focus();
			form.Bcity.value='';
			return false;
		}
		for(i=0;i<count;i++)
		{
			tempchar = bcity.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing city name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bcity.value='';
				form.Bcity.focus();
				return false; 
			}
        }
	}
	
	if(bstate=='')
	{
		alert("Enter billing address state.");
		form.Bstate.focus();
	 	return false;
 	}
	else
	{
		count=bstate.length;
		
		if(count >30 )
		{
			alert("Enter Correct billing address State.");
			    form.Bstate.value='';
				form.Bstate.focus();
			
			return false;
		}
		
		for(i=0;i<count;i++)
		{
			tempchar = bstate.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing state name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bstate.value='';
				form.Bstate.focus();
				return false; 
			}
        }
	}
	if(bcountry=='')
	{
		alert("Enter billing address country.");
		form.Bcountry.focus();
 		return false;
	}
	else
	{
		count=bcountry.length;
		if(count >30 )
		{
			alert("Enter Correct billing address Country.");
			form.Bcountry.focus();
			form.Bcountry.value='';
			return false;
		}
		for(i=0;i<count;i++)
		{
			tempchar = bcountry.substring (i,i+1);
			if (refalpha.indexOf (tempchar, 0) == -1)
			{
				alert("Please enter valid billing country name. No special characterslike "+tempchar+" are not  allowed.");
				form.Bcountry.value='';
				form.Bcountry.focus();
				return false; 
			}
        }
	}
	if(bpincode=='')
	{
		alert("Enter billing address pincode.");
		form.Bpincode.focus();
		return false;
	}
	else
	{
		if(bpincode.length > 9)
		{
	 		alert("Invalid billing address pincode.");
			form.Bpincode.focus();
			form.Bpincode.value='';
			return false;
		}
	}
	if(bareacode=='')
	{
		alert("Enter billing address areacode");
		form.Bareacode.focus();
		return false;
	}
	else
	{
		if(bareacode.length >9)
   		{
			alert("Please enter valid billing address areacode.");
			form.Bareacode.focus();
			form.Bareacode.value='';
			return false;
		}
	}	
	*/
	//xajax_passengerstore(xajax.getFormValues('deliveryform'),'insert');
	xajax_updatedelivery(xajax.getFormValues('deliveryform'));
	
	
}
function EditPassenger()
{
	//alert("Edit Passenger12");
	document.getElementById("DivPassengerdetails").className = "show";
	//document.getElementById("DivPassengershow").className = "hide";
	//document.getElementById("DivUpdatepassenger").className = "show";
	
	document.getElementById("DivDeliveryshow").className = "hide";
	document.getElementById("DivUpdatedeliveryshow").className = "show";
	
}
function EditDelivery()
{
	//alert("Edit Delivery");
	document.getElementById("DivBillingdetails").className = "show";
	document.getElementById("DivDeliveryshow").className = "hide";
	document.getElementById("DivUpdatedeliveryshow").className = "show";
}
function bilingchange()
{
	if(document.getElementById("change").checked == true)
	{
		document.getElementById("DivBiling").className ="show";
	}
	else
	{
		document.getElementById("DivBiling").className ="hide";
	}
}

function createnewuser()
{
	//alert("Show createnewuser")
	document.getElementById("DivLogindetails").className = "hide";
	document.getElementById("DivNewuserdetails").className = "show";
}

function newuservalidation()
{
	//alert("new user validation");
		
	var user=document.newuserform;
	//alert("Passenger")
	if (user.Loginid.value == "")
	{
   		alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
  		user.Loginid.focus();
   		return false;
	}
	if (user.Password.value == "")
	{
  	 	alert("Please enter the first password");
  	 	user.Password.focus();
  		 return false;
	}
	
	if (user.Rpasswd.value == "")
	{
  	 	alert("Please enter the second password");
  	 	user.Rpasswd.focus();
  		 return false;
	}
	if (user.Firstname.value == "")
	{
   		alert("Please enter the first name");
   		user.Firstname.focus();
   		return false;
	}
	if (user.Mobileno.value == "")
	{
   		alert("Please provide your correct Mobile number \n so that we will be able to contact you when it is necessary");
   		user.Mobileno.focus();
   		return false;
	}
	if (user.Loginid.value != "")
	{
		if(!EmailCheck(user.Loginid))
			return false;
	}
	if (user.Password.value !=  user.Rpasswd.value) 
	{
		//PassCheckBoth(user.Password , user.Rpasswd);
		alert("Incorrect Password two ");
		user.Password.value="";
		user.Rpasswd.value="";
		user.Password.focus();
		return false;
	} 

	xajax_xajaxnewuser(xajax.getFormValues('newuserform'));
 	visible();
	return true;
}

function sendpassword(divpwd)
{
	
	if(divpwd == 'latestforgotpwd')
	{
	  mail_to=trim(document.getElementById('latestemailid').value);
	   			if(mail_to.length<=0 )
                {
                      alert("Please enter your loginid");
                      document.getElementById('latestemailid').focus();
                      return false;
                }else if(emailcheck(mail_to)==false)                 
				{
						document.getElementById('latestemailid').value="";
						document.getElementById('latestemailid').focus();
				}else 
				{
					xajax_sendpassword(mail_to);
				}
	}
	if(divpwd == 'forgotpwd')
	{
	  mail_to=trim(document.getElementById('emailid').value);
	   			if(mail_to.length<=0 )
                {
                      alert("Please enter your loginid");
                      document.getElementById('emailid').focus();
                      return false;
                }else if(emailcheck(mail_to)==false)                 
				{
						document.getElementById('emailid').value="";
						document.getElementById('emailid').focus();
				}else 
				{
					xajax_sendpassword(mail_to);
				}
	}

}


function newusersignup(divname)
{
	//alert("Show createnewuser")
	
	if(divname == "logintpldiv")
	{
		document.getElementById("logintpldiv").className = "hide";
		document.getElementById("latestforgotdiv").className = "hide";
		document.getElementById("latestsignupdivshow").className = "show";
		document.getElementById("latestnewLoginid").value = "";
		document.getElementById("latestnewPassword").value = "";
		document.getElementById("latestnewFirstname").value = "";
		document.getElementById("latestnewLoginid").focus();
	}
	else if(divname == "divloginmain")
	{
		document.getElementById("divloginmain").className = "hide";
		document.getElementById("forgotdiv").className = "hide";
		document.getElementById("signupdivshow").className = "show";
		document.getElementById("newLoginid").value = "";
		document.getElementById("newPassword").value = "";
		document.getElementById("newFirstname").value = "";
		document.getElementById("newLoginid").focus();
	}
}
function forgotpassword(divname)
{
	//alert("Show createnewuser")
	if(divname == "logintpldiv")
	{
		document.getElementById("latestforgotdiv").className = "show";
		document.getElementById("logintpldiv").className = "hide";
		document.getElementById("latestemailid").value = "";
		document.getElementById("latestemailid").focus();
	}
	else if(divname == "divloginmain")
	{
		document.getElementById("forgotdiv").className = "show";
		document.getElementById("divloginmain").className = "hide";
		document.getElementById("divagentlogin").className = "hide";
		document.getElementById("emailid").value = "";
		document.getElementById("emailid").focus();
	}
}

function newuservalidationcheck(type)
{
	if(document.getElementById("latestnewLoginid"))
	{
		divname = "logintpldiv";
		if (document.getElementById("latestnewLoginid").value == "")
		{
			alert("Enter your e-mail id");
			document.getElementById("latestnewLoginid").focus();
			return false;
		}
		if (document.getElementById("latestnewLoginid").value != "")
		{
			if(emailcheck(document.getElementById("latestnewLoginid").value)==false)
			{
				document.getElementById('latestnewLoginid').value = "";
				document.getElementById('latestnewPassword').value = "";
				document.getElementById('latestnewFirstname').value = "";
				document.getElementById('latestnewLoginid').focus();
				return false;
			}
				
		}
		if (document.getElementById("latestnewPassword").value == "")
		{
			alert("Please enter your password");
			document.getElementById("latestnewPassword").focus();
			 return false;
		}
		
		if (document.getElementById("latestnewFirstname").value == "")
		{
			alert("Please enter your name");
			document.getElementById("latestnewFirstname").focus();
			return false;
		}
		if(type == 'coupon')
		{
			xajax_latestnewuser(xajax.getFormValues("latestsignupformmain"),divname,type);
		}
		else
		{
			xajax_latestnewuser(xajax.getFormValues("latestsignupformmain"),divname,'');
		}
	}
	else
	{
		divname ="divloginmain";
		
		if (document.getElementById("newLoginid").value == "")
		{
			alert("Enter your e-mail id");
			document.getElementById("newLoginid").focus();
			return false;
		}
		if (document.getElementById("newLoginid").value != "")
		{
			if(emailcheck(document.getElementById("newLoginid").value)==false)
			{
				document.getElementById('newLoginid').value = "";
				document.getElementById('newPassword').value = "";
				//document.getElementById('newFirstname').value = "";
				document.getElementById('newLoginid').focus();
				return false;
			}
				
		}
		if (document.getElementById("newPassword").value == "")
		{
			alert("Please enter your password");
			document.getElementById("newPassword").focus();
			 return false;
		}
		document.getElementById("newFirstname").value = document.getElementById('newLoginid').value;
		requestidvalue ='';
		if(document.getElementById('newrequestidvalue'))
		{
			requestidvalue = document.getElementById('newrequestidvalue').value;
		}
		if(type == 'coupon')
		{
			xajax_latestnewuser(xajax.getFormValues("signupformmain"),divname,type);
		}
		else
		{
			xajax_newuser(xajax.getFormValues("signupformmain"),divname,requestidvalue);
		}
	}
	//user.submit();
	
	return true;
}
 

function EmailCheck(mail)
{
	var str = mail.value;	
	//alert(str)
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1)
	{
	   alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
	   mail.value='';
	   mail.focus();
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at) == lstr)
	{
	  alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
	   mail.value = "";
	   mail.focus();
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot) == lstr)
	{
	    alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		mail.value = "";
	    mail.focus();
	    return false;
	}
	if (str.indexOf(at,(lat+1))!= -1)
	{
		alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		mail.value = "";
	    mail.focus();
	    return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2) == dot)
	{
		alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		mail.value = "";
	    mail.focus();
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
		mail.value = "";
		mail.focus();
		return false;
	}
	if (str.indexOf(" ")!= -1)
	{
		alert("Enter your E-mail id. Please provide the correct e-mail id so that we will be able to communicate");
	    mail.value = "";
		mail.focus();
		return false;
	}
 	return true;					
}

function visible()
{
	//alert("ok validation");
	document.getElementById("DivLogindetails").className = "show";
	document.getElementById("DivNewuserdetails").className = "hide";
}
	
function commentnotempty(commentform)
{
	var commentname = document.commentform.name.value;
	var commentemail = document.commentform.email.value;
	var comment = document.commentform.commentsbox.value;
	var commenttype = document.commentform.radio1.value; 
	var commentfound = document.commentform.found.value;
	var commentrate = document.commentform.box2.value;

	if (commentname == '')
	{
		alert("Please enter your name");
        return false;
	}

	if (commentemail == '')
	{
		alert("Please provide your email id");
        return false;
	}
	if (comment == '')
	{
		alert("Please provide the comment");
        return false;
	}
	if (commenttype == '')
	{
		alert("Please provide the nature of your feedback");
        return false;
	}
	if (commentfound == '')
	{
		alert("Please tell us how you heard about atyourprice.in");
        return false;
	}
	if (commentrate == '')
	{
		alert("Do you like to rate our services, if so, please do so ");
        return false;
	}
}

function loginpage()
{
	//alert('login1')
	pass = document.getElementById("Userpwd").value;
	user = document.getElementById("Loginid").value;
	if(user=="")
	{
		alert("Please enter your valid login id ");
		return false;
	}
	else
	{
		if(emailcheck(user)==false)
		{
			//document.loginform.Loginid.value=''
			//document.loginform.Loginid.focus();
			user.focus();
			return false;
		}
	}
	
	
	if(pass=="")
	{
		alert('Please enter your password');
		return false;
	}
	//alert(user+"  AND  "+pass);
	xajax_loginpagecheck(xajax.getFormValues('loginform'))
}

function loginpagemain()
{
	//alert('login2')
	pass = document.getElementById("Userpwd").value;
	user = document.getElementById("Loginid").value;
	//alert(user+pass)
	if(user=="")
	{
		alert("Please enter your valid login id");
		return false;
	}
	else
	{
		if(emailcheck(user)==false)
		{
			//document.loginform.Loginid.value=''
			//document.loginform.Loginid.focus();
			user.focus();
			return false;
		}
	}
	if(pass=="")
	{
		alert("Please enter your password");
		return false;
	}
	//alert(user+"  AND  "+pass);
	xajax_loginmainpagecheck(xajax.getFormValues('loginformmain'));
	//window.location.reload();
}



/*function hidediv(divname,imgid,divid)
{
	//alert(imgname)
	img1_open = new Image();
	img1_close = new Image();
	img1_open = 'images/arrow_down.gif';
	img1_close = 'images/arrow_right.gif';
	class = document.getElementById(divname).className;
	if(divid=="passenger")
	{
		count = document.getElementById("counti").value;
	}
	if(class=="show")
	{
		document.getElementById(divname).className = "hide";
		document.getElementById(imgid).src = img1_close;
	}
	else
	{
		document.getElementById(divname).className = "show";
		document.getElementById(imgid).src = img1_open;
	}
	
	//image = document.getElementById(imgid).src;
	//alert(image)
}*/

function loginpagepopup(logintype)
{
	//alert('login1new ')
	pass = document.getElementById("passpopup").value;
	user = document.getElementById("loginpopup").value;
	//alert(user+" pass "+pass)
	if(user=="")
	{
		alert("Please enter your valid login id");
		document.getElementById("loginpopup").focus();
		return false;
	}
	else
	{
		if(emailcheck(user)==false)
		{
			//document.loginform.Loginid.value=''
			//document.loginform.Loginid.focus();
			document.getElementById("loginpopup").value = "";
			document.getElementById("passpopup").value = "";
			document.getElementById("loginpopup").focus();
			return false;
		}
	}
	if(pass=="")
	{
		alert("Please enter your password");
		document.getElementById("passpopup").focus();
		return false;
	}
	//alert(user+"  AND  "+pass);
	if(logintype == 'request')
	{
		xajax_loginpagecheck(xajax.getFormValues('loginformpopup'),'accept');
	}
	else if (logintype == 'coupon')
	{
		xajax_loginpagecheck(xajax.getFormValues('loginformpopup'),'coupon');
	}
}

function loginpagemainpopup()
{
	//alert('loginpagemainpopup')
	pass = document.getElementById("passpopupmain").value;
	user = document.getElementById("loginpopupmain").value;
	//alert(user);
	//alert(user+"   "+pass)
	if(user=="")
	{
		alert("Please enter your valid login id");
		document.getElementById("loginpopupmain").focus();
		return false;
	}
	if (user != "")
	{
		if(!emailcheck(user))
		{
			document.getElementById("loginpopupmain").value = "";
			document.getElementById("passpopupmain").value = "";
			document.getElementById("loginpopupmain").focus();
			return false;
		}
	}
	if(pass=="")
	{
		alert("Please enter your password");
		document.getElementById("passpopupmain").focus();
		return false;
	}
	requestidvalue ='';
	if(document.getElementById('newrequestidvalue'))
	{
		requestidvalue = document.getElementById('newrequestidvalue').value;
	}
	//alert(user+"  AND  "+pass);
	xajax_loginmainpagecheck(xajax.getFormValues('loginformmainpopup'),'',requestidvalue);
	//window.location.reload();
}

function agentlogincheck()
{
	pass = document.getElementById("agentpassword").value;
	user = document.getElementById("agentid").value;
	//alert(user);
	//alert(user+"   "+pass)
	if(user=="")
	{
		alert("Please enter your valid login id");
		document.getElementById("agentid").focus();
		return false;
	}
	if (user != "")
	{
		if(!emailcheck(user))
		{
			document.getElementById("agentid").value = "";
			document.getElementById("agentpassword").value = "";
			document.getElementById("agentid").focus();
			return false;
		}
	}
	if(pass=="")
	{
		alert("Please enter your password");
		document.getElementById("agentpassword").focus();
		return false;
	}
	//alert(user+"  AND  "+pass);
	xajax_loginmainpagecheck(xajax.getFormValues('agentloginfrm'),'agent');
}

function loginmainshow()
{
	//alert('loginmainshow')
	document.getElementById('logindivshow').className = "show";
}

function newusershow()
{
	//alert('newusershow')
	document.getElementById('signupdivshow').className = "show";
}


/*
function alertcall(content)
{
	document.getElementById('insidealert').innerHTML = content;
	document.getElementById('insidealert').className = "show";
	document.getElementById('alert').className = "show";
	
}*/
/*function itineraryprint()
{
	alert("Print");
	printpage.document.getElementById('printarea').innerHTML=document.getElementById('Itinerary').innerHTML;
	printpage.selfprint();
}*/
function submitrequest() 
{ 
		var radioobject=document.filterusers.condition;
		var option="";
		var startdate="";
		var enddate="";
		var lastcondition="";
		var today="";
		var emailuser="";
			
		var len = document.filterusers.condition.length
		
		for (i=0; i <len; i++) 
		{
			if (document.filterusers.condition[i].checked) 
			{
				optionvalue = document.filterusers.condition[i].value;
				
				break;
			}
		}
		
		if(optionvalue=="userem")
		{
			if(document.getElementById("useremail"))
			{
				emailuser=document.getElementById("useremail").value;
				if(trim(emailuser)=="")
				 {
					 alert("Please enter the e-mail id");
					 document.getElementById("emailuser").focus();
					 return false;
				 }
					
				else
				{
				//var str=form.Bemailid.value;
				var at="@";
				var dot=".";
				var lat=emailuser.indexOf(at);
				var lstr=emailuser.length;
				var ldot=emailuser.indexOf(dot);
				if (emailuser.indexOf(at)==-1)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.indexOf(at)==-1 || emailuser.indexOf(at)==0 || emailuser.indexOf(at)==lstr)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.indexOf(dot)==-1 || emailuser.indexOf(dot)==0 || emailuser.indexOf(dot)==lstr)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.indexOf(at,(lat+1))!=-1)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.substring(lat-1,lat)==dot || emailuser.substring(lat+1,lat+2)==dot)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.indexOf(dot,(lat+2))==-1)
				{
					alert("Please enter the valid e-mail id");
					return false
				}
				if (emailuser.indexOf(" ")!=-1)
				{
				   alert("Please enter the valid e-mail id");
					return false
				}
		
			}
		}




		}
else if(optionvalue=="daterange")
		{
			 startdate=document.getElementById("startdate").value;
			 enddate=document.getElementById("enddate").value;
			// alert(startdate);
			// alert(enddate);
			  //alert(optionvalue);
			 if(trim(startdate)=="")
			 {
				 alert("Please Enter Start Date");
				 document.getElementById("startdate").focus();
				 return false;
		     }
			 if(trim(enddate)=="")
			 {
				 alert("Please Enter End Date");
				 document.getElementById("enddate").focus();
				 return false;
		     }
		}else if(optionvalue=="last")
		{
				lastcondition=document.getElementById("lastcondition").value;
				 // alert(lastcondition);
		}
		userfrom=document.getElementById("usersource").value;
		//userfrom='';
		xajax_displayusers(lastcondition,userfrom,startdate,enddate,emailuser);
		
} 

function displaybooking() 
{ 
		var radioobject=document.showbook.condition;
		var emailid = document.getElementById("email").value;
		var resource = document.getElementById("request_source").value;
		var option="";
		var startdate="";
		var enddate="";
		var lastcondition="";
		var today="";
		var particularmail=document.getElementById("partemailid").value;
		
		var len = document.showbook.condition.length
		
		for (i=0; i <len; i++) 
		{
			if (document.showbook.condition[i].checked) 
			{
				optionvalue = document.showbook.condition[i].value;
				break;
			}
		}
		
				
		
		if(optionvalue=="daterange")
		{
			 startdate=document.getElementById("startdate").value;
			 enddate=document.getElementById("enddate").value;
			// alert(startdate);
			// alert(enddate);
			  //alert(optionvalue);
			 if(trim(startdate)=="")
			 {
				 alert("Please Enter Start Date");
				 document.getElementById("startdate").focus();
				 return false;
		     }
			 if(trim(enddate)=="")
			 {
				 alert("Please Enter End Date");
				 document.getElementById("enddate").focus();
				 return false;
		     }
		}
		else if(optionvalue=="last")
		{
				lastcondition=document.getElementById("lastcondition").value;
				 // alert(lastcondition);
		}
		else if(optionvalue=="singlerequest")
		{
				lastcondition=document.getElementById("partrequest").value;
				if(lastcondition == '')
				{
					alert("Please enter the request number");
					 document.getElementById("partrequest").focus();
					 return false;
				}
				 // alert(lastcondition);
		}
		xajax_searchorder(emailid,lastcondition,startdate,enddate,particularmail,resource);
		
} 



function showdate(valueRadio)
{
	if(valueRadio=="daterange")
	{
		document.getElementById("dateshow").style.display='block';
		
	}else
	{
		document.getElementById("dateshow").style.display='none';
	}
	if(document.getElementById("individualshow"))
	{
		if(valueRadio=="individual")
		{
			document.getElementById("individualshow").style.display='block';
		}
		else
		{
			document.getElementById("individualshow").style.display='none';
		}
	}

	if(document.getElementById("usershow"))
	{

		if(valueRadio=="userem")
		{
			document.getElementById("usershow").style.display='block';
		}
		else
		{
			document.getElementById("usershow").style.display='none';
		}
	}


}

function insertsymbolstartdate(datevalue,evt)
{
	
	if (!(evt.keyCode == 46 || evt.keyCode == 8)) 
	{
			if(datevalue.length==4)
			{
				document.getElementById('startdate').value=datevalue+"-";
			}
			else if(datevalue.length==7)
			{
				document.getElementById('startdate').value=datevalue+"-";
			}else if(datevalue.length==8)
			{
				document.getElementById('startdate').value=datevalue+"-";
			}
	}
}

function insertsymbolenddate(datevalue,evt)
{
	if (!(evt.keyCode == 46 || evt.keyCode == 8)) 
	{		
				if(datevalue.length==4)
				{
						document.getElementById('enddate').value=datevalue+"-";
				}
				else if(datevalue.length==7)
				{
						document.getElementById('enddate').value=datevalue+"-";
				}
				else if(datevalue.length==8)
				{
						document.getElementById('enddate').value=datevalue+"-";
				}
	}
}
// add new enter key press call submit function 
function entsub(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	  if(loginpagemainpopup())
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
     return true;
  }
}

function entsubsecond(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	 if(loginpagepopup('request'))
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
    return true;
  }
}
function entsubnewuservalue(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	 if(newuservalidationcheck())
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
    return true;
  }
}
function entsubforgot(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	 if(sendpassword('latestforgotpwd'))
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
    return true;
  }
}
function entsubforgotnext(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	 if(sendpassword('forgotpwd'))
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
      return true;
  }
}
function entsubnewuser(event,ourform) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
	 if(newuservalidationcheck())
	 {
		return true; 
	 }
	 else
	 {
		return false; 
	 }
  }
  else
  {
    return true;
  }
}

function entsubagent(event,ourform)
{
	if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  	{
		 if(agentlogincheck())
		 {
			return true;	
		 }
		 else
		 {
			return false; 
		 }
  	}
  	else
  	{
   	 return true;
  	}
}

function entsubfocus(event,focusdivname) 
{
  if( (window.event && window.event.keyCode == 13) || (event && event.which == 13) )
  {
    document.getElementById(focusdivname).focus();
  }
  else
  {
    return true;
  }
}
// end bala enter key press function 
