
    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)
  	{
  	    BuildMyOverlay();   
  	    var win = new Window({className: "dialog", title: "", 
                      top:70, left:100, width:(Client.viewportWidth() -100), height:(Client.screenHeight() -100), 
                      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/logo-splash.gif" width="280" height="62" />'
        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)
  	{
  	    var splashPage = document.getElementById(id);
  	    if (splashPage != null)
  	        id = id + '1';
  	    Dialog.info(content, {className: "alphacube",  width:350, id: id, showProgress: "true"}); 
  	    
  	}


    // ****************************************************************
    // * Get Information About the Client Browser
    // ****************************************************************
    
    // GET 
    // viewportHeight() = total height including scroll
    // viewportWidth() = available screen width;
    // screenHeight() = visible screen height not including scroll 

    var Client = {
       viewportHeight: function() {
            if (window.innerHeight && window.scrollMaxY) {// Firefox
		        yWithScroll = window.innerHeight + window.scrollMaxY;
		        xWithScroll = window.innerWidth + window.scrollMaxX;
	        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		        yWithScroll = document.body.scrollHeight;
		        xWithScroll = document.body.scrollWidth;
	        } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		        yWithScroll = document.body.offsetHeight;
		        xWithScroll = document.body.offsetWidth;
  	        }
  	        if (this.screenHeight() > yWithScroll)
  	        {
  	            return this.screenHeight();
  	        }
  	        return yWithScroll;
          },
          viewportWidth: function() 
          {
            return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
          },
          screenHeight: function() 
          {
            if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                myWidth = window.innerWidth;
                myHeight = window.innerHeight;
              } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight;
              }       
              return myHeight;
          },
          prepareIE: function(height, overflow){
		    bod = document.getElementsByTagName('body')[0];
		    bod.style.height = height;
		    bod.style.overflow = overflow;
      
		    htm = document.getElementsByTagName('html')[0];
		    htm.style.height = height;
		    htm.style.overflow = overflow; 
	    },
	    // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	    getScroll: function(){
		    if (self.pageYOffset) {
			    yPos = self.pageYOffset;
		    } else if (document.documentElement && document.documentElement.scrollTop){
			    yPos = document.documentElement.scrollTop; 
		    } else if (document.body) {
			    yPos = document.body.scrollTop;
		    }
	    },
	    // In IE, select elements hover on top of the lightbox
	    hideSelects: function(visibility){
		    selects = document.getElementsByTagName('select');
		    for(i = 0; i < selects.length; i++) {
			    selects[i].style.visibility = visibility;
		    }
	    },
	    setScroll: function(x, y){
		    window.scrollTo(x, y); 
	    }
      }
