

function HideButton(id) {
    var btn = document.getElementById(id);
    if (btn != null) {
        btn.style.display = 'none';
    }
}

// *******************************************************
// * Vader Show Offer Result Control
// *******************************************************   

// Determine with Boxes are selected in a category
function Compare(category) {

    var compare = new String('Compare;');
    var counter = 0;
    var name = new String(category) + 'CompareAndProdIdCell';
    // Get Sub Items Products
    var capCell = document.getElementsByName(name);
    for (var index = 0; index < capCell.length; index++) {
        if (capCell[index].childNodes.length > 0) {
            var _productKey = new String();
            var _itemSelected = new Boolean();

            for (var i = 0; i < capCell[index].childNodes.length; i++) {
                var childControl = capCell[index].childNodes[i];
                if (childControl != null) {
                    var str = new String();
                    str = childControl.id;
                    if (str != null) {
                        if (str.search(/productValue/) != -1)
                            _productKey = childControl.attributes['value'].value;

                        if (str.search(/compareCheck/) != -1) {
                            _itemSelected = childControl.checked;
                            if (_itemSelected == false)
                                break;
                        }
                    }
                }
            }

            if (_itemSelected == true) {
                counter++;
                compare += _productKey + ',' + index + '|';
            }
        }
    }

    compare += category;
    // Make sure right amount of item are selected
    if ((counter < 2) || (counter > 4)) {
        alert('In order to use the comparison feature, you must select either a minimum of two or a maximum of four of the same products.');
        return false;
    }
    // Make a call to the server
    CallServer(compare, 'prodComparison');
}


// ****************************************************************


// ****************************************************************
// * Server Call Back Procedure
// ****************************************************************
function ReceiveServerData(rValue, context) {
    if (CartReLoadCounter_Increment != null) CartReLoadCounter_Increment();

    switch (context) {
        case 'prodComparison':
            showDetailURL(rValue);
            break;
    }
}

// ****************************************************************
// * Show PopUp Windows
// ****************************************************************
function showDetailURL(url, _browserVer) {
    //To resolve Details page showing blank screen in IE6
    if (_browserVer == 'IE6') {
        window.open(url, 'offerDetailsWindow', 'width=600,height=600,scrollbars=yes,resizable=yes');
    }
    else {
        var win = new Window({ className: "dialog", title: "",
            top: 70, left: 100, width: 600, height: 500,
            url: url, showEffectOptions: { duration: 0.5 }
        });
        win.setDestroyOnClose();
        win.showCenter();
    }
}

function showDetailURLSetSize(url, _width, _height, _browserVer) {
    //To resolve ChannelLineUp page showing blank screen in IE6
    if (_browserVer == 'IE6') {
        window.open(url, 'channelLineupWindow', 'width=400,height=500,scrollbars=yes,resizable=yes');
    }
    else {
        var win = new Window({ className: "dialog", title: "",
            top: 70, left: 100, width: _width, height: _height,
            url: url, showEffectOptions: { duration: 0.5 }
        });
        win.setDestroyOnClose();
        win.showCenter();
    }

}

// ****************************************************************
// * Client Side Shopping Cart 
// ****************************************************************
function LoadCart(prodId) {
    CallServer(prodId, 'addToCart');
}

var masterPageId = 'ctl00_Main_';

function AddToCart(controlArray, buttonIndex) {

    var tableButtons = document.getElementsByName(controlArray);
    if (tableButtons.length > 0) {
        var addToCartLink = tableButtons[buttonIndex];
        if (navigator.appName == 'Microsoft Internet Explorer') {
            addToCartLink.children[0].click();
        }
        else {
            var attr = new String(addToCartLink.attributes["onclick"].value);
            addToCartLink.focus();
            addToCartLink.onclick();

        }
        return true;
    }
    return false;
}

// ****************************************************************
// * Search Process
// ****************************************************************
function SubmitSearchProcess(rValue, context) {
    switch (context) {
        case 'dispatch':
            if (rValue != null) {
                // Status:Failure;Message:
                var result = new String(rValue);
                var values = result.split(';');
                var status = values[0].split(':')[1];
                if (status == 'Failure') {
                    var message = new String(values[1].split(':')[1]);
                    if (message.length > 0)
                        alert(message);
                }
                else {
                    var url = new String(values[1].split(':')[1]);
                    postToParent(url);
                }
            }
            break;
    }
}

function ParseDomainFromUrl(pUrl) {
    var lUrl = unescape(pUrl);
    var lPieces = lUrl.split('/');
    var lDomain = (lPieces.length >= 3) ? lPieces[2] : '';
    var lPortPos = lDomain.indexOf(':');
    if (lPortPos >= 0) lDomain = lDomain.substr(0, lPortPos);
    return lDomain;
}


function postToParent(parentURL) {
    var opener = this;
    if (window.opener == null)
        opener = this.parent;

    displaySplash();

    // change
    opener.location.replace(parentURL);
}

function displaySplash() {
    // show splash page
    var splashContent = new String('');

    // build content      
    splashContent = '<div id="splashDiv" style="display: block" align="center">';
    splashContent = splashContent + '<img src="/images/logo-splash.gif" width="220" height="60" />';
    splashContent = splashContent + '<br />';
    splashContent = splashContent + '<br />';
    splashContent = splashContent + '<img src="/images/searching.gif" width="220" height="60" />';
    splashContent = splashContent + '</div>';
    showSplash(splashContent);
}

// ****************************************************************
// * Show PopUp Div
// ****************************************************************

function changeAddress(url) {
    var win = new Window({ className: "dialog", title: "New Search",
        top: 70, left: 100, width: 460, height: 238,
        url: url, showEffectOptions: { duration: 0.5}
    });
    win.setDestroyOnClose();
    win.showCenter();
}
function showSplash(content) {
    showSplash(content, 'splashPage1');
}
function showSplash(content, id) {
    try {
        var splashPage = document.getElementById(id);
        if (splashPage != null)
            id = id + '1';
        Dialog.info(content, { className: "alphacube", width: 350, id: id, showProgress: "true" });

    } catch (e) {
        return;
    }
}
  	

