//Called onload for Google setup
function findGoogle() 
{ 
    //Find search term textbox
    var q = document.getElementById('q');
    if (q) 
    { 
        //Set search term
        var regEx = new RegExp("([^?=&]+)(=([^&]*))?");
        var m = regEx.exec(location.search);
        if (m && m[0] && m[0,3])
            q.value = decodeURIComponent(m[0,3]);
        else
            q.value = "";

        //Set watermark
        var n = navigator; 
        var l = location; 
        if (n.platform == 'Win32') 
        { 
            q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;'; 
        } 
        var b = function() 
        { 
            if (q.value == '') 
            { 
                q.style.background = '#FFFFFF url(http://www.google.com/coop/intl/en/images/google_custom_search_watermark.gif) left no-repeat'; 
            } 
        }; 
        var f = function() 
        { 
            q.style.background = '#ffffff'; 
        }; 
        q.onfocus = f; 
        q.onblur = b; 
        if (!/[&?]q=[^&]/.test(l.search)) 
        { 
            b(); 
        } 
    } 
}

//Called for all form submits
function checkGoogleSubmit()
{
    var s = document.getElementById('ctl00_txtSearch');
    if (s)
    {
        if (s.value == '' || s.value == ' - Search Bimba - ')
        {
            var q = document.getElementById('q');
            if (q)
                s.value = q.value;
        }
    }
}

// to apply a search when enter is pressed
function googleKeyPress(event)
{
    if (event.which || event.keyCode)
    {
        if ((event.which == 13) || (event.keyCode == 13))
        {
            googleSearch();
            return false;
        }
    }
    else
        return true;
} 

// call the google search
function googleSearch()
{
    var q = document.getElementById('q');
    var cof = document.getElementById('cof');
    var cx = document.getElementById('cx');
    window.location = 'Search2.aspx?q=' + encodeURIComponent(q.value) + 
        '&cof=' + encodeURIComponent(cof.value) + 
        '&cx=' + encodeURIComponent(cx.value);
}
