function ChangeCategory(objList) {
//			index  = index-1;
	sIndex = objList.selectedIndex;
}

function AddtoCart(objForm,Ident)
{ 

	Qty = 1
	if(objForm.c_quantity.length)
	{
		objQty =objForm.c_quantity[Index];			
		Qty = objQty.value;
	}
	else
	{
		objQty =objForm.c_quantity;			
		Qty = objForm.c_quantity.value
	}
	if(isNaN(Qty))
	{
		alert("Quantity must be numeric");
		objQty.focus();
		return false;
	}
	if(Qty<=0)
	{
		alert("Quantity must be positive number");
		objQty.focus();
		return false;
	}
	if(!IsNumber(objForm.c_quantity.value,"Quantity"))	{
	objForm.c_quantity.focus();
	return false;
	}
	objForm.c_product.value = Ident;
	objForm.c_action.value  = 1;
	objForm.c_qty.value		= Qty;
}
function qtyupdate(Ident,objForm,Index)
{
 if (event.keyCode==13)
 {
	 AddtoCart(Ident,objForm,Index);
 }
}
function ImagePopup(imageName,pwidth,pheight)
{
	  var page= strPopupPage+"?imageName="+imageName +"&width="+ pwidth +"&height="+pheight;
	  window.open(page,"SpecsImage","toolbar=no, location=no,directories=no,status=no,menubar=no,resizable=YES,copyhistory=no,scrollbars=Yes,width=" + pwidth + ",height=" + pheight + ",top=50,left=50");
}

function ChangeAmount(index,objList) {
	index  = index-1;
	sIndex = objList.selectedIndex-1;
	if(sIndex >= 0)
	{ 
		strAmount = strAttributes[index][sIndex]["Amount"];
		//alert("["+index+"]["+sIndex+"][Amount] = "+strAmount);
		if(floatRound(strAmount,2) != 0.00)
		{ 
			document.getElementById("ProductPrice").innerHTML = strAmount;
		}
	}
	else
	{  
		document.getElementById("ProductPrice").innerHTML = "0.00"; //ProductAmount;
	}
}
function Discount_Validate(objForm)
{ 
   if(!IsValid(objForm.promcode.value,"Discount/Coupon"))
   {
   objForm.promcode.focus();
   return false;
   }
}

function c_select(mode)
{
	objForm = document.c_form;
	check = (mode==0)?true:false;
	for(i=0; i<objForm.elements.length; i++)		
	{
		if(objForm.elements[i].name == "c_Check[]")
			objForm.elements[i].checked = check;
	}
}
function c_Validate(objForm)
{  
	if(objForm.c_Action.value==2)
		return confirm("Are you sure to Remove all the Items from the Cart?");
	if(objForm.c_Action.value==3)
	{
		for(j=0;j<objForm.elements.length;j++)
		{ 
			if(objForm.elements[j].name == "c_Quantity[]")
			{
			   var ValidChars = "0123456789";
			   var IsNumber=true;
			   var Char;
			   for (i = 0; i < objForm.elements[j].value.length && IsNumber == true; i++) 
			   { 
				  Char = objForm.elements[j].value.charAt(i); 
				  if(ValidChars.indexOf(Char) == -1) 
				  {
					 IsNumber = false;
				  }
			   }
			   if(!IsNumber)
			   {
				alert("Quantity must be a positive numeric value")
				objForm.elements[j].focus();
				return false;
				}
			}
		}					
/*				for(i=0;i<objForm.elements.length;i++)
		{
			if(objForm.elements[i].name == "c_Quantity[]" && (isNaN(objForm.elements[i].value) || (objForm.elements[i].value<=0)))
			{
				alert("Quantity must be a positive numeric value");
				objForm.elements[i].focus();
				return false;
			}
		}*/
	}
}
function qtyupdate1()
{
 if (event.keyCode==13)
 {
   document.c_form.c_Action.value=3;
 }
}
function LoginOption(formObj) 
{
	for(var i=0; i<=2; i++) 
	{
		if (formObj.loginoption[i].checked == true)
		
		var loginoption = formObj.loginoption[i].value;
	}
	
	if (loginoption == 1) 
	{ 
		
		var username = formObj.username.value;
		if (username.length == 0) 
		{
			alert("Enter Email Address");
			formObj.username.focus();
			return false;
		} 
		else 
		{
			var result = isEmailAddr(username);
			if (!result) 
			{
				alert("Invalid Email Address!");
				formObj.username.select();
				return result;
			}
		}
	
		var password = formObj.password.value;
		if(password.length==0) 
		{
			alert("Please enter password");
			formObj.password.focus();
			return false;
		} else 
		{
			 
		//		formObj.action="login.php";
		}
	} 
	else if (loginoption == 2) 
	{   
	       /* if(formObj.username.value!="")
			{
				alert("My email should be empty");
				formObj.username.focus();
				return false;
			}*/
			formObj.login_option.value = 2;
			formObj.username.value="";
			formObj.action="registration.php";
			
	   } 
	   else if (loginoption == 21) 
	{ 
			
			formObj.login_option.value = 3;
			formObj.username.value="";
			formObj.NonMember.value="21";
			formObj.action="registration.php";
	}
	/*else if (loginoption == 3) 
	{ 
			formObj.action="forgotpass.php";
	}*/	
}
function CheckLogin(formObj)
{
		
	var username = formObj.username.value;
		if (username.length == 0) 
		{
			alert("Enter Email Address");
			formObj.username.focus();
			return false;
		} 
		else 
		{
			var result = isEmailAddr(username);
			if (!result) 
			{
				alert("Invalid Email Address!");
				formObj.username.select();
				return result;
			}
		}
	
		var password = formObj.password.value;
		if(password.length==0) 
		{
			alert("Please enter password");
			formObj.password.focus();
			return false;
		} else 
		{
			//alert();
			//formObj.action="login.php";
		}
	
	
}
function CopyBilling(isChecked,objForm)
{
	if(isChecked)
	{
		objForm.SFirstName.value 		= objForm.BFirstName.value;
		objForm.SLastName.value 		= objForm.BLastName.value;
		objForm.SCompany.value 			= objForm.BCompany.value;
		objForm.SAddress1.value 		= objForm.BAddress1.value;
		objForm.SAddress2.value 		= objForm.BAddress2.value;
		objForm.SCity.value 			= objForm.BCity.value;
		objForm.SZipCode.value			= objForm.BZipCode.value;
		objForm.SPhone.value 			= objForm.BPhone.value;
		objForm.SAltPhone.value 		= objForm.BAltPhone.value;
		objForm.SState.selectedIndex	= objForm.BState.selectedIndex;
		objForm.SCountry.selectedIndex	= objForm.BCountry.selectedIndex;
	}
}

function Validation(objForm)
{
/*		if(!IsValid(objForm.ShippingModule.value,"Shipping Module"))
	{
		objForm.ShippingModule.focus();
		return false;
	}*/
	if(!IsValid(objForm.BFirstName.value,"Billing First Name"))
	{
		objForm.BFirstName.focus();
		return false;
	}
	if(!IsValid(objForm.BLastName.value,"Billing Last Name"))
	{
		objForm.BLastName.focus();
		return false;
	}
	if(!IsValid(objForm.Email.value,"Email Address"))
	{
		objForm.Email.focus();
		return false;
	}
	if(!isEmailAddr(objForm.Email.value))
	{
		alert("Invalid Email Address");
		objForm.Email.focus();
		return false;
	}
	
	if(!IsValid(objForm.BAddress1.value,"Billing Address"))
	{
		objForm.BAddress1.focus();
		return false;
	}
	if(!IsValid(objForm.BZipCode.value,"Billing Zip Code"))
	{
		objForm.BZipCode.focus();
		return false;
	}
	if(!IsValid(objForm.BPhone.value,"Billing Phone Number"))
	{
		objForm.BPhone.focus();
		return false;
	}
	if(!IsValid(objForm.SFirstName.value,"Shipping First Name"))
	{
		objForm.SFirstName.focus();
		return false;
	}
	if(!IsValid(objForm.SLastName.value,"Shipping Last Name"))
	{
		objForm.SLastName.focus();
		return false;
	}
	if(!IsValid(objForm.SAddress1.value,"Shipping Address"))
	{
		objForm.SAddress1.focus();
		return false;
	}
	if(!IsValid(objForm.SZipCode.value,"Shipping Zip Code"))
	{
		objForm.SZipCode.focus();
		return false;
	}
	if(!IsValid(objForm.SPhone.value,"Shipping Phone Number"))
	{
		objForm.SPhone.focus();
		return false;
	}
//		objForm.c_action.value = "1";
}
function Validate(MyForm)
{
		
		if(!IsValid(MyForm.PaymentType.value,"Payment Type"))
		{	
			MyForm.PaymentType.focus()
			return false;
		}	
		
	return true;		
	
	
}
/*
function ValidateCreditcard(MyForm)
{
		if(!IsValid(MyForm.CardType.value,"Card Type"))
		{	
			MyForm.CardType.focus()
			return false;
		}
		if(!IsNumber(MyForm.CreditNo.value,"Credit Card Number"))
		{	
			MyForm.CreditNo.focus()
			return false;
		}
		if(!IsaCardno(MyForm.CreditNo))
		{	
			MyForm.CreditNo.focus();
			return false;
		}
		if(!IsNumber(MyForm.ExpMonth.value,"Expire Month"))
		{	
			MyForm.ExpMonth.focus()
			return false;
		}
		if(!IsNumber(MyForm.ExpYear.value,"Expire Year"))
		{	
			MyForm.ExpYear.focus()
			return false;
		}	
	return true;		
}
*/
function PrintWindow(id)
{ 
	ScreenWidth  = screen.width
	ScreenHeight = screen.height
	PopupWidth   = 800
	PopupHeight  = 450
	PopupLeft    = (ScreenWidth-PopupWidth)/2
	PopupTop     = (ScreenHeight-PopupHeight)/2
	 window.open("print.php?id="+id,"PopupWindow","toolbar=no, location=no,directories=no,status=no,menubar=no,resizable=YES,copyhistory=no,scrollbars=Yes,width=" + PopupWidth + ",height=" + PopupHeight + ",top=" + PopupLeft + ",left=" + PopupTop + "");
}
function CopyBilling1(isChecked,objForm)
{
	if(isChecked)
	{
		objForm.SAddress1.value 			= objForm.BAddress1.value;
		objForm.SAddress2.value 			= objForm.BAddress2.value;
		objForm.SCity.value 				= objForm.BCity.value;
		objForm.SState.value				= objForm.BState.value;
		objForm.SCountry.value 				= objForm.BCountry.value;
		
		objForm.SCountry.selectedIndex		= objForm.BCountry.selectedIndex;
		objForm.SZipCode.value			 	= objForm.BZipCode.value;
		objForm.SPhone.value				= objForm.BPhone.value;
		objForm.SAltPhone.value				= objForm.BAltPhone.value;
		
		
		
	}
}

function validateRegister(formObj) {
	alert("ss");
	var result = true;
	result = IsValidName(formObj.FirstName.value,"First Name");
	formObj.FirstName.focus();
	if (!result)
		return result;
	result = true;
	result = IsValidName(formObj.LastName.value,"Last Name");
	formObj.LastName.focus();
	if (!result)
		return result;

	if(!IsValid(formObj.Email.value,"Email Address"))
	{
		formObj.Email.focus();
		return false;
	}
	if(!isEmailAddr(formObj.Email.value))
	{
		alert("Invalid Email Address");
		formObj.Email.focus();
		return false;
	}
	
	result = true;
	result = IsValid(formObj.BAddress1.value,"Address1");
	formObj.BAddress1.focus();
	if (!result)
		return result;

	/*result = true;
	result = IsValid(formObj.BCity.value,"City");
	formObj.BCity.focus();
	if (!result)
		return result;*/


	result = true;
	result = IsPhoneNo(formObj.BZipCode.value,"Zip Code");
	formObj.BZipCode.focus();
	if (!result)
		return result;

	result = true;
	result = IsFax(formObj.BPhone.value,"Phone Code");
	formObj.BPhone.focus();
	if (!result)
		return result;

	result = true;
	result = IsValid(formObj.SAddress1.value,"Address1");
	formObj.SAddress1.focus();
	if (!result)
		return result;

	/*result = true;
	result = IsValid(formObj.SCity.value,"City");
	formObj.SCity.focus();
	if (!result)
		return result;*/

	result = true;
	result = IsPhoneNo(formObj.SZipCode.value,"Zip Code");
	formObj.SZipCode.focus();
	if (!result)
		return result;

	result = true;
	result = IsFax(formObj.SPhone.value,"Phone Number");
	formObj.SPhone.focus();
	if (!result)
		return result;
		
//	if(formObj.pass.value !=""){
		result = true;	
		result = IsValid(formObj.pass.value,"Password");
		formObj.pass.focus();
		if (!result)
			return result;
		
		result = true;	
		result = IsValid(formObj.confirmpass.value,"Confirm Password");
		formObj.confirmpass.focus();	
		if (!result)
			return result;
	
		if (formObj.pass.value != formObj.confirmpass.value) {
			alert("Confirm Password does not match");
			formObj.confirmpass.select();
			return false;
		}
//	}
}
function ContactValidation(objForm)
{
   if(!IsValid(objForm.txtName.value,"Name"))
	{
		objForm.txtName.focus();
		return false;
	}
	
	if(!isEmailAddr(objForm.txtEmail.value,"Email"))
	{
	    alert("Enter valid email address");
		objForm.txtEmail.focus();
		return false;
	}
	
	if(!IsValid(objForm.txtMsg.value,"Message"))
	{
		objForm.txtMsg.focus();
		return false;
	}
	if(!IsValid(objForm.txtverification.value,"Verification Code"))
	{
		objForm.txtverification.focus();
		return false;
	}

}

function validate_form(frm)
{
	for(var i=0;i<frm.elements.length;i++)
	{ 
	
		switch(frm.elements[i].type)	{	
			case "text" :
				if (frm.elements[i].attributes["validate"].value=="Yes")	{
					r=IsValid(frm.elements[i].value,frm.elements[i].attributes["title"].value);
					if (r==false)	{
						frm.elements[i].focus();
						return r;
					} 
				}
			break;
			case "textarea" :
				if (frm.elements[i].attributes["validate"].value=="Yes")	{
					r=IsValid(frm.elements[i].value,frm.elements[i].attributes["title"].value);
					if (r==false)	{
						frm.elements[i].focus();
						return r;
					} 
				}
			break;
		/*	case "radio" :
				strCountR=0;
				strHdName = ("hr"+frm.elements[i].attributes["title"].value)
				strEndValue = document.getElementById(strHdName).value
				for(j=0;j<strEndValue;j++)	{
					strName = frm.elements[i].attributes["title"].value + j
					if(document.getElementById(strName).checked)	{
						strCountR++;
						break;
					}
				}
				if (strCountR==0)	{
					alert ("Please select atleast "+frm.elements[i].attributes["title"].value +" one to proceed");
					return false;
				}
			break;*/
			case "checkbox" : 
				strCount=0;
				strHdName = ("hd"+frm.elements[i].attributes["title"].value)
				strEndValue = document.getElementById(strHdName).value
				
				for(j=0;j<strEndValue;j++)	{
					strName = frm.elements[i].attributes["title"].value + j
					if(document.getElementById(strName).checked)	{
						strCount++;
						break;
					}
				}
				if (strCount==0)	{
					alert ("Please select atleast one "+frm.elements[i].attributes["title"].value +" to proceed");
					return false;
				}
			break;
			case "select-one" :
				//strCountS=0;
				if(document.getElementById('Quantity')){
				}else{
				alert(frm.elements[i].attributes["title"].value)
					strHdName = frm.elements[i].attributes["title"].value;
					if(document.getElementById(strHdName).value ==''){
					alert ("Please select atleast one "+frm.elements[i].attributes["title"].value +" to proceed");
						return false;
					}
				}
			break;
					
		}
	} //end for
		return true;
}


function AdminvalidateRegister(formObj) {
	
	if(!isEmailAddr(formObj.txtEmail.value))
	{
		alert("Invalid Email Address");
		formObj.txtEmail.focus();
		return false;
	}

		result = true;	
		result = IsValid(formObj.txtPass.value,"Password");
		formObj.txtPass.focus();
		if (!result)
			return result;
		
		result = true;	
		result = IsValid(formObj.txtRetypePass.value,"Confirm Password");
		formObj.txtRetypePass.focus();	
		if (!result)
			return result;
	
		if (formObj.txtPass.value != formObj.txtRetypePass.value) {
			alert("Confirm Password does not match");
			formObj.txtRetypePass.select();
			return false;
		}
	//}

	
	var result = true;
	result = IsValidName(formObj.txtFirstName.value,"First Name");
	formObj.txtFirstName.focus();
	if (!result)
		return result;
	result = true;
	result = IsValidName(formObj.txtLastName.value,"Last Name");
	formObj.txtLastName.focus();
	if (!result)
		return result;

	if(!IsValid(formObj.txtEmail.value,"Email Address"))
	{
		formObj.txtEmail.focus();
		return false;
	}
	
	result = true;
	result = IsValid(formObj.txtAddressLine1.value,"Address1");
	formObj.txtAddressLine1.focus();
	if (!result)
		return result;

	result = true;
	result = IsValid(formObj.txtCity.value,"City");
	formObj.txtCity.focus();
	if (!result)
		return result;


	result = true;
	result = IsPhoneNo(formObj.txtZip.value,"Zip Code");
	formObj.txtZip.focus();
	if (!result)
		return result;

	result = true;
	result = IsFax(formObj.txtPrimaryPhone.value,"Phone Code");
	formObj.txtPrimaryPhone.focus();
	if (!result)
		return result;

	result = true;
	result = IsValid(formObj.txtSAddressLine1.value,"Address1");
	formObj.txtSAddressLine1.focus();
	if (!result)
		return result;

	result = true;
	result = IsValid(formObj.txtSCity.value,"City");
	formObj.txtSCity.focus();
	if (!result)
		return result;

	result = true;
	result = IsPhoneNo(formObj.txtSZip.value,"Zip Code");
	formObj.txtSZip.focus();
	if (!result)
		return result;

/*	result = true;
	result = IsFax(formObj.txtSecondaryPhone.value,"Phone Number");
	formObj.txtSecondaryPhone.focus();
	if (!result)
		return result;
*/		
	//if(formObj.txtPass.value!=""){
}
//For Trade Company Management
function TradevalidateRegister(formObj) {

	var result = true;
	result = IsValid(formObj.txtAccount.value,"Account Number");
	formObj.txtAccount.focus();
	if (!result)
	return result;
	
	if(!IsValid(formObj.txtPassword.value,"Password"))
	{
		formObj.txtPassword.focus();
		return false;
	}
	/*if(formObj.txtRetypePassword)	{
	if (formObj.txtPassword.value != formObj.txtRetypePassword.value) {
		alert("Confirm Password does not match");
		formObj.txtRetypePassword.select();
		return false;
	}
	}*/
	result = IsValid(formObj.txtCompanyName.value,"Company Name");
	formObj.txtCompanyName.focus();
	if (!result)
		return result;
	result = true;
	result = IsValid(formObj.txtContactName.value,"Contact Name");
	formObj.txtContactName.focus();
	if (!result)
		return result;

	if(!IsValid(formObj.txtEmail.value,"Email Address"))
	{
		formObj.txtEmail.focus();
		return false;
	}
	if(!isEmailAddr(formObj.txtEmail.value))
	{
		alert("Invalid Email Address");
		formObj.txtEmail.focus();
		return false;
	}
	/*if(!IsValid(formObj.txtCurrency.value,"Currency"))
	{
		formObj.txtCurrency.focus();
		return false;
	}
	*/
	result = true;
	result = IsValid(formObj.txtAddressLine1.value,"Address1");
	formObj.txtAddressLine1.focus();
	if (!result)
		return result;
		
	result = true;
	result = IsValid(formObj.txtAddressLine2.value,"Address2");
	formObj.txtAddressLine2.focus();
	if (!result)
		return result;
		
	result = true;
	result = IsValid(formObj.txtCity.value,"City");
	formObj.txtCity.focus();
	if (!result)
		return result;

	result = true;
	result = IsPhoneNo(formObj.txtPostalCode.value,"Postal Code");
	formObj.txtPostalCode.focus();
	if (!result)
		return result;

	result = true;
	result = IsPhoneNo(formObj.txtTelephone.value,"Phone Number");
	formObj.txtTelephone.focus();
	if (!result)
		return result;
	
	result = true;
	result = IsValid(formObj.txtFax.value,"Fax");
	formObj.txtFax.focus();
	if (!result)
		return result;
}