
function reg() {
if (navigator.appName == 'Netscape'){
	if (window.captureEvents){
	//document.captureEvents(Event.KeyPress);
	//document.onkeypress = netscapeKeyPress;
	}
}
}

function netscapeKeyPress(e) {
	if (e.which==13){
	//var eventname ;
	//eventname =e.target.name;
	fnTrapKD("",e);	// disabled
}
}


function fnTrapKD(btn, event){
//alert(event.keyCode)
if (event.keyCode == 13)
	doIT(btn, event);
}

function doIT(btn, event) {
//alert(btn)
//alert(window.event.keyCode)
	document.Form1.enterkey.value=btn
	event.returnValue=false;
	event.cancel = true;
	if (btn.length !=0) 
	document.Form1.submit();
//else
// event.keyCode = 0;
}

var usernameenterkeyevent
usernameenterkeyevent =false
var eventname


//function for Netscape

function validatefieldswithfocus(fields,count,texttype){
	var returnvalue
	returnvalue =true
	for (var i=0; i< count;i++)
	{
		eval("var otmp = document.Form1." + fields[i][0]);
		if (otmp=="[object]" || otmp=="[object HTMLInputElement]") {
			if (otmp.value=="") {
					alert(fields[i][1])
					otmp.focus()
					returnvalue = false
					break;
			} else {
			// check if password is blank or not . move cursor to password if password is blank
				i++;
				eval("var otmp = document.Form1." + fields[i][0]);
				if (otmp=="[object]" || otmp=="[object HTMLInputElement]") {
					if (otmp.value=="") {
					otmp.focus()
					returnvalue = false
					break;
					}
				}
			}
		}
	}
	return returnvalue
}

//function for addto cart
function disabledenterkey()
{
	if (window.event.keyCode ==13)
	{
		window.event.keyCode =0
	}
}

function clickAddtoCart(e, buttonid,thebox,thevalidator){
	var bt = document.getElementById(buttonid);
	if (typeof bt == 'object'){
		if(navigator.appName.indexOf("Netscape")>(-1)){
			if (e.keyCode == 13){
						validate = CheckQuantity1(thebox,thevalidator)
						if (validate) {
						bt.click();
						return false; }
				}
			}
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
				if (event.keyCode == 13){
					validate = CheckQuantity1(thebox,thevalidator)
						if (validate) {
						bt.click();
						return false; }
						else
						{
						cancelevent()
						event.keyCode = 9;
					}
				}
		}
	}
}

function clickAddtoCartQuickOrder(e, buttonid,thebox){//,thevalidator){
	var bt = document.getElementById(buttonid);
	if (typeof bt == 'object'){
		if(navigator.appName.indexOf("Netscape")>(-1)){
			if (e.keyCode == 13){
					//	if (validate) {
					bt.click();
					return false; //}
				}
			}
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
			if (event.keyCode == 13){
				//    validate = CheckQuantity1(thebox,thevalidator)
					//	if (validate) {
						cancelevent();
						bt.click(); 
						return false;
			}
		}
	}
}
//functions for checkout login page
var checkoutloginfields = [['txtUserName','Please enter your Username'],['txtPassword','Please enter your password']]
var forgetfields = [['yourpostcode','Please enter your postal code'],['txtEmail','Email address is required.']]
var eventname;
function clickCheckLogin(e, buttonid,type){

	var bt = document.getElementById(buttonid);
	if (typeof bt == 'object'){
		if(navigator.appName.indexOf("Netscape")>(-1)){
			if (e.keyCode == 13){
				if ( type=="checkoutlogin")
					validate = validatefields(checkoutloginfields)
				else
					validate = validatefields(forgetfields);
				if (validate) {
				bt.click();
				return false; }
				}
			}
			if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
				if (event.keyCode == 13){
					if ( type=="checkoutlogin")
							validate = validatefields(checkoutloginfields)
						else
							validate = validatefields(forgetfields);
						if (validate) {
					bt.click();
					return false; }
					else
					{
					cancelevent()
					event.keyCode = 9;
					}
			}
		}
	}
}

function cancelevent()
{
	event.returnValue=false;
	event.cancel = true;
}

function validatefields(fields){
for (var i=0; i< fields.length;i++){
	var returnvalue
	returnvalue = true
	eval("var otmp = document.Form1." + fields[i][0]);
	if (otmp=="[object]" || otmp=="[object HTMLInputElement]") {
		if (otmp.value=="") {
				alert(fields[i][1]);
				otmp.focus();
				returnvalue =  false;
				break;
		}else if (eventname == fields[0][0]) {
					eval("var otmp = document.Form1." + fields[i+1][0]);
					if (otmp=="[object]" || otmp=="[object HTMLInputElement]"){
						if (otmp.value==""){
							otmp.focus()
							returnvalue =  false
							break;
						}
					}
		}
	}
	}
	return returnvalue
}

var value
function SetupProvinceCode()
{var countrycode
var currcountrycode
var statecode
var description
var dCountry
var dState
var index
var lastindex
var isempty = false

	dState = document.Form1.Account1_dState
	dCountry =document.Form1.Account1_dCountry
	for (i=0;i<dCountry.length ;i++){
		if (dCountry.options[i].selected) {
			countrycode=dCountry.options[i].value
			break;
		}
	}
	do {    isempty=false
			for (var i=0;i<dState.length;i++){
				dState .options [i]=null
				isempty=true
			}
		}
	while(isempty)

	var j =0 
	tOption= new Option("Select a Prov./State","")
	dState.options [j]=tOption
	j=j+1
	for(i=0;i<StateCodes.length -1 ;i++){
		value = StateCodes[i]
		currcountrycode =getcode()
		if (currcountrycode == countrycode){
			statecode =getcode()
			description =getcode()
			tOption= new Option(description,statecode)
			dState.options [j]=tOption
			j=j+1
		}
	}
	dState.options[0].selected =true
}

function getcode(){
var index;
var code;
index =value.indexOf(":");
if (index==-1)
	{code =value}
else {
	code =value.substring(0,index);
	value =value.substring(index+1);
}
return code
}


function loginneeded()
{
alert("");
return false;
}

function CheckQuantity1(theQty,theValidator){
var thistalue;
var theText = document.getElementById(theQty);
var validator = document.getElementById(theValidator);
if (typeof theText == 'object'){
thistalue = theText.value
if (parseFloat(thistalue) == 0) {
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		validator.style.display =""
	else
		alert("Quantity must be greater than 0");
	theText.focus();
	return false;}
if (!IsBlank(thistalue)) {
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		validator.style.display =""
	else
		alert("Quantity must be all numeric.");
	theText.focus();
	return false;}
else{
	theText.value=parseFloat(thistalue);
	theText.focus();
	return true;
	}
}
}

function CheckQuantity(theText){
var thistalue;
thistalue =theText.value;

if (parseFloat(thistalue) == 0) {
	alert("Quantity must be greater than 0");
	theText.focus();
	return false;}
if (!IsNumeric(thistalue)) {
	alert("Quantity must be all numeric.");
	theText.focus();
	return false;}
else{
	theText.value=parseFloat(thistalue);
	theText.focus();
	return true;
	}
}

function IsBlank(thevalue)
{
//  check for valid numeric strings	
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (thevalue.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < thevalue.length && blnResult == true; i++)
      {
      strChar = thevalue.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
var strValidChars = "0123456789";
var strChar;
var blnResult = true;

if (strString.length == 0) return false;
//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
		blnResult = false;
		}
	}
	return blnResult;
}

