﻿
    function hideNotification( id )
    {
        var hideDiv = new Fx.Style($(id), 'opacity', {duration: 500} );
        hideDiv.addEvent('onComplete', function() {  var div = $(id).setStyles({ display:'none', opacity: 0 }) });		
        hideDiv.start(0);   
    }
    
    function toggleSection( id )
    {            
        var details = $(id);
        if (details.style.display == "block")
        {            
            details.style.display = "none";
        } else {
            details.style.display = "block";
        }
    }
    
    function showSection( id )
    {            
        $(id).setStyles({ display:'block', opacity: 1 });
    }
    
    function hideSection( id )
    {            
        $(id).setStyles({ display:'none', opacity: 0 });
    }
    
    function printResults()
    {

        var url = "Search.aspx?" + window.location.search.substring(1) + "&print=1";            
        
        w = 640;
        h = 480;            
        left=(screen.availWidth)?(screen.availWidth-w)/2:50;
        top=(screen.availHeight)?(screen.availHeight-h)/2:50;
        settings='width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';            
        win=window.open(url,'print',settings);
        if(win.focus){ win.focus(); }
        
    }

    function setCheckedVal(field_id, value_txt)
    {
        if (value_txt != "False") 
        {
            $(field_id).checked = true;
        }
    }
    
    function setSelectedVal(field_id, value_txt)
    {
        var list = $(field_id);
        
        for(var i=0; i<list.options.length; i++) {
            if (value_txt.indexOf( list.options[i].value ) != -1) 
            {
                list.options[i].selected = true;
            }
        }
        
    }
    
    function getSelectedVal(field_id)        
    {
        var select = $(field_id);
        return select.options[select.selectedIndex].value;
    }
    
    function replaceNasties( value )
    {
        value = value.replace(/&lt;/gi,"<");
        value = value.replace(/&gt;/gi,">");
        value = value.replace("&","and")
        return value;
    }
    
    function checkSearch( e, site_path )
    {
        var characterCode
        if (e && e.which) { 
            e = e
            characterCode = e.which 
        } else {
            e = event
            characterCode = e.keyCode 
        }
        if(characterCode == 13){
            runSearch( site_path );
            return false
        }
        else{
            return true
        }
    }
    function runSearch( site_path )
    {
        if (document.getElementById('search_box').value != '') { 
            window.location = site_path + '/Search/?keywords=' + document.getElementById('search_box').value; 
        }
    }