function load_product(product_details){
	attribute=attribute_name;
	//identify the number of product attributes
	numberOfAttributes=product_details.split("---").length+1; //add one to account for the product number
	if(typeof(products_string)=="undefined"){
		products_string="";
	}
	//determine the product number for the product incrementally automatically as a unique identifier
	if(typeof(product_number)=="undefined"){
		product_number=-1;
	}
	//reconstruct the products_string alphabetically by inserting the new product in the appropriate place
		product_number++;
		products_string_2="";
		inserted=false;
		//add each attribute for each product
		for(d=0;d<products_string.split("---").length;d++){
			//before adding the attributes for each product, check to see if the new product should be slotted in before it 
			if(d%numberOfAttributes==0){
				//if the new product's attribute is less than (alphabetically), or belongs before the next product, add it before adding the next product
				if(product_details.split("---")[attribute-1]<products_string.split("---")[d+attribute]&&inserted==false){
					if(d!=0){
						products_string_2+="---";
					}
					products_string_2+=product_number+"---"+product_details;
					//tag inserted as true so as to not add it again
					inserted=true;
				}
			}
			if(products_string_2!=""){
				products_string_2+="---";
			}
			products_string_2+=products_string.split("---")[d];
			
			//if the new product doesn't fit before any of the current products, place it at the end
			if(d+1>=products_string.split("---").length&&inserted==false){
				if(products_string_2!=""){
					products_string_2+="---";
				}
				products_string_2+=product_number+"---"+product_details;
			}
		}
		products_string=products_string_2;
	//convert the products_string to an array
	products_array=new Array();
	for(c=0;c<products_string.split("---").length;c++){
		products_array[c]=products_string.split("---")[c];
	}
	/*thisthing="";
	for(that=0;that<products_string.split("---").length;that++){
		if(that%numberOfAttributes==0){
			thisthing+="\n";
		}
		if(that%numberOfAttributes!=0){
			thisthing+="---"
		}
		thisthing+=products_string.split("---")[that];
	}
	alert(thisthing)*/
}
function select_single_product(product_number,products_array,numberOfAttributes){
	single_product=new Array();
	//start at the product's product number and get all of the attributes
	for(n=product_number*numberOfAttributes+attribute_number;n<product_number*numberOfAttributes+attribute_number+numberOfAttributes;n++){
		single_product[single_product.length]=products_array[n];
	}
	return single_product;
}
function select_products(attribute,value,products_array,numberOfAttributes){
	//RETURN THE POSITION IN THE PRODUCTS ARRAY WHERE THE PRODUCT APPEARS,NOT THE PRODUCT NUMBER - THE PRODUCT NUMBERS AREN'T IN ORDER ONCE ALPHABETIZED
	if(isNaN(attribute)||attribute>=numberOfAttributes){
		attribute=attribute_category;
	}
	numberOfProducts=products_array.length/numberOfAttributes;
	selected_products_array=new Array();
	//IF NO VALUE IS PASSED, RETURN NOTHING
	if(typeof page_category=="undefined"&&value=="none"||page_category=="Welcome"){
		return selected_products_array;
	}
	//if no value is passed, return all products
	if(value=="none"||value.toLowerCase()=="all"){
		for(b=0;b<numberOfProducts;b++){
			//DON'T DISPLAY THE **noshow** PRODUCTS
			if(products_array[eval(b*numberOfAttributes)+attribute_category]!="**noshow**"){
				selected_products_array[selected_products_array.length]=b;
			}
			//selected_products_array[selected_products_array.length]=products_array[eval(b*numberOfAttributes)+attribute_number];
		}
		return selected_products_array;
	}
	//separate each product by the numberOfAttributes
	for(b=0;b<numberOfProducts;b++){
		//look at the multiples of the attribute eg. multiple categories (separated by "|")
		for(i=0;i<products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|").length;i++){
			//if the product attribute matches the passed value...
			//PREVIOUS ONLY IF THIS IS THE CATEGORY NAME if(products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i]==value){
			//make sure that the value passed appears at the beginning of the product's category attribute ie. that it exists and it's at the beginning - eg. dogs»small»puppies we want dogs»small to display dogs»small»puppies products but not animals»small»puppies (small»puppies appears in both which means that we can't just see if it exists) ALSO make sure that this value is a full category not just partial eg. Dog shouldn't display Doggie nor should Do. Do this by ensuring that the next character is either a » or nothing.
			if(products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i].split(value).length>1&&products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i].split(value)[0]==""&&products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i].split(value)[1].charAt(0)=="»"||products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i].split(value)[1]==""&&products_array[eval(attribute)+eval(b*numberOfAttributes)].split("|")[i].split(value)[0]==""){
				//store this product in the selected_products_array
				selected_products_array[selected_products_array.length]=b;
				//selected_products_array[selected_products_array.length]=products_array[eval(b*numberOfAttributes+attribute_number)];
			}
		}
	}
	//if nothing matches the criteria, send all of the products back
	if(selected_products_array==""){
		for(b=0;b<numberOfProducts;b++){
			//DON'T DISPLAY THE **noshow** PRODUCTS
			if(products_array[eval(b*numberOfAttributes)+attribute_category]!="**noshow**"){
				selected_products_array[selected_products_array.length]=b;
			}
			//selected_products_array[selected_products_array.length]=products_array[eval(b*numberOfAttributes)+attribute_number];
		}
	}
	return selected_products_array;
}
function make_categories(selected_category,attribute,products_array,numberOfAttributes){
	if(isNaN(attribute)||attribute>=numberOfAttributes){
		attribute=attribute_category;
	}
	//This will be replaced with "All" - leaving it blank ensures that when alphabetized it will stay at the top
	categories_array=new Array("");
	numberOfProducts=products_array.length/numberOfAttributes;
	selected_category_levels=selected_category.split("»").length;
	selected_category_added=false;
	alreadyThere=false;
	//look at all of the products' attribute
	for(d=0;d<numberOfProducts;d++){
		//look at the multiples of the attribute eg. multiple categories (separated by "|")
		for(h=0;h<products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|").length;h++){
			//DON'T DISPLAY THE **noshow** PRODUCTS
			if(products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h]=="**noshow**"){
				alreadyThere=true;
			}
			//compare these with the categories which have been collected
			for(e=0;e<categories_array.length;e++){
				//look at the main category - the first in the category value
				//leave the selected main category so that we can gather information about its subcategories
					if(products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[0]!=selected_category.split("»")[0]&&products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[0]==categories_array[e].split("»")[0]){
						alreadyThere=true;
					}
			}
			//if the category isn't already listed
			if(e==categories_array.length&&alreadyThere==false){
				//if this is the category which has been selected
				if(products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[0]==selected_category.split("»")[0]){
					//Only add the selected main category once
					if(selected_category_added==false){
						categories_array[categories_array.length]=products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[0];
						selected_category_added=true;
					}//create subcategories
					//put each layer/level of the category into the appropriate array - only if the layer exists eg. chicken»eggs doesn't have a 3rd layer
					for(bb=1;bb<=selected_category_levels&&bb<products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»").length;bb++){
						//define the subcategory array if it hasn't yet been created
						if(eval("typeof subcategories_array_"+bb+"=='undefined'")){
							//alert(bb+" "+selected_category_levels+" "+products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»").length)
							eval("subcategories_array_"+bb+"=new Array()");
						}
						//alert(bb+" "+eval("subcategories_array_"+bb))
						subcat_alreadyThere=false;
						//check to make sure that the previous category and subcategories matched the selected category and subcategories - we don't want to show the subcategories which are aren't selected 
						previous_subcategory="";
						previous_selected_subcategory="";
						for(ff=0;ff<bb;ff++){
							previous_subcategory+="»"+products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[ff];
							previous_selected_subcategory+="»"+selected_category.split("»")[ff];
						}
						//make sure that it hasn't already been added
						for(cc=0;cc<eval("subcategories_array_"+bb+".length");cc++){
							//if it has been added, note this
							if(eval("subcategories_array_"+bb+"["+cc+"]=='"+products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[bb]+"'")){
								subcat_alreadyThere=true;
							}
						}
						//if it hasn't already been added, add it
						if(subcat_alreadyThere==false&&previous_selected_subcategory==previous_subcategory){
						//alert(products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[bb]+" --- "+previous_selected_subcategory+" ||| "+previous_subcategory+" "+eval(previous_selected_subcategory==previous_subcategory));
							eval("subcategories_array_"+bb+"[subcategories_array_"+bb+".length]='"+products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[bb]+"'")//'"+products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h]+"'";
						}
						//alert(subcategories_array_1);
					}				
				}else{
					categories_array[categories_array.length]=products_array[eval(attribute)+eval(d*numberOfAttributes)].split("|")[h].split("»")[0];
				}
			}
			//reset alreadyThere for the next product
			alreadyThere=false;
		}
	}
	//CHANGE CARTOODLE CATEGORY TO zzz***Cartoodle TO ENSURE THAT IT APPEARS LAST
	for(cc=0;cc<categories_array.length;cc++){
		if(categories_array[cc]=="Cartoodle"){
			categories_array[cc]=replace_characters(categories_array[cc],"Cartoodle","zzz***Cartoodle");
		}
	}
	categories_and_subcategories_array=new Array();
	categories_and_subcategories_array[0]=categories_array.sort();
	//REVERT CARTOODLE CATEGORY BACK TO ORIGINAL NAME
	categories_and_subcategories_array[0][categories_and_subcategories_array[0].length-1]=replace_characters(categories_and_subcategories_array[0][categories_and_subcategories_array[0].length-1],"zzz***","");
	//Replace the blank space with "All"
	categories_and_subcategories_array[0][0]="All";
	//get all of the category and subcategory levels
	for(dodo=1;dodo<=selected_category_levels;dodo++){
		//make sure that the subcategory level exists and isn't blank
		if(eval("typeof subcategories_array_"+dodo+"!='undefined'")&&eval("subcategories_array_"+dodo+"!=''")){	
			categories_and_subcategories_array[dodo]=eval("subcategories_array_"+dodo+".sort()");
			//alert(dodo+" "+eval("subcategories_array_"+dodo+".sort()"))
		}
	}
	return categories_and_subcategories_array;
}
function get_url_variable(variable_name){
	//get the entire url
	all_variables=document.location.href.split("?")[1];
	//check that there are variables
	if(typeof(all_variables)!="undefined"){
		//look at all of the variables
		for(e=0;e<all_variables.split("&").length;e++){
			if(all_variables.split("&")[e].split("=")[0]==variable_name){
				//remove the %20 characters representing a space and replace %BB which represents »
				return replace_characters(replace_characters(all_variables.split("&")[e].split("=")[1],"%20"," "),"%BB","»");
			}
		}
	}
	return "none";
}
function get_cookie(cookie_name){
	this_cookie=document.cookie.split("; ");
	for(g=0;g<this_cookie.length;g++){
		if(cookie_name==this_cookie[g].split("=")[0]){
			return this_cookie[g].split("=")[1];
		}
	}
	//if there is no cookie by that name, return false
	return "";
}
function replace_characters(text,findChars,replacementChars){
	//make sure that there is text being passed
	if(typeof(text)=="undefined"){
		return text;
	}
	newText="";
	for(rrr=0;rrr<text.length;rrr++){
		//Set char string to compare
		charString="";
		//starting at rrr, create charString to compare findChars with (according to number of chars)
		for(sss=rrr;sss<rrr+findChars.length&&sss<text.length;sss++){
			charString+=text.charAt(sss);
		}
		//If the charString matches findChars
		if(charString==findChars){
			//add charString to nextText
			newText+=replacementChars;
			//and move on, starting at next unchecked char
			rrr=rrr+eval(findChars.length-1);
		}
		else{
			//Add letter to nextText
			newText+=text.charAt(rrr);
		}
	}
	return newText;
}
function add_product(product_number){
	product_number_location=get_product_number_location(product_number,products_array,numberOfAttributes);
	//generate variables
	are_there_options=isNaN(products_array[product_number_location*numberOfAttributes+attribute_price]);
	no_of_options=products_array[product_number_location*numberOfAttributes+attribute_price].split("|||").length;
	product_category=replace_characters(get_url_variable("category")," ","%20");
	product_type=replace_characters(get_url_variable("type")," ","%20");
	page_number=get_url_variable("page");
	product_customisable=products_array[product_number_location*numberOfAttributes+attribute_customisable];
	//define cookie characteristics
	now=new Date();
	expireDate=new Date();
	expireDate.setMonth(expireDate.getMonth()+6);
	//make sure that the shopping_cart cookie is defined
	shopping_cart_cookie=get_cookie("shopping_cart");
	if(shopping_cart_cookie!=""){
		//separate each product
		product_details="|";
	}else{
		//create shopping cart cookie
		product_details="";
	}
	//if the product is customisable
	if(product_customisable=="yes"){
		product_customisation=eval("document.products_form.customise_"+product_number+".value");
	}else{//alert(product_number)
		product_customisation="n/a";
	}
	//if there is no category listed, make it 'all'
	if(product_category=="none"){
		product_category="All";
	}
	//if no page is listed, assume that it's the first page
	if(page_number=="none"){
		page_number=1;
	}
	//get the options for the product if there are some(price)
	product_options="";
	if(are_there_options==true){
		//list the selected options
		for(v=0;v<no_of_options;v++){
			if(v!=0){
				product_options+="&";
			}
			product_options+=eval("document.products_form.option_"+product_number+"_"+v+".selectedIndex");	
		}
	}else{
		product_options="n/a";
	}
	product_quantity=eval("document.products_form.quantity_"+product_number+".value");
	//set the product's attributes as variables
	product_details+=product_number+","+product_options+","+product_quantity+","+product_customisation+","+product_type+","+product_category+","+page_number;
	//make sure that the item hasn't already been added
	already_added=false;
	for(k=0;k<shopping_cart_cookie.split("|").length&&already_added==false;k++){
		added_product_number=shopping_cart_cookie.split("|")[k].split(",")[cart_attribute_number];
		added_product_customisation=shopping_cart_cookie.split("|")[k].split(",")[cart_attribute_customisation];
		added_product_options=shopping_cart_cookie.split("|")[k].split(",")[cart_attribute_options];
		//check to product to add against those already added - if a matching product is found, tag already added as true
		if(product_number==added_product_number&&product_customisation==added_product_customisation&&product_options==added_product_options){
			already_added=true;
			return "already_added";//indicates that the product already exists
		}
	}
	//make sure that a quantity and customisation (if applicable) are included
	product_errors="";
	if(product_customisable=="yes"&&replace_characters(eval("document.products_form.customise_"+product_number+".value")," ","")==""){
		product_errors+="customisation";
	}
	if(!isInteger(eval("document.products_form.quantity_"+product_number+".value"))){
		if(product_errors!=""){
			product_errors+="|";
		}
		product_errors+="quantity";
	}
	if(product_errors!=""){
		return product_errors;
	}
	//end quantity and customisation verification
	if(already_added==false){
		//if this is the first item to be added
		if(shopping_cart_cookie==""){
			document.cookie="shopping_cart="+product_details+";expires="+expireDate.toGMTString();
			return "added";//indicates that the product was added
		}
		//group items of the same product number
		//look at all the items in the shopping cart and find the last product number matching the product to add
		temp_shopping_cart_cookie="";
		product_added=false;
		for(x=0;x<shopping_cart_cookie.split("|").length;x++){
			if(x!=0){
				temp_shopping_cart_cookie+="|";
			}
			temp_shopping_cart_cookie+=shopping_cart_cookie.split("|")[x];
			//if we're looking at the last product currently in the shopping cart, add the new product after it 
			if(product_added==false&&x==shopping_cart_cookie.split("|").length-1){
				temp_shopping_cart_cookie+=product_details;
				product_added=true;
			}
			//if the product we're looking at in the shopping cart matches the new product to add and is also different to the next product in the shopping cart, add it now (to keep the same products together)
			if(product_added==false&&shopping_cart_cookie.split("|")[x].split(",")[cart_attribute_number]==product_number&&shopping_cart_cookie.split("|")[x+1].split(",")[cart_attribute_number]!=product_number){
				temp_shopping_cart_cookie+=product_details;
				product_added=true;
			}
		}
		document.cookie="shopping_cart="+temp_shopping_cart_cookie+";expires="+expireDate.toGMTString();
		return "added";//indicates that the product was added
	}
}
function add_single_product(product_number){
	product_number_location=get_product_number_location(product_number,products_array,numberOfAttributes);
	//if the item is successfully added, to the shopping cart
	notification_text="";
	add_attempt=add_product(product_number);
	single_product=select_single_product(product_number_location,products_array,numberOfAttributes);
	if(add_attempt=="added"){
		document.location.href="./shopping_cart.html#"+product_number;
	}else if(add_attempt=="already_added"){
		//Get the product's details
		notification_text+=replace_characters(single_product[attribute_name],'&quot;','"');
		//customisation
		if(product_customisable=="yes"){
			notification_text+=" '"+eval("document.products_form.customise_"+product_number+".value")+"'";
		}
		//options
		if(are_there_options==true){
			for(y=0;y<no_of_options;y++){
				selected_option=eval("document.products_form.option_"+product_number+"_"+y+".selectedIndex");
				option_description=products_array[product_number_location*numberOfAttributes+attribute_price].split("|||")[y].split("***")[0].split("&")[selected_option].split("|")[0];
				notification_text+=" '"+replace_characters(option_description,"*","")+"'";
			}
		}
		notification_text+=" has already been added.\n\nWould you like to view your shopping cart now?";
		if(confirm(notification_text)){
			document.location.href="./shopping_cart.html#"+product_number;
		}
	}else{
		notification_text+=single_product[attribute_name]+" cannot be added to your shopping cart because of the following errors:\n\n";
		for(r=0;r<add_attempt.split("|").length;r++){
			if(add_attempt.split("|")[r]=="customisation"){
				notification_text+=" * the 'customise' field must be filled in";
			}else if(add_attempt.split("|")[r]=="quantity"){
				notification_text+=" * the quantity must be a positive integer";
			}
		}
		alert(notification_text);
	}
}
function add_multiple_products(){
	//look at all of the products to see which are selected
	already_added_array=new Array();
	just_added_array=new Array();
	cant_be_added_array=new Array();	
	for(j=0;j<selected_products_array.length;j++){
		product_checked=eval("document.products_form.add_"+products_array[selected_products_array[j]*numberOfAttributes+eval(attribute_number)]+".checked");
		product_quantity=eval("document.products_form.quantity_"+products_array[selected_products_array[j]*numberOfAttributes+eval(attribute_number)]+".value");
		if(product_checked==true){
			add_attempt=add_product(products_array[selected_products_array[j]*numberOfAttributes+eval(attribute_number)]);
			//get a list of the items which have already been added and the ones which haven't
			if(add_attempt=="already_added"){
				already_added_array[already_added_array.length]=j;
			}else if(add_attempt=="added"){
				just_added_array[just_added_array.length]=j;
			}else{
				cant_be_added_array[cant_be_added_array.length]=j+"|"+add_attempt;
			}
		}
	}
	//notify of products which were already added
	if(already_added_array.length==0&&cant_be_added_array.length==0){
		document.location.href="./shopping_cart.html";
	}else{
		notification_text="";
		//list any errors which occurred
		if(cant_be_added_array.length!=0){
			for(l=0;l<cant_be_added_array.length;l++){
				//errors heading
				if(l!=0){
					notification_text+="\n";
				}else{
					notification_text+="The following products cannot be added to your shopping cart because of errors:\n\n";
				}	
				notification_text+=" - "+products_array[eval(cant_be_added_array[l].split("|")[0]*numberOfAttributes)+eval(attribute_name)];
				for(p=1;p<cant_be_added_array[l].split("|").length;p++){
					if(cant_be_added_array[l].split("|")[p]=="customisation"){
						notification_text+=" * the 'customise' field must be filled in";
					}else if(cant_be_added_array[l].split("|")[p]=="quantity"){
						notification_text+=" * the quantity must be a positive integer";
					}
				}
			}
		}
		//list all the items which were already added
		for(l=0;l<already_added_array.length;l++){
			//separate each product
			if(l!=0){
				notification_text+="\n";
			}else{
				if(notification_text!=""){
					notification_text+="\n\n";
				}
				notification_text+="The following products are already in your shopping cart:\n\n";
			}
			notification_text+=" - "+products_array[eval(already_added_array[l]*numberOfAttributes)+eval(attribute_name)];
			//if the product is customisable
			if(products_array[eval(already_added_array[l]*numberOfAttributes)+eval(attribute_customisable)]=="yes"){	
				notification_text+=" '"+eval("document.products_form.customise_"+products_array[eval(already_added_array[l]*numberOfAttributes)+eval(attribute_number)]+".value")+"'";
			}
			//if the product has options
			if(isNaN(products_array[eval(already_added_array[l]*numberOfAttributes)+eval(attribute_price)])==true){	
				for(z=0;z<products_array[already_added_array[l]*numberOfAttributes+attribute_price].split("|||").length;z++){
					notification_text+=" '"+products_array[already_added_array[l]*numberOfAttributes+attribute_price].split("|||")[z].split("***")[0].split("&")[eval("document.products_form.option_"+products_array[eval(already_added_array[l]*numberOfAttributes)+eval(attribute_number)]+"_"+z+".selectedIndex")].split("|")[0]+"'";
				}
			}
		}
		//list all the items which were just added
		for(l=0;l<just_added_array.length;l++){
			if(l!=0){
				notification_text+="\n";
			}else{
				notification_text+="\n\nThe following products have now been added to your shopping cart:\n\n";
			}
			notification_text+=" - "+products_array[eval(just_added_array[l]*numberOfAttributes)+eval(attribute_name)];
			//if the item is customisable
			if(products_array[eval(just_added_array[l]*numberOfAttributes)+eval(attribute_customisable)]=="yes"){	
				notification_text+=" '"+eval("document.products_form.customise_"+products_array[eval(just_added_array[l]*numberOfAttributes)+eval(attribute_number)]+".value")+"'";
			}
		}
		//if there are only errors - alert
		if(just_added_array.length==0&&already_added_array.length==0){
			alert(notification_text);
		}else{
			if(confirm(notification_text+"\n\nWould you like to view you shopping cart now?")!=false){
				document.location.href="./shopping_cart.html";
			}
		}
	}
}
function isInteger(value){
	if(value<=0){
		return false;
	}
	return(parseInt(value)==value);
}
function remove_all_products(){
	now=new Date();
	expireDate=new Date();
	expireDate.setMonth(expireDate.getMonth()-6);
	document.cookie="shopping_cart=;expires="+expireDate.toGMTString();
}
function remove_single_product(shopping_cart_number){
	shopping_cart_cookie=get_cookie("shopping_cart");
	temp_shopping_cart_cookie="";
	now=new Date();
	expireDate=new Date();
	//if we're removing the last item, delete the cookie
	if(shopping_cart_cookie.split("|").length==1){
		expireDate.setMonth(expireDate.getMonth()-6);
	}else{
		expireDate.setMonth(expireDate.getMonth()+6);
	}
	for(p=0;p<shopping_cart_cookie.split("|").length;p++){
		//add all but the product to remove
		if(p!=shopping_cart_number){
			//separate
			if(temp_shopping_cart_cookie!=""){
				temp_shopping_cart_cookie+="|";
			}
			temp_shopping_cart_cookie+=shopping_cart_cookie.split("|")[p];
		}
	}
	//look at all of the products in the shopping cart
	document.cookie="shopping_cart="+temp_shopping_cart_cookie+";expires="+expireDate.toGMTString();
	document.location.href="./shopping_cart.html";
}
function update_shopping_cart(){
	shopping_cart_cookie=get_cookie("shopping_cart");
	temp_shopping_cart_cookie="";
	now=new Date();
	expireDate=new Date();
	expireDate.setMonth(expireDate.getMonth()+6);
	for(p=0;p<shopping_cart_cookie.split("|").length;p++){
		//separate
		if(temp_shopping_cart_cookie!=""){
			temp_shopping_cart_cookie+="|";
		}
		//look at each shopping cart detail and update the custom and quantity fields
		for(q=0;q<shopping_cart_cookie.split("|")[p].split(",").length;q++){
			if(q!=0){
				temp_shopping_cart_cookie+=",";
			}
			//update quantity from form field
			if(q==cart_attribute_quantity){
				form_quantity=eval("document.shopping_cart_form.quantity_"+p+".value");
				//make sure that the quantity is a number
				if(isInteger(form_quantity)){
					temp_shopping_cart_cookie+=form_quantity;
				}else{
					temp_shopping_cart_cookie+=shopping_cart_cookie.split("|")[p].split(",")[q];
				}
			//update customisation from form field
			}else if(q==cart_attribute_customisation){
				//if this product is customisable
				if(shopping_cart_cookie.split("|")[p].split(",")[q]!="n/a"){
					form_customisation=eval("document.shopping_cart_form.customise_"+p+".value");
					//make sure that the customisation field isn't empty
					if(replace_characters(form_customisation," ","")!=""){			
						temp_shopping_cart_cookie+=form_customisation;
					}else{
						temp_shopping_cart_cookie+=shopping_cart_cookie.split("|")[p].split(",")[q];
					}
				}else{
					temp_shopping_cart_cookie+="n/a";
				}
			//update everything else from the cookie
			}else{
				temp_shopping_cart_cookie+=shopping_cart_cookie.split("|")[p].split(",")[q];
			}
		}
	}
	//look at all of the products in the shopping cart
	document.cookie="shopping_cart="+temp_shopping_cart_cookie+";expires="+expireDate.toGMTString();
	document.location.href="./shopping_cart.html";
}
function decimalPlaces(value){
	decimalValue=Math.round(eval(value)*100)/100;
	decimalValue+="";
	if(decimalValue.split(".").length>=2&&decimalValue.split(".")[1].length==1){
		decimalValue+="0";
	}
	else if(decimalValue.split(".").length<2){
		decimalValue+=".00";
	}
	return decimalValue;
}
function image_window(image_name,option_code,window_title){//alert(option_code)
	window_title=replace_characters(window_title,'_',' ');
	//if we're opening an image which is an option
	if(option_code!=""){
		imageURL="../images/content/products/large/"+replace_characters(image_name,".","_"+eval(option_code)+".");
	}else{
		imageURL="../images/content/products/large/"+image_name;
	}
	var img = new Image();
	img.src = imageURL;
	screenWidth=screen.width;
	screenHeight=screen.height;
	windowWidth=700;//img.width+70;
	windowHeight=screen.height-60;//img.height+120;
	xLocation=eval(screenWidth-windowWidth)/2;
	yLocation=eval(screenHeight-windowHeight)/2;
	var win = window.open("","","width="+windowWidth+",height="+windowHeight+",screenX="+xLocation+",screenY="+yLocation+",left="+xLocation+",top="+yLocation+",resizable=1,toolbar=0,location=0,status=0,menubar=0,scrollbars=1,alwaysRaised=1,dependent=1");
	
	win.document.open();
	
	win.document.write("<html><head><title>Cartoodle | "+window_title+"</title><link type='text/css' rel='stylesheet' href='../css/main.css'></head>");
	win.document.write("<script language='javascript'>");
	win.document.write("function sizeWindow(width, height){if(height>screen.height){height=screen.height-40}window.resizeTo(width, height);}");
	win.document.write("</script>");
	win.document.write("<BODY bgcolor='#FFFFFF'>\n<table width=100% height=100% border=0 cellspacing=0 cellpadding=0>\n<tr height=100% valign=center align=center>\n<td>\n<table width='1' height='1' border='0' cellpadding='1' cellspacing='0' bgcolor='#CCCCCC'><tr> <td align='center' valign='middle'> <table border='0' cellspacing='0' cellpadding='0.0' bgcolor='#FFFFFF'><tr><td align='center' valign='middle'><img name='imageToDisplay' src='" + imageURL + "' border=0 onLoad='sizeWindow(document.imageToDisplay.width+140, document.imageToDisplay.height+140)'></td></tr></table> </td></tr></table>\n</td>\n</tr>\n<tr height=2% valign=center>\n<td align=center><a href='javascript:window.close();'>Close</a></td>\n</tr>\n</table>\n</body>\n</html>\n");
	win.document.close();
}
function get_product_number_location(product_number,products_array,numberOfAttributes){
	for(tt=0;tt<products_array.length;tt+=numberOfAttributes){
		if(products_array[tt]==product_number){
			product_number_location=tt/numberOfAttributes;
			return product_number_location;
		}
	}
}