// JavaScript Document

//Function for checking the login details IN API
function checklogin(frm)
{
	var cond=true;
	if(frm.txtemail.value.length==0)
	{
		alert(" Enter Email Address ");
		if(cond==true){
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.\n");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtpass.value.length==0)
	{
		alert(" Enter password ");
		if(cond==true){
			frm.txtpass.focus();
		}
		cond=false;
		return false;
	}
	if(cond=true)
	{
		frm.hidlogin.value="valid";
		return true;	
	}
	
}

//Function for checking the Forget Password IN API
function checkfpass(frm)
{
	var cond=true;
	if(frm.txtemail.value.length==0)
	{
		alert(" Enter Email Address ");
		if(cond==true){
		frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.\n");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(cond=true)
	{
		frm.hidforgot.value="forgot";
		return true;	
	}
	
}

//Function for checking the Quotataion form IN API
function checkquotation(frm)
{
	var cond=true;
	if(frm.txtprd.value=="")
	{
		alert(" Select Product Name ");
		if(cond==true){
		frm.txtprd.focus();
		}
		cond=false;
		return false;
	}
	else if(frm.txtprd.value=="Other")
	{
		if(frm.txtotherprd.value.length==0)
		{
			alert(" Enter Product Name ");
			if(cond==true){
			frm.txtotherprd.focus();
			}
			cond=false;
			return false;
		}
	}
	if(frm.txtsize.value.length==0)
	{
		alert(" Enter Size ");
		if(cond==true){
		frm.txtsize.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtcolor.value.length==0)
	{
		alert(" Enter Color ");
		if(cond==true){
		frm.txtcolor.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtother.value.length==0)
	{
		alert(" Enter Stock ");
		if(cond==true){
		frm.txtother.focus();
		}
		cond=false;
		return false;
	}
	
	////////////////////////////////////////////
	if(frm.txtquntity.value.length==0 || isNaN(frm.txtquntity.value))
		{
			alert(" Enter Proper Quantity1. ");
			if(cond==true){
			frm.txtquntity.value = "";
			frm.txtquntity.focus();
			}
			cond=false;
			return false;
		}
		
	/*if(frm.txtquntity2.value.length==0 || isNaN(frm.txtquntity2.value))
		{
			alert(" Enter Proper Quantity2. ");
			if(cond==true){
			frm.txtquntity2.value = "";
			frm.txtquntity2.focus();
			}
			cond=false;
			return false;
		}
		
	if(frm.txtquntity3.value.length==0 || isNaN(frm.txtquntity3.value))
		{
			alert(" Enter Proper Quantity3. ");
			if(cond==true){
			frm.txtquntity3.value = "";
			frm.txtquntity3.focus();
			}
			cond=false;
			return false;
		}
	if(frm.txtquntity4.value.length==0 || isNaN(frm.txtquntity4.value))
		{
			alert(" Enter Proper Quantity4. ");
			if(cond==true){
			frm.txtquntity4.value = "";
			frm.txtquntity4.focus();
			}
			cond=false;
			return false;
		}*/
	///////////////
	if(frm.txtfullname.value.length==0)
	{
		alert(" Enter Your Full Name ");
		if(cond==true){
		frm.txtfullname.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtemail.value.length==0)
	{
		alert(" Enter Email Address. ");
		if(cond==true){
		frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.\n");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtphone1.value.length!=3 || isNaN(frm.txtphone1.value))
	{
		alert(" Enter Proper Phone No. ");
		if(cond==true){
		frm.txtphone1.value="";	
		frm.txtphone1.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtphone2.value.length!=3 || isNaN(frm.txtphone2.value))
	{
		alert(" Enter Proper Phone No. ");
		if(cond==true){
		frm.txtphone2.value="";	
		frm.txtphone2.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtphone3.value.length!=4 || isNaN(frm.txtphone3.value))
	{
		alert(" Enter Proper Phone No. ");
		if(cond==true){
		frm.txtphone3.value="";	
		frm.txtphone3.focus();
		}
		cond=false;
		return false;
	}

/*	if(frm.txtfile1.value.length==0)
	{
		alert(" Please upload at least 1 artwork file ");
			if(cond==true){
			frm.txtfile1.value = "";
			frm.txtfile1.focus();
			}
			cond=false;
			return false;
	}*/

	/*if(frm.txtfile2.value.length!=0)
	{
		alert(" Enter Proper File. ");
			if(cond==true){
			frm.txtfile2.value = "";
			frm.txtfile2.focus();
			}
			cond=false;
			return false;
	}*/
	/*if(frm.txtfile3.value.length!=0)
	{
		alert(" Enter Proper File. ");
			if(cond==true){
			frm.txtfile3.value = "";
			frm.txtfile3.focus();
			}
			cond=false;
			return false;
	}
	if(frm.txtfile4.value.length!=0)
	{
		alert(" Enter Proper File. ");
			if(cond==true){
			frm.txtfile4.value = "";
			frm.txtfile4.focus();
			}
			cond=false;
			return false;
	}*/
	if(frm.txtcompanyname.value.length==0)
	{
		alert("Enter Company Name.");
		if(cond==true){
		frm.txtcompanyname.focus();
		}
		cond=false;
		return false;
	}	
	if(cond=true)
	{
		frm.hidsave.value="quote";
		return true;	
	}
	
}

//Function  for Checking the Register Details IN API
function checkregister(frm)
{	
	var cond=true;
	if (frm.txtfname.value.length==0){
		alert("Please Enter Firstname.");
		if(cond==true){
		frm.txtfname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtlname.value.length==0){
		alert("Please Enter Lastname.");
		if(cond==true){
		frm.txtlname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtcname.value.length==0){
		alert("Please Enter Company Name.");
		if(cond==true){
		frm.txtcname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtemail.value.length==0){
		alert("Please Enter Email Address.");
		if(cond==true){
		frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtnpass.value.length==0){
		alert("Please Enter Password.");
		if(cond==true){
		frm.txtnpass.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtcpass.value.length==0){
		alert("Please Confirm Password.");
		if(cond==true){
		frm.txtcpass.focus();
		}
		cond=false;
		return false;
	}
	if(frm.txtnpass.value !== frm.txtcpass.value)
	{
		alert("Your passwords do not match. Please re-enter them.");
		if(cond==true){
		frm.txtcpass.focus();
		}
		cond=false;
		return false;
	}	
	if (frm.txtadd1.value.length==0){
		alert("Please Enter Address 1 .");
		if(cond==true){
		frm.txtadd1.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.txtadd2.value.length==0){
		alert("Please Enter Address 2 .");
		if(cond==true){
		frm.txtadd2.focus();
		}
		cond=false;
		return false;
	}*/
	if (frm.txtcity.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		frm.txtcity.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtstate.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.txtstate.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.selectcnty.value==""){
		alert("Please Select Country.");
		if(cond==true){
		frm.selectcnty.focus();
		}
		cond=false;
		return false;
	}*/
	
	if (frm.txtzip.value.length==0 || isNaN(frm.txtzip.value)){
		alert("Please Enter Proper Zip code.");
		if(cond==true){
		frm.txtzip.value = "";
		frm.txtzip.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.birthdate.value.length==0){
		alert("Please Enter Birthdate.");
		if(cond==true){
		frm.birthdate.value="";
		frm.birthdate.focus();
		}
		cond=false;
		return false;
	}*/
	if (frm.phono1.value.length!=3 || isNaN(frm.phono1.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono1.value="";
		frm.phono1.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phono2.value.length!=3 || isNaN(frm.phono2.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono2.value="";
		frm.phono2.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phono3.value.length!=4 || isNaN(frm.phono3.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono3.value="";
		frm.phono3.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.fax1.value.length!=3 || isNaN(frm.fax1.value)){
		alert("Please Enter Proper Fax No.");
		if(cond==true){
		frm.fax1.value="";
		frm.fax1.focus();
		}
		cond=false;
		return false;
	}
	if (frm.fax2.value.length!=3 || isNaN(frm.fax2.value)){
		alert("Please Enter Proper Fax No.");
		if(cond==true){
		frm.fax2.value="";
		frm.fax2.focus();
		}
		cond=false;
		return false;
	}
	if (frm.fax3.value.length!=4 || isNaN(frm.fax3.value)){
		alert("Please Enter Proper Fax No.");
		if(cond==true){
		frm.fax3.value="";
		frm.fax3.focus();
		}
		cond=false;
		return false;
	}*/
	/*if (frm.selectgen.value==""){
		alert("Please Select Gender.");
		if(cond==true){
		frm.selectgen.focus();
		}
		cond=false;
		return false;
	}	*/
	if(cond=true)
	{
		frm.hidreg.value="register";
		return true;	
	}
}

function getshipvalue(val,frm)
{		
	if(frm.chksame.checked)
	{
		frm.txtsfname.value = frm.txtfname.value;
		frm.txtslname.value = frm.txtlname.value;
		frm.txtscname.value = frm.txtcname.value;
		frm.txtsadd1.value = frm.txtadd1.value;
		frm.txtsadd2.value = frm.txtadd2.value;
/*
		frm.txtscity.value = frm.txtcity.value;
		frm.txtsstate.value = frm.txtstate.value;
		frm.txtszip.value = frm.txtzip.value;
*/	
		frm.Slocation2.value = frm.Blocation2.value;
		frm.Slocation3.value = frm.Blocation3.value;
		frm.Slocation4.value = frm.Blocation4.value;
		document.getElementById("countrySelect2").selectedIndex = document.getElementById("countrySelect1").selectedIndex;
	}
}

//Function  for Checking the Shipping INFO IN API
function checkshipping(frm)
{	
	var cond=true;
	if (frm.txtfname.value.length==0){
		alert("Please Enter Firstname.");
		if(cond==true){
		frm.txtfname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtlname.value.length==0){
		alert("Please Enter Lastname.");
		if(cond==true){
		frm.txtlname.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtcname.value.length==0){
		alert("Please Enter Company Name.");
		if(cond==true){
		frm.txtcname.focus();
		}
		cond=false;
	}
	if (frm.txtadd1.value.length==0){
		alert("Please Enter Address 1 .");
		if(cond==true){
		frm.txtadd1.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.txtadd2.value.length==0){
		alert("Please Enter Address 2 .");
		if(cond==true){
		frm.txtadd2.focus();
		}
		cond=false;
		return false;
	}*/
	if (frm.txtcity.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		frm.txtcity.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtstate.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.txtstate.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtzip.value.length==0 || isNaN(frm.txtzip.value)){
		alert("Please Enter Proper Zip code.");
		if(cond==true){
		frm.txtzip.value = "";
		frm.txtzip.focus();
		}
		cond=false;
		return false;
	}
	
	if (isNaN(frm.txtphone1.value)){
		alert("Please Enter Proper phone no.");
		if(cond==true){
		frm.txtphone1.value = "";
		frm.txtphone1.focus();
		}
		cond=false;
		return false;
	}	
	if (isNaN(frm.txtphone2.value)){
		alert("Please Enter Proper phone no.");
		if(cond==true){
		frm.txtphone2.value = "";
		frm.txtphone2.focus();
		}
		cond=false;
		return false;
	}	
	if (isNaN(frm.txtphone3.value)){
		alert("Please Enter Proper phone no.");
		if(cond==true){
		frm.txtphone3.value = "";
		frm.txtphone3.focus();
		}
		cond=false;
		return false;
	}	

	
	if (isNaN(frm.txtfax1.value)){
		alert("Please Enter Proper Fax no.");
		if(cond==true){
		frm.txtfax1.value = "";
		frm.txtfax1.focus();
		}
		cond=false;
		return false;
	}	
	if (isNaN(frm.txtfax2.value)){
		alert("Please Enter Proper Fax no.");
		if(cond==true){
		frm.txtfax2.value = "";
		frm.txtfax2.focus();
		}
		cond=false;
		return false;
	}	
	if (isNaN(frm.txtfax3.value)){
		alert("Please Enter Proper Fax no.");
		if(cond==true){
		frm.txtfax3.value = "";
		frm.txtfax3.focus();
		}
		cond=false;
		return false;
	}	
	if (frm.txtbemail.value.length==0){
		alert("Please Enter Email Address.");
		if(cond==true){
		frm.txtbemail.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(frm.txtbemail.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			frm.txtbemail.value="";
			frm.txtbemail.focus();
		}
		cond=false;
		return false;
	}
	if(!frm.chksame.checked)
	{
		if (frm.txtsfname.value.length==0){
			alert("Please Enter Firstname.");
			if(cond==true){
			frm.txtsfname.focus();
			}
			cond=false;
			return false;
		}
		if (frm.txtslname.value.length==0){
			alert("Please Enter Lastname.");
			if(cond==true){
			frm.txtslname.focus();
			}
			cond=false;
			return false;
		}
		if (frm.txtscname.value.length==0){
			alert("Please Enter Company Name.");
			if(cond==true){
			frm.txtscname.focus();
			}
			cond=false;
		}
		if (frm.txtsadd1.value.length==0){
			alert("Please Enter Address 1 .");
			if(cond==true){
			frm.txtsadd1.focus();
			}
			cond=false;
			return false;
		}
		/*if (frm.txtsadd2.value.length==0){
			alert("Please Enter Address 2 .");
			if(cond==true){
			frm.txtsadd2.focus();
			}
			cond=false;
			return false;
		}*/
		if (frm.txtscity.value.length==0){
			alert("Please Enter City.");
			if(cond==true){
			frm.txtscity.focus();
			}
			cond=false;
			return false;
		}
		if (frm.txtsstate.value.length==0){
			alert("Please Enter State.");
			if(cond==true){
			frm.txtsstate.focus();
			}
			cond=false;
			return false;
		}
		if (frm.txtszip.value.length==0 || isNaN(frm.txtszip.value)){
			alert("Please Enter Proper Zipcode.");
			if(cond==true){
			frm.txtszip.value = "";
			frm.txtszip.focus();
			}
			cond=false;
			return false;
		}
	}
	/*if(frm.chkblind.checked)
	{
		if (frm.txtshipper.value.length==0)
		{
			alert("Please Enter Proper UPS Shipper no.");
			if(cond==true){
				frm.txtshipper.value = "";
				frm.txtshipper.focus();
			}
			cond=false;
			return false;
		}
	}*/
	if(cond=true)
	{
		frm.hidcheck.value="final";
		return true;	
	}
}

//Function  for Checking the AUTHORIZE NET INFO IN API
function regauthdetail(frm)
{
	var cond=true;	
	
	if(frm.txtcname.value.length==0)
	{
		alert(" Enter Card Holder Name ");
		frm.txtcname.focus();
		cond=false;
		return false;
	}	
	if(frm.txtcno.value.length==0 || isNaN(frm.txtcno.value))
	{
		alert(" Enter Credit Card No ");
		frm.txtcno.value="";
		frm.txtcno.focus();
		cond=false;
		return false;
	}
	if(frm.txtcvalid.value.length==0)
	{
		alert(" Enter Credit Validation Code ");
		frm.txtcvalid.focus();
		cond=false;
		return false;
	}
	
	if(cond=true)
	{
		frm.hidauth.value="authorize";
		return true;	
	}
}

//Function  for Checking the AUTHORIZE NET INFO IN API
function checksample(frm)
{	
	var cond=true;
	if (frm.txtcname.value.length==0){
		alert("Please Enter Company Name.");
		if(cond==true){
		frm.txtcname.focus();
		}
		cond=false;
	}
	if (frm.txtfname.value.length==0){
		alert("Please Enter Full Name.");
		if(cond==true){
		frm.txtfname.focus();
		}
		cond=false;
		return false;
	}	
	if (frm.txtadd1.value.length==0){
		alert("Please Enter Address 1 .");
		if(cond==true){
		frm.txtadd1.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.txtadd2.value.length==0){
		alert("Please Enter Address 2 .");
		if(cond==true){
		frm.txtadd2.focus();
		}
		cond=false;
		return false;
	}*/
	if (frm.txtcity.value.length==0){
		alert("Please Enter City.");
		if(cond==true){
		frm.txtcity.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtstate.value.length==0){
		alert("Please Enter State.");
		if(cond==true){
		frm.txtstate.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtzip.value.length==0 || isNaN(frm.txtzip.value)){
		alert("Please Enter Proper Zip code.");
		if(cond==true){
		frm.txtzip.value = "";
		frm.txtzip.focus();
		}
		cond=false;
		return false;
	}
	if (frm.txtemail.value.length==0){
		alert("Please Enter Email Address.");
		if(cond==true){
		frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	else if(!checkMail(frm.txtemail.value)){
		alert("Email must contain an email address.");
		if(cond==true){
			frm.txtemail.value="";
			frm.txtemail.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phono1.value.length!=3 || isNaN(frm.phono1.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono1.value="";
		frm.phono1.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phono2.value.length!=3 || isNaN(frm.phono2.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono2.value="";
		frm.phono2.focus();
		}
		cond=false;
		return false;
	}
	if (frm.phono3.value.length!=4 || isNaN(frm.phono3.value)){
		alert("Please Enter Proper Phone No.");
		if(cond==true){
		frm.phono3.value="";
		frm.phono3.focus();
		}
		cond=false;
		return false;
	}
	/*if (frm.txtshipper.value.length==0){
		alert("Please Enter Proper UPS Shipper No.");
		if(cond==true){
		frm.txtshipper.value="";
		frm.txtshipper.focus();
		}
		cond=false;
		return false;
	}*/
	if (frm.txtnote.value.length==0){
		alert("Please Enter Notes. ");
		if(cond==true){
		frm.txtnote.focus();
		}
		cond=false;
		return false;
	}	
	if(cond=true)
	{
		frm.hidfree.value="free";
		return true;	
	}
}

function checkMail(email){
var x = email;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x)){
	return true;
	}
	else {
	  return false;
	}
}
