﻿// JavaScript Document
function movepage(page, proId)
{
	if(page == "shopCart.asp")
	{
		window.open("preShopcart.asp","_parent");	
	}
	else
		if(page == "dtlProduct.asp")
		{
			window.open("dtlProduct.asp?ProductId="+proId,"_parent");	
		}	
		else
		{
			window.open("proCatalog.asp","_parent");
		}
}

function shopcart_onsubmit(action)
{
	document.ShopCart.action.value=action;
	document.ShopCart.submit();
}

function addtocart_onclick(id)
{
	document.stores.addcart.value="on";
	document.stores.PRODUCTID.value=id;
	
	Qty = document.all("Qty"+id)
	 
	document.stores.QUANTITY.value = Qty.value
    
  	document.stores.submit();
}

function checkSyntax_Login()
{
	if(document.FormLogin.txtAccountName.value=="")
	{
		alert("Please enter Account name")
		document.FormLogin.txtAccountName.focus()
		return false
	}
	if(document.FormLogin.txtPassword.value=="")
	{
		alert("Please enter Password");
		document.FormLogin.txtPassword.focus();
		return false;
	}
}

function checkSyntax_RegisterCustomer()
{
	if(document.NewCustomer.txtCustomerName.value=="")
	{
		alert("Please enter your name")
		document.NewCustomer.txtCustomerName.focus()
		return false
	}
	if(document.NewCustomer.txtAddress.value=="")
	{
		alert("Please enter your Address")
		document.NewCustomer.txtAddress.focus()
		return false
	}
	if(document.NewCustomer.txtCity.value=="")
	{
		alert("Please enter City")
		document.NewCustomer.txtCity.focus()
		return false
	}
	if(document.NewCustomer.txtCountry.value=="")
	{
		alert("Please select country")
		document.NewCustomer.txtCountry.focus()
		return false
	}
	if(isNaN(document.NewCustomer.txtZipcode.value))
	{
		alert("Please enter a number value")
		document.NewCustomer.txtZipcode.focus()
		return false
	}
	if(document.NewCustomer.txtEmail.value=="")
	{
		alert("Please enter email Address")
		document.NewCustomer.txtEmail.focus()
		return false
	}
	else
		if (CheckEmailAddress(document.NewCustomer.txtEmail.value) != document.NewCustomer.txtEmail.value)
		{
			alert("Email address is invalid.")
			document.NewCustomer.txtEmail.focus()
			return false
		}
	if(document.NewCustomer.txtAccountName.value=="")
	{
		alert("Please enter Account name")
		document.NewCustomer.txtAccountName.focus()
		return false
	}
	if(document.NewCustomer.txtPassword.value=="")
	{
		alert("Please enter Password");
		document.NewCustomer.txtPassword.focus();
		return false;
	}
	if(document.NewCustomer.txtPassword.value != document.NewCustomer.txtConfirmPassword.value)
	{
		alert("Password you type do not match")
		document.NewCustomer.txtPassword.focus()
		return false
	}
	//document.NewCustomer.submit()
}

function checkSyntax_RegCus()
{
	if(document.NewCustomer.txtAccountName.value=="")
	{
		alert("Please enter Account name")
		document.NewCustomer.txtAccountName.focus()
		return false
	}
}
function checkSyntax_TellFriend()
{
	if(document.FormTellFriend.SenderMail.value=="")
	{
		alert("Please enter Your mail address.")
		document.FormTellFriend.SenderMail.focus()
		return false
	}
	else
		if (CheckEmailAddress(document.FormTellFriend.SenderMail.value) != document.FormTellFriend.SenderMail.value)
		{
			alert("Email address is invalid.")
			document.FormTellFriend.SenderMail.focus()
			return false
		}
	if(document.FormTellFriend.ReceiverMail.value=="")
	{
		alert("Please enter Receiver mail address.")
		document.FormTellFriend.ReceiverMail.focus()
		return false
	}
	else
		if (CheckEmailAddress(document.FormTellFriend.ReceiverMail.value) != document.FormTellFriend.ReceiverMail.value)
		{
			alert("Email address is invalid.")
			document.FormTellFriend.ReceiverMail.focus()
			return false
		}
	if(document.FormTellFriend.Content.value=="")
	{
		alert("Please enter content mail.")
		document.FormTellFriend.Content.focus()
		return false
	}
}
function checkSyntax_ContactUs()
{
	if(document.FormContactUs.name.value=="")
	{
		alert("Please enter Your name.")
		document.FormContactUs.name.focus()
		return false
	}
	if(document.FormContactUs.email.value=="")
	{
		alert("Please enter Your Email address.")
		document.FormContactUs.email.focus()
		return false
	}
	else {
		if (CheckEmailAddress(document.FormContactUs.email.value) != document.FormContactUs.email.value)
		{
			alert("Email address is invalid.")
			document.FormContactUs.email.focus()
			return false
		} 
			}
	if(document.FormContactUs.request.value=="")
	{
		alert("Please enter your request.")
		document.FormContactUs.request.focus()
		return false
	}
}
function Toggle(item, name) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
     key.innerHTML=name;
   } else {
      obj.style.display="block";
      key.innerHTML=name;
   }
}