function PreloadImages(arr) {
    cache = [];
    for(var i = 0; i < arr.length; i++)
    {
    	cache[i] = new Image;
    	cache[i].src = arr[i];
    }
}

function SwapHeroImage(img) {
	document.getElementById('hero_image').src = img;
}

function ToggleVisible(id) {
	var obj = document.getElementById(id);
	if (obj.style.display == "none") obj.style.display = "block";
	else obj.style.display = "none";
}

function TogglePaymentOptions(id) {
	if (document.getElementById('payment_account')) document.getElementById('payment_account').style.display = "none";
	document.getElementById('payment_credit').style.display = "none";
	document.getElementById('payment_cheque').style.display = "none";
	document.getElementById('payment_internet').style.display = "none";
	
	if (id == "account") document.getElementById('payment_account').style.display = "block";
	if (id == "credit") document.getElementById('payment_credit').style.display = "block";
	if (id == "cheque") document.getElementById('payment_cheque').style.display = "block";
	if (id == "internet") document.getElementById('payment_internet').style.display = "block";
}

function ShowSizeChart() {
	mywindow = window.open ("/message/size-chart/", "mywindow","location=0,status=0,scrollbars=1,width=320,height=400");
}

function ShowStockists() {
	mywindow = window.open ("/message/stockists/", "mywindow","location=0,status=0,scrollbars=1,width=320,height=400");
}

function ShowDescription(obj, id) {
	var target = document.getElementById(id);
	var coords = findPos(obj);
	if (coords[0] < 130) coords[0] = 130;
	if (coords[1] < 130) coords[1] = 130;
	//target.style.left = (coords[0] - 122) + "px";
	//target.style.top = (coords[1] - 122) + "px";
	target.style.left = (coords[0] + 18) + "px";
	target.style.top = (coords[1] + 18) + "px";
	target.style.display="inline";
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
