function $(id) {return document.getElementById(id);}

function keepBrowsing() {
	$('overlayFrame').src = "";
	$('dimmer').style.display = 'none';
	$('popup').style.display = 'none';
	$('cartalert').style.display = 'none';
}

function showOverlay(url, boxwidth, boxheight, borderCol) {
	$('overlayFrame').src = url;
	centreElement('popup',boxwidth+10,boxheight+10);
	$('dimmer').style.display = 'block';
	$('popup').style.borderColor = borderCol;
	$('popup').style.display = 'block';
}

function addedToCart(strDollName) {
	if (strDollName == "The Yoozzoo set")
		$('dollthumb').src = "/Assets/Yoozzoo/Images/Photos/group-thumb.jpg";
	else
		$('dollthumb').src = "/Assets/Yoozzoo/Images/Photos/" + strDollName + "-thumb.jpg";
	$('dollthumb').alt = strDollName;
	$('dollname').innerHTML = strDollName;
	centreElement('cartalert',380,215);
	$('dimmer').style.display = 'block';
	$('cartalert').style.display = 'block';
}

function centreElement(id,elWidth,elHeight){
    var element = $(id);
	var my_width  = 0;
    var my_height = 0;
    if (typeof(window.innerWidth) == 'number') {
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    } else if ( document.body && ( document.body.clientWidth || document.body.clientHeight )) {
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }
    element.style.position = 'absolute';
    var scrollY = 0;
    if ( document.documentElement && document.documentElement.scrollTop ) {
        scrollY = document.documentElement.scrollTop;
    } else if ( document.body && document.body.scrollTop ) {
        scrollY = document.body.scrollTop;
    } else if ( window.pageYOffset ) {
        scrollY = window.pageYOffset;
    } else if ( window.scrollY ) {
        scrollY = window.scrollY;
    }
    var setX = (my_width-elWidth)/2;
    var setY = (my_height-elHeight)/2 + scrollY;
    setX = (setX < 0) ? 0 : setX;
    setY = (setY < 0) ? 0 : setY;
    element.style.left = setX + 'px';
    element.style.top  = setY + 'px';
    element.style.display = 'block';
}
