﻿// JScript File
function writeCartCount() {
	//document.write("<font color=#0000bb>" + itemsInCart() + "</font>");
	document.write("item(s)");
}
function itemsInCart() {
	var numItems = 0
	var stuff = getCookie("cart");

	if ('a' + stuff  != 'aundefined') {
		arrayOfStrings = stuff.split('&');
		for (var i=0; i < arrayOfStrings.length; i+=1) {
			tmp = arrayOfStrings[i];
			arrtmp = tmp.split('=');
			numItems += parseInt(arrtmp[1]);
		}
		if ('a' + numItems == "aNaN") {
			numItems = 0;
		}
	}
	
	return numItems
}

function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
         offset += search.length
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1)
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }
   }
}
function doClick(buttonName,e)
{
	//the purpose of this function is to allow the enter key to  point to the correct button to click.
	var key;

	if(window.event)
		key = window.event.keyCode;     //IE
	else
		key = e.which;     //firefox

	if (key == 13)
	{
		//Get the button the user wants to have clicked
		var btn = document.getElementById(buttonName);
		if (btn != null)
		{ //If we find the button click it
			btn.click();
			event.keyCode = 0
		}
	}
}
function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}
