﻿function test() {
    alert('hello');
}

function searchWithType(term, searchtype) {
    var url = '/Search/?cx=000852135505018975094%3Amlw_zsapbk0&cof=FORID%3A11%3BNB%3A1&q=' + term;
    var ws = 'product catalog';
    if (searchtype == ws) {
        url = '/Catalog/Search.aspx?q=' + term;
    }
    document.location = url;
    return true;
}

function search(term) {
    var searchType = 'web site';
    var wsElem = $get('rdo_search_product');
    if (wsElem && wsElem.checked)
        searchType = wsElem.value;
    searchWithType(term, searchType);
}

function EnterGoogle(SearchInput, evt) {
    var mozKey = evt.which;     //firefox
    if (mozKey == 13 && SearchInput.value != "") {
        search(SearchInput.value);
        return false;
    }
    if (window.event && window.event.keyCode == 13 && SearchInput.value != "") {
        search(SearchInput.value);
        return false;
    }
    else {
        return true;
    }
}

function SiteSeachBtnClick(searchBox) {
    search(searchBox.value);
}


//get the querystring from 
var queryString = window.top.location.search.substring(1);

function getParameter(queryString, parameterName) {
    // Add "=" to the parameter name (i.e. parameterName=value)
    var parameterName = parameterName + "=";
    if (queryString.length > 0) {
        // Find the beginning of the string
        begin = queryString.indexOf(parameterName);
        // If the parameter name is not found, skip it, otherwise return the value
        if (begin != -1) {
            // Add the length (integer) to the beginning
            begin += parameterName.length;
            // Multiple parameters are separated by the "&" sign
            end = queryString.indexOf("&", begin);
            if (end == -1) {
                end = queryString.length
            }
            // Return the string
            return unescape(queryString.substring(begin, end));
        }
        // Return "null" if no parameter has been found
        return "null";
    }
}    

function setChecked(wsElem)
{
    if (wsElem )
    {
        wsElem.checked = true;
        return false; 
    }
    return true;        
} 
