
/*
function fadeReplaceShow (elem, url, params, debug)
{
	var isLoaded = false;
	var elemItem = { 
		cycle: function() {
			new Effect.Fade(elem, { // the id of the <DIV> containing the photos 
				duration: 0.3, 
				fps: 50, 
				from:1.0,
				to:0.01,
				afterFinish: function() { 
					new Ajax.Updater(elem,url, { // URL for next <IMG> tag 
						asynchronous: true, 
						parameters: params,
						evalScripts: true,
						onComplete: function() { 
							if(debug == true) alert("Loading complete: "+url);
							new Effect.Fade(elem, {
								duration: 0.3,
								fps: 50,
								from:0.01,
								to:1.0,
								queue:'end'
							})
						} 
					}) 
				} 
			}) 
		} 
	}
	elemItem.cycle();
}
*/

function fadeReplaceShow (elem, url, params, debug)
{
	new Ajax.Updater(elem,url, 
	{
		asynchronous: true, 
		parameters: params,
		evalScripts: true,
		onComplete: function() 
		{ 

		} 
	});
}

var loaded = new Array();
function loadType(type)
{
	if(loaded[type] != true)
	{
		fadeReplaceShow('type'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/styles.php?type='+type+'&rand='+ new Date().getTime(), '', false);
		loaded[type] = true;
	}
	var elem = document.getElementById('type'+(type+1));
	elem.style.backgroundImage = "";
	
}

function loadStyle(type, style)
{
	loaded[type] = false;
	fadeReplaceShow('type'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/customize.php?type='+type+'&style='+style+'&rand='+ new Date().getTime(), '', false);
	//window.setTimeout('changeBackground('+type+')', 1000);
}

function changeBackground(type)
{
	var elem = document.getElementById('type'+(type+1));
	elem.style.backgroundImage = "url("+PATH_RELATIVE+"modules/productcatalogmodule/images/bg"+type+".jpg)";
	elem.style.backgroundPosition = "top right";
	elem.style.backgroundRepeat = "no-repeat";
}

function pickFinish(type, style, finish)
{
	fadeReplaceShow('sizes'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/customize.php?type='+type+'&style='+style+'&finish='+finish+'&rand='+ new Date().getTime(), '', true);	
}

function pickSize(type, style, finish, size)
{
	fadeReplaceShow('colours'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/customize.php?type='+type+'&style='+style+'&finish='+finish+'&size='+size+'&rand='+ new Date().getTime(), '', false);	
}

function pickColour(type, productcolour)
{
	fadeReplaceShow('detail'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/detail.php?productcolour='+productcolour+'&rand='+ new Date().getTime(), '', false);	
}

function addToCart(type, productcolour)
{
	fadeReplaceShow('cart'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/cart.php?productcolour='+productcolour+'&rand='+ new Date().getTime(), '', false);			
}

function removeFromCart(type, productcolour)
{
	fadeReplaceShow('cart'+(type+1), PATH_RELATIVE+'modules/productcatalogmodule/cart.php?action=remove&productcolour='+productcolour+'&rand='+ new Date().getTime(), '', false);			
}

