var images = new Array();
var imagePath = "/images/site/v2/";
var selectedImage = "";

var productImages = new Array();
var tshirtImages = new Array();

// cache the images
var imageNames = new Array("shop", "about", "extra", "free_stuff", "contact_us");
for (i=0;i<imageNames.length; i++) {
    images[imageNames[i]+"_on"] = new Image();
    images[imageNames[i]+"_on"].src = imagePath+imageNames[i]+"_on.jpg";

    images[imageNames[i]+"_off"] = new Image();
    images[imageNames[i]+"_off"].src = imagePath+imageNames[i]+"_off.jpg";

}

/*
* turns the button passed on and swithes the currently selected button off
*/
function buttonOn(name) {
	if (name != selectedImage) {
		document.images[name].src = images[name+"_on"].src;
		if (selectedImage != "") {
			document.images[selectedImage].src = images[selectedImage+"_off"].src;
		}
	}
}
/*
* turns the buttton passed off and switched the currently seleced button on
*/
function buttonOff(name) {
	if (name != selectedImage) {
		document.images[name].src = images[name+"_off"].src;
		if (selectedImage != "") {
			document.images[selectedImage].src = images[selectedImage+"_on"].src;
		}
	}
}

function selectButton(name) {
	buttonOn(name);
	selectedImage = name
}

function productDetailsChangeColour(productId) {
    list = document.forms["product"+productId].elements["ColorID"]
    colour = list.options[list.selectedIndex].value;
    //document.images[productId+"pic"].src = "http://crankclothing.com/images/"+productId+"/"+colour+"_tshirt_big.gif";
    document.images[productId+"pic"].src = productImages[productId][colour].src;
}

function productDetailsAddProductImage(productId, colour) {
    if (!productImages[productId]) {
        productImages[productId] = new Array();
    }
    productImages[productId][colour] = new Image();
    productImages[productId][colour].src = "/images/"+productId+"/medium_product_"+colour+".gif"
}

function addTshirtImage(url) {
    tshirtImages[tshirtImages.length] = new Image();
    tshirtImages[tshirtImages.length-1].src = "/images/"+url;
}

function changeTshirtImage(index) {

    document.images["tshirt"].src = tshirtImages[index].src;
}
/*




function openTShirtWindow(id) {
    properties = "width=280,height=555,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no";
    window.open("http://crankclothing.com/images/"+id+"/large_product_black.gif", new Date().getTime(), properties);

}

function displayEmailSubjectInfo() {
    list = document.forms["sendEmail"].elements["subject"]
    subject = list.options[list.selectedIndex].value;

    if (subject == "BUG") {
        text =
        "You have selected to send us a bug report.\n"+
        "Please ensure that you give use enough information\n"+
        "to solve the problem by supplying us with the\n"+
        "following:\n"+
        "\n"+
        " 1 The URL of the page you were on when the error occurred.\n"+
        " 2 The exact error message if there is one.\n"+
        " 3 Your browser name and version number\n"+
        "   e.g. Internet Explorer 4.5.\n"+
        " 4 Your operating system e.g. Windows XP.\n"+
        " 5 Please describe exactly what you were doing when the \n"+
        "   error occurred.  Too much information is better than\n"+
        "   too little information.\n"+
        "\n"+
        "Thank you\n";
        alert(text);
    }
}
*/
