// JavaScript Document
//script for open pop up window
var newwindow;
function poptastic1(url)
{
	newwindow=window.open(url,'name1','scrollbars=no,resizable=no,height=500,width=450');
	if (window.focus) {newwindow.focus()}
}
//script for registration
	function user_validation()
	{
		if(document.userfrm.varUserName.value=="")
		{
			alert("Please enter the User ID");
			document.userfrm.varUserName.focus();
			return false;
		}
		if(document.userfrm.varUserName.value.length <4)
		{
			alert("User ID must be atleast 4 character");
			document.userfrm.varUserName.focus();
			return false;
		}
		if(document.userfrm.varPassword.value=="")
		{
			alert("Please enter the Password");
			document.userfrm.varPassword.focus();
			return false;
		}
		if(document.userfrm.varPassword.value.length <4)
		{
			alert("Password must be atleast 4 character");
			document.userfrm.varPassword.focus();
			return false;
		}
		if(document.userfrm.varRepassword.value=="")
		{
			alert("Please enter the confirm Password");
			document.userfrm.varRepassword.focus();
			return false;
		}
		if(document.userfrm.varRepassword.value != document.userfrm.varPassword.value)
		{
			alert("Password should be same as Confirm Password");
			document.userfrm.varRepassword.focus();
			return false;
		}
		if(document.userfrm.varPassHint.value=="")
		{
			alert("Please enter the Password Hint");
			document.userfrm.varPassHint.focus();
			return false;
		}
		if(document.userfrm.varFirstName.value=="")
		{
			alert("Please enter the First Name");
			document.userfrm.varFirstName.focus();
			return false;
		}
		if(document.userfrm.varLastName.value=="")
		{
			alert("Please enter the Last name");
			document.userfrm.varLastName.focus();
			return false;
		}
		if(document.userfrm.varAddress.value=="")
		{
			alert("Please enter the Address");
			document.userfrm.varAddress.focus();
			return false;
		}
		if(document.userfrm.varCity.value=="")
		{
			alert("Please enter the City");
			document.userfrm.varCity.focus();
			return false;
		}
		if(document.userfrm.varState.value == "")
		{
			alert("Please select the State");
			document.userfrm.varState.focus();
			return false;
		}
		if(document.userfrm.varCountry.value == "Choose")
		{
			alert("Please select the Country");
			document.userfrm.varCountry.focus();
			return false;
		}
		if(document.userfrm.intZip.value=="")
		{
			alert("Please enter the Zip Code");
			document.userfrm.intZip.focus();
			return false;
		}
		if(document.userfrm.intPhone.value=="")
		{
			alert("Please enter the Phone Number");
			document.userfrm.intPhone.focus();
			return false;
		}
		if(isNaN(document.userfrm.intPhone.value))
		{
			alert("Phone Number must be Numeric");
			document.userfrm.intPhone.focus();
			return false;
		}
		if(document.userfrm.varEmail.value=="")
		{
			alert("Please enter the Email Address");
			document.userfrm.varEmail.focus();
			return false;
		}
		if(!validateEmail(document.userfrm.varEmail.value,1,1))
		{
			document.userfrm.varEmail.focus();
			return false;
		}
	}

//----------------script for login validation------------------//
function login_validation()
{
	if(document.loginfrm.login_name.value == "")
	{
		alert("Please enter the User Name");
		document.loginfrm.login_name.focus();
		return false;
	}
	if(document.loginfrm.login_pass.value == "")
	{
		alert("Please enter the Password");
		document.loginfrm.login_pass.focus();
		return false;
	}
}
//script for edit profile

	function useredit_validation()
	{
		if(document.userfrm.password_hint.value=="")
		{
			alert("Please enter the Password Hint");
			document.userfrm.password_hint.focus();
			return false;
		}
		if(document.userfrm.first_name.value=="")
		{
			alert("Please enter the First Name");
			document.userfrm.first_name.focus();
			return false;
		}
		if(document.userfrm.last_name.value=="")
		{
			alert("Please enter the Last name");
			document.userfrm.last_name.focus();
			return false;
		}
		if(document.userfrm.address.value=="")
		{
			alert("Please enter the Address");
			document.userfrm.address.focus();
			return false;
		}
		if(document.userfrm.city.value=="")
		{
			alert("Please enter the Address");
			document.userfrm.city.focus();
			return false;
		}
		if(document.userfrm.zip_code.value=="")
		{
			alert("Please enter the Zip Code");
			document.userfrm.zip_code.focus();
			return false;
		}
		if(document.userfrm.phone.value=="")
		{
			alert("Please enter the Phone");
			document.userfrm.phone.focus();
			return false;
		}
		if(document.userfrm.email.value=="")
		{
			alert("Please enter the Email Address");
			document.userfrm.email.focus();
			return false;
		}

	}
	//script for change password
	
	function changepass()
{
	if(document.c_passfrm.new_pass.value=="")
	{
		alert("Please enter the New Password");
		document.c_passfrm.new_pass.focus();
		return false;
	}
	if(document.c_passfrm.new_pass.value <=4)
	{
		alert("New Password muse be greater than 4 character");
		document.c_passfrm.new_pass.focus();
		return false;
	}
	if(document.c_passfrm.confirm_new_pass.value=="")
	{
		alert("Please enter the Confirm Password");
		document.c_passfrm.confirm_new_pass.focus();
		return false;
	}
	if(document.c_passfrm.new_pass.value != document.c_passfrm.confirm_new_pass.value)
	{
		alert("Password should be same as Confirm Password");
		document.c_passfrm.confirm_new_pass.focus();
		return false;
	}
}
//script for dealer information edit
function dealeredit_validation()
{
/*	if(document.applicationfrm.varUserName.value == "")
	{
		alert("Please enter the User Name");
		document.applicationfrm.varUserName.focus();
		return false;
	}
	if(document.applicationfrm.varUserName.value.length <4)
	{
		alert("User ID must be atleast 4 character");
		document.applicationfrm.varUserName.focus();
		return false;
	}
	if(document.applicationfrm.varPassword.value=="")
	{
		alert("Please enter the Password");
		document.applicationfrm.varPassword.focus();
		return false;
	}
	if(document.applicationfrm.varPassword.value.length <4)
	{
		alert("Password must be atleast 4 character");
		document.applicationfrm.varPassword.focus();
		return false;
	}
	if(document.applicationfrm.varRepassword.value=="")
	{
		alert("Please enter the confirm Password");
		document.applicationfrm.varRepassword.focus();
		return false;
	}
	if(document.applicationfrm.varRepassword.value != document.applicationfrm.varPassword.value)
	{
		alert("Password should be same as Confirm Password");
		document.applicationfrm.varRepassword.focus();
		return false;
	}
	if(document.applicationfrm.varFirmName.value=="")
	{
		alert("Please enter the Firm Name");
		document.applicationfrm.varFirmName.focus();
		return false;
	}
*/	if(document.applicationfrm.varDealerNumber.value=="")
	{
		alert("Please enter the Seller's Permit Number");
		document.applicationfrm.varDealerNumber.focus();
		return false;
	}
	if(document.applicationfrm.varAddress.value=="")
	{
		alert("Please enter the Address");
		document.applicationfrm.varAddress.focus();
		return false;
	}
	if(document.applicationfrm.varCity.value=="")
	{
		alert("Please enter the City");
		document.applicationfrm.varCity.focus();
		return false;
	}
	if(document.applicationfrm.varState.value=="")
	{
		alert("Please enter the State");
		document.applicationfrm.varState.focus();
		return false;
	}
	if(document.applicationfrm.varZip.value=="")
	{
		alert("Please enter the Zip code");
		document.applicationfrm.varZip.focus();
		return false;
	}
	if(document.applicationfrm.varPhone.value=="")
	{
		alert("Please enter the Phone Number");
		document.applicationfrm.varPhone.focus();
		return false;
	}
	if(document.applicationfrm.varEmail.value=="")
	{
		alert("Please enter the Email Address");
		document.applicationfrm.varEmail.focus();
		return false;
	}
	if(!validateEmail(document.applicationfrm.varEmail.value,1,1))
	{
		document.applicationfrm.varEmail.focus();
		return false;
	}
}

//script for login validation(Dealer)
function loginpass_validation()
{
	if(document.loginfrm1.login_name.value=="")
	{
		alert("Please enter the User Name");
		document.loginfrm1.login_name.focus();
		return false;
	}
	if(document.loginfrm1.login_pass.value== "")
	{
		alert("Please enter the Password");
		document.loginfrm1.login_pass.focus();
		return false;
	}
}
//----------------script for forgot password validation---------//
function forgotpass_validation()
{
	if(document.forgotpassfrm.UserName.value == "")
	{
		alert("Please enter the User Name");
		document.forgotpassfrm.UserName.focus();
		return false;
	}
	if(document.forgotpassfrm.Email.value == "")
	{
		alert("Please enter the Email Address");
		document.forgotpassfrm.Email.focus();
		return false;
	}
	if(!validateEmail(document.forgotpassfrm.Email.value,1,1))
	{
		document.forgotpassfrm.Email.focus();
		return false;
	}
}
function dealer_validation()
{
	if(document.applicationfrm.varUserName.value == "")
	{
		alert("Please enter the User Name");
		document.applicationfrm.varUserName.focus();
		return false;
	}
	if(document.applicationfrm.varUserName.value.length <4)
	{
		alert("User ID must be atleast 4 character");
		document.applicationfrm.varUserName.focus();
		return false;
	}
	if(document.applicationfrm.varPassword.value=="")
	{
		alert("Please enter the Password");
		document.applicationfrm.varPassword.focus();
		return false;
	}
	if(document.applicationfrm.varPassword.value.length <4)
	{
		alert("Password must be atleast 4 character");
		document.applicationfrm.varPassword.focus();
		return false;
	}
	if(document.applicationfrm.varRepassword.value=="")
	{
		alert("Please enter the confirm Password");
		document.applicationfrm.varRepassword.focus();
		return false;
	}
	if(document.applicationfrm.varRepassword.value != document.applicationfrm.varPassword.value)
	{
		alert("Password should be same as Confirm Password");
		document.applicationfrm.varRepassword.focus();
		return false;
	}
	if(document.applicationfrm.varFirmName.value=="")
	{
		alert("Please enter the Firm Name");
		document.applicationfrm.varFirmName.focus();
		return false;
	}
	if(document.applicationfrm.varDealerNumber.value=="")
	{
		alert("Please enter the Seller's Permit Number");
		document.applicationfrm.varDealerNumber.focus();
		return false;
	}
	if(document.applicationfrm.varAddress.value=="")
	{
		alert("Please enter the Address");
		document.applicationfrm.varAddress.focus();
		return false;
	}
	if(document.applicationfrm.varCity.value=="")
	{
		alert("Please enter the City");
		document.applicationfrm.varCity.focus();
		return false;
	}
	if(document.applicationfrm.varState.value=="")
	{
		alert("Please enter the State");
		document.applicationfrm.varState.focus();
		return false;
	}
	if(document.applicationfrm.varZip.value=="")
	{
		alert("Please enter the Zip code");
		document.applicationfrm.varZip.focus();
		return false;
	}
	if(document.applicationfrm.varPhone.value=="")
	{
		alert("Please enter the Phone Number");
		document.applicationfrm.varPhone.focus();
		return false;
	}
	if(document.applicationfrm.varEmail.value=="")
	{
		alert("Please enter the Email Address");
		document.applicationfrm.varEmail.focus();
		return false;
	}
	if(!validateEmail(document.applicationfrm.varEmail.value,1,1))
	{
		document.applicationfrm.varEmail.focus();
		return false;
	}
	
	//  Validate Principal Details
	if(document.applicationfrm.varPname1.value=="")
	{
		alert("Please enter Principal Name");
		document.applicationfrm.varPname1.focus();
		return false;
	}
	if(document.applicationfrm.varPtitle1.value=="")
	{
		alert("Please enter Principal's Title");
		document.applicationfrm.varPtitle1.focus();
		return false;
	}
	if(document.applicationfrm.varPaddress1.value=="")
	{
		alert("Please enter Principal's Address");
		document.applicationfrm.varPaddress1.focus();
		return false;
	}
	if(document.applicationfrm.varPcity1.value=="")
	{
		alert("Please enter Principal's City");
		document.applicationfrm.varPcity1.focus();
		return false;
	}
	if(document.applicationfrm.varPstate1.value=="")
	{
		alert("Please enter Principal's State");
		document.applicationfrm.varPstate1.focus();
		return false;
	}
	if(document.applicationfrm.varPzip1.value=="")
	{
		alert("Please enter Principal's Zip Code");
		document.applicationfrm.varPzip1.focus();
		return false;
	}
	
	//  Validate Business References
	if(document.applicationfrm.varBname1.value=="")
	{
		alert("Please enter Business Refernence Name");
		document.applicationfrm.varBname1.focus();
		return false;
	}
	if(document.applicationfrm.varBaccount1.value=="")
	{
		alert("Please enter Account Number");
		document.applicationfrm.varBaccount1.focus();
		return false;
	}
	if(document.applicationfrm.varBaddrees1.value=="")
	{
		alert("Please enter Business Refernence Address");
		document.applicationfrm.varBaddrees1.focus();
		return false;
	}
	if(document.applicationfrm.varBcity1.value=="")
	{
		alert("Please enter Business Refernence City");
		document.applicationfrm.varBcity1.focus();
		return false;
	}
	if(document.applicationfrm.varBstate1.value=="")
	{
		alert("Please enter Business Refernence State");
		document.applicationfrm.varBstate1.focus();
		return false;
	}
	if(document.applicationfrm.varBzip1.value=="")
	{
		alert("Please enter Business Refernence Zip Code");
		document.applicationfrm.varBzip1.focus();
		return false;
	}
	if(document.applicationfrm.varBphone1.value=="")
	{
		alert("Please enter Business Refernence Phone");
		document.applicationfrm.varBphone1.focus();
		return false;
	}
	if(document.applicationfrm.varBfax1.value=="")
	{
		alert("Please enter Business Refernence Fax");
		document.applicationfrm.varBfax1.focus();
		return false;
	}
	
	
	
	if(document.applicationfrm.varBname2.value=="")
	{
		alert("Please enter Business Refernence Name");
		document.applicationfrm.varBname2.focus();
		return false;
	}
	if(document.applicationfrm.varBaccount2.value=="")
	{
		alert("Please enter Account Number");
		document.applicationfrm.varBaccount2.focus();
		return false;
	}
	if(document.applicationfrm.varBaddrees2.value=="")
	{
		alert("Please enter Business Refernence Address");
		document.applicationfrm.varBaddrees2.focus();
		return false;
	}
	if(document.applicationfrm.varBcity2.value=="")
	{
		alert("Please enter Business Refernence City");
		document.applicationfrm.varBcity2.focus();
		return false;
	}
	if(document.applicationfrm.varBstate2.value=="")
	{
		alert("Please enter Business Refernence State");
		document.applicationfrm.varBstate2.focus();
		return false;
	}
	if(document.applicationfrm.varBzip2.value=="")
	{
		alert("Please enter Business Refernence Zip Code");
		document.applicationfrm.varBzip2.focus();
		return false;
	}
	if(document.applicationfrm.varBphone2.value=="")
	{
		alert("Please enter Business Refernence Phone");
		document.applicationfrm.varBphone2.focus();
		return false;
	}
	if(document.applicationfrm.varBfax2.value=="")
	{
		alert("Please enter Business Refernence Fax");
		document.applicationfrm.varBfax2.focus();
		return false;
	}
	
	// Validate BANK Information
	if(document.applicationfrm.varbankName.value=="")
	{
		alert("Please enter Bank Name");
		document.applicationfrm.varbankName.focus();
		return false;
	}
	if(document.applicationfrm.varcontactPerson.value=="")
	{
		alert("Please enter Bank Contact Person");
		document.applicationfrm.varcontactPerson.focus();
		return false;
	}
	if(document.applicationfrm.varcontactPerson.value=="")
	{
		alert("Please enter Bank Contact Person");
		document.applicationfrm.varcontactPerson.focus();
		return false;
	}
	if(document.applicationfrm.varbankAddress.value=="")
	{
		alert("Please enter Bank Address");
		document.applicationfrm.varbankAddress.focus();
		return false;
	}
	if(document.applicationfrm.varbankCity.value=="")
	{
		alert("Please enter Bank City");
		document.applicationfrm.varbankCity.focus();
		return false;
	}
	if(document.applicationfrm.varbankState.value=="")
	{
		alert("Please enter Bank State");
		document.applicationfrm.varbankState.focus();
		return false;
	}
	if(document.applicationfrm.varbankZip.value=="")
	{
		alert("Please enter Bank Zip");
		document.applicationfrm.varbankZip.focus();
		return false;
	}
	if(document.applicationfrm.varbankPhone.value=="")
	{
		alert("Please enter Bank Phone");
		document.applicationfrm.varbankPhone.focus();
		return false;
	}
	/*
	if(document.applicationfrm.Is_business[0].value == "" && document.applicationfrm.Is_business[1].value == "")
	{
		alert("Please select Is Business option");
		return false;
	}
	*/
	if(document.applicationfrm.dt_join.value=="")
	{
		alert("Please enter Date Join");
		document.applicationfrm.dt_join.focus();
		return false;
	}
	if(document.applicationfrm.business_state.value=="")
	{
		alert("Please enter Bank State");
		document.applicationfrm.business_state.focus();
		return false;
	}
	if(document.applicationfrm.EstdYear.value=="")
	{
		alert("Please enter Year Established");
		document.applicationfrm.EstdYear.focus();
		return false;
	}
	if(document.applicationfrm.MonthPurchase.value=="")
	{
		alert("Please enter Purchase Month");
		document.applicationfrm.MonthPurchase.focus();
		return false;
	}
	if(document.applicationfrm.varbankruptcy[0].value == "" && document.applicationfrm.varbankruptcy[1].value == "")
	{
		alert("Please select bankruptcy option");
		return false;
	}
	
	
	
}
//script for checkout form

var ShippingFName;
var ShippingLName;
var ShippingAddress;
var ShippingCity;
var ShippingState;
var ShippingCountry;
var ShippingZip;
var ShippingPhone;

function InitSaveVariables(form) 
{
	    ShippingFName  = form.varShipFirstName.value;
	    ShippingLName  = form.varShipLastName.value;
		ShippingAddress = form.varShipAddress.value;
        ShippingCity       = form.varShipCity.value;
		ShippingState    = form.varShipState.value;
		ShippingCountry = form.varShipCountry.value;
        ShippingZip        = form.varShipZip.value;
	    ShippingPhone   = form.varShipPhone.value;
}

function ShipToBillPerson(form) 
{
        if (form.ShipAddress.checked) 
		{
                InitSaveVariables(form);
			    form.varShipFirstName.value = form.varFirstName.value;
                form.varShipLastName.value = form.varLastName.value;
			    form.varShipAddress.value    = form.varAddress.value;
                form.varShipCity.value          = form.varCity.value;
                form.varShipState.value        = form.varState.value;
                form.varShipCountry.value    = form.varCountry.value;
                form.varShipZip.value           = form.varPostcode.value;
				form.varShipPhone.value       = form.varPhoneNo.value;
        }
        else 
		{
				form.varShipFirstName.value  =ShippingFName;
				form.varShipLastName.value  =ShippingLName
				form.varShipAddress.value    =ShippingAddress; 
				form.varShipCity.value		    =ShippingCity;
				form.varShipState.value        =ShippingState;
				form.varShipCountry.value     =ShippingCountry;
				form.varShipZip.value           =ShippingZip;
				form.varShipPhone.value       =ShippingPhone;
       }
}
//script for registeration
function checkout_validation()
{
	if(document.checkout_frm.varEmail.value == "")
	{
		alert("Please enter the Email Address");
		document.checkout_frm.varEmail.focus();
		return false;
	}
	if (!validateEmail(document.checkout_frm.varEmail.value,1,1)) 
	 {
	 document.checkout_frm.varEmail.focus();
	 return false;
	 }
	if(document.checkout_frm.ConfirmEmail.value == "")
	{
		alert("Please enter the Confirm - Email Address");
		document.checkout_frm.ConfirmEmail.focus();
		return false;
	}
	if(document.checkout_frm.varEmail.value!= document.checkout_frm.ConfirmEmail.value)
	{
		alert("Please enter correct Confirm - Email Address");
		document.checkout_frm.ConfirmEmail.focus();
		return false;
	}
//------script for billing address --------------------------//
	if(document.checkout_frm.varFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.checkout_frm.varFirstName.focus();
		return false;
	}
	 	if(document.checkout_frm.varLastName.value == "")
	{
		alert("Please enter the Last Name");
		document.checkout_frm.varLastName.focus();
		return false;
	}
	if(document.checkout_frm.varAddress.value == "")
	{
		alert("Please enter the Address");
		document.checkout_frm.varAddress.focus();
		return false;
	}
	if(document.checkout_frm.varCity.value == "")
	{
		alert("Please enter the City");
		document.checkout_frm.varCity.focus();
		return false;
	}
	if(document.checkout_frm.varState.value == "" && document.checkout_frm.varStateOthers.value == "")
	{
		alert("Please enter the State");
		document.checkout_frm.varState.focus();
		return false;
	}
	if(document.checkout_frm.varCountry.value =="Choose")
	{
		alert("Please enter the Country");
		document.checkout_frm.varCountry.focus();
		return false;
	}
	if(document.checkout_frm.varPostcode.value =="")
	{
		alert("Please enter the Zip Code");
		document.checkout_frm.varPostcode.focus();
		return false;
	}	
	if(document.checkout_frm.varPhoneNo.value == "")
	{
		alert("Please enter the Phone Number");
		document.checkout_frm.varPhoneNo.focus();
		return false;
	}
	if(isNaN(document.checkout_frm.varPhoneNo.value))
	{
		alert("Phone Number Must ber Numeric");

		document.checkout_frm.varPhoneNo.focus();
		return false;
	}
//--------------Code for shipping address section-------------------//
	if(document.checkout_frm.varShipFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.checkout_frm.varShipFirstName.focus();
		return false;
	}
	
	 	if(document.checkout_frm.varShipLastName.value == "")
	{
		alert("Please enter the Last Name");
		document.checkout_frm.varShipLastName.focus();
		return false;
	}
	if(document.checkout_frm.varShipAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.checkout_frm.varShipAddress.focus();
		return false;
	}
	if(document.checkout_frm.varShipCity.value == "")
	{
		alert("Please enter the City");
		document.checkout_frm.varShipCity.focus();
		return false;
	}
	if(document.checkout_frm.varShipState.value == "" && document.checkout_frm.varShipStateOthers.value == "")
	{
		alert("Please enter the State");
		document.checkout_frm.varShipState.focus();
		return false;
	}
	if(document.checkout_frm.varShipCountry.value =="Choose")
	{
		alert("Please enter the Country");
		document.checkout_frm.varShipCountry.focus();
		return false;
	}
	if(document.checkout_frm.varShipZip.value =="")
	{
		alert("Please enter the Zip Code");
		document.checkout_frm.varShipZip.focus();
		return false;
	}	
	if(document.checkout_frm.varShipPhone.value == "")
	{
		alert("Please enter the Phone Number");
		document.checkout_frm.varShipPhone.focus();
		return false;
	}
	if(isNaN(document.checkout_frm.varShipPhone.value))
	{
		alert("Phone Number Must ber Numeric");
		document.checkout_frm.varShipPhone.focus();
		return false;
	}
}


// Valid Email  Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}

	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}

 //Function phone validation Script
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
// To Validate Password Field in changepassword file
function pass_validate()
{
	     var oldpassword = document.ChangePass.oldpassword.value;
		 if (oldpassword == "" )
		 { 
			 alert ("Please enter Your Old Password");
			 document.ChangePass.oldpassword.focus();
			 return false;
		 }
		 var newpassword = document.ChangePass.newpassword.value;
		 if (newpassword == "" )
		 { 
			 alert ("Please enter Your New Password");
			 document.ChangePass.newpassword.focus();
			 return false;
		 }
		 var newpassword = document.ChangePass.newpassword.value;
		 if (document.ChangePass.newpassword.value.length < 6)
		 { 
			 alert ("New Password must be greater than 5 character");
			 document.ChangePass.newpassword.focus();
			 return false;
		 }
		 var confirmpassword = document.ChangePass.confirmpassword.value;
		 if (confirmpassword == "" )
		 { 
			 alert ("Please enter Your Confirm Password");
			 document.ChangePass.confirmpassword.focus();
			 return false;
		 }
		 var confirmpassword = document.ChangePass.confirmpassword.value;
		 if (document.ChangePass.confirmpassword.value != document.ChangePass.newpassword.value)
		 { 
			 alert ("Paasword and Confirm Password must be same");
			 document.ChangePass.confirmpassword.focus();
			 return false;
		 }
}
function confirmMsg(msg)
{
	if(!confirm(msg))
	 {
		 return false;
	 }
	 else
	 {
		window.location.href="index.php?log=msg";
		return false;
	 }
}
function delconfirmMsg(dmsg)
{
	if(!confirm(dmsg))
	{
		return false;

	} else 
	{
		return true;

	}
}
function topic_validation()
{
	if(document.NewTopicForm.varSubject.value == "")
	{
		alert("Please enter the subject");
		document.NewTopicForm.varSubject.focus();
		return false;
	}
		if(document.NewTopicForm.txtMessage.value == "")
	{
		alert("Please enter the Message");
		document.NewTopicForm.txtMessage.focus();
		return false;
	}
return true;
}
function editmsg(thread)
{
	if (thread == "")
	{
		if(document.EditTopicForm.varSubject.value == "")
		{
			alert("Please enter the subject");
			document.EditTopicForm.varSubject.focus();
			return false;
		}
	}
	if(document.EditTopicForm.txtMessage.value == "")
	{
		alert("Please enter the Message");
		document.EditTopicForm.txtMessage.focus();
		return false;
	}
return true;
}
function postmsg()
{
		if(document.reply.txtMessage.value == "")
	{
		alert("Please enter the Message");
		document.reply.txtMessage.focus();
		return false;
	}
return true;
}

function money_contact_validate(){
	if(document.contact.txtFromName.value == "")
	{
		alert("Please enter Your Name");
		document.contact.txtFromName.focus();
		return false;
	}
	if(document.contact.txtFromEmail.value == "")
	{
		alert("Please enter the Email Address");
		document.contact.txtFromEmail.focus();
		return false;
	}
	if (!validateEmail(document.contact.txtFromEmail.value,1,1)) 
	{
		document.contact.txtFromEmail.focus();
		return false;
	}
	if(document.contact.Telephone.value == "")
	{
		alert("Please enter Your Telephone Number");
		document.contact.Telephone.focus();
		return false;
	}
	var phoneno = document.contact.Telephone;
	if (checkInternationalPhone(phoneno.value)==false){
		alert("Please Enter a Valid Phone Number");
		phoneno.focus();
		return false;
	} 
	if(document.contact.Subject.value == "")
	{
		alert("Please enter the Subject");
		document.contact.Subject.focus();
		return false;
	}
	if(document.contact.Comments.value == "")
	{
		alert("Please enter your Comments");
		document.contact.Comments.focus();
		return false;
	}
	if(document.contact.money.value == "")
	{
		alert("Please enter the Money used for");
		document.contact.money.focus();
		return false;
	}
	if(document.contact.amtneeded.value == "")
	{
		alert("Please enter the Amount needed");
		document.contact.amtneeded.focus();
		return false;
	}
	if((document.contact.turnedover[0].checked == false) && (document.contact.turnedover[1].checked == false))
	{
		alert("Please select the turned over Collection");
		return false;
	}
}