function dropDown()
{
   varx = document.getElementById("CATEGORY").value;
   
   if(varx != "")
   {
   window.location.href = varx + ".php";   
   }
}

function dropDown2()
{
   varx = document.getElementById("MANUFACTURER").value;
   
   if(varx != "")
   {
   window.location.href = varx + ".php";   
   }
}

basketCost = 0;
basketNum = 0;
inBasket = "";
basketArray = new Array();
order = "";
basketString = "";

<!-- CODE ADDED 10-04-05 -->
function readCookie()
{

   if((document.cookie).indexOf("hairroom") != -1)
   {
       orderArray = document.cookie.split(";");

       for(j=0; j<orderArray.length; j++)
       {
		  if(orderArray[j].indexOf("hairroom") != -1)
		  {
		     order = orderArray[j];
		  }
       }

       fullArray = ((order.split("="))[1]).split("#");
       artArray = new Array();
       placeInArray = 0;

	   for(p=0; p<fullArray.length; p++)
	   {
	      if(fullArray[p] != "")
	      {
	      artArray[placeInArray] = fullArray[p];
	      placeInArray++;
	      }
	   }

	   for(k=0; k<artArray.length; k++)
	   {

	   basketArray[k] = artArray[k];


          if((artArray[k].split('/'))[0] != "")
          {
	      basketCost += parseInt((artArray[k].split('/'))[1]);
	      }

          if((artArray[k].split('/'))[0] != "")
          {
	      basketNum += parseInt((artArray[k].split('/'))[2]);
	      }

	      if((artArray[k].split('/'))[0] != "")
	      {
	      basketString = "<B>Shopping Basket</B> " + basketNum + " item(s)";
		  }

	   }

      document.getElementById("BAG").innerHTML = basketString;
      writeCookie();
   }
}
<!-- -->

function addToBag(item,price,quantity,colour)
{

   match = "false";
   newQuantity = "";
   
   if(colour == "colour")
   {
      
      if(document.getElementById("PRODUCTCOLOUR").value != "")
      {
   
	   for(i=0; i<basketArray.length; i++)
	   {
	      testProduct = (basketArray[i].split('/'))[0] + "/" + (basketArray[i].split('/'))[1] + "/" + (basketArray[i].split('/'))[3];

	      if(testProduct == (item + "/" + price + "/" + document.getElementById("PRODUCTCOLOUR").value))
	      {
		     match = "true";
		     newQuantity = parseInt((basketArray[i].split('/'))[2]) + parseInt(quantity);
		     basketArray[i] = item + "/" + price + "/" + newQuantity + "/" + document.getElementById("PRODUCTCOLOUR").value;
	      }
	   }

	   if(match == "false")
	   {
	   basketArray[parseInt(basketArray.length)] = item + "/" + price + "/" + quantity + "/" + document.getElementById("PRODUCTCOLOUR").value;
	   }
	   
	   basketCost = basketCost + parseInt(price);

	   basketNum = basketNum + quantity;

	   document.getElementById("BAG").innerHTML = "<B>Shopping Basket</B> " + basketNum + " item(s)";

	   alert(item + " added to your bag.");

	   writeCookie();
   
      }
      else
      {
         alert("Please select a colour for the product.");
      }
   
   }
   else
   {

	   for(i=0; i<basketArray.length; i++)
	   {
	      testProduct = (basketArray[i].split('/'))[0] + "/" + (basketArray[i].split('/'))[1];

	      if(testProduct == (item + "/" + price))
	      {
		     match = "true";
		     newQuantity = parseInt((basketArray[i].split('/'))[2]) + parseInt(quantity);
		     basketArray[i] = item + "/" + price + "/" + newQuantity + "/ -";
	      }
	   }

	   if(match == "false")
	   {
	   basketArray[parseInt(basketArray.length)] = item + "/" + price + "/" + quantity + "/ -";
	   }

           basketCost = basketCost + parseInt(price);

           basketNum = basketNum + quantity;

           document.getElementById("BAG").innerHTML = "<B>Shopping Basket</B> " + basketNum + " item(s)";

           alert(item + " added to your bag.");

           writeCookie();
   
   }

}


function writeCookie()
{
arrayContent = 0;

chocChipCookie = "hairroom=";

	for(i=0; i<basketArray.length; i++)
	{
	   if(basketArray[i] != "undefined")
	   {

          chocChipCookie += basketArray[i] + "#"
          arrayContent++;
	   }
	}
	
	chocChipCookie += ";path=/";

    if(arrayContent != 0)
    {
    document.cookie = chocChipCookie;
    }
    else
    {
    var kill_time = new Date("February 11, 1975");
    document.cookie = "hairroom=;expires=" + kill_time.toGMTString() + ";path=/";
    document.cookie = "hairroomBasket=;expires=" + kill_time.toGMTString() + ";path=/";
    document.cookie = "basket=;expires=" + kill_time.toGMTString() + ";path=/";
    document.getElementById("BAG").innerHTML = "your bag is empty";
    }

}
