
function showElement(element, maxOpacity) {
    Appear(element, 0, maxOpacity);
}

function hideElement(element) {
    document.getElementById(element).style.display='none';
}

function showItem(item) {
    document.getElementById(item).style.display='';
}

function hideItem(item) {
    document.getElementById(item).style.display='none';
}

function setLocation()
{
	window.open(path+'shop/setshippinglocation.aspx', '', 'dependent,modal=yes,height=250,width=450,status=yes,toolbar=no,menubar=no,location=no');
}

function showCart()
{
	try{
		showElement('shoppingcart',80);
		showElement('shoppingcart_overlay',100);
		showElement('shoppingcart_content',100);
	} catch(ex) {
		document.getElementById('shoppingcart').style.display='';
		document.getElementById('shoppingcart_overlay').style.display='';
		document.getElementById('shoppingcart_content').style.display='';
	}
	if(document.getElementById('thumb')!=null)dd.elements.thumb.hide();
}

function updateCart()
{
    document.getElementById("frm_cart").submit();
}

function removeVoucher(voucherId)
{
    document.getElementById("VoucherId").value = voucherId;
    document.getElementById("btnRemoveVoucher").click();
}

function refresh()
{
    document.getElementById("frm_refresh").submit();
}

function recalculateShipping(billingordelivery)
{
	if(document.getElementById('ddl' + billingordelivery + 'Country').value == '')return null;	
	if(!document.getElementById('chkSameAsBilling').checked && billingordelivery == 'Billing')return null;
	
	if(document.getElementById('txt' + billingordelivery + 'PostCode').value == '')
	{
		alert('Please enter your post code before selecting your country so that we can calculate the delivery cost to your location');
		document.getElementById('ddl' + billingordelivery + 'Country').value = '';
		return null;
	}
	
	//alert('We are about to recalculate the shipping cost for your order. Please review your order total before completing checkout.');
    document.getElementById('btnCalcShipping').click();
}

function swapImage(image) {
	if (document.images) {
		if(image.src.match(/_over/) != null)
		{
			image.src=image.src.replace('_over.png','.png');
		}
		else
		{
			image.src=image.src.replace('.png','_over.png');
		}
	}
}

function pageHeight() {
    height = document.innerHeight;

    if (height == undefined) {
        height = document.documentElement.clientHeight;
        if (height == 0) { height = document.body.clientHeight; }
    }

    return height;
}

function itemHeight() {
    var Height;

    if (window.innerHeight && window.scrollMaxY) {// Firefox         
        Height = window.innerHeight + window.scrollMaxY;
        //xWithScroll = window.innerWidth + window.scrollMaxX;     
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac         
        Height = document.body.scrollHeight;
        //xWithScroll = document.body.scrollWidth;     
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
        Height = document.body.offsetHeight;
        //xWithScroll = document.body.offsetWidth;       
    }

    return Height;
}

function itemInnerHeight(item) {
    var Height = document.getElementById(item).innerHeight;

    if (Height == undefined) {
        Height = document.getElementById(item).clientHeight;
    }

    return Height;
}

function setItemHeight(item, height) {
    document.getElementById(item).style.height = height;
}

function Appear(id, opacity, maxOpacity) {

    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + (opacity + 10) + ")";
    object.display = '';

    if (opacity + 20 <= maxOpacity) {
        setTimeout("Appear('" + id + "', " + (opacity + 15) + ", " + maxOpacity + ");", 1);
    }
}
