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("SearchProducts1_pvalueid").value=i.value;
document.getElementById("SearchProducts1_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_products1_pvalueid").value=i.value;
document.getElementById("View_products1_pid").value=pid;
//alert('pvalueid ' + document.getElementById("View_products1_pvalueid").value);
//alert('pid ' + document.getElementById("View_products1_pid").value);
}
function emptyField(textobj)
{
	
	if(textobj.value.length==0)
	{
		 textobj.focus();
		 return true;
	}
	for(var i=0;i < textobj.value.length;++i)
	{
		var ch =textobj.value.charAt(i);
	if(ch!=' '&&ch!= '\t') 
		return false;
	}
	textobj.focus();
	return true;
}
function isInt(argvalue) 
{
	argvalue = argvalue.toString();

	if (argvalue.length == 0)
	{
		return true;
	}

	for (var n = 0; n < argvalue.length ; n++)
	{
	
		if(argvalue.substring(n, n+1) == "0")
			continue;
			
		else if(argvalue.substring(n, n+1) == "1")
			continue;
			
		else if(argvalue.substring(n, n+1) == "2")
			continue;
			
		else if(argvalue.substring(n, n+1) == "3")
			continue;
			
		else if(argvalue.substring(n, n+1) == "4")
			continue;
			
		else if(argvalue.substring(n, n+1) == "5")
			continue;
				
		else if(argvalue.substring(n, n+1) == "6")
			continue;
				
		else if(argvalue.substring(n, n+1) == "7")
			continue;
				
		else if(argvalue.substring(n, n+1) == "8")
			continue;
			
		else if(argvalue.substring(n, n+1) == "9")
			continue;
			
		/*else if(argvalue.substring(n, n+1) == " ")
			continue;*/
			
		else
			return false;

	}
return true;
}
function check_qty(txtqty)
{
				var test =0;
				var con = 2;
				for (var i=0; i<document.form1.length; i++)
				{
				
					
							if (emptyField(document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty")))
								{
									alert('Please enter Quantity');
									document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty").focus();
									return false;
								}
								
							if (document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty").value < 1)
								
								{
									alert('Quentity must be Greater then Zero.');
									document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty").focus();
									return false;
								}
					
							if (!isInt(document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty").value))
								
								{
									alert('Please enter Integer value.');
									document.getElementById("Cartdtls1_shoppingdtlsdg__ctl"+con+"_txtqty").focus();
									return false;
								}
					
					
						con =con + 1;			
				}
}

function set_shippingInfo()
{
	if(document.getElementById("chkShip").checked==true)
	{
		document.Form1.txtShipFname.value = document.getElementById("txtBillFname").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.txtShipFname.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("txtBillFname")))
	{
		alert("Enter your First Name");
		document.getElementById("txtBillFname").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 Town/City");
		document.getElementById("txtBillCity").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillState")))
	{
		alert("Enter your State");
		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 Post Code/Zip');
		document.getElementById("txtBillPost").focus();
		return false;
	}
	if (emptyField(document.getElementById("txtBillPhone")))
	{
		alert('Enter Telephone Number.');
		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("txtShipFname")))
	{
		alert("Enter your First Name");
		document.getElementById("txtShipFname").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 State");
		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;
				}  
			}
			
			
		///vishal script//	
		/*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);
					}
				}
				
			}
			//alert('discount: ' +document.getElementById("dis").value);
			if (document.getElementById("dis").value!="")
			{
			document.getElementById("NetPrc").value	=parseFloat(document.getElementById("NetPrc").value) - parseFloat(document.getElementById("dis").value);		
			}
			tot=(parseFloat(document.getElementById("NetPrc").value)).toFixed(2);			
					
			SetText("Contenttot", tot);
		}*/
		
		//end of vishal script
		
		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;
			}
		}	