   function alphaNum(str) {
      return str.replace(/[^a-zA-Z0-9]/g, '');
   }

   function trim(str) {
      if (str == null) {
         return(null);
      }

      return str.replace(/^\s+|\s+$/g, '');
   };

   function isNumeric(str) {
      var validChars = "0123456789.";
      var isNumber=true;
      var cchar;
      var i;

      for (i=0; i<str.length; i++) {
	 cchar = str.charAt(i);
	 if (validChars.indexOf(cchar) == -1) {
	    isNumber = false;
	    break;
	 }
      }

      return(isNumber);
   }

   function isValidQuantity(str) {
      var validChars = "0123456789";
      var isNumber=true;
      var cchar;
      var i;

      for (i=0; i<str.length; i++) {
	 cchar = str.charAt(i);
	 if (validChars.indexOf(cchar) == -1) {
	    isNumber = false;
	    break;
	 }
      }

      return(isNumber);
   }

   function hasValue(str) {
      if (str == null) {
	 return(false);
      }

      tstr = trim(str);
      return(tstr.length > 0);
   }

   function isBlank(str) {
      return(!hasValue(str));
   }

   function empty_cart() {
      if (confirm("Are You Sure You Wish To Delete ALL Items From Your Shopping Cart?")) {
	 location = "/cgi-bin/updatecart.pl?op=empty";
      }
   }

   function check_selection(form) {
      postagemethod = document.postageform.elements["postagemethod"].value;
      //alert(postagemethod);

      if ( (postagemethod != null) && (postagemethod.length > 0) ) {
	 form.submit();
      } else {
	 alert("Please Select a Shipping Method");
      }
   }

   function update_mail(method_id, nonus, non_mainland) {
      newlocation = "checkout3.shtml?shipping_method=" + method_id + "&nonus=" + nonus + "&non_mainland=" + non_mainland;
      document.location = newlocation;
   }

   function airmailmsg() {
      msg = "We regret that airmail delivery is available only within the USA";
      alert(msg);
   }

   function continentalmsg() {
      // msg = "Please note that non-continental US orders must ship via airmail.\nA customer services representative will contact you should any additional charges apply";
      msg = "Please note, as your order contains items being shipped to non continental US states, it must be shipped via AirMail at the additonal charge of US $15";

      alert(msg);
   }

   function qsearch(form) {
      theme_idx = parseInt(form.theme.selectedIndex);
      price_idx = form.price_range.selectedIndex;

      theme_id = form.theme[theme_idx].value;

      if ( theme_idx == 0 && price_idx == 0 ) {
	 alert("Please Select a Theme or Price Range to Search For.");
      } else {
	 //if (36 == theme_id) {
	 //  location = "/promotion/promotion26.shtml";
	 //} else {
	    form.submit();
	 //}
      }
   }

    function checkcart(form) {
       pcnt = form.personalised_cnt.value;
 
       if (pcnt > 0) {
	  if (pcnt == 1) {
	     str = "You have a personalised which does not have a message.\nPlease supply a personalisation for this item.";
	     alert(str);
	  } else {
	     str = "You have " + pcnt + " personalised items which do not have a message.\nPlease supply a personalisation for these items before you proceed.";
	     alert(str);
	  }
       } else {
	  location="/checkout.shtml";
       }
    }

    function map_search(form) {
       theme_idx = form.theme.selectedIndex;
       price_idx = form.price_range.selectedIndex;

       if ( (theme_idx <= 0) && (price_idx <= 0) ) {
	  alert("Please Select Theme or Price Range.");
       } else {
	  form.submit();
       }
    }

    function search(form) {
       keyword = form.keywords.value;
       mfr_idx = form.manu_code.selectedIndex;
	
       // Check <= 0 since some browsers intialise selectedIndex to 0, some -1
       if ( ((keyword == null) || (keyword.length == 0)) && (mfr_idx <= 0) ) {
	  alert("Please Select a Manufacturer or Keyword to Search For.");
       } else {
	  form.submit();
       }

    }
    
    function showproduct(id) {
       target = "/showproduct.shtml?id=" + id;
       win=window.open(target, "product", "toolbar=no,scrollbars=yes,width=500,height=500,resizable")
    }

    function validate(form) {
       var total_orders=0;
       var qty=0;
       var backorder = "";
       var option_code = "";
       var product_name = "";

       // First check that there are orders to be processed
       count = form.elements["itemcount"].value;

       for (i = 1; i<=count; i++) {

	  elementname = "qty_" + i;
	  qty = form.elements[elementname].value;
	  qty -= 0;  // Force numeric conversion

	  // Add this to the running total
	  total_orders+=qty;
       }

       if (total_orders == 0) {
	  msg = "Please specify a quantity for the item you wish to purchase.";
	  alert(msg);
	  return;
       }

       for (i = 1; i<=count; i++) {
	  elementname = "backorder_" + i;
	  backorder = form.elements[elementname].value;

	  elementname = "option_code_" + i;
	  op_code = form.elements[elementname].value;

	  elementname = "qty_" + i;
	  qty = form.elements[elementname].value;
	  qty -= 0;  // Force numeric conversion

	  elementname = "stock_status_" + i;
	  stock_status = form.elements[elementname].value;
	  stock_status -= 0; // Force numeric conversion

	  elementname = "stock_level_" + i;
	  stock_level = form.elements[elementname].value;
	  stock_level -= 0;  // Force numeric conversion

	  elementname = "stock_lwm_" + i;
	  stock_lwm = form.elements[elementname].value;
	  stock_lwm -= 0;    // Force numeric conversion

	  elementname = "delivery_date_" + i;
	  delivery_date = form.elements[elementname].value;

	  elementname = "msg_" + i;
	  msg_len = form.elements[elementname].value;

	  elementname = "product_name_" + i;
	  product_name = form.elements[elementname].value;

	  elementname = "has_suboption_menu_" + i;
	  has_suboption_menu = form.elements[elementname].value;

	  elementname = "has_sz_menu_" + i;
	  has_sz_menu = form.elements[elementname].value;

	  elementname = "restricted_" + i;
	  restricted = form.elements[elementname].value;

	  // If the status is 1, allow any order but prompt if it would push
	  // the order below minimum level (or would make it negative)

	  if (qty > 0) {

	     if (has_suboption_menu != 0) {
		menu_name = "suboption_" + i;
		suboption_menu = form.elements[menu_name];
		menu_idx = suboption_menu.selectedIndex;
   
		if (menu_idx == 0) {
		   alert("Please select your preferred option for this product.");
		   return;
		}
	     }

	     if (has_sz_menu != 0) {
		menu_name = "option_size_" + i;
		menu_ref = form.elements[menu_name];
		menu_idx = menu_ref.selectedIndex;

		if (menu_idx == 0) {
		   alert("Please select your preferred size for this product.");
		   return;
		}
	     }


	     if (stock_status == 1) {
		if ( ((stock_level - qty) < stock_lwm) && (stock_lwm > 0) ) {
		   str = "Item " + op_code + " (" + product_name + ") is on backorder. The expected delivery date is " + delivery_date + ".\nDo you still wish to add this item to your cart?";
		   if (!confirm(str)) {
		      return;
		   } else {
		      // Do nothing
		   }
		}
	     } else {
		// Cannot place an order for this item if it would push the stock below min.
		// level. Implies cannot place this order if the item is already below min. level.
		if ((stock_level - qty) < stock_lwm) {
		   str = "Item " + op_code + " (" + product_name + ") may not be available in the quantity requested.\nPlease contact our toll free office at 800 223 8100 between 8am and 8pm E.S.T if you wish to order this item";
		   alert(str);
		   return;
		}
	     }

	     if (restricted != 0) {
		msg = "You must be at least 21 years of age to purchase this product.\nPlease confirm that you and the person accepting delivery of this product are at least 21 years of age.";
		if (!confirm(msg)) {
		   return;
		}
	     }

	     if (msg_len > 0) {
		str = "Item " + op_code + " (" + product_name + ") can be personalised.\nYou may enter a message from the shopping cart page.";
		alert(str);
	     }
	  }
       }
       form.submit();
   }

      function checkform(form) {
	 referal_idx = form.refsource.selectedIndex;

	 if (referal_idx == 0) {
	    alert("Please Select an Item from the Menu");
	 } else {
	    form.submit();
	 }
      }

      function clearform(form) {
	 form.elements["fname"].value = "";
	 form.lname.value = "";
	 form.street_addr.value = "";
	 form.street_addr2.value = "";
	 form.city.value = "";
	 form.zip.value = "";
	 form.phone.value = "";
	 form.fax.value = "";
	 form.email.value = "";
      }

      function checkmsg(orderid, msglen, qty) {
	 if (qty != 1) {
	    msg = "You may only personalize orders for a single product. Please change the quantity of this order to 1.";
	    alert(msg);
	    return(false);
	 } else {
	    newpage = "/get_pmsg.shtml?order_id=" + orderid + "&msglen=" + msglen;
	    document.location = newpage;
	 }
      }

      function isEmail(s) {
	 var i = 1;
	 var sLength = s.length;
     
	 // look for @
	 while ((i < sLength) && (s.charAt(i) != "@")) { i++; }
     
	 if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	 else i += 2;
     
	 // look for .
	 while ((i < sLength) && (s.charAt(i) != ".")) { i++; }
     
	 // there must be at least one character after the .
	 if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	 else return true;
      }

      function checkaddr(form) {
	 fname = form.elements["fname"].value;
	 lname = form.elements["lname"].value;
	 street_addr = form.elements["street_addr"].value;
	 city = form.elements["city"].value;
	 email = form.elements["email"].value;
	 country = form.country.options[form.country.selectedIndex].value;
	 state = form.state.options[form.state.selectedIndex].value;
	 zip = form.elements["zip"].value;
	 line_id = form.elements["line_id"].value;

	 if ( !hasValue(fname) ) {
	    alert("Please supply your first name");
			form.fname.focus();
	    return(false);
	 }

	 if ( !hasValue(lname) ) {
	    alert("Please supply your surname");
			form.lname.focus();
	    return(false);
	 }

	 if ( !hasValue(street_addr) ) {
	    alert("Please supply your street address");
			form.street_addr.focus();
	    return(false);
	 }

	 if ( !hasValue(city) ) {
	    alert("Please supply your city");
			form.city.focus();
	    return(false);
	 }

	 // Only check email for billing address
	 if ( (!hasValue(line_id)) || (line_id == "0")) {
	    if ( ! hasValue(email) ) {
	       alert("Please supply your email address");
	       form.email.focus();
	       return(false);
	    } else {
	       if (! isEmail(email)) {
		  alert("Your email address appears to be invalid.\nPlease re-enter your email address.");
		  form.email.focus();
		  return(false);
	       }
	    }
	 }

	 if (country == "USA") {
	    if (state == "XX") {
	       msg = "Please select a state.";
	       alert(msg);
	    } else if ((zip == "none") || (zip == null) || (zip.length != 5) ) {
	       msg = "Please supply a 5 digit zip code.";
	       alert(msg);
	    } else {
	       form.submit();
	    }
	 } else {
	    if (state != "XX") {
	       msg = "The state field applies only to the US. Please set this to Not Applicable which appears at the top of the drop down menu.";
	       alert(msg);
	    } else if ((zip != "none") && (zip != null) && (zip.length != 0) ) {
	       alert ("The zip code applies only to US addresses. If you have a non-US postal code please insert this after the city name.");
	    } else {
	       form.submit();
	    }
	 }
      }

      function checkmsg(orderid, msglen, qty) {
	 if (qty != 1) {
	    msg = "You may only personalize orders for a single product. Please change the quantity of this order to 1.";
	    alert(msg);
	    return(false);
	 } else {
	    newpage = "/get_pmsg.shtml?order_id=" + orderid + "&msglen=" + msglen;
	    document.location = newpage;
	 }
      }


      function checkCreditCard(form) {
	 var cc1 = trim(form.elements["cc1"].value);
	 var cc2 = trim(form.elements["cc2"].value);
	 var cc3 = trim(form.elements["cc3"].value);
	 var cc4 = trim(form.elements["cc4"].value);

	 var cc = cc1 + cc2 + cc3 + cc4;

	 var cctype = form.cctype.options[form.cctype.selectedIndex].value;
	 var ccname = form.cctype.options[form.cctype.selectedIndex].text;
	 var exp_month = form.exp_month.options[form.exp_month.selectedIndex].value;
	 var exp_year = form.exp_year.options[form.exp_year.selectedIndex].value;

	 var exp_month_text = form.exp_month.options[form.exp_month.selectedIndex].text;
	 var exp_year_text = form.exp_year.options[form.exp_year.selectedIndex].text;
 

	 if (cctype == "xx") {
	    alert("Please select your credit card type");
			form.cctype.focus();
	    return(false);
	 }

	 if (!hasValue(cc)) {
			alert("Please enter your credit card details.");
			form.cc1.focus();
	    return(false);
	 }

	 if (!isValidCreditCardType(cctype, cc)) {
	    str = "Your credit card details appear not to match.\nPlease check the details below.\n\n";
	    str = str + "Card Type: " + ccname + "\n";
	    str = str + "Expires: " + exp_month + " " + exp_year + "\n";
	    str = str + "Number: " + cc1 + " " + cc2 + " " + cc3 + " " + cc4 + " ";
	    str = str + "\n\n\nIf you have trouble placing your order please contact\n";
	    str = str + "our toll free number on (US) 800 223 6716.";
	    alert(str);
	    return(false);
	 } 

	 // Submit for payment
	 var purchaseButton = document.getElementById("purchasebutton");
	 //purchaseButton.value = "Please wait...";
	 purchaseButton.src = "/images/pleasewait.gif";

	 form.submit();
       }
       

       function isValidCreditCardType(cctype, cc) {
	  return( ((cctype == "V") && (isVisa(cc))) || 
		  ((cctype == "A") && (isAmex(cc))) || 
		  ((cctype == "M") && (isMC(cc)))
		);
       }

       function isCreditCard(cc) {
   
	 // Encoding only works on cards with less than 19 digits
	 if (cc.length > 19)
	   return (false);
       
	 sum = 0; 
	 mul = 1; 
	 l = cc.length;
	 for (i = 0; i < l; i++) {
	   digit = cc.substring(l-i-1,l-i);
	   tproduct = parseInt(digit, 10) * mul;
       
	   if (tproduct >= 10) {
	     sum += (tproduct % 10) + 1;
	   } else {
	     sum += tproduct;
	   }
       
	   if (mul == 1) {
	     mul++;
	   } else {
	     mul--;
	   }
	 }
       
	 if ((sum % 10) == 0) {
	   return (true);
	 } else {
	   return (false);
	 }
       } 

       function isVisa(cc) {
	 if (((cc.length == 16) || (cc.length == 13)) && (cc.substring(0,1) == 4))
	   return isCreditCard(cc);
	 return false;
       }  
      
       function isMC(cc) {
	 firstdig = cc.substring(0,1);
	 seconddig = cc.substring(1,2);
	 if ((cc.length == 16) && (firstdig == 5) && ((seconddig >= 1) && (seconddig <= 5)))
	   return isCreditCard(cc);
	 return false;
       
       } 
       
       function isAmex(cc) {
	 firstdig = cc.substring(0,1);
	 seconddig = cc.substring(1,2);
	 if ((cc.length == 15) && (firstdig == 3) && ((seconddig == 4) || (seconddig == 7)))
	   return isCreditCard(cc);
	 return false;
       
       } 

function set_shipping_addr(order_id, type) {
	if (type == "F") {
		alert("Please Note: Your free gift may accompany any paid for order.\nHowver, we regret that it is not possible to ship your free gift separately.");
	}
	location = "/checkout.shtml?order_id=" + order_id;
}

function signup(form) {
	var fname=form.fname.value;
	var lname=form.lname.value;
	var email=form.email.value;

	if ( isBlank(fname) ) {
		alert("Please Supply Your Name.");
		form.fname.focus();
		return(false);
	}

	if ( isBlank(lname) ) {
		alert("Please Supply Your Name.");
		form.lname.focus();
		return(false);
	}

	if ( isBlank(email) ) {
		alert("Please Supply Your Email Address.");
		form.email.focus();
		return(false);
	}

	if (! isEmail(email)) {
	   alert("Your email address appears to be invalid.\nPlease re-enter your email address.");
	   form.email.focus();
	   return(false);
	}

		var fname_enc = escape(fname);
		var lname_enc = escape(lname);
		var email_enc = escape(email);
		var target = "/signup.php?fname="+fname+"&lname="+lname+"&email="+email;

	win=window.open(target, "Signup", "toolbar=no,scrollbars=yes,width=400,height=300,resizable")
}

/**
 * Set a cookie for the customer iff they don't alreay have one.
 */
function setCustomerCookie(newCookieValue) {
	var cookieValue;
	var currentCookie = getCookie("shopshannon");

	if ( (null == currentCookie) || ("undefined" == currentCookie) || ("" == currentCookie) || (currentCookie.length < 30) ) {
		//cookieValue = Math.round(Math.random() * (1000*1000*1000));
		cookieValue = newCookieValue;

		expHours = (24 * 365);	// Expire one year hence
		setCookie('shopshannon', cookieValue, '/', '', expHours);
	}
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Number of hours in which to expire
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *	      (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *	      secure transmission
 */
function setCookie(name, value, path, domain, expires, secure) {
	var expHours = (expires ? expires : 0);
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expHours*60*60*1000));

    	document.cookie= name + "=" + escape(value) +
       	 ((expires) ? "; expires=" + exp.toGMTString() : "") +
       	 ((path) ? "; path=" + path : "") +
       	 ((domain) ? "; domain=" + domain : "") +
       	 ((secure) ? "; secure" : "");
}


/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);

    if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
    } else {
	begin += 2;
    }

    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
	end = dc.length;
    }

    return unescape(dc.substring(begin + prefix.length, end));
}

function contact(form) {
	name = form.fname.value;
	surname  = form.surname.value;
	subject = form.subject.value;
	email = form.email.value;
	message = form.message.value;

	if ( (name == null) || (name.length == 0) ) {
		alert("Please supply your first name");
		form.fname.focus();
		return(false);
	}

	if ( (surname == null) || (surname.length == 0) ) {
		alert("Please supply your surname");
		form.surname.focus();
		return(false);
	}

	if ( (subject == null) || (subject.length == 0) ) {
		alert("Please supply a subject for your message");
		form.subject.focus();
		return(false);
	}

	if ( (email == null) || (email.length == 0) ) {
		alert("Please supply your email address");
		form.email.focus();
		return(false);
	}

	if ( (message == null) || (message.length == 0) ) {
		alert("Please supply your message");
		form.message.focus();
		return(false);
	}
	
	form.submit();
}

function goToCheckout(itemcount) {
	if (0 == itemcount) {
		alert("Your cart is currently empty, you may not proceed to the checkout yet.");
	} else {
		location = "/checkout.shtml";
	}
}

function setProductImage(url) {
	var image = document.getElementById("productImage");
	image.src = url;
}

function requestCatalog(form) {
	fname = form.elements["fname"].value;
	lname = form.elements["lname"].value;
	street_addr = form.elements["street_addr"].value;
	city = form.elements["city"].value;
	email = form.elements["email"].value;
	country = form.country.options[form.country.selectedIndex].value;
	state = form.state.options[form.state.selectedIndex].value;
	zip = form.elements["zip"].value;

	if ( !hasValue(fname) ) {
		alert("Please supply your first name");
		form.fname.focus();
		return(false);
	}

	if ( !hasValue(lname) ) {
		alert("Please supply your surname");
		form.lname.focus();
		return(false);
	}

	if ( !hasValue(street_addr) ) {
		alert("Please supply your street address");
		form.street_addr.focus();
		return(false);
	}

	if ( !hasValue(city) ) {
		alert("Please supply your city");
		form.city.focus();
		return(false);
	}

	if ( hasValue(email) ) {
		if (! isEmail(email)) {
			alert("Your email address appears to be invalid.\nPlease re-enter your email address.");
			form.email.focus();
			return(false);
		}
	}

	if (country == "USA") {
		if (state == "XX") {
			alert("Please select a state.");
			return(false);
		} else if ((zip == "none") || (zip == null) || (zip.length != 5) ) {
			alert("Please supply a 5 digit zip code.");
			form.zip.focus();
			return(false);
		}
	} else {
		if (state != "XX") {
			msg = "The state field applies only to the US. Please set this to Not Applicable which appears at the top of the drop down menu.";
			alert(msg);
		} else if ((zip != "none") && (zip != null) && (zip.length != 0) ) {
			alert ("The zip code applies only to US addresses. If you have a non-US postal code please insert this after the city name.");
		}
	}

	form.submit();
}

function userLogin(form) {
 	var login = form.login.value;
 	var passwd = form.passwd.value;

	if (!hasValue(login)) {
		alert("Please supply your login name.");
		form.login.focus();
		return(false);
	}

	if (!hasValue(passwd)) {
		alert("Please supply your password.");
		form.passwd.focus();
		return(false);
	}

	form.submit();
}

function setAddress(lineId, form) {
	var addressIdx = form.address.selectedIndex;
	var addressId = form.address[addressIdx].value;

	var dest = "/checkout.php?action=address&line_id="+lineId+"&address_id="+addressId;
	location = dest;
}

function postContact(form) {
	var fname = form.fname.value;
	var lname = form.lname.value;
	var email = form.email.value;

	if ( !hasValue(fname) ) {
		alert("Please supply your first name.");
		form.fname.focus();
		return(false);
	}

	if ( !hasValue(lname) ) {
		alert("Please supply your last name.");
		form.lname.focus();
		return(false);
	}


	if ( !hasValue(email) ) {
		alert("Please supply your email address.");
		form.email.focus();
		return(false);
	}

	if (!isEmail(email)) {
		alert("Your email address appears to be invalid, please re-enter it.");
		form.email.focus();
		return(false);
	}

	form.submit();
}

function userRegister(form) {
	var uname = form.uname.value;
	var email = form.email.value;

	if ( !hasValue(uname) ) {
		alert("Please supply your name.");
		form.uname.focus();
		return(false);
	}

	if ( !hasValue(email) ) {
		alert("Please supply your email address.");
		form.email.focus();
		return(false);
	}

	if (!isEmail(email)) {
		alert("Your email address appears to be invalid, please re-enter it.");
		form.email.focus();
		return(false);
	}

	var enc_uname = escape(uname);
	var enc_email = escape(email);

	var target = "/register.php?uname="+enc_uname+"&email="+enc_email;
	var win=window.open(target, "Register", "toolbar=no,scrollbars=yes,width=400,height=300,resizable")
}

function pwReminder() {
	var target = "/reminder.php";
	var win=window.open(target, "Reminder", "toolbar=no,scrollbars=yes,width=400,height=300,resizable")
}

function tradeLogin() {
	var target = "/tradelogin.php";
	var win=window.open(target, "Reminder", "toolbar=no,scrollbars=yes,width=500,height=600,resizable")
}


function checkReminder(form) {
	var email = form.email.value;

	if ( !hasValue(email) ) {
		alert("Please supply your email address.");
		form.email.focus();
		return(false);
	}

	if (!isEmail(email)) {
		alert("Your email address appears to be invalid, please re-enter it.");
		form.email.focus();
		return(false);
	}

	form.submit();
}

function autoTab(elem, maxLength, nextElem, event) {
	var entry = elem.value;

	if (isBlank(entry)) {
		return(false);
	}

	if (event.keyCode == 9 || event.keyCode == 16) {
		/* Ignore tabs */
		return(false);
	}

	if (entry.length == maxLength) {
		nextElem.focus();
	}
}

function showCategoryMenu() {
	var categoryMenuDiv = document.getElementById("categoryMenu");
	var brandMenuDiv = document.getElementById("brandMenu");
	var categoryTab = document.getElementById("categoryTab");
	var brandTab = document.getElementById("brandTab");
	brandTab.src = "/images/brand_off.gif";
	categoryTab.src = "/images/cat_on.gif";

	brandMenuDiv.style.display = 'none';
	categoryMenuDiv.style.display = 'block';

	expHours = (24 * 365);	// Expire one year hence
	setCookie('menuTab', 'cat', '/', '', expHours);
}

function showBrandMenu() {
	var categoryMenuDiv = document.getElementById("categoryMenu");
	var brandMenuDiv = document.getElementById("brandMenu");
	//var brandTab = document.getElementById("brandTab");
	//brandTab.src = "/images/brand_on.gif";

	var categoryTab = document.getElementById("categoryTab");
	var brandTab = document.getElementById("brandTab");
	brandTab.src = "/images/brand_on.gif";
	categoryTab.src = "/images/cat_off.gif";

	categoryMenuDiv.style.display = 'none';
	brandMenuDiv.style.display = 'block';

	expHours = (24 * 365);	// Expire one year hence
	setCookie('menuTab', 'brand', '/', '', expHours);
}

function toggleDisplay(id) {
	var elem = document.getElementById(id);
	var displayStatus = elem.style.display;
	elem.style.display = (displayStatus == "none") ? "block" : "none";
}

function searchStockists(form) {
	var pid = form.pid.value;
	var county = form.county.value;
	var target = "/stockists.php?county="+county+"&pid="+pid;

	win=window.open(target, "stockists", "toolbar=no,scrollbars=yes,width=500,height=500,resizable")
}

function checkBrochureOrder(form) {
	var email = form.email.value;
	var brochureIdx = form.brochure.selectedIndex;
	var sourceIdx = form.source.selectedIndex;

	if (isBlank(email)) {
		alert("Please supply your email address.");
		form.email.focus();
		return(false);
	}

	if (!isEmail(email)) {
		alert("Your email address appears to be invalid.\nPlease re-enter your email address.");
		form.email.focus();
		return(false);
	}

	if (sourceIdx < 1) {
		alert("Please specify where you heard about B&G.");
		return(false);
	}

	if (brochureIdx < 1) {
		alert("Please specify which brochure you would like.");
		return(false);
	}

	form.submit();
}

function printableOrder(oid) {
       target = "/printableorder.php?oid=" + oid;
       win=window.open(target, "product", "toolbar=no,scrollbars=yes,width=640,height=800,resizable")
}
