/*  ********************************************************************************************	
	Name	   :	Common.js
	Called From:	Top of all pages
	Description:	We need all these functions on top of each page
	Date			Author			Description
	--------------------------------------------------------------------------------------------
	06/04/02		Moji			
	********************************************************************************************	
*/
function Login_(x,c)
{
	alert("Inside Login_()");
	if (c == "")
	{
		c = 0;
	}	
	document.forms[0].action = x + 'Login.asp?nc=1&ci='+c;
	//alert(document.forms[0].action);
	return true;
}

function Home()
{
	x = document.forms[0].AUTH.value;
	if (x != "")
	{
		if (!confirm("Click OK to Logout"))
		{
			returnVal = false;
		}
		else
		{
			location="Logout.asp"
			returnVal = true;
		}
	}	
	else	
		location="Logout.asp"
}	

function SubHome(cnt,y)
{
	x = document.forms[0].AUTH.value;
	if (x != "")
	{
		if (cnt > 0)
		{
			if (!confirm("You have items in the cart that you have not saved.\nIf you logout, you will loose your cart.\nClick OK to discard the cart and logout.\nClick Cancel to stop logout and go to checkout."))
			{
				returnVal = false;
			}
			else
			{
				location=y+"Logout.asp"
				returnVal = true;
			}
		}	
		else	
			location=y+"Logout.asp"
	}
	else	
		location=y+"Logout.asp"
}	

function SubmitNew(x)
{
	//document.Order.New.value="Y"
	//document.Order.action=x;
	//return true
	//alert("here");
	//alert("New " + document.forms[0].New.value);
	document.forms[0].New.value="Y";
	document.forms[0].action=x;
	return true;
}

function ChkVal()
{
	if (document.Order.Name.value == "")
	{
		alert("Name must be entered");
		document.Order.Name.focus();
		returnVal = false;
	}
	else
	{
		if (document.Order.Address1.value == "")
		{
			alert("Address1 must be entered");
			document.Order.Address1.focus();
			returnVal = false;
		}
		else
		{
			if (document.Order.City.value == "")
			{
				alert("City must be entered");
				document.Order.City.focus();
				returnVal = false;
			}
			else
			{
				if (document.Order.State.value == "")
				{
					alert("State must be entered");
					document.Order.State.focus();
					returnVal = false;
				}
				else
				{
					if (document.Order.Zip.value == "")
					{
						alert("Zip must be entered");
						document.Order.Zip.focus();
						returnVal = false;
					}
					else
					{
						if (document.Order.Country.value == "")
						{
							alert("Country must be entered");
							document.Order.Country.focus();
							returnVal = false;
						}
						else
						{
							if (document.Order.WPhone.value == "")
							{
								alert("Country must be entered");
								document.Order.WPhone.focus();
								returnVal = false;
							}
							else
							{
								if (document.Order.Email.value == "")
								{
									alert("Email must be entered");
									document.Order.Email.focus();
									returnVal = false;
								}
								else
								{
									//Made changes by Nutan as per Esmail email on 07/16/04
									//alert("Some of information you have entered is incorrect.  Please try again.  If this problem continues, please call us at (800) 729-9960.");
									//alert("If you experience difficulty submitting this page, you may call us at (800) 729-9960 or print the page and fax it to us at (714) 666-8685.");
									//returnVal = false;	
									//Original code by Nutan as per Esmail on 07/21/04
									returnVal = true;
								}
							}
						}
					}
				}
			}
		}
	}
}

function OnSearch(ss)
{
	document.forms[0].action = ss + "order.asp";
	document.forms[0].submit();
}

function GetItem()
{
	it = document.forms[0].tmpcount.value;
	return it;
}

function ForPassword()
{
    popup=open( "ForgotPW.asp?u=1","" , "width=600,height=660,resizeable=yes,scrollbars=yes" );
}	 		

function checkin()
{
	if (document.Password.email.value == "")
	{
		alert("Enter your email address");
		document.Password.email.focus();
		return false;	
	}
	else
		return true
}	


function ChngCat(CTID,CTName,cllink)
{
	//alert("in here");
	if (document.forms[0].Psearch.value!="")
	{
		document.forms[0].CTName.value="All Categories";
		document.forms[0].MFName.value="All Brands";
	}
	document.forms[0].PageNum.value=1
	document.forms[0].Next2.value=""   
	document.forms[0].cntr_.value=1
	document.forms[0].MClick.value=1;
	document.forms[0].BMark.value=0;
	document.forms[0].CTName.value=CTName;
	document.forms[0].CTID.value=CTID;
	document.forms[0].SUBCTID.value=0;
	document.forms[0].SUBSUBCTID.value=0;
	document.forms[0].SUGPRID.value = 0;
	document.forms[0].Psearch.value="";
	document.forms[0].action = cllink + "order.asp?BType=0";
	document.forms[0].submit();
}

function ShowSugItems(prid,cllink)
{
	document.forms[0].SUGPRID.value = prid;
	document.forms[0].CTName.value="";
	document.forms[0].CTID.value=0;
	document.forms[0].SUBCTID.value=0;
	document.forms[0].SUBSUBCTID.value=0;
	document.forms[0].PageNum.value=1
	document.forms[0].Next2.value=""   
	document.forms[0].cntr_.value=1
	document.forms[0].MClick.value=1;
	document.forms[0].BMark.value=0;
	document.forms[0].Psearch.value="";
	document.forms[0].action = cllink + "order.asp?BType=0";
	document.forms[0].submit();
}

