

    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('Please select between 2 and 4 products for comparison');
            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)
  	{
  	    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();     
  	}
  	
  	
  	
  	// ****************************************************************
    // * 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 = null;
        if (window.opener == null)
            opener = this.parent;
        else
        {
            try 
            {
                var domain = ParseDomainFromUrl(window.opener.location.href);
                opener = (domain.indexOf('homes') >= 0) ? window.opener : this;
            } catch(err) {
                opener = this;
            }
        }            
        
        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/articles/logo-splash.gif" width="280" height="62" />'
        splashContent = splashContent + '<div id="splashImage" style="width:252px;height:53px;background-image:url(images/default/saveology-moving.gif)"></div>'
        splashContent = splashContent + '<br /><br /><b>We are searching for special offers in your area.<br/>You can begin reviewing your offers momentarily. Thank you!</b>'
        splashContent = splashContent + '<br />'
        //splashContent = splashContent + '<img src="images/articles/searching.gif" width="220" height="60" />'
        splashContent = splashContent + '<div id="splashImage" style="width:220px;height:60px;background-image:url(images/articles/searching.gif)"></div>'
        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)
  	{
  	    var splashPage = document.getElementById(id);
  	    if (splashPage != null)
  	        id = id + '1';
  	    Dialog.info(content, {className: "alphacube",  width:350, id: id, showProgress: "true"}); 
  	    
  	}
