
    var searchFields = Array();
    var searchPhrases = Array();
    var searchLinks = Array();
    var searchActions = Array();
    var searchActionsBegin = Array();
    var searchActionsEnd = Array();
    var typeIcons = Array();
    var searchQuery = '';

            
        searchPhrases[6] = 'For example: Nokia 8800';
        searchLinks[6] = 'http://goods.us.marketgid.com/';
        searchActions[6] = 'http://goods.us.marketgid.com/search/';
        searchFields[6] = 'query';
        typeIcons[6] = '.png';
            
        searchPhrases[7] = 'Beyonce Rihanna Lady Gaga';
        searchLinks[7] = 'http://clipta.com/';
        searchActions[7] = 'http://clipta.com/search/<<searchQuery>>';
        searchFields[7] = '';
        typeIcons[7] = '.gif';
        var defaultId = 7;
    document.getElementById('hs-menu').innerHTML = '<li id="formSearch6"><img src="http://img.dt00.net/images/search/6/icon-2.png" id="hs_icon_6" border="0"><span onclick="setFormSearch(6)">Search Products</span></li><li id="formSearch7"><img src="http://img.dt00.net/images/search/7/icon-2.png" id="hs_icon_7" border="0"><span onclick="setFormSearch(7)">Video Search</span></li>';



    function setCookie( name, value, expires, path, domain, secure ) {

        var today = new Date();
        today.setTime( today.getTime() );

        if ( expires )
        {
        expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );

        document.cookie = name + "=" +escape( value ) +
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
        ( ( path ) ? ";path=" + path : "" ) +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
    }

    function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
            begin = dc.indexOf(prefix);
            if (begin != 0) return null;
        } else {
            begin += 2;
        }
        var end = document.cookie.indexOf(";", begin);
        if (end == -1) {
            end = dc.length;
        }
        return unescape(dc.substring(begin + prefix.length, end));
    }

    document.getElementById('hs-query').onclick = function(){
        for (i=0; i<searchPhrases.length; i++) {
            if (document.getElementById('hs-query').value == searchPhrases[i]) {
                document.getElementById('hs-query').value = '';
            }
        }
    }

    function disabledOldSearch(id){
        if (document.getElementById('formSearch' + id)) {
            document.getElementById('formSearch' + id).className = '';
            document.getElementById('hs_icon_'+id).src = dirImage +id+'/icon-2'+typeIcons[id];
        }
    }

    function setFormSearch(id){
        disabledOldSearch(searchId);
        if (!document.getElementById('formSearch'+id)) {
            id = defaultId;
        }
        document.getElementById('hs-query').name = searchFields[id];
        document.getElementById('hs-query').value = searchPhrases[id];
        document.getElementById('hs-form').action = searchActions[id];
        document.getElementById('hs-partner').href = searchLinks[id];
        document.getElementById('formSearch'+id).className = 'hs-menu-active';
        document.getElementById('hs-logo').src = dirImage +id+'/form.gif';
        document.getElementById('hs_icon_'+id).src = dirImage +id+'/icon-1'+typeIcons[id];
        searchId = id;
        setCookie('MGformStatus', searchId, 30, '/');
    }

    var dirImage = 'http://img.dt00.net/images/search/';
    var searchId = getCookie('MGformStatus')?parseInt(getCookie('MGformStatus')):defaultId;
    setFormSearch(searchId);

    document.getElementById('hs-form').onsubmit=function(){
        var words = document.getElementById('hs-query').value;
        words = words.split('For example:').join('');
        words = words.split('Например:').join('');
        url = searchActions[searchId]
        if (searchFields[searchId]) {
            url += '?'+searchFields[searchId]+'='+encodeURIComponent(words);
        }
        var template = searchActions[searchId];
        var start = template.indexOf('<<searchQuery>>');
        if (start > -1) {
            url = template.substr(0, start);
            url += encodeURIComponent(words);
            if (template.length != start+15){
                url += template.substr(start+15);
            }
        }

        url=url.replace("%2F","%252F");
        document.location=url;
        return false;
    }


