function openWindow(pageURL, windowWidth, windowHeight, showScrollbars, windowName)
{
    var windowPosX;
	var windowPosY;
	var newWindow;

	windowPosX=(screen.width-windowWidth)/2;
	windowPosY=(screen.height-windowHeight)/4;
	if (windowPosX<0) windowPosX=0;
	if (windowPosY<0) windowPosY=0;
	newWindow=window.open(pageURL, windowName, "toolbar=no,location=no,left=" + windowPosX + ",top=" + windowPosY + ",directories=no,status=no,menubar=no,scrollbars="+showScrollbars+",resizable=no,width=" + windowWidth + ",height=" + windowHeight);
	newWindow.focus();
}

function setBackgroundColor(element, color)
{
    document.getElementById(element).style.backgroundColor = color;
}

function applyCoupon() {
    refreshProductSelection();
}

function refreshProductSelection()
{
    var form = document.getElementById('purchaseForm');
    form.action = '';
    form.submit();
}

function submitProductSelection()
{
    var form = document.getElementById('purchaseForm');
    form.action = '/purchase/redirect/';
    form.submit();
    form.action = '';
}

function getScrollX() {
    var x = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
    }
    return x;
} 

function getScrollY() {
    var y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        y = document.documentElement.scrollTop;
    }
    return y;
}

function setScrollY(y) {
    window.scrollTo(getScrollX, y);
}