function confirmMsg(msg)
{
	if(!confirm(msg))
	{
		return false;
	} 
	else 
	{
		return true;

	}
}

function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=350,width=500,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) 
	{
		newwindow.focus();
	}
}
// Check Item Quantity in Product Details Page
function check_Quantity()
{
	var itemqty=document.form1.itemqty.value;
	if(itemqty == "")
	{
		alert("Quantity is empty");
		document.form1.itemqty.focus();
		return false;
	}
	return true;

}

// Check Item Quantity in Product Details Page

// Check Item Quantity in Product Details Page
function search_check_Quantity1()
{
	var itemqty=document.searchproduct.itemqty.value;
	if(itemqty == "")
	{
		alert("Quantity is empty");
		document.productdetails.itemqty.focus();
		return false;
	}
	return true;

}


//Script Validation for Admin panel
function admin_validation()
{
	var txtUsername=document.Login.txtUsername.value;
	if(txtUsername == "")
	{
		alert("User name  is empty");
		document.Login.txtUsername.focus();
		return false;
	}
	var txtPassword=document.Login.txtPassword.value;
	if(txtPassword == "")
	{
		 alert("Password  is empty");
		 document.Login.txtPassword.focus();
		 return false;
	}
}

function poporder(url)
{
	newwindow=window.open(url,'name1','scrollbars=yes,resizable=no,height=450,width=550,left=100,top=100');
	if (window.focus) 
	{
		newwindow.focus();
	}
}

//Script validation for change password

function pwd_validation()
{
	var oldpwd=document.changepwd.oldpwd.value;
	if(oldpwd == "")
	 {
			 alert("Old password is empty");
			 document.changepwd.oldpwd.focus();
			 return false;
	 }
	var txtNewPassword1=document.changepwd.txtNewPassword1.value;
	if(txtNewPassword1 == "")
	 {
			 alert("New password is empty");
			 document.changepwd.txtNewPassword1.focus();
			 return false;
	 }
	else if(parseInt(txtNewPassword1.length) < 6)
	{
			 alert("Please enter the password with atleast 6 characters");
			 document.changepwd.txtNewPassword1.focus();
			 return false;
	} 
	var txtNewPassword2=document.changepwd.txtNewPassword2.value;
	 if(txtNewPassword2 == "")
	 {
			 alert("Confirm  password is empty");
			 document.changepwd.txtNewPassword2.focus();
			 return false;
	 }
	if(txtNewPassword2 != txtNewPassword1)
	{
			alert("Type the confirm password corredtly");
			document.changepwd.txtNewPassword2.focus();
			return false;
	}
}

function showcredit()
{
	var chklen = document.checkout.ONE.length;
	for(index = 0; index < chklen ; index++)
	{		
				 if (document.checkout.ONE[index].checked)
				 {
						if(document.checkout.ONE[index].value == "AN")
						{
							cardstyle=document.getElementById("creditcard");
								if(cardstyle)
								{
								cardstyle.style.display="block";
								cardstyle.style.visibility="visible";
								}				
						}//End of If
						else 
						{
							cardstyle=document.getElementById("creditcard");
								if(cardstyle)
								{
								cardstyle.style.display="none";
								cardstyle.style.visibility="hidden";
								}
						}//End of Else
				}//End of If
		} //End of For
}

//Function for adjusting the category order
//Move the Settings
function move(index,to) {
		var list = document.form.list;
		var total = list.options.length-1;
		if (index == -1) return false;
		if (to == +1 && index == total) return false;
		if (to == -1 && index == 0) return false;
		var items = new Array;
		var values = new Array;
		for (i = total; i >= 0; i--) {
		items[i] = list.options[i].text;
		values[i] = list.options[i].value;
		}
		for (i = total; i >= 0; i--) {
		if (index == i) {
		list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
		list.options[i] = new Option(items[i + to], values[i]);
		i--;
		}
		else {
		list.options[i] = new Option(items[i], values[i]);
		   }
		}
		list.focus();
}
//Function Priority
function productordersubmitForm() 
{
	var list = document.form.list;
	theList="";
	// start with a "?" to make it look like a real query-string
	for (i = 0; i <= list.options.length-1; i++) 
	{ 
	theList += list.options[i].text;
	// a "&" only BETWEEN the items, so not at the end
	if (i != list.options.length-1) theList += "&;";
	}
	document.form.priority.value=theList;
	document.form.action="index.php?task=productorder";
}

//Function Open Window
function OpenWin(url,winName,w,h,other)
	{
	var acc = "width=" + w + ",height=" + h + "," + other;
	window.open(url,winName,acc);
	}
	
function showState(passcountry){
		if (document.getElementById(passcountry).value == "United States of America"){
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="block";
				postate.style.visibility="visible";
			}
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="none";
				pootherstate.style.visibility="hidden";
			}
		}
		else{
			pootherstate = document.getElementById("postotherstate");
			if(pootherstate){
				pootherstate.style.display="block";
				pootherstate.style.visibility="visible";
			}
			postate = document.getElementById("poststate");
			if(postate){
				postate.style.display="none";
				postate.style.visibility="hidden";
			}
		}
	}

function showhide(){
		if (!(document.frm_register.chkDelivery.checked)){
		delistyle=document.getElementById("delivery");
		    if(delistyle){
			delistyle.style.display="block";
			delistyle.style.visibility="visible";
			}				
		}
		else
		{
			delistyle=document.getElementById("delivery");
			if(delistyle){
			delistyle.style.display="none";
			delistyle.style.visibility="hidden";
			}
		}
	}
//Function for View Replies
function changeCategoryProducts(){
	var catname=document.frm_viewproducts.catid.value;
		if (catname==""){
				window.location.href="index.php?task=viewproducts";
		}
		else{
				window.location.href="index.php?task=viewproducts&x_category="+document.frm_viewproducts.catid.value;
		}
	}

//Function
	function changecat_orders()
	{
	var catname=document.frm_orders.catid.value;
	
		if (catname=="All")
			{
				window.location.href="index.php";
			}
		else
			{
				window.location.href="index.php?task=vieworders&orders="+document.frm_orders.catid.value;
			}
	}

function opinion_validate(){
		if(document.opinion.yourname.value=="")
			{
			   alert("Please Enter Your Name");
			   document.opinion.yourname.focus();
			   return false;
			}
	 if (!validateEmail(document.opinion.youremail.value,1,1)) 
			{
				document.opinion.youremail.focus();
				return false;
			}
		if(document.opinion.comments.value=="")
			{
			   alert("Please Enter Your Opinion");
			   document.opinion.comments.focus();
			   return false;
			}
	return false;
}

//validation for add image
function addimg_validate(){
		if(document.addimage.filename.value=="")
			{
			   alert("Choose the file name");
			   document.addimage.filename.focus();
			   return false;
			}
}

//Validation for System settings
function systemsetting_validate(){
	if(document.frm_sysset.company.value =="")
	 {
		 alert("Please enter the Company name.");
		 document.frm_sysset.company.focus();
		 return false;
	 }
	if(document.frm_sysset.address.value =="")
	 {
		 alert("Please enter the Address line.");
		 document.frm_sysset.address.focus();
		 return false;
	 }
	if(document.frm_sysset.city.value =="")
	 {
		 alert("Please enter the city.");
		 document.frm_sysset.city.focus();
		 return false;
	 }
	 if(document.frm_sysset.country.value == "Choose") 
	 {
		 alert("Please select the country.");
		 document.frm_sysset.country.focus();
		 return false;
	 }
	 if(document.frm_sysset.country.value=="United States of America" && document.frm_sysset.state1.value=="")
	 {
		 alert("Please select the state.");
		 document.frm_sysset.state1.focus();
		 return false;
	 }
	 if(document.frm_sysset.country.value !="United States of America" && document.frm_sysset.state.value=="")
	 {
		 alert("Please enter the state.");
		 document.frm_sysset.state.focus();
		 return false;
	 }

	 if(document.frm_sysset.zip.value =="")
	 {
		 alert("Please enter the Zipcode.");
		 document.frm_sysset.zip.focus();
		 return false;
	 }
	 if(document.frm_sysset.phone.value =="")
	 {
		 alert("Please enter the Phone.");
		 document.frm_sysset.phone.focus();
		 return false;
	 }
	   cphone = document.frm_sysset.phone;
		if (checkInternationalPhone(cphone.value)==false)
		{
			alert("Please Enter a Valid Phone Number");
			cphone.value="";
			cphone.focus();
			return false;
		}

 if (!validateEmail(document.frm_sysset.emailaddr.value,1,1)) 
		{
			document.frm_sysset.emailaddr.focus();
			return false;
		}


	if(document.frm_sysset.sitename.value ==""){
		 alert("Please enter the site URL.");
		 document.frm_sysset.sitename.focus();
		 return false;
	 }

	 recordvalue = document.frm_sysset.records.value;
	 if( (recordvalue == "")  || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) || (recordvalue > 65535) ){
	    alert("Please enter the valid records per page count");
		document.frm_sysset.records.focus();
		return false;
		}

	 
}

//Validation For Enquiry Section
//Project Status code validation
function procategory_validate()
{
	txt_catname = document.frm_procategory.txt_catname;
		if (txt_catname.value == ""){
			alert("Please enter the product category");
			txt_catname.focus();
			return false;
		}
	if(document.frm_procategory.webtitle.value == "")
	{
		alert("Enter the page title");
		document.frm_procategory.webtitle.focus();
		return false;
	}
	if(document.frm_procategory.metakeywords.value == "")
	{
		alert("Enter the meta keyword");
		document.frm_procategory.metakeywords.focus();
		return false;
	}
	if(document.frm_procategory.metadesc.value == "")
	{
		alert("Enter the meta description");
		document.frm_procategory.metadesc.focus();
		return false;
	}
	if(document.frm_procategory.metadesc.value == "")
	{
		alert("Enter the meta description");
		document.frm_procategory.metadesc.focus();
		return false;
	}
}

function feedback_validate(){
	if(document.feedback.frndname.value == "")
	{
		alert("Enter the name");
		document.feedback.frndname.focus();
		return false;
	}
	if(document.feedback.frndemail.value == "")
	{
		alert("Enter the email");
		document.feedback.frndemail.focus();
		return false;
	}
	if(!validateEmail(document.feedback.frndemail.value,1,1)) 
	{
		document.feedback.frndemail.focus();
		return false;
	}
}

function friend_validate(){
	if(document.tell_story.frndname.value == "")
	{
		alert("Enter your friend name");
		document.tell_story.frndname.focus();
		return false;
	}
	if(document.tell_story.frndemail.value == "")
	{
		alert("Enter your friend email");
		document.tell_story.frndemail.focus();
		return false;
	}
	if(!validateEmail(document.tell_story.frndemail.value,1,1)) 
	{
		document.tell_story.frndemail.focus();
		return false;
	}
	if(document.tell_story.yourname.value == "")
	{
		alert("Enter your your name");
		document.tell_story.yourname.focus();
		return false;
	}
	if(document.tell_story.youremail.value == "")
	{
		alert("Enter your your email");
		document.tell_story.youremail.focus();
		return false;
	}
	if(!validateEmail(document.tell_story.youremail.value,1,1)) 
	{
		document.tell_story.youremail.focus();
		return false;
	}
	if(document.tell_story.comments.value == "")
	{
		alert("Enter the comments");
		document.tell_story.comments.focus();
		return false;
	}
}

function product_validate()
{
	selCategory = document.frm_product.selCategory;
		if (selCategory.value == ""){
			alert("Please select the product category");
			selCategory.focus();
			return false;
		}
	txtProduct = document.frm_product.txtProduct;
		if (txtProduct.value == ""){
			alert("Please enter the product name");
			txtProduct.focus();
			return false;
		}
		
		txtProductCode = document.frm_product.txtProductCode;
		if (txtProductCode.value == ""){
			alert("Please enter the product code");
			txtProductCode.focus();
			return false;
		}
		
		recordvalue = document.frm_product.txtRegprice.value;
	 	if( (recordvalue == "")  || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) ){
	    alert("Please enter the valid records per page count");
		document.frm_product.txtRegprice.focus();
		return false;
		}
		
		brandentry = document.frm_product.rdoBrand[0].checked;
		if(brandentry){
			txtBrand1 = document.frm_product.txtBrand1.value;
			txtBrandCode1 = document.frm_product.txtBrandCode1.value;
			txtBrandPrice1 = document.frm_product.txtBrandPrice1.value;
			if(txtBrand1 == "" || txtBrandCode1 == "" || txtBrandPrice1 == ""){
				alert("Please enter atleast one brand with brand name, code and price");
				document.frm_product.txtBrand1.focus();
				return false;
			}
			
		}
		
		
}

//Validation for  message editor
function msgedit_validate(){
	 if (document.msgeditor.txtFrom.value == "") 
		{
				alert ("Please enter the from name.");
				document.msgeditor.txtFrom.focus();
				return false;
		}
	 if (!validateEmail(document.msgeditor.txtEmail.value,1,1)) 
		{
				document.msgeditor.txtEmail.focus();
				return false;
		}
	if (document.msgeditor.txtThanks.value == "") 
		{
				alert ("Please enter the message.");
				document.msgeditor.txtThanks.focus();
				return false;
		}
}

//Function Newsletter validation
function newsletter_validation(){
	var txtMember=document.frm_newsletter.txtMember;
	 if(txtMember.value == "")
			 {
			 alert("No prospects are registered for newsletter");
			 txtMember.focus();
			 return false;
			 }
	var newstitle=document.frm_newsletter.txtTitle;
	 if(newstitle.value == "")
			 {
			 alert("Newsletter title is empty");
			 newstitle.focus();
			 return false;
			 }
	
		
}

function mailform(){
	var name=document.signup.name;
	 if(name.value == "")
			 {
			 alert("Please Enter the name");
			 name.focus();
			 return false;
			 }
	 if (!validateEmail(document.signup.email.value,1,1)) 
		{
				document.signup.email.focus();
				return false;
		}
}

//contact validation
function contactform(){
	var name=document.contact.name;
	 if(name.value == "")
			 {
			 alert("Please Enter the name");
			 name.focus();
			 return false;
			 }
	 if (!validateEmail(document.contact.email.value,1,1)) 
		{
				document.contact.email.focus();
				return false;
		}
	var city=document.contact.city;
	 if(city.value == "")
			 {
			 alert("Please Enter the city");
			 city.focus();
			 return false;
			 }
	var state=document.contact.state;
	 if(state.value == "")
			 {
			 alert("Please Enter the state");
			 state.focus();
			 return false;
			 }
	var contact=document.contact.subject;
	 if(contact.value == "")
			 {
			 alert("Please Enter the subject");
			 contact.focus();
			 return false;
			 }
			if (document.contact.phoneno.value=="")
			{
			alert("Please enter the phone number");
			document.contact.phoneno.focus();
			return false;
			}
			if (isNaN(document.contact.phoneno.value))
			{
			alert("Please enter the valid phone number");
			document.contact.phoneno.value="";
			document.contact.phoneno.focus();
			return false;
			}
}

//Email Validation 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);
}

//script validation for date 
function date_valid(dateissue,dateissue2){
	var stdate=dateissue.split("/");
	var enddate=dateissue2.split("/");
	var prostdate = new Date();
	prostdate.setFullYear(stdate[2]);
	prostdate.setMonth(stdate[0]-1);
	prostdate.setDate(stdate[1]);
	
	var proenddate = new Date();
	proenddate.setFullYear(enddate[2]);
	proenddate.setMonth(enddate[0]-1);
	proenddate.setDate(enddate[1]);
	
	var startingdate = prostdate.getTime();
	var endingdate = proenddate.getTime();

	if(startingdate > endingdate)
	{
		return false;
	}
	return true;
}

function openw(){
	document.viewcart.action="viewproducts.php";
	document.viewcart.submit();
}
function openwi(){
	document.viewcart.action="checkout.php";
	document.viewcart.submit();
}

function opencart(){
/*var len=document.viewcart.ONE.length;
	  var flag=0;
		for(var index=0;index<len;index++)
		{
		quantity = document.viewcart.ONE[index].value;
			if( (quantity == "")  || isNaN(quantity) || (quantity == 0) || (quantity.indexOf("-") >= 0) || (quantity.indexOf(".") >= 0) || (quantity > 4) )
			{
						alert("Quantity must be in the range of 1 to 4");
						document.viewcart.ONE[index].focus();
						return false;
			}
								
		}*/
document.viewcart.action="modifycart.php";
document.viewcart.submit();
}

function openwindow(){
	document.viewcart.action="deletecart.php";
	document.viewcart.submit();
}


function state_display() {
var us_state_value_list = new Array();
var us_state_text_list = new Array();
var in_state_value_list = new Array();
var in_state_text_list = new Array();
var check_state = document.frm_register.txtPostState;

    if (check_state.length >1){
		   var k;
			 for (k=0;k<check_state.length; k++)
			 check_state[k+1] = null;   
		}

	  if (document.frm_register.txtPostCountry.value == "IN"){
	  	 in_state_value_list.push('AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH');
		   in_state_text_list.push('Andaman & Nicobar (UT)','Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chandigarh (UT)','Chhattisgarh','Dadra and Nagar Haveli (UT)','Daman and Diu (UT)','Delhi (UT)','Goa','Gujarat','Haryana','Himachal Pradesh','Jammu and Kashmir ','Jharkhand','Karnataka','Kerala','Lakshadweep (UT)','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry (UT)','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttar Pradesh','Uttaranchal','West Bengal');
       var i;
       for (i=0; i<in_state_value_list.length; i++)
       {
          var opt = document.createElement('OPTION');
          opt.value = in_state_value_list[i];
          opt.text = in_state_text_list[i];
          var instateList = document.frm_register.txtPostState;
          instateList[i+1] = opt;
       }		 	 
		 }
		 else{
		   us_state_value_list.push('NN','AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','DC','WV','WI','WY','NN');
		   us_state_text_list.push('Non US','Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin','Wyoming','Non US');
       var j;
       for (j=0; j<us_state_value_list.length; j++)
       {
          var opt = document.createElement('OPTION');
          opt.value = us_state_value_list[j];
          opt.text = us_state_text_list[j];
          var usstateList = document.frm_register.txtPostState;

          usstateList[j+1] = opt;
       }		 	 			 
 	  } 
}

function default_state(){
  var in_state_value_list = new Array();
  var in_state_text_list = new Array();

	  in_state_value_list.push('AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH');
		in_state_text_list.push('Andaman & Nicobar (UT)','Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chandigarh (UT)','Chhattisgarh','Dadra and Nagar Haveli (UT)','Daman and Diu (UT)','Delhi (UT)','Goa','Gujarat','Haryana','Himachal Pradesh','Jammu and Kashmir ','Jharkhand','Karnataka','Kerala','Lakshadweep (UT)','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry (UT)','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttar Pradesh','Uttaranchal','West Bengal');
 		var i;
    for (i=0; i<in_state_value_list.length; i++)
    {
       var opt = document.createElement('OPTION');
       opt.value = in_state_value_list[i];
       opt.text = in_state_text_list[i];
       var instateList = document.frm_register.txtPostState;
       instateList[i+1] = opt;
    }		 	 
}
//-->

function state_displaycopy() {
var us_state_value_list = new Array();
var us_state_text_list = new Array();
var in_state_value_list = new Array();
var in_state_text_list = new Array();
var check_state = document.frm_register.txtDeliState;

    if (check_state.length >1){
		   var k;
			 for (k=0;k<check_state.length; k++)
			 check_state[k+1] = null;   
		}

	  if (document.frm_register.txtDeliCountry.value == "IN"){
	  	 in_state_value_list.push('AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH');
		   in_state_text_list.push('Andaman & Nicobar (UT)','Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chandigarh (UT)','Chhattisgarh','Dadra and Nagar Haveli (UT)','Daman and Diu (UT)','Delhi (UT)','Goa','Gujarat','Haryana','Himachal Pradesh','Jammu and Kashmir ','Jharkhand','Karnataka','Kerala','Lakshadweep (UT)','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry (UT)','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttar Pradesh','Uttaranchal','West Bengal');
       var i;
       for (i=0; i<in_state_value_list.length; i++)
       {
          var opt = document.createElement('OPTION');
          opt.value = in_state_value_list[i];
          opt.text = in_state_text_list[i];
          var instateList = document.frm_register.txtDeliState;
          instateList[i+1] = opt;
       }		 	 
		 }
		 else{
		   us_state_value_list.push('NN','AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','DC','WV','WI','WY','NN');
		   us_state_text_list.push('Non US','Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','Washington D.C.','West Virginia','Wisconsin','Wyoming','Non US');
       var j;
       for (j=0; j<us_state_value_list.length; j++)
       {
          var opt = document.createElement('OPTION');
          opt.value = us_state_value_list[j];
          opt.text = us_state_text_list[j];
          var usstateList = document.frm_register.txtDeliState;

          usstateList[j+1] = opt;
       }		 	 			 
 	  } 
}

function default_statecopy(){
  var in_state_value_list = new Array();
  var in_state_text_list = new Array();

	  in_state_value_list.push('AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH');
		in_state_text_list.push('Andaman & Nicobar (UT)','Andhra Pradesh','Arunachal Pradesh','Assam','Bihar','Chandigarh (UT)','Chhattisgarh','Dadra and Nagar Haveli (UT)','Daman and Diu (UT)','Delhi (UT)','Goa','Gujarat','Haryana','Himachal Pradesh','Jammu and Kashmir ','Jharkhand','Karnataka','Kerala','Lakshadweep (UT)','Madhya Pradesh','Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry (UT)','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttar Pradesh','Uttaranchal','West Bengal');
 		var i;
    for (i=0; i<in_state_value_list.length; i++)
    {
       var opt = document.createElement('OPTION');
       opt.value = in_state_value_list[i];
       opt.text = in_state_text_list[i];
       var instateList = document.frm_register.txtDeliState;
       instateList[i+1] = opt;
    }		 	 
}
//-->


//validation for register validations(admin reg & frontregister page)
function register_validate()
{
	 if (document.frm_register.txtUser.value == "")
	 {
		alert("Enter the user name");
		document.frm_register.txtUser.focus();
		return false;
	 }
	 if (document.frm_register.txtPassword.value == "")
	 {
		alert("Enter the password");
		document.frm_register.txtPassword.focus();
		return false;
	 }
	 if (document.frm_register.txtConfirmPassword.value == "")
	 {
		alert("Enter the confirm password");
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	  if (document.frm_register.txtPassword.value != document.frm_register.txtConfirmPassword.value)
	 {
		alert("Enter the same password");
		document.frm_register.txtConfirmPassword.value="";
		document.frm_register.txtConfirmPassword.focus();
		return false;
	 }
	 if(!validateEmail(document.frm_register.txtEmail.value,1,1))
	{
	   document.frm_register.txtEmail.focus();
	   return false;
	}
	if (document.frm_register.txtFirst.value == "")
	 {
		alert("Enter the first name");
		document.frm_register.txtFirst.focus();
		return false;
	 }
	 if (document.frm_register.txtLast.value == "")
	 {
		alert("Enter the last name");
		document.frm_register.txtLast.focus();
		return false;
	 }
	 if (document.frm_register.txtPostcode1.value == "")
	 {
		alert("Enter the address line2");
		document.frm_register.txtPostcode1.focus();
		return false;
	 }
	
	if (document.frm_register.txtPostcode2.value == "")
	 {
		alert("Enter the address line2");
		document.frm_register.txtPostcode2.focus();
		return false;
	 }
	 if (document.frm_register.txtPostCity.value == "")
	 {
		alert("Enter the city");
		document.frm_register.txtPostCity.focus();
		return false;
	 }
	
	if(document.frm_register.txtPostCountry.value == "Choose")
		{
		   alert("Select the country");
		   document.frm_register.txtPostCountry.focus();
		   return false;
		}
			 if (document.frm_register.txtPostZip.value == "")
	 {
		alert("Enter the zipcode");
		document.frm_register.txtPostZip.focus();
		return false;
	 }

	 if (document.frm_register.txtPostState.value == "")
	 {
		alert("Enter the Post State");
		document.frm_register.txtPostState.focus();
		return false;
	 }
	
	if(!(document.frm_register.chkDelivery.checked))
		{
		    if(document.frm_register.txtDelicode1.value=="")
			{
			   alert("Enter the delivery address line1");
			   document.frm_register.txtDelicode1.focus();
			   return false;
			} 
			if(document.frm_register.txtDelicode2.value=="")
			{
			   alert("Enter the delivery address line2");
			   document.frm_register.txtDelicode2.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCity.value=="")
			{
			   alert("Enter the city");
			   document.frm_register.txtDeliCity.focus();
			   return false;
			}
			if(document.frm_register.txtDeliCountry.value == "Choose")
			{
			   alert("Select the country");
			   document.frm_register.txtDeliCountry.focus();
			   return false;
			}
			if(document.frm_register.txtDeliState.value=="")
			{
			   alert("Enter the state");
			   document.frm_register.txtDeliState.focus();
			   return false;
			}
			if(document.frm_register.txtDeliZip.value=="")
			{
			   alert("Enter the zipcode");
			   document.frm_register.txtDeliZip.focus();
			   return false;
			}
			
		}
		
		if(document.frm_register.txtBusinessph.value=="")
			{
			   alert("Enter the Business phone number");
			   document.frm_register.txtBusinessph.focus();
			   return false;
			}
		phone = document.frm_register.txtBusinessph;
		if (checkInternationalPhone(phone.value)==false)
		{
			alert("Please Enter a Valid Phone Number")
			phone.value=""
			phone.focus()
			return false
		}
		if(document.frm_register.txtHomeph.value=="")
			{
			   alert("Enter the Home phone number");
			   document.frm_register.txtHomeph.focus();
			   return false;
			}
			if(document.frm_register.txtFax.value=="")
			{
			   alert("Enter the Fax number");
			   document.frm_register.txtFax.focus();
			   return false;
			}
}

function checkform()
{
	if(name = document.checkout.name.value == "")
	{
		alert("Enter your name");
		document.checkout.name.focus();
		return false;
	}
	if(Address = document.checkout.Address.value == "")
	{
		alert("Enter your Address");
		document.checkout.Address.focus();
		return false;
	}
	if(city = document.checkout.city.value == "")
	{
		alert("Enter your city");
		document.checkout.city.focus();
		return false;
	}
	if(state = document.checkout.state.value == "")
	{
		alert("Select your state");
		document.checkout.state.focus();
		return false;
	}
		if(state = document.checkout.country.value == "")
	{
		alert("Select your country");
		document.checkout.country.focus();
		return false;
	}

	if(zip = document.checkout.zip.value == "")
	{
		alert("Enter your zip code");
		document.checkout.zip.focus();
		return false;
	}
	
	if(phone = document.checkout.phone.value == "")
	{
		alert("Enter your phone");
		document.checkout.phone.focus();
		return false;
	}
	
	 if (!validateEmail(document.checkout.email.value,1,1)) 
		{
			document.checkout.email.focus();
			return false;
		}
}

// Hide Shopping Cost in Add Product Page
function showlaptop(theTable)
{
     if (document.getElementById(theTable).style.display == 'none')
     {
          document.getElementById(theTable).style.display = 'block';
     }
     else
     {
          document.getElementById(theTable).style.display= 'visible';
     }
}
//-->
<!-- validation for date search
function hidelaptop(theTable)
{
     if (document.getElementById(theTable).style.display == 'none')
     {
          document.getElementById(theTable).style.display = 'hidden';
		  
     }
     else
     {
          document.getElementById(theTable).style.display = 'none';
     }
}


/*

// Hide Shopping Cost in Add Product Page
function showquantity(theyesTable)
{
	if (document.getElementById(theyesTable).style.display == 'none')
     {
          document.getElementById(theyesTable).style.display = 'block';
     }
     else
     {
          document.getElementById(theyesTable).style.display= 'visible';
         // document.getElementById(thenotable).style.display= 'hidden';		  
     }
}
//-->

<!-- validation for date search
function hidequantity(theyesTable)
{
	if (document.getElementById(theyesTable).style.display == 'none')
     {
		    document.getElementById(theyesTable).style.display = 'block';
		 //   document.getElementById(thenotable).style.display = 'visible';
     }
     else
     {

          document.getElementById(theyesTable).style.display = 'none';
     }
}

*/
// JavaScript product add val
//javascript payment_gatewaysetup page
function  gate_val()
{
	if(document.form1.selCurrency.value=="")
			{
			   alert("Enter the SelCurrency");
			   document.form1.selCurrency.focus();
			   return false;
			}
	if(document.form1.txtPOD.value=="")
			{
			   alert("Enter the POD");
			   document.form1.txtPOD.focus();
			   return false;
			}
	if(document.form1.txtpaypal.value=="")
			{
			   alert("Enter the Paypal");
			   document.form1.txtpaypal.focus();
			   return false;
			}		
	
return true;

}
//javascript currencycodes page
function currency_validate()
{
    if(document.frm_currency.txtCode.value=="")
			{
			   alert("Enter the Currency code");
			   document.frm_currency.txtCode.focus();
			   return false;
			}
	if(document.frm_currency.txtSymbol.value=="")
			{
			   alert("Enter the symbol");
			   document.frm_currency.txtSymbol.focus();
			   return false;
			}
	if(document.frm_currency.txtRate.value=="")
			{
			   alert("Enter the rate");
			   document.frm_currency.txtRate.focus();
			   return false;
			}	
    return true;			

}
//javascript  validations of userlogin index page
function  frontlog()
{
	if(document.Frmlogin.txtUsername.value=="")
	{
	   alert("Enter the Username");
	   document.Frmlogin.txtUsername.focus();
	   return false;
	}
	if(document.Frmlogin.txtPassword.value=="")
	{
	   alert("Enter the Password");
	   document.Frmlogin.txtPassword.focus();
	   return false;
	}	
	
	return true;
}

function memsearch_validation()
{
	if(document.membersearch.sortby.value == "")
		{
			alert("Please enter the search text");
			document.membersearch.sortby.focus();
			return false;
		}
		return true;
}
