function check_fields()
{
	var flag;
	if (emptyField(document.getElementById("Login_User1_txtUser")))
	{
		alert("Enter your Email Address");
		document.getElementById("Login_User1_txtUser").focus();
		return false;
	}
	
	arg=document.getElementById("Login_User1_txtUser").value;
	flag=check_email(arg);
	if (flag==0)
	{
		alert('Enter valid e-mail address.');
		document.getElementById("Login_User1_txtUser").focus();
		return false;	
	}
	if (emptyField(document.getElementById("Login_User1_txtPassword")))
	{
		alert("Enter Password");
		document.getElementById("Login_User1_txtPassword").focus();
		return false;
	}
}

function Signup_fields()
{
	var arg;
	var flag;
	
	if (emptyField(document.getElementById("Signup1_txtEmail")))
	{
		alert("Enter your Email Address");
		document.getElementById("Signup1_txtEmail").focus();
		return false;
	}
	
	arg=document.getElementById("Signup1_txtEmail").value;
	flag=check_email(arg);
	if (flag==0)
	{
		alert('Enter valid e-mail address.');
		document.getElementById("Signup1_txtEmail").focus();
		return false;	
	}
	
	
	
	if (emptyField(document.getElementById("Signup1_txtPass")))
	{
		alert('Enter Password..');
		document.getElementById("Signup1_txtPass").focus();
		return false;
	}
	
	if (emptyField(document.getElementById("Signup1_txtPassAgain")))
	{
		alert('Enter Confirm Password..');
		document.getElementById("Signup1_txtPassAgain").focus();
		return false;
	}
	
	var pass1=document.getElementById("Signup1_txtPass").value;
	var pass2=document.getElementById("Signup1_txtPassAgain").value;
	flag=check_password(pass1,pass2)
	if (flag==0 || flag== 1)
	{
		alert('Password and confirm password must be same.');
		document.getElementById("Signup1_txtPass").focus();
		return false;
	}
	
	if (emptyField(document.getElementById("Signup1_txtFname")))
	{
		alert('Enter Your First Name.');
		document.getElementById("Signup1_txtFname").focus();
		return false;
	}
	if (emptyField(document.getElementById("Signup1_txtLname")))
	{
		alert('Enter Your Last Name.');
		document.getElementById("Signup1_txtLname").focus();
		return false;
	}
	
	if (document.getElementById("Signup1_ddlDate").value == "0")
	{
		alert('Select Day.');
		document.getElementById("Signup1_ddlDate").focus();
		return false;
	}
	if (document.getElementById("Signup1_ddlMonth").value == "0")
	{
		alert('Select Month.');
		document.getElementById("Signup1_ddlMonth").focus();
		return false;
	}
	if (document.getElementById("Signup1_ddlYear").value == "0")
	{
		alert('Select Year.');
		document.getElementById("Signup1_ddlYear").focus();
		return false;
	}
}

/*function check_product(i)
{
	if(i.value==0)
	{
		alert('Select product');
		return false;
	}
}*/
function check_product(i,pid)
{
//pvalueid
//pid

document.getElementById("SearchProductsNew1_pvalueid").value=i.value;
document.getElementById("SearchProductsNew1_pid").value=pid;

//alert('pvalueid ' + document.getElementById("SearchProducts1_pvalueid").value);
//alert('pid ' + document.getElementById("SearchProducts1_pid").value);

//return false;
	/*if(i.value==0)
	{
		alert('Select product');
		return false;
	}*/
}

function check_product1(i,pid)
{
//pvalueid
//pid

document.getElementById("View_productsnew1_pvalueid").value=i.value;
document.getElementById("View_productsnew1_pid").value=pid;
//alert('pvalueid ' + document.getElementById("View_products1_pvalueid").value);
//alert('pid ' + document.getElementById("View_products1_pid").value);
}

function check_qty(txtqty)
{       		var test =0;
				var con = 2;
var con1 =0;
				for (var i=0; i<document.Form1.length; i++)
				{
				
					if (con < 10)
				    	{				        
				        	con1 = "0"+con;		
				    	}
				   	 else    
				   	{
				        	 con1 = con;

				    	} 
							
							if (emptyField(document.getElementById("dgCart_ctl"+con1+"_txtqty")))
								{
									alert('Please enter Quantity');
									document.getElementById("dgCart_ctl"+con1+"_txtqty").focus();
									return false;
								}
								
							if (document.getElementById("dgCart_ctl"+con1+"_txtqty").value < 1)
								
								{
									alert('Quantity must be Greater then Zero.');
									document.getElementById("dgCart_ctl"+con1+"_txtqty").focus();
									return false;
								}
					
							if (!isInt(document.getElementById("dgCart_ctl"+con1+"_txtqty").value))
								
								{
									alert('Please enter Integer value.');
									document.getElementById("dgCart_ctl"+con1+"_txtqty").focus();
									return false;
								}
					
							 if (parseFloat(document.getElementById("dgCart_ctl"+con1+"_txtqty").value) > parseFloat(document.getElementById("dgCart_ctl"+con1+"_lblstock").value))
                                                           {                                                                                   
                                                               //alert('Only '+ document.getElementById("dgCart_ctl"+con1+"_lblstock").value + ' products in stock' );
								alert('Only ' + document.getElementById("dgCart_ctl"+con1+"_lblstock").value + ' of this product in stock');
                                                               return false;
                                                           }
						con =con + 1;			
				}
}

function set_shippingInfo()
{
	if(document.getElementById("chkShip").checked==true)
	{
		document.Form1.txtShipCompanyName.value = document.getElementById("txtBillCompanyName").value;
		//document.Form1.txtShipLname.value = document.getElementById("txtBillLname").value;
		document.Form1.txtShipAddr1.value = document.getElementById("txtBillAddr1").value;
		document.Form1.txtShipAddr2.value = document.getElementById("txtBillAddr2").value;
		document.Form1.txtShipCity.value = document.getElementById("txtBillCity").value;
		document.Form1.txtShipState.value = document.getElementById("txtBillState").value;
		document.Form1.ddlShipCountry.value = document.getElementById("ddlBillCountry").value;
		document.Form1.txtShipPost.value = document.getElementById("txtBillPost").value;
		document.Form1.txtShipPhone.value = document.getElementById("txtBillPhone").value;
		
		
	}
	else if(document.getElementById("chkShip").checked==false)
	{
		document.Form1.txtShipCompanyName.value = "";
		//document.Form1.txtShipLname.value = "";
		document.Form1.txtShipAddr1.value = "";
		document.Form1.txtShipAddr2.value = "";
		document.Form1.txtShipCity.value = "";
		document.Form1.txtShipState.value = "";
		document.Form1.ddlShipCountry.value = "0";
		document.Form1.txtShipPost.value = "";
		document.Form1.txtShipPhone.value = "";
	}
}
function check_billingInfo()
{
	var arg;
	var flag;
	// check billing info fields
	if (emptyField(document.getElementById("txtBillCompanyName")))
	{
		alert("Enter your Name");
		document.getElementById("txtBillCompanyName").focus();
		return false;
	}
	//if (emptyField(document.getElementById("txtBillLname")))
	//{
		//alert("Enter your Last Name");
		//document.getElementById("txtBillLname").focus();
		//return false;
	//}
	if (emptyField(document.getElementById("txtBillAddr1")))
	{
		alert("Enter your Frist Address");
		document.getElementById("txtBillAddr1").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillCity")))
	{
		alert("Enter your City");
		document.getElementById("txtBillCity").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillState")))
	{
		alert("Enter your County");
		document.getElementById("txtBillState").focus();
		return false;
	}
	if (document.getElementById("ddlBillCountry").value == "0")
	{
		alert('Select Your Country.');
		document.getElementById("ddlBillCountry").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillPost")))
	{
		alert('Enter PostCode');
		document.getElementById("txtBillPost").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillPhone")))
	{
		alert('Enter Phone No.');
		document.getElementById("txtBillPhone").focus();
		return false;
	}
	//if (!isInt(document.getElementById("txtBillPhone").value))
	//{
	//	alert('Please enter only digits.');
	//	document.getElementById("txtBillPhone").focus();
//		return false;
//	}
	
	// check shipping info fields
	if (emptyField(document.getElementById("txtShipCompanyName")))
	{
		alert("Enter your Name");
		document.getElementById("txtShipCompanyName").focus();
		return false;
	}
	//if (emptyField(document.getElementById("txtShipLname")))
	//{
		//alert("Enter your Last Name");
		//document.getElementById("txtShipLname").focus();
		//return false;
	//}
	if (emptyField(document.getElementById("txtShipAddr1")))
	{
		alert("Enter your Frist Address");
		document.getElementById("txtShipAddr1").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtShipCity")))
	{
		alert("Enter your City");
		document.getElementById("txtShipCity").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtShipState")))
	{
		alert("Enter your County");
		document.getElementById("txtShipState").focus();
		return false;
	}
	if (document.getElementById("ddlShipCountry").value == "0")
	{
		alert('Select Your Country.');
		document.getElementById("ddlShipCountry").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtShipPost")))
	{
		alert('Enter PostCode');
		document.getElementById("txtShipPost").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtShipPhone")))
	{
		alert('Enter Phone No.');
		document.getElementById("txtShipPhone").focus();
		return false;
	}
	//if (!isInt(document.getElementById("txtShipPhone").value))
	//{
	//	alert('Please enter only digits.');
	//	document.getElementById("txtShipPhone").focus();
	//	return false;
//	}
}


function getObjectByID(Objid){	
				var ns4 = document.layers;
			var ns6 = document.getElementById && !document.all;
			var ie4 = document.all;
				if(ns4)
				{
					return eval('document.' + Objid)
				}
				if(ns6)
				{
					return document.getElementById(Objid);
				}
				if(ie4)
				{
					return document.all(Objid);      
				}  
				return null
			}


			function SetText(objid,msg, fg, bg){
				var ns4 = document.layers;
			var ns6 = document.getElementById && !document.all;
			var ie4 = document.all;
				if(!fg) fg = "#ff0000";
				if(!bg) bg = "#FFFFFF";
				
				var content = msg ;
				if(ns4)
				{
					objItm = eval('document.' + objid)
					objItm.document.write(content);
					objItm.document.close();
					objItm.visibility = "visible";
				}
				if(ns6)
				{
					document.getElementById(objid).innerHTML = content;
				}
				if(ie4)
				{
					document.all(objid).innerHTML=content;
				}  
			}
			
			
		function check_radiobutton()
		{ 
			var i;
			var tot;
			for(i=0;i<document.Form1.length;i++)
			{
				if(document.Form1.elements[i].type=="radio")
				{
					if(document.Form1.elements[i].checked==true)
					{
						document.getElementById("NetPrc").value	 = parseFloat(document.getElementById("subtot").value) + parseFloat(document.Form1.elements[i].value);
					}
				}
				
			}
		
			if (document.getElementById("dis").value!="")
			{
			document.getElementById("NetPrc").value	=parseFloat(document.getElementById("NetPrc").value) - parseFloat(document.getElementById("dis").value); 		
			}
			
			document.getElementById("NetPrc").value = parseFloat(document.getElementById("NetPrc").value) - parseFloat(document.getElementById("spdis").value);
			
			tot=(parseFloat(document.getElementById("NetPrc").value)).toFixed(2);			
					
			SetText("Contenttot", tot);
		}
		
		
		
		function checkKey(b1,e)
		{
			if (e.keyCode == 13)
			{
				document.getElementById(b1).click();
				return false;
			}
		}	
		
		function check_Product()
		{
			var test =0;
				var con = 1;
				for (var i=0; i<5; i++)
				{
				
							
							if (i==0)
							{
								if (emptyField(document.getElementById("QuickBy1_txtname"+con)))
								{
									alert('Please enter Product Code');
									document.getElementById("QuickBy1_txtname"+con).focus();
									return false;
								}
								if (emptyField(document.getElementById("QuickBy1_txtqty"+con)))
								{
									alert('Please enter Quantity');
									document.getElementById("QuickBy1_txtqty"+con).focus();
									return false;
								}
							}
							
							if (!emptyField(document.getElementById("QuickBy1_txtname"+con)))
							{
								if (emptyField(document.getElementById("QuickBy1_txtqty"+con)))
								{
									alert('Please enter Quantity');
									document.getElementById("QuickBy1_txtqty"+con).focus();
									return false;
								}
							}
							
							
							if (!emptyField(document.getElementById("QuickBy1_txtqty"+con)))
							{
								if (document.getElementById("QuickBy1_txtqty"+con).value < 1)
								
								{
									alert('Quantity must be Greater then Zero.');
									document.getElementById("QuickBy1_txtqty"+con).focus();
									return false;
								}
					
								if (!isInt(document.getElementById("QuickBy1_txtqty"+con).value))
								
								{
									alert('Please enter Integer value.');
									document.getElementById("QuickBy1_txtqty"+con).focus();
									return false;
								}
							}	
							
					
					
						con =con + 1;			
				}
		}
		
function checkcreditcard() {
    
        if (document.getElementsByName("CardType").value="") {
            alert('Please select Card type.');
            document.getElementsByName("CardType").focus();
            return false;
        }

        if (emptyField(document.getElementById("CardNumber"))) {
            alert('Please enter card number.');
            document.getElementById("CardNumber").focus();
            return false;
        }

        if (emptyField(document.getElementById("CardHolder"))) {
            alert('Please enter card holder name.');
            document.getElementById("CardHolder").focus();
            return false;
        }

        if (emptyField(document.getElementById("CV2"))) {
            alert('Please enter credit card verification number.');
            document.getElementById("CV2").focus();
            return false;
        }
    
}