		
	function addcart_clicked()
	{
	
	document.frm_addtocart.submit() ;
	
	}
	
	
	function submit_product(prd_id)
	{
	//alert(prd_id);
	window.location = "product-details.asp?product_id=" + prd_id;
	
	}
	
	//this function submits the form onchange of select option
	function cat_change_frmSubmit()
		{
		document.prd_form.frm_submit_status.value = "0" ;//hidden feild stores the value "0" 
		document.prd_form.submit()
		}
	
	//this function submits the form onchange of select option of subcategory
	function sub_cat_change_frmSubmit()
		{
		document.prd_form.frm_submit_status.value = "2" ;//hidden feild stores the value "0" 
		document.prd_form.submit()
		}



	//this function submits the form when save button is clicked
		function main_frmSubmit()
			{
			document.prd_form.frm_submit_status.value = "1";//hidden feild  stores the value "1" 
			
			}
			
			
			
			
			
	
	function trim( instr ) {
    	var reFirst = /\S/;		// regular expression for first non-white char
    	var reLast = /\s+$/;	// regular expression for first white char after last non-white char
    	var firstChar = instr.search(reFirst);
    	var lastChar = instr.search(reLast);
    	
    	if( lastChar == -1 ) 
			lastChar = instr.length;    	
    	outstr = instr.substring( firstChar, lastChar );
    	return outstr;
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


function valfrm(prd_form)
{
if(trim((prd_form.txt_prd_name.value))=="")
{
alert("Product Name cannot be empty");
prd_form.txt_prd_name.focus();
return false;
}

else if(trim((prd_form.txt_prd_code.value))=="")
{
alert("Product Code cannot be empty");
prd_form.txt_prd_code.focus();
return false;
}
else if(trim((prd_form.txt_prd_desc.value))=="")
{
alert("Product Description cannot be empty");
prd_form.txt_prd_desc.focus();
return false;
}
else if(trim((prd_form.txt_prd_weight.value))=="")
{
alert("Weight Cannot be empty");
prd_form.txt_prd_weight.focus();
return false;
}
else if(trim((prd_form.txt_prd_price.value))=="")
{
alert("Price Cannot be empty");
prd_form.txt_prd_price.focus();
return false;
}

else if(trim((prd_form.txt_prd_discount_value.value))=="")
{
alert("Discount Cannot be empty");
prd_form.txt_prd_discount_value.focus();
return false;
}
else if (digitvalidation(txt_prd_weight,1,2,"You MUST enter 1 or 2 integer digits","I")==false) {txt_prd_weight.focus(); return false;}
else
{
return true;
}
}

	
