// JavaScript Document
// ------------- This is Script For Admin Pages----------------------//


//Login Validation
function login_validate(){
	if(document.Login.UserName.value == "")
	{
		alert("Plase enter the Username.");
		document.Login.UserName.focus();
		return false;
	}
	if(document.Login.Password.value == "")
	{
		alert("Plase enter the password.");
		document.Login.Password.focus();
		return false;
	}
}


function checkout_validation()
{

	if(document.frm_donate.varEmail.value == "")
	{
		alert("Please enter the Email Address");
		document.frm_donate.varEmail.focus();
		return false;
	}
	if (!validateEmail(document.frm_donate.varEmail.value,1,1)) 
	 {
	 document.frm_donate.varEmail.focus();
	 return false;
	 }
	if(document.frm_donate.ConfirmEmail.value == "")
	{
		alert("Please enter the Confirm - Email Address");
		document.frm_donate.ConfirmEmail.focus();
		return false;
	}
	if(document.frm_donate.varEmail.value!= document.frm_donate.ConfirmEmail.value)
	{
		alert("Please enter correct Confirm - Email Address");
		document.frm_donate.ConfirmEmail.focus();
		return false;
	}
//------script for billing address --------------------------//
	if(document.frm_donate.varFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.frm_donate.varFirstName.focus();
		return false;
	}
// 	 	if(document.frm_donate.CompanyName.value == "")
// 	{
// 		alert("Please enter the Company Name");
// 		document.frm_donate.CompanyName.focus();
// 		return false;
// 	}
	if(document.frm_donate.varAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.frm_donate.varAddress.focus();
		return false;
	}
	if(document.frm_donate.varCity.value == "")
	{
		alert("Please enter the City");
		document.frm_donate.varCity.focus();
		return false;
	}
	if(document.frm_donate.varCountry.value =="Choose")
	{
		alert("Please enter the Country");
		document.frm_donate.varCountry.focus();
		return false;
	}

	if(document.frm_donate.varPostcode.value =="")
	{
		alert("Please enter the Post code");
		document.frm_donate.varPostcode.focus();
		return false;
	}	
	//if (!postit(document.frm_donate.varPostcode.value)) 
//		 {
//		 document.frm_donate.varPostcode.focus();
//		 return false;
//		 }
	if(document.frm_donate.varPhoneNo.value == "")
	{
		alert("Please enter the Phone Number");
		document.frm_donate.varPhoneNo.focus();
		return false;
	}
// 	if(isNaN(document.frm_donate.varPhoneNo.value))
// 	{
// 		alert("Phone Number Must ber Numeric");
// 		document.frm_donate.varPhoneNo.focus();
// 		return false;
// 	}
//--------------Code for shipping address section-------------------//
	if(document.frm_donate.varShipFirstName.value == "")
	{
		alert("Please enter the First Name");
		document.frm_donate.varShipFirstName.focus();
		return false;
	}
	
// 	 	if(document.frm_donate.varShipCompanyName.value == "")
// 	{
// 		alert("Please enter the company Name");
// 		document.frm_donate.varShipCompanyName.focus();
// 		return false;
// 	}
	if(document.frm_donate.varShipAddress.value == "")
	{
		alert("Please enter the Shipping Address");
		document.frm_donate.varShipAddress.focus();
		return false;
	}
	if(document.frm_donate.varShipCity.value == "")
	{
		alert("Please enter the City");
		document.frm_donate.varShipCity.focus();
		return false;
	}
	
	if(document.frm_donate.varShipCountry.value =="Choose")
	{
		alert("Please enter the Country");
		document.frm_donate.varShipCountry.focus();
		return false;
	}

	if(document.frm_donate.varShipZip.value =="")
	{
		alert("Please enter the Post code");
		document.frm_donate.varShipZip.focus();
		return false;
	}	
//	if (!postit(document.frm_donate.varShipZip.value)) 
//		 {
//		document.frm_donate.varShipZip.focus();
//		 return false;
//		 }
	if(document.frm_donate.varShipPhone.value == "")
	{
		alert("Please enter the Phone Number");
		document.frm_donate.varShipPhone.focus();
		return false;
	}
// 	if(isNaN(document.frm_donate.varShipPhone.value))
// 	{
// 		alert("Phone Number Must ber Numeric");
// 		document.frm_donate.varShipPhone.focus();
// 		return false;
// 	}
}
// 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 calldel(m)
{
  if(!confirm(m))
  {
    return false;
  }
  else
  return true;
}

// 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;
}

/////Member Validation
//script for add member
function member_reg(type)
{	
	 var firstname = document.CustomersForm.firstname.value;
	 if (firstname == "" )
	 { 
	 alert ("Please enter the First Name");
	 document.CustomersForm.firstname.focus();
	 return false;
	 }
	 var lastname = document.CustomersForm.lastname.value; 
	 if (lastname == "")
	 { 
	 alert ("Please enter the Last Name");
	 document.CustomersForm.lastname.focus();
	 return false;
	 }
	 var emailid = document.CustomersForm.emailid.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the Email Address");
	 document.CustomersForm.emailid.focus();
	 return false;
	 }	
	 if (!validateEmail(document.CustomersForm.emailid.value,1,1)) 
	 {
	 document.CustomersForm.emailid.focus();
	 return false;
	 }
	 var address1 = document.CustomersForm.address.value;
	 if (address1 == "" )
	 { 
	 alert ("Please enter the Address");
	 document.CustomersForm.address.focus();
	 return false;
	 }
	 var city=document.CustomersForm.city.value;
	 if (city=="" )
	 { 
	 alert ("Please enter the City Name");
	 document.CustomersForm.city.focus();
	 return false;
	 }

	 	 var zipcode = document.CustomersForm.zipcode.value;
	 if (zipcode == "" )
	 { 
	 alert ("Please enter the Post Code");
	 document.CustomersForm.zipcode.focus();
	 return false;
	 }	
	
	 var country=document.CustomersForm.country.value;
	 if (country == "")
	 { 
	 alert ("Plese Enter Country");
	 document.CustomersForm.country.focus();
	 return false;
	 }
	 var phoneno = document.CustomersForm.phoneno.value;
	 if (phoneno == "")
	 { 
	 alert ("Please enter the Phone Number");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	
	 if (isNaN(document.CustomersForm.phoneno.value))
	 { 
	 alert ("Phone Number must be numeric");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	
	 
	 if(type != "edit")
	 {
		 var  Username= document.CustomersForm.username.value;
		 if (Username == "")
		 { 
		 alert ("Please enter the User Name");
		 document.CustomersForm.username.focus();
		 return false;
		 }	
		 var  password= document.CustomersForm.password.value;
		 if (password == "")
		 { 
		 alert ("Please enter the password");
		 document.CustomersForm.password.focus();
		 return false;
		 }	
		 var  confirmpass= document.CustomersForm.confirmpass.value;
		 if (confirmpass == "")
		 { 
		 alert ("Please enter the Confirm Password");
		 document.CustomersForm.confirmpass.focus();
		 return false;
		 }	
		 if (password != confirmpass)
		 { 
		 alert ("Password and Confirm Password must be the same");
		 document.CustomersForm.confirmpass.focus();
		 return false;
		 }	
	 }
		 txtCourse="";
		 txtCourseLength = document.CustomersForm.USERS.length;
		 var i=0;
		if(txtCourseLength > 1){
			for(CourseIndex = 0; CourseIndex < txtCourseLength; CourseIndex++ ){
				if(document.CustomersForm.USERS[CourseIndex].checked == false){
					i=i+1;
				}
			}
			if(i==txtCourseLength)
			{
				alert("Please select Atleast one file");
				return false;
			}	
		}


}

//script for add buyer
function buyer_reg()
{	
	 var firstname = document.CustomersForm.firstname.value;
	 if (firstname == "" )
	 { 
	 alert ("Please enter the Name");
	 document.CustomersForm.firstname.focus();
	 return false;
	 }
	 var emailid = document.CustomersForm.emailid.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the Email Address");
	 document.CustomersForm.emailid.focus();
	 return false;
	 }	
	 if (!validateEmail(document.CustomersForm.emailid.value,1,1)) 
	 {
	 document.CustomersForm.emailid.focus();
	 return false;
	 }
	 var address = document.CustomersForm.address.value;
	 if (address == "" )
	 { 
	 alert ("Please enter the Address");
	 document.CustomersForm.address.focus();
	 return false;
	 }
	 var city=document.CustomersForm.city.value;
	 if (city=="" )
	 { 
	 alert ("Please enter the City Name");
	 document.CustomersForm.city.focus();
	 return false;
	 }
// 	 var state = document.CustomersForm.state.value;
// 	 if (state == "Choose")
// 	 { 
// 	 alert ("Please Choose the State Name");
// 	 document.CustomersForm.state.focus();
// 	 return false;
// 	 }
	  var zipcode = document.CustomersForm.zipcode.value;
	 if (zipcode == "" )
	 { 
	 alert ("Please enter the Post Code");
	 document.CustomersForm.zipcode.focus();
	 return false;
	 }	
// 	 if (isNaN(document.CustomersForm.zipcode.value))
// 	 { 
// 	 alert ("Post Code must be numeric");
// 	 document.CustomersForm.zipcode.focus();
// 	 return false;
// 	 }	
	 var country=document.CustomersForm.country.value;
	 if (country == "")
	 { 
	 alert ("Plese Enter Country");
	 document.CustomersForm.country.focus();
	 return false;
	 }
	 var phoneno = document.CustomersForm.phoneno.value;
	 if (phoneno == "")
	 { 
	 alert ("Please enter the Phone Number");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	
	 if (isNaN(document.CustomersForm.phoneno.value))
	 { 
	 alert ("Phone Number must be numeric");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	
	 var buyercomments = document.CustomersForm.buyercomments.value;
	 if (buyercomments == "" )
	 { 
	 alert ("Please enter the buyer comments");
	 document.CustomersForm.buyercomments.focus();
	 return false;
	 }
}


function contactvalidate()
{
var name = document.contactfrm.name.value;
		 if (name == "" )
		 { 
			 alert ("Please enter Your name");
			 document.contactfrm.name.focus();
			 return false;
		 }
var city = document.contactfrm.txtcity.value;
		 if (city == "" )
		 { 
			 alert ("Please enter Your City");
			 document.contactfrm.txtcity.focus();
			 return false;
		 }
var country = document.contactfrm.txtcountry.value;
		 if (country == "" )
		 { 
			 alert ("Please enter Your Country");
			 document.contactfrm.txtcountry.focus();
			 return false;
		 }
 var emailid = document.contactfrm.txtemail.value;
	 if (emailid == "")
	 { 
	 alert ("Please enter the Email Address");
	 document.contactfrm.txtemail.focus();
	 return false;
	 }	
	 if (!validateEmail(document.contactfrm.txtemail.value,1,1)) 
	 {
	 document.contactfrm.txtemail.focus();
	 return false;
	 } 
	 
	var phone = document.contactfrm.txtphone.value;
		 if (phone == "" )
		 { 
			 alert ("Please enter Your Phonenumber");
			 document.contactfrm.txtphone.focus();
			 return false;
		 }
		 
		 
}

function openwindow(field,value){
	//alert(document.viewcart.chk_list.length);
	//var len;
	len = document.frm_cart.chk_list.length;
	//len=len+1;
	len2=0;
	//alert(len);
	for (i = 0; i < len; i++) 
			{
				var chkname	=	document.frm_cart.chk_list[i].checked;
				//alert(chkname);
					//alert(len2);
					if (chkname == false) 
						{
							len2 = len2 + 1;
						}
						
			}
			if(len == len2)
			{
				//alert(len2);
				alert("Please Select Atleast one");
				return false;
			}
			
document.frm_cart.action="viewcart.php";
document.frm_cart.submit();

}
function donate_check()
{
		
		var name = document.frm_donate.name.value;
		 if (name == "" )
		 { 
			 alert ("Please Enter Your Name");
			 document.frm_donate.name.focus();
			 return false;
		 }
		 var email = document.frm_donate.email.value;
		 if (email == "" )
		 { 
			 alert ("Please Enter Your E-mail address");
			 document.frm_donate.email.focus();
			 return false;
		 }
		 if (!validateEmail(document.frm_donate.email.value,1,1)) 
		 {
		 document.frm_donate.email.focus();
		 return false;
		 }
		  var phoneno = document.frm_donate.Phonetxt.value;
	 if (phoneno == "")
	 { 
	 alert ("Please enter the Phone Number");
	 document.frm_donate.Phonetxt.focus();
	 return false;
	 }	
	 if (isNaN(document.frm_donate.Phonetxt.value))
	 { 
	 alert ("Phone Number must be numeric");
	 document.frm_donate.Phonetxt.focus();
	 return false;
	 }	
	 
	if(document.frm_donate.txt_cctype.value == "")
	{
		alert("Please choose the card type");
		document.frm_donate.txt_cctype.focus();
		return false;
	}
	if(document.frm_donate.card_number.value == "")
	{
		alert("Please enter the card Number");
		document.frm_donate.card_number.focus();
		return false;
	}
	if(isNaN(document.frm_donate.card_number.value))
	{
		alert("Card Number Must ber Numeric");
		document.frm_donate.card_number.focus();
		return false;
	}
	if(document.frm_donate.cardholder_name.value == "")
	{
		alert("Please enter the card holders name");
		document.frm_donate.cardholder_name.focus();
		return false;
	}
	if(document.frm_donate.card_cvvx.value == "")
	{
		alert("Please enter the card cvv2 number");
		document.frm_donate.card_cvvx.focus();
		return false;
	}
	if(isNaN(document.frm_donate.card_cvvx.value))
	{
		alert("CVV Number Must ber Numeric");
		document.frm_donate.card_cvvx.focus();
		return false;
	}
	if(document.frm_donate.country.value == "")
	{
		alert("Please select the country");
		document.frm_donate.country.focus();
		return false;
	}
	if(document.frm_donate.address.value == "")
	{
		alert("Please enter the address");
		document.frm_donate.address.focus();
		return false;
	}
	if(document.frm_donate.city.value == "")
	{
		alert("Please enter the city");
		document.frm_donate.city.focus();
		return false;
	}  
	if(document.frm_donate.state.value == "")
	{
		alert("Please enter the state");
		document.frm_donate.state.focus();
		return false;
	} 
	if(document.frm_donate.zip.value == "")
	{
		alert("Please enter the zip code");
		document.frm_donate.zip.focus();
		return false;
	}
	if(document.frm_donate.shippingcountry.value == "")
	{
		alert("Please select the shipping country");
		document.frm_donate.shippingcountry.focus();
		return false;
	}
	if(document.frm_donate.shippingaddress.value == "")
	{
		alert("Please enter the shipping address");
		document.frm_donate.shippingaddress.focus();
		return false;
	}
	if(document.frm_donate.shippingcity.value == "")
	{
		alert("Please enter the shipping city");
		document.frm_donate.shippingcity.focus();
		return false;
	}  
	if(document.frm_donate.shippingstate.value == "")
	{
		alert("Please enter the shipping state");
		document.frm_donate.shippingstate.focus();
		return false;
	} 
	if(document.frm_donate.shippingzip.value == "")
	{
		alert("Please enter the shipping zip code");
		document.frm_donate.shippingzip.focus();
		return false;
	}
}



function opencart(rows)
{

	var len=document.frm_cart.ONE.length;
	   if(rows == 1)
	   {
			quantity = document.frm_cart.ONE.value;
			stockvalue = document.frm_cart.STOCK.value;
			original = document.frm_cart.STOCK1.value;

				if( (quantity == ""))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}
				else if((quantity == 0))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}
				
				else if(isNaN(quantity))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf("-") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf(".") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity > 65535))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.frm_cart.ONE.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
						return false;
				}		 
	   }
		   else
		   {
			   var flag=0;
		  	for(var index=0;index<rows;index++)
			{
			quantity = document.frm_cart.ONE[index].value;
			stockvalue = document.frm_cart.STOCK[index].value;
			original = document.frm_cart.STOCK1[index].value;
				if( (quantity == ""))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
				else if((quantity == 0))
				{
					alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
				
				else if(isNaN(quantity))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity.indexOf("-") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity.indexOf(".") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
							return false;
				}
				else if((quantity > 65535))
				{
						alert("Type the valid quantity");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.frm_cart.ONE[index].focus();
						document.frm_cart.ONE[index].value=document.frm_cart.STOCK1[index].value;
						return false;
				}
						
			}
		   }
}






function openaddcart()
{
	var len=document.frm_cart.Quantity.length;

			quantity = document.frm_cart.Quantity.value;
			stockvalue = document.frm_cart.STOCK.value;
			original = document.frm_cart.STOCK1.value;

				if( (quantity == ""))
				{
					alert("Type the valid quantity");
						document.frm_cart.Quantity.focus();
						document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
						return false;
				}
				else if((quantity == 0))
				{
					alert("Type the valid quantity");
						document.frm_cart.Quantity.focus();
						document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
						return false;
				}
				
				else if(isNaN(quantity))
				{
					alert("Type the valid quantity");
							document.frm_cart.Quantity.focus();
						document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf("-") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.Quantity.focus();
						document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity.indexOf(".") >= 0))
				{
					alert("Type the valid quantity");
							document.frm_cart.Quantity.focus();
						document.frm_cart.ONE.value=document.frm_cart.STOCK1.value;
							return false;
				}
				else if((quantity > 65535))
				{
					alert("Type the valid quantity");
							document.frm_cart.Quantity.focus();
						document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
							return false;
				}
				if(parseInt(quantity) > parseInt(stockvalue)){
						alert("Quantity is out of stock");
						document.frm_cart.Quantity.focus();
						alert("Stock Value is "+document.frm_cart.STOCK1.value);
						//document.frm_cart.Quantity.value=document.frm_cart.STOCK1.value;
						return false;
				}		 
}
		  

function member_regchangepass()
{	
  var oldpassword = document.CustomerspassForm.oldpassword.value;
		 if (oldpassword == "" )
		 { 
			 alert ("Please enter Your Old Password");
			 document.CustomerspassForm.oldpassword.focus();
			 return false;
		 }
		 var newpassword = document.CustomerspassForm.newpassword.value;
		 if (newpassword == "" )
		 { 
			 alert ("Please enter Your New Password");
			 document.CustomerspassForm.newpassword.focus();
			 return false;
		 }
		 var confirmpass = document.CustomerspassForm.confirmpass.value;
		 if (confirmpass == "" )
		 { 
			 alert ("Please enter Your Confirm Password");
			 document.CustomerspassForm.confirmpass.focus();
			 return false;
		 }
		 var confirmpass = document.CustomerspassForm.confirmpass.value;
		 if (document.CustomerspassForm.confirmpass.value != document.CustomerspassForm.newpassword.value)
		 { 
			 alert ("Password and Confirm Password must be same");
			 document.CustomerspassForm.confirmpass.focus();
			 return false;
		 }
	 
}

function Product_validation(type)
{	

	 var intCatid = document.Product_frm.intCatid.value;
	 if (intCatid == "Choose" )
	 { 
	 alert ("Please Choose the Category Name");
	 document.Product_frm.intCatid.focus();
	 return false;
	 }
	 var intSubCatid = document.Product_frm.intSubCatid.value;
	 if (intSubCatid == "Choose" )
	 { 
	 alert ("Please Choose the SubCategory Name");
	 document.Product_frm.intSubCatid.focus();
	 return false;
	 }
	  var varProName = document.Product_frm.varProName.value;
	 if (varProName == "" )
	 { 
	 alert ("Please enter the Product Name");
	 document.Product_frm.varProName.focus();
	 return false;
	 } 
	 var Price = document.Product_frm.Price.value;
	 if (Price == "" )
	 { 
	 alert ("Please enter the Price");
	 document.Product_frm.Price.focus();
	 return false;
	 }
	  if (isNaN(Price))
		 { 
			 alert ("Price must be Numeric");
			 document.Product_frm.Price.focus();
			 return false;
		 }
	 
	  var Quantity = document.Product_frm.Quantity.value;
	 if (Quantity == "" )
	 { 
	 alert ("Please enter the Quantity");
	 document.Product_frm.Quantity.focus();
	 return false;
	 }
	  if (isNaN(Quantity))
		 { 
			 alert ("Quantity must be Numeric");
			 document.Product_frm.Quantity.focus();
			 return false;
		 }
		
	 var ProductImge = document.Product_frm.ProductImge.value;
	 if (ProductImge == "" )
	 { 
	 alert ("Please Upload the ProductImge");
	 document.Product_frm.ProductImge.focus();
	 return false;
	 }
		
}
function Product_validationedit(type)
{	

	 var intCatid = document.Product_frm.intCatid.value;
	 if (intCatid == "Choose" )
	 { 
	 alert ("Please Choose the Category Name");
	 document.Product_frm.intCatid.focus();
	 return false;
	 }
	 var intSubCatid = document.Product_frm.intSubCatid.value;
	 if (intSubCatid == "Choose" )
	 { 
	 alert ("Please Choose the SubCategory Name");
	 document.Product_frm.intSubCatid.focus();
	 return false;
	 }
	  var varProName = document.Product_frm.varProName.value;
	 if (varProName == "" )
	 { 
	 alert ("Please enter the Product Name");
	 document.Product_frm.varProName.focus();
	 return false;
	 } 
	 var Price = document.Product_frm.Price.value;
	 if (Price == "" )
	 { 
	 alert ("Please enter the Price");
	 document.Product_frm.Price.focus();
	 return false;
	 }
	  if (isNaN(Price))
		 { 
			 alert ("Price must be Numeric");
			 document.Product_frm.Price.focus();
			 return false;
		 }
	 
	  var Quantity = document.Product_frm.Quantity.value;
	 if (Quantity == "" )
	 { 
	 alert ("Please enter the Quantity");
	 document.Product_frm.Quantity.focus();
	 return false;
	 }
	  if (isNaN(Quantity))
		 { 
			 alert ("Quantity must be Numeric");
			 document.Product_frm.Quantity.focus();
			 return false;
		 }

		
}


//  Begin -->
function postit(postcodetxt){ //check postcode format is valid

 var test = postcodetxt; 
 var size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 //document.details.pcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
 // document.details.pcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
  // document.details.pcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
  // document.details.pcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
  // document.details.pcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   //document.details.pcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
  // document.details.pcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
  // document.details.pcode.focus();
   return false;
  }
//alert("Postcode Format OK");
return true;
}
//  End -->

