
   // Browser styles
   /*
	var bIsIE = navigator.appName == "Microsoft Internet Explorer" ;
	var bIsIE4 = bIsIE && parseInt(navigator.appVersion) == 4 ;
	if (bIsIE4) {
	  sCSS = '<LINK REL="stylesheet" TYPE="text/css" HREF="IE4.css">'
	}
	else {
	  if (bIsIE) {
	    sCSS = '<LINK REL="stylesheet" TYPE="text/css" HREF="IE3.css">'
	  }
	}
	document.write(sCSS) ;
	*/

	// View product
	function viewProduct(thisElement) {
	  var itemId = new String(thisElement.id);
	  var url = "product.asp?qId=";
	  var target = url + itemId;
	  window.navigate(target);
	}

	function onProcessLogon(sAction)
	{
		document.Logon.setAttribute('action',"Logon.asp");
		document.Logon.sAction.setAttribute('value',sAction);
		document.Logon.submit();
	}
	function onProcessCart(sAction)
	{
		document.SaveCart.sAction.setAttribute('value',sAction);
		document.SaveCart.submit();
	}
	

    // Empty validation
	function emptyvalidation(entered, alertbox) {
	  with (entered) {
	    if (value==null || value=="") {
	      if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
	}


	// Flip image
	function flipImage(filespec) {
	  if (window.event.srcElement.tagName == "IMG" ) {
	  window.event.srcElement.src = filespec;
	}
	}


	// Phone validation
	function phoneCheck (entered) {
	  var re = /\d/
	  var newstring = ""
	  var errStr = ""
	  with (entered) {
	    for (var i = 0; i < value.length; i ++) {
	      var character = value.charAt(i);
	      if (!(i==0 && (character=="1" || character=="0")) && character.match(re)) {
	        newstring=newstring+character;
	      }
	    }
	  }
	  if (newstring.length!=10) {errStr = "Please enter the phone number,\n including an area code."};
	  if (errStr !="") {alert(errStr); return false;}
	}


    // Valid credit card number
	function valCreditCard(cardnum, alertbox) {
	with(cardnum){
	if (isNaN(value)) {
	alert(alertbox);
	return 0;
	}
	if (CheckLUHN(value))
	return 1;
	else
	alert("this is not a valid card number");
	return 0;
	}
	}

	// returns 1 or 0 indicating whether number is valid
	function CheckLUHN(cardnum) { 
	if (cardnum == "") return 0;
	var RevNum = new String(cardnum);
	RevNum = Reverse(RevNum);
	var total = new Number(0);
	for ( var i = 0; i < RevNum.length; i += 1 ) {
	var temp = 0;
	if (i % 2) {
	temp = RevNum.substr(i, 1) * 2;
	if (temp >= 10) {
	var splitstring = new String(temp);
	temp = parseInt(splitstring.substr(0, 1)) + parseInt(splitstring.substr(1, 1));
	   }
	}
	else temp = RevNum.substr(i, 1);
	total += parseInt(temp); 
	}
	// if there's no remainder, we return 1 (true)
	return (total % 10) ? 0 : 1;
	}
	function Reverse(strToReverse) {
	var strRev = new String;
	var i = strToReverse.length;
	while (i--)
	strRev += strToReverse.charAt(i);
	return strRev;
	}


	// Jump to the product page from item rows
	function viewProduct(thisElement) {
	  window.event.returnValue = false;
	  var itemId =  new String(thisElement.id);
	  var url = "product.asp?qId=";
	  var target = url + itemId;
	  window.navigate(target);
	}


  // Postal code validation
  function postalCheck(oCode) {

    oCode.value = LRTrim(oCode.value);
    
    var strCode = oCode.value;
    
	if (strCode.length < 6) return false; //Postal code must be at least 6 characters long
		
	//declarations
	var strValidChars; //will hold valid first characters
	var cTemp; //holding var for current character being tested, needed for NS bug
	var strAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";  //valid chars
	var str0to9 = "0123456789"; //valid numbers
	var cSpace = " "; //space
		
	//Valid first characters for provincial postal codes
	var cdCA = "ABCEGHJKLMNPRSTVXY"; //all of Canada
	var cdAB = "T";
	var cdBC = "V";
	var cdMB = "R";
	var cdNB = "E";
	var cdNF = "A";
	var cdNS = "B";
	var cdON = "KLMNP";
	var cdPE = "C";
	var cdQC = "E";
	var cdSK = "S";
	var cdYK = "Y";
	var cdNT = "X";

	strCode = strCode.toUpperCase();
	
	if (! postalCheck.arguments) //if version of JS does not support optional parameters
		strValidChars = cdCA;
	else if(postalCheck.arguments.length < 2)
		strValidChars = cdCA;
	else
	{
		strValidChars = eval("cd" + postalCheck.arguments[1]);
		if (strValidChars.length == 0) 
		{
			alert("Error: Invalid provincial abbreviation passed to postalCheck().");
			return false;
		}
	}

    //check validity of individual postal code characters
	cTemp = strCode.charAt(0);
	if (strValidChars.indexOf(cTemp) == -1) return false; //first character of strCode not a valid first character
	cTemp = strCode.charAt(1);
	if (str0to9.indexOf(cTemp) == -1) return false;
	cTemp = strCode.charAt(2);
	if (strAlpha.indexOf(cTemp) == -1) return false;
	cTemp = strCode.charAt(3);
	if (cSpace.indexOf(cTemp) == -1 && strCode.length == 7 || str0to9.indexOf(cTemp) == -1 && strCode.length == 6) return false;
	cTemp = strCode.charAt(4);
	if (str0to9.indexOf(cTemp) == -1 && strCode.length == 7 || strAlpha.indexOf(cTemp) == -1 && strCode.length == 6) return false;
	cTemp = strCode.charAt(5);
	if (strAlpha.indexOf(cTemp) == -1 && strCode.length == 7 || str0to9.indexOf(cTemp) == -1 && strCode.length == 6) return false;
	cTemp = strCode.charAt(6);
	if (str0to9.indexOf(cTemp) == -1 && strCode.length == 7 || strAlpha.indexOf(cTemp) == -1  && strCode.length == 6) return false;
	if (strCode.length == 6) // If we made it here, check to see if there's only 6 chars
	{
		// put a space in the 4th position
		oCode.value = strCode.substring(0,3) + " " + strCode.substring(3,6);
		return true;
	}
	return true; //if we made it this far, it must be valid!
  }


  function LRTrim(str) {
	var strTrim = "";
	len = str.length;

	// Find non white space at start
	for (i=0; i < len; i++)	{
	  strChar = str.charAt(i);
	  if (strChar != " " && strChar != "\t")
	  break;
	}

	//Find non white space at end
	for (j=(len - 1); j > i; j--) {
	  strChar = str.charAt(j);
	  if (strChar != " " && strChar != "\t")
		break;
	}

	// Loop through and copy the remaining data
	for (k=i; k <= j; k++)
		strTrim += str.charAt(k);

	return strTrim;
  }

	// Digit-Validation (c) Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	function digitvalidation(entered, min, max, alertbox, datatype){
	with (entered)
	{
	checkvalue=parseFloat(value);
	if (datatype)
	  {smalldatatype=datatype.toLowerCase();
	   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
	  }
	if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
	}

	<!-- Version 1.1:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

	<!-- This script and many more are available free online at -->
	<!-- The JavaScript Source!! http://javascript.internet.com -->

	function emailCheck (entered) {
	var emailStr=entered.value
	/* The following pattern is used to check if the entered e-mail address
	   fits the user@domain format.  It also is used to separate the username
	   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
	   characters.  We don't want to allow special characters in the address. 
	   These characters include ( ) < > @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a 
	   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern represents the range of characters allowed as
	   the first character in a valid username or domain.  I just made it
	   the same as above, but if you want to add a different constraint,
	   you would change it here. */
	var firstChars=validChars
	/* The following pattern applies if the "user" is a quoted string (in
	   which case, there are no rules about which characters are allowed
	   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
	   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents at atom (basically a series of
	   non-special characters.) */
	var atom="(" + firstChars + validChars + "*" + ")"
	/* The following string represents one word in the typical username.
	   For example, in john.doe@somewhere.com, john and doe are words.
	   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
	   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	/* Finally, let's start trying to figure out if the supplied address is
	   valid. */

	/* Begin with the course pattern to simply break up user@domain into
	   different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
	  /* Too many/few @'s or something; basically, this address doesn't
	     even fit the general mould of a valid e-mail address. */
		alert("Email address seems incorrect (check @ and .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	// See if "user" is valid 
	if (user.match(userPat)==null) {
	    // user is not valid
	    alert("The username doesn't seem to be valid.")
	    return false
	}
	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("Destination IP address is invalid!")
			return false
		    }
	    }
	    return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("The domain name doesn't seem to be valid.")
	    return false
	}
	/* domain name seems valid, but now make sure that it ends in a
	   three-letter word (like com, edu, gov) or a two-letter word,
	   representing country (uk, nl).
	   If there's a country code at the end of the address, the full domain
	   must include a hostname and category (e.g. host.co.uk or host.pub.nl).
	   If it ends in a .com or something, make sure there's a hostname.*/

	/* Now we need to break up the domain to get a count of how many atoms
	   it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("The address must end in a three-letter domain, or two letter country.")
	   return false
	}

	/* If it just ends in .com, .gov, etc., make sure there's a host name.
	   This case can never actually happen because earlier checks take
	   care of this implicitly, but we'll do it anyway. */
	if (domArr[domArr.length-1].length==3 && len<2) {
	   var errStr="This address is missing a hostname!"
	   alert(errStr)
	   return false
	}
	// If we've gotten this far, everything's valid!
	return true;
	}
