function validateNewUserForm()
{


	if(document.procNewUser.txtUserName.value == "")
	{
	alert("please enter the User Name");
	return false;
	}

	/*if(document.procNewUser.email.value == "")
	{
	alert("please enter the email address");
	return false;
	}*/
	if(document.procNewUser.email.value !== "")
	{
		if(!validEmail(document.procNewUser.email.value))
		{
			alert("Invalid email address");
			document.procNewUser.email.focus()
			return false;
		}
	}
	if(document.procNewUser.pwd.value == "" || document.procNewUser.pwdconfirm.value == "")	
	{
		alert("password can not be left blank");
		document.procNewUser.pwd.focus()
		return false;
	}
	if(!isPasswordMatch(document.procNewUser.pwd.value, document.procNewUser.pwdconfirm.value))
	{
		alert("password doesn't match");
		document.procNewUser.pwd.focus()
		return false;
	}
	if(document.procNewUser.custName.value == "")
	{
		alert("Name can not be left blank");
		document.procNewUser.custName.focus()
		return false;
	}
	if(document.procNewUser.compName.value == "")
	{
		alert("company name can not be left blank");
		document.procNewUser.compName.focus()
		return false;
	}
	if(document.procNewUser.addr1.value == "")
	{
		alert("Address 1 can not be left blank");
		document.procNewUser.addr1.focus()
		return false;
	}
	if(document.procNewUser.city.value == "")
	{
		alert("City can not be left blank");
		document.procNewUser.city.focus()
		return false;
	}
	if(document.procNewUser.state.value == "")
	{
		alert("State can not be left blank");
		document.procNewUser.state.focus()
		return false;
	}
	if(document.procNewUser.country.value == "")
	{
		alert("County can not be left blank");
		document.procNewUser.country.focus()
		return false;
	}
	if(document.procNewUser.zipcode.value == "")
	{
		alert("Zipcode can not be left blank");
		document.procNewUser.zipcode.focus()
		return false;
	}
	if(document.procNewUser.TelephoneNo.value == "")
	{
		alert("Telephone can not be left blank");
		document.procNewUser.TelephoneNo.focus()
		return false;
	}
	return true;
	
}

function validateUpdateUserPasswordForm(form)
{ 
	//if (form.userchangepassword.txtUserName.value == "") 
	if (form.txtUserName.value == "") 
	{
		alert("Please enter your user name.")
		//form.userchangepassword.txtUserName.focus();
		form.txtUserName.focus();
		return false;		
	}	
	//if (form.userchangepassword.oldpwd.value == "") 
	if (form.oldpwd.value == "") 
	{
		alert("Please enter your old password.")
		//form.userchangepassword.oldpwd.focus();
		form.oldpwd.focus();
		return false;		
	}	

	//if(form.userchangepassword.pwd.value == "" || form.userchangepassword.pwdconfirm.value == "")	
	if(form.pwd.value == "" || form.pwdconfirm.value == "")	
	{
		alert("New Password can not be left blank.");
		return false;
	}
	//if(!isPasswordMatch(form.userchangepassword.pwd.value, form.userchangepassword.pwdconfirm.value))
	if(!isPasswordMatch(form.pwd.value, form.pwdconfirm.value))
	{
		alert("password doesn't match");
		return false;
	}
	return true;
}


function validateAdminSLCSUserForm()
{
	if(document.AdminSLCSUser.email.value == "")
	{
		alert("please enter the User Name");
		return false;
	}

	if(document.AdminSLCSUser.pwd.value == "" || document.AdminSLCSUser.pwdconfirm.value == "")	
	{
		alert("password can not be left blank");
		return false;
	}
	if(!isPasswordMatch(document.AdminSLCSUser.pwd.value, document.AdminSLCSUser.pwdconfirm.value))
	{
		alert("password doesn't match");
		return false;
	}
	return true;
	
}

function ValidateLoginForm()
{ 
	if (document.authenticate.email.value == "") {
		alert("Please enter your User Name")
		document.authenticate.email.focus()
		return false		
	}	
	if (document.authenticate.pwd.value == "") 
	{
		alert("Please enter Your Password")
		document.authenticate.pwd.focus()
		return false		
	}	
document.authenticate.submit();
}

function validateStateForm()
{
	if(document.State.abbr.value == "")
	{
		alert("State Abbreviation can not be left blank");
		document.State.abbr.focus()
		return false;
	}
	if(document.State.description.value == "")
	{
		alert("State Description can not be left blank");
		document.State.description.focus()
		return false;
	}
	return true;	
}

function validateCountryForm()
{
	if(document.Country.abbr.value == "")
	{
		alert("Country Abbreviation can not be left blank");
		document.Country.abbr.focus()
		return false;
	}
	if(document.Country.description.value == "")
	{
		alert("Country Description can not be left blank");
		document.Country.description.focus()
		return false;
	}
	return true;	
}

function validateDeliveryTypeForm()
{
	if(document.DeliveryType.abbr.value == "")
	{
		alert("Delivery Type Abbreviation can not be left blank");
		document.DeliveryType.abbr.focus()
		return false;
	}
	if(document.DeliveryType.description.value == "")
	{
		alert("Delivery Type Description can not be left blank");
		document.DeliveryType.description.focus()
		return false;
	}
	return true;	
}

function validateDeliveryVehicleForm()
{
	if(document.DeliveryVehicle.abbr.value == "")
	{
		alert("Delivery Vehicle Abbreviation can not be left blank");
		document.DeliveryVehicle.abbr.focus()
		return false;
	}
	if(document.DeliveryVehicle.description.value == "")
	{
		alert("Delivery Vehicle Description can not be left blank");
		document.DeliveryVehicle.description.focus()
		return false;
	}
	return true;	
}

function validatePaymentTypeForm()
{
	if(document.PaymentType.abbr.value == "")
	{
		alert("Payment Type Abbreviation can not be left blank");
		document.PaymentType.abbr.focus()
		return false;
	}
	if(document.PaymentType.description.value == "")
	{
		alert("Payment Type Description can not be left blank");
		document.PaymentType.description.focus()
		return false;
	}
	return true;	
}

function validateDeliveryStatusForm()
{
	if(document.DeliveryStatus.abbr.value == "")
	{
		alert("Delivery Status Abbreviation can not be left blank");
		document.DeliveryStatus.abbr.focus()
		return false;
	}
	if(document.DeliveryStatus.description.value == "")
	{
		alert("Delivery Status Description can not be left blank");
		document.DeliveryStatus.description.focus()
		return false;
	}
	return true;	
}

function validatePackageTypeForm()
{
	if(document.PackageType.abbr.value == "")
	{
		alert("Package Type Abbreviation can not be left blank");
		document.PackageType.abbr.focus()
		return false;
	}
	if(document.PackageType.description.value == "")
	{
		alert("Package Type Description can not be left blank");
		document.PackageType.description.focus()
		return false;
	}
	return true;	
}

function validateZipCodePriceForm()
{
	if(document.ZipCodePrice.FromZipCode.value == "")
	{
		alert("From Zip Code can not be left blank");
		document.ZipCodePrice.FromZipCode.focus()
		return false;
	}
	if(document.ZipCodePrice.ToZipCode.value == "")
	{
		alert("To Zip Code can not be left blank");
		document.ZipCodePrice.ToZipCode.focus()
		return false;
	}
	if(document.ZipCodePrice.DelType.value == "")
	{
		alert("Delivery Type can not be left blank");
		document.ZipCodePrice.DelType.focus()
		return false;
	}
	if(document.ZipCodePrice.DelVehicle.value == "")
	{
		alert("Delivery Vehicle can not be left blank");
		document.ZipCodePrice.DelVehicle.focus()
		return false;
	}
	if(document.ZipCodePrice.DeliveryPrice.value == "")
	{
		alert("Delivery price can not be left blank");
		document.ZipCodePrice.DeliveryPrice.focus()
		return false;
	}
	return true;	
}

function validateSpSrvcTypeForm()
{
	if(document.SpecialServiceType.abbr.value == "")
	{
		alert("Special Service Type Abbreviation can not be left blank");
		document.SpecialServiceType.abbr.focus()
		return false;
	}
	if(document.SpecialServiceType.description.value == "")
	{
		alert("Special Service Type Description can not be left blank");
		document.SpecialServiceType.description.focus()
		return false;
	}
	if(document.SpecialServiceType.price.value == "")
	{
		alert("Special Service Type Price can not be left blank");
		document.SpecialServiceType.price.focus()
		return false;
	}
	return true;	
}

function validateBobtailPriceForm()
{
	if(document.BobtailPrice.BobtailSrvcType.value == "")
	{
		alert("Bobtail Service Type can not be left blank");
		document.BobtailPrice.BobtailSrvcType.focus()
		return false;
	}
	if(document.BobtailPrice.BobtailRate.value == "")
	{
		alert("Bobtail price for this Service Type can not be left blank");
		document.BobtailPrice.BobtailRate.focus()
		return false;
	}
	return true;
}

function validateCourtFilingPriceForm()
{
	if(document.CourtFilingPrice.CourtFilingSrvcType.value == "")
	{
		alert("Court Filing price for this Service Type can not be left blank");
		document.CourtFilingPrice.CourtFilingSrvcType.focus()
		return false;
	}
	if(document.CourtFilingPrice.CourtFilingRate.value == "")
	{
		alert("Court Filing price for this Service Type can not be left blank");
		document.CourtFilingPrice.CourtFilingRate.focus()
		return false;
	}
	return true;
}
//CustomerProfile validation
function validateContactInformationform()
{
	//alert("----------alert----------");
	if(document.procCostProfile.ToName.value == "")
	{
	alert("Please enter the Customer Name");
	document.procCostProfile.ToName.focus()
	return false;
	}

	if(document.procCostProfile.ToCompanyName.value == "")
	{
		alert("Company Name can not be left blank");
		document.procCostProfile.ToCompanyName.focus()
		return false;
	}
	if(document.procCostProfile.Toaddr1.value == "")
	{
		alert("Address 1 can not be left blank");
		document.procCostProfile.Toaddr1.focus()
		return false;
	}
	if(document.procCostProfile.Tocity.value == "")
	{
		alert("City can not be left blank");
		document.procCostProfile.Tocity.focus()
		return false;
	}
	if(document.procCostProfile.Tostate.value == "")
	{
		alert("State can not be left blank");
		document.procCostProfile.Tostate.focus()
		return false;
	}
	if(document.procCostProfile.Tocountry.value == "")
	{
		alert("County can not be left blank");
		document.procCostProfile.Tocountry.focus()
		return false;
	}
	if(document.procCostProfile.Tozipcode.value == "")
	{
		alert("Zipcode can not be left blank");
		document.procCostProfile.Tozipcode.focus()
		return false;
	}
	if(document.procCostProfile.ToTelephoneNo.value == "")
	{
		alert("Telephone can not be left blank");
		document.procCostProfile.ToTelephoneNo.focus()
		return false;
	}
	if(document.procCostProfile.ToEmail.value !== "")
	{
		if(!validEmail(document.procCostProfile.ToEmail.value))
		{
			alert("Invalid email address");
			document.procCostProfile.ToEmail.focus()
			return false;
		}
	}
	if(document.procCostProfile.ToEmail.value == "")
	{
		alert("Email can not be left blank");
		document.procCostProfile.ToEmail.focus()
		return false;
	}
	//return true;
//}
//function validateBillingInformationform()
//{
	if(document.procCostProfile.BillName.value != "" || document.procCostProfile.BillCompanyName.value != "" || document.procCostProfile.Billaddr1.value != "" || document.procCostProfile.Billaddr1.value != "" || document.procCostProfile.Billcity.value != "" || document.procCostProfile.Billzipcode.value != "" || document.procCostProfile.BillTelephoneNo.value != "" )
	{
		if(document.procCostProfile.BillName.value == "")
		{
		alert("Please enter the name");
		document.procCostProfile.BillName.focus()
		return false;
		}
	
		if(document.procCostProfile.BillCompanyName.value == "")
		{
			alert("Billing Company Name can not be left blank");
			document.procCostProfile.BillCompanyName.focus()
			return false;
		}
		if(document.procCostProfile.Billaddr1.value == "")
		{
			alert("Billing Address 1 can not be left blank");
			document.procCostProfile.Billaddr1.focus()
			return false;
		}
		if(document.procCostProfile.Billcity.value == "")
		{
			alert("Billing City can not be left blank");
			document.procCostProfile.Billcity.focus()
			return false;
		}
		if(document.procCostProfile.Billstate.value == "")
		{
			alert("Billing State can not be left blank");
			document.procCostProfile.Billstate.focus()
			return false;
		}
		if(document.procCostProfile.Billcountry.value == "")
		{
			alert("Billing County can not be left blank");
			document.procCostProfile.Billcountry.focus()
			return false;
		}
		if(document.procCostProfile.Billzipcode.value == "")
		{
			alert("Billing Zipcode can not be left blank");
			document.procCostProfile.Billzipcode.focus()
			return false;
		}

		if(document.procCostProfile.BillTelephoneNo.value == "")
		{
			alert("Billing Telephone can not be left blank");
			document.procCostProfile.BillTelephoneNo.focus()
			return false;
		}
		if(document.procCostProfile.BillEmail.value !== "")
		{
			if(!validEmail(document.procCostProfile.BillEmail.value))
			{
				alert("Invalid email address");
				document.procCostProfile.BillEmail.focus()
				return false;
			}
		}
		if(document.procCostProfile.BillEmail.value == "")
		{
			alert("Email can not be left blank");
			document.procCostProfile.BillEmail.focus()
			return false;
		}
	}
	return true;
}

//End CustomerProfile Validation

function isPasswordMatch(pwd, confirmPwd)
{
	if(pwd != confirmPwd)
	{
		return false;
	}
	return true;	
}

function validEmail(email) {	
	invalidChars = " /:,;"

	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length)	{
		return false
	}
	return true
}




