function SetGarmentOption(strSKU, strWhichColor, strColor, strSKUSuffix) {
    createCookie(strWhichColor, strColor, 7);
    createCookie('CurrProd', strSKU);
    //alert(GetGarmentColor());
    //alert(document['main_image'].src);
    document['main_image'].src = '/catalogue/ProductColorModule/' + strSKU + '.' + GetGarmentColor() + ".jpg";
	//alert(document['main_image'].src);
    document.getElementById('CurrentFullSKU').innerHTML = readCookie('CurrProd') + strSKUSuffix + document.getElementById('ctl00_ContentPlaceHolder1_Size').value;
}

function GetGarmentColor() {
    //alert(readCookie('Color1'));
    var garment = "";
    if (readCookie('Color0') != "" && readCookie('Color0') != null)
        garment = readCookie('Color0');
    if (readCookie('Color1') != "" && readCookie('Color1') != null)
        garment += "." + readCookie('Color1');
    if (readCookie('Color2') != "" && readCookie('Color2') != null)
        garment += "." + readCookie('Color2');
//alert(garment);
    return garment;
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}