//Preloads images for the dock
dockpic1 = new Image;
dockpic1.src='images/gtfo/gtfo_black_on.png';

dockpic2 = new Image;
dockpic2.src='images/gtfo/gtfo_blue_on.png';

dockpic3 = new Image;
dockpic3.src='images/gtfo/gtfo_green_on.png';

dockpic4 = new Image;
dockpic4.src='images/gtfo/gtfo_orange_on.png';

dockpic5 = new Image;
dockpic5.src='images/gtfo/gtfo_pink_on.png';

dockpic6 = new Image;
dockpic6.src='images/gtfo/gtfo_red_on.png';

addtocart5 = new Image;
addtocart5.src='images/remove.png';

addtocart6 = new Image;
addtocart6.src='images/addtocart_checked.png';

//Checks the form to make sure the user checked a box
function checkform (){
    valid = true;
	
    if (document.gtfopillows.gtfob.value == "no" && document.gtfopillows.gtfog.value == "no" && document.gtfopillows.gtfor.value == "no" && document.gtfopillows.gtfobl.value == "no" && document.gtfopillows.gtfoo.value == "no" && document.gtfopillows.gtfop.value == "no") {
	alert("Please check the boxes for the items you want to add to your cart.");
	valid = false;
    }

    if (valid == true) {
	showSpinner();
    }
    
    return valid;
}

//If the user checks a box switch images of dock and checkbox
function addtocart(name, dockname, object) {
    var txt;
    var tbox = document.getElementById(object);
	
    //If the are adding to the cart (the value is already zero)
    if (tbox.value == "no") {
	document[name].src='images/remove.png';
		
	if (dockname == "fd012") {
	    document[dockname].src= 'images/gtfo/gtfo_black_on.png';
	}
		
	if (dockname == "db012") {
	    document[dockname].src='images/gtfo/gtfo_blue_on.png';
	}
		
	if (dockname == "it012") {
	    document[dockname].src='images/gtfo/gtfo_green_on.png';
	}
		
	if (dockname == "ip012") {
	    document[dockname].src='images/gtfo/gtfo_orange_on.png';
	}
		
	if (dockname == "ic012") {
	    document[dockname].src='images/gtfo/gtfo_pink_on.png';
	}
		
	if (dockname == "pb012") {
	    document[dockname].src='images/gtfo/gtfo_red_on.png';
	}
		
	//sets the value of the hidden input box to yes
	txt = "yes";
	tbox.value = txt;
		
	//changes the add to cart button to bright color
	if (document.gtfopillows.gtfob.value == "yes" || document.gtfopillows.gtfog.value == "yes" || document.gtfopillows.gtfor.value == "yes" || document.gtfopillows.gtfobl.value == "yes" || document.gtfopillows.gtfoo.value == "yes" || document.gtfopillows.gtfop.value == "yes") {
	    var imagebutton = document.getElementById("addtocartbutton");
	    imagebutton.src = "images/addtocart_checked.png";
	}
    } else {
		
	//if the user is removeing item from cart
	if (tbox.value == "yes") {
	    document[name].src='images/button.png';
			
	    //resets the way the checkboxes look
	    if (dockname == "fd012") {
		document[dockname].src= 'images/gtfo/gtfo_black_off.png';
	    }
			
	    if (dockname == "db012") {
		document[dockname].src='images/gtfo/gtfo_blue_off.png';
	    }
			
	    if (dockname == "it012") {
		document[dockname].src='images/gtfo/gtfo_green_off.png';
	    }
			
	    if (dockname == "ip012") {
		document[dockname].src='images/gtfo/gtfo_orange_off.png';
	    }
			
	    if (dockname == "ic012") {
		document[dockname].src='images/gtfo/gtfo_pink_off.png';
	    }
			
	    if (dockname == "pb012") {
		document[dockname].src='images/gtfo/gtfo_red_off.png';
	    }
			
			
	    //sets hidden input box to no
	    txt = "no";
	    tbox.value = txt;
			
	    //returns the add to cart button to normal
	    if (document.gtfopillows.gtfob.value == "no" && document.gtfopillows.gtfog.value == "no" && document.gtfopillows.gtfor.value == "no" && document.gtfopillows.gtfobl.value == "no" && document.gtfopillows.gtfoo.value == "no" && document.gtfopillows.gtfop.value == "no") {
		var imagebutton = document.getElementById("addtocartbutton");
		imagebutton.src = "images/addtocart.png";
	    }
	}
    }
}

function LoadItemsInCart() {
    itemsAdded = false;
	
    if 	(document.gtfopillows.gtfob.value == "yes") {
	document['gtfobadd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if 	(document.gtfopillows.gtfobl.value == "yes") {
	document['gtfobladd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if 	(document.gtfopillows.gtfog.value == "yes") {
	document['gtfogadd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if 	(document.gtfopillows.gtfoo.value == "yes") {
	document['gtfooadd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if 	(document.gtfopillows.gtfop.value == "yes") {
	document['gtfopadd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if 	(document.gtfopillows.gtfor.value == "yes") {
	document['gtforadd'].src='images/remove.png';
	itemsAdded = true;
    }
	
    if (itemsAdded) {
	var imagebutton = document.getElementById("addtocartbutton");
	imagebutton.src ="images/addtocart_checked.png";
    }
	
}

