// JavaScript Document
<!--
function changeImage(Lcount)
{
 switch(Lcount){
      case 0:
	  case 1:
	  case 2:  $('shirt').innerHTML = "<img id='shirt' src='shirts/rocker.jpg' border='0'>";
	          break;
	  case 4:
	  case 5:
	  case 6:
	  case 7:
	  case 8:
	  case 9:
	  case 10:
	  case 11:
	  case 12:
	  case 13:
	  case 14:
	  case 15:
	  case 16:
	  case 17:
	  case 18:
	  case 19:
	  case 20: $('shirt').innerHTML = "<img id='shirt' src='shirts/jettyratslogo.jpg' border='0'>";
	          break;
	  case 22:
	  case 23:
	  case 24:
	  case 25:
	  case 26:
	  case 27:
	  case 28:
	  case 29: $('shirt').innerHTML = "<img id='shirt' src='shirts/piratelogo.jpg' border='0'>";
	           break;
	  case 31:
	  case 32:
	  case 33: 
	  case 34:
	  case 35:
	  case 36:
	  case 37:
	  case 38: $('shirt').innerHTML = "<img id='shirt' src='shirts/whitesleeve.jpg' border='0'>";
	           break;	 	   
	  case 40:
	  case 41:
	  case 42:
	  case 43:
	  case 44: $('shirt').innerHTML = "<img id='shirt' src='shirts/ladytank.jpg' border='0'>";
	           break;
   }			   
}

function changeHidden()
{
  var whichNum = $('ADDITIONALINFO').selectedIndex;
  if (whichNum == 0)
  {
	$('PRICE').value="24.00";
	$('NAME').value="Rocker - Mens M";
    $('ID_NUM').value="00000001";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 1)
  {
	$('PRICE').value="24.00";
    $('NAME').value="Rocker - Mens L";
    $('ID_NUM').value="00000001";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 2)
  {
	$('PRICE').value="24.00";
    $('NAME').value="Rocker - Mens XL";
    $('ID_NUM').value="00000001";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 4)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Mens S";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 5)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Mens M";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 6)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Mens L";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 7)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Mens XL";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 8)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Boys S";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 9)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Boys M";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 10)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Boys L";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 11)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Boys XL";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 12)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Youth S";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 13)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Youth M";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 14)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Youth L";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 15)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Youth XL";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  
  if (whichNum == 16)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Girls Tank SX";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  
  if (whichNum == 17)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Girls Tank S";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  
  if (whichNum == 18)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Girls Tank M";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  
  if (whichNum == 19)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Girls Tank L";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  
  if (whichNum == 20)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Band Logo - Girls Tank XL";
    $('ID_NUM').value="00000002";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 22)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Mens S";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 23)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Mens M";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 24)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Mens L";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 25)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Mens XL";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 26)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Boys S";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 27)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Boys M";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 28)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Boys L";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 29)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Pirate Logo - Boys XL";
    $('ID_NUM').value="00000003";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 31)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Mens S";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 32)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Mens M";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 33)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Mens L";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 34)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Mens XL";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 35)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Boys S";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 36)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Boys M";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 37)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Boys L";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 38)
  {
	$('PRICE').value="20.00";
    $('NAME').value="White Logo - Boys XL";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
   if (whichNum == 40)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Girls Tank - Girls SX";
    $('ID_NUM').value="00000005";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 41)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Girls Tank - Girls S";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 42)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Girls Tank - Girls M";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 43)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Girls Tank - Girls L";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
  if (whichNum == 44)
  {
	$('PRICE').value="20.00";
    $('NAME').value="Girls Tank - Girls XL";
    $('ID_NUM').value="00000004";
    //order.SHIPPING.value="7.95";
  }
}


var jettyratrocker = new Item("Rocker",2400,0);
var jettyratshort = new Item("Short",2000,0);
var jettyratbandlogo = new Item("Band Logo", 2000,0);
var jettyratpiratelogo = new Item("Pirate Logo Tee",2000,0);
var jettyratwhitelogo = new Item("White Logo Tee",2000,0);
var jettyratgirlstank = new Item("100% Cotton Girls Tank",2000,0);

function purchase() // OPENS WINDOW THAT CONFIRMS PURCHASE AND SAYS THANKS
{

var porder="";
// add order array and item array
var cart = Item;
alert("CART Length: " + cart.contents.length);
if (cart.contents.length == 0) alert("can't add for zero reasons");

for (i=0; i<cart.contents.length; i++)
{

// Here is the cookie setter functions
var porder = porder + cart.contents[i].name + "||" + cart.contents[i].price + "||" + cart.contents[i].ship;
if (i<cart.contents.length-1) porder = porder + "&&";
}
alert("PORDER: " + porder);

// End cookie



purchaseWin = window.open("cartthankyou.html","","width=350,height=350,scrollbars=1,resizable=1,menubar=0,status=0,directories=0,location=0,toolbar=1");
}

function getdisplay()
{
 if (dropform.s.selectedIndex == 1)
  {
	jettyratrocker.display();
  }
  if (dropform.s.selectedIndex == 2)
  {
	jettyratshort.display();
  }
  if (dropform.s.selectedIndex == 3)
  {
 	jettyratbandlogo.display();
  }
  if (dropform.s.selectedIndex == 4)
  {
	jettyratpiratelogo.display();
  }
  if (dropform.s.selectedIndex == 5)
  {
	jettyratwhitelogo.display();
  }
  if (dropform.s.selectedIndex == 6)
  {
	jettyratgirlstank.display();
  }
  cart.iship.focus();
}  

function Item(name,price,ship) // THE ITEM OBJECT CONSTRUCTOR FUNCTION
{
this.name = name;
this.price = price;
this.ship = ship;
this.selected = false; // VARIABLE THAT IS TURNED ON WHEN ITEM IS SELECTED
}

function toCurrency(x) // SWICHES NUMERIC VALUES TO CURRENCY STRINGS
{
if (x == 0) return "$0.00";
x = x.toString();
var pre = x.substring(0,(x.length - 2));
var post = x.substring((x.length - 2),(x.length));
return "$" + pre + "." + post;
}

// INITIALIZE CLASS VARIABLES
Item.total = 0; // TOTAL PRICE
Item.contents = new Array(); // STORE CONTENTS OF CART
Item.counter = 0; // DESIGNATE A UNIQUE INTIGER FOR INITIALIZATION OF AN ELEMENT OF ITEM.CONTENTS


Item.prototype.display = function() // METHOD TO SET OBJECT VALUES IN DISPLAY FIELDS 
{
jettyratrocker.selected = false;
jettyratshort.selected = false;
jettyratbandlogo.selected = false;
jettyratpiratelogo.selected = false;
jettyratwhitelogo.selected = false;
jettyratgirlstank.selected = false;
document.cart.iname.value = this.name;
document.cart.iprice.value = toCurrency(this.price);
//document.cart.iship.value = this.ship;
document.cart.iship.value = 0;
this.selected = true; // TURN ON THIS VARIABLE TO SELECT IT FOR INCLUSION IN THE CART
}

Item.prototype.add = function() // METHOD TO ADD AN ITEM OBJECT TO THE CART
{
Item.total = Item.total + (this.price * cart.iship.value); // ADD TO THE TOTAL PRICE
Item.contents[Item.counter] = this; // PLACE AN ITEM INTO A NEW ARRAY ELEMENT
Item.contents[Item.counter].ship = Math.round(parseInt(cart.iship.value));
document.cart.total.value = toCurrency(Item.total); // PURELY FOR DISPLAY
document.cart.iname.value = ""; // UPDATE DISPLAY FIELDS
document.cart.iprice.value = ""; // UPDATE DISPLAY FIELDS
document.cart.iship.value = ""; // UPDATE DISPLAY FIELDS
document.dropform.s.value = "selecta";
Item.counter++ // INCREMENT COUNTER FOR NEXT ARRAY ELEMENT
}

Item.show = function() // DISPLAY WINDOW TO REVEAL CART CONTENTS
{
cartWin = window.open("showcart.html","cartWin","width=300,height=400,scrollbars=1,resizable=0,menubar=0,status=0,directories=0,location=0,toolbar=0,left=320,top=20");
cartWin.focus();
}

Item.removalOf = function(x) // REMOVE AN ITEM FROM THE CART, WHEW!
{
Item.total = Item.total - (Item.contents[x].price * Item.contents[x].ship); // REDUCE TOTAL
Item.contents[x] = ""; // VOID OUT THE ARRAY ELEMENT
document.cart.total.value = toCurrency(Item.total); // UPDATE DISPLAY
Item.contents.sort(function (a,b) // RESORT OUR ARRAY
   {
   if (a == "") a = 1; else a = 0;
   if (b == "") b = 1; else b = 0;
   return a - b;
   });
var holdPoint = Item.contents.length;
for (i=0; i<Item.contents.length; i++) // DESIGNATE WHERE EMPTY ELEMENTS BEGIN
   {
   if (Item.contents[i] == "") { holdPoint = i; break; }
   }
Item.contents = Item.contents.slice(0,holdPoint); // DISCARD EMPTY ELEMENTS
Item.counter--; // DECREMENT COUNTER TO MATCH BACK UP TO ARRAY
}

Item.addToCart = function(ship) // FIGURE OUT WHICH ITEM IS SELECTED
{

// Check for int or NaN
zerot = parseInt(ship);
//zerot = parseInt(cart.iship.value);
zerot = Math.round(zerot);

NotNum = isNaN(zerot);

if (zerot == "0" || NotNum) 
{
  alert("User must enter a numeric quantity to add item to cart");
  return true;
}  

// Get cookie 

if (jettyratrocker.selected) { jettyratrocker.add(zerot); jettyratrocker.selected = false; }
if (jettyratshort.selected) { jettyratshort.add(zerot); jettyratshort.selected = false; }
if (jettyratbandlogo.selected) { jettyratbandlogo.add(zerot); jettyratbandlogo.selected = false; }
if (jettyratpiratelogo.selected) { jettyratpiratelogo.add(zerot); jettyratpiratelogo.selected = false; }
if (jettyratwhitelogo.selected) { jettyratwhitelogo.add(zerot); jettyratwhitelogo.selected = false; }
if (jettyratgirlstank.selected) { jettyratgirlstank.add(zerot); jettyratgirlstank.selected = false; }

// Set cookie + new order nze
var cart = Item;
var porder = "";

// Here is the cookie setter functions NZE
var name = "test";
var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	cookie_stuff = unescape( document.cookie.substring( len, end ) );
	alert("CCOOKIE " + cookie_stuff);
	order = cookie_stuff.split("&&");
	for (i=0; i<order.length; i++)
    {
	  alert("Order: "+order [i]);
	}

if (i<cart.contents.length-1) porder = porder + "&&";
Set_Cookie( 'test', porder, '', '/', '', '' );
alert("PORDER Me: " + porder);

}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	cookie_stuff = unescape( document.cookie.substring( len, end ) );
	order = cookie_stuff.split("&&");
	for (i=0; i<order.length; i++)
    {
	  alert("Order: "+order [i]);
	}  
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


// remember, these are the possible parameters for Set_Cookie:
// name, value, expires, path, domain, secure
function proc_cookie()
{ 
  var prorder = cart.iname.value + "&&" + cart.iprice.value + "&&" + cart.iship.value + "&&" + cart.total.value;
  Set_Cookie( 'test', prorder, '', '/', '', '' );
  if ( Get_Cookie( 'test' ) ) alert( Get_Cookie('test'));
  // and these are the parameters for Delete_Cookie:
  // name, path, domain
  // make sure you use the same parameters in Set and Delete Cookie.
  /////nze/Delete_Cookie('test', '/', '');
   ( Get_Cookie( 'test' ) ) ? alert( Get_Cookie('test')) : 
  alert( 'it is gone');
}

//-->