﻿function zwxwload()
{ 
  document.getElementById("cp").style.backgroundImage="";
  document.getElementById("qy").style.backgroundImage="";
  document.getElementById("zx").style.backgroundImage="";
  document.getElementById("qy").style.color = "";
  document.getElementById("cp").style.color = "";
  document.getElementById("zx").style.color = "";
  document.getElementById("cp").style.fontWeight="normal";
  document.getElementById("qy").style.fontWeight="normal";
  document.getElementById("zx").style.fontWeight="normal";
  document.getElementById("qy").style.width="42";
  document.getElementById("zx").style.width="42";
  
 
}
function zwxwchange(liid)
{
  zwxwload();
  if(liid==null) return;
  document.getElementById(liid).style.backgroundImage="url(/img/cp.jpg)";
  document.getElementById(liid).style.color = "#FB7708";
  document.getElementById(liid).style.fontWeight = "bold";
  document.getElementById("qy").style.width="54";
  document.getElementById("zx").style.width="54";
  
 }
 function click_qy()
 { 
    document.getElementById("s1").style.display = "none";
    document.getElementById("s2").style.display = "none";
    var url= document.getElementById("qy").target;  
    document.getElementById("fSearch").action=url;
 }
  function click_zx()
 {
    document.getElementById("s1").style.display = "block";
    document.getElementById("s2").style.display = "none";
    var url= document.getElementById("zx").target;   
    document.getElementById("fSearch").action=url;
    
 }
function click_cp()
 {
    document.getElementById("s1").style.display = "none";
    document.getElementById("s2").style.display = "block";
    var url= document.getElementById("cp").target;  
//    var keywords=document.getElementById("SearchKeyWords").value;
//    var URL=url+"?KeyWords="+escape(keywords); 
    document.getElementById("fSearch").action=url;
 }
 function click_load()
 {
    document.getElementById("gyxx_img").style.backgroundImage="url(/img/dhs.jpg)";
    document.getElementById("qgxx_img").style.backgroundImage="url(/img/dhs.jpg)";
   
 }
 function click_load2()
 {
    
    document.getElementById("gyxx_img2").style.backgroundImage="url(/img/dhs.jpg)";
    document.getElementById("qgxx_img2").style.backgroundImage="url(/img/dhs.jpg)";
 }
   function click_gyxx(httppath,liid)
 {
    click_load();
    if(liid==null) return;
    document.getElementById("qgxx_con").style.display = "none";
    document.getElementById("gyxx_con").style.display = "block";
    document.getElementById("alink").href=httppath;
    document.getElementById(liid).style.backgroundImage="url(/img/dad.jpg)";
 }
   function click_qgxx(httppath,liid)
 {
    click_load();
    if(liid==null) return;
    document.getElementById("qgxx_con").style.display = "block";
    document.getElementById("gyxx_con").style.display = "none";
    document.getElementById("alink").href=httppath;
    document.getElementById(liid).style.backgroundImage="url(/img/dad.jpg)";
 }
 function click_gyxx2(httppath,liid)
 {
    click_load2();
    if(liid==null) return;
    document.getElementById("qgxx_con2").style.display = "none";
    document.getElementById("gyxx_con2").style.display = "block";
    document.getElementById("alink2").href=httppath;
    document.getElementById(liid).style.backgroundImage="url(/img/hs2.jpg)";
 }
   function click_qgxx2(httppath,liid)
 {
    click_load2();
    if(liid==null) return;
    document.getElementById("qgxx_con2").style.display = "block";
    document.getElementById("gyxx_con2").style.display = "none";
    document.getElementById("alink2").href=httppath;
    document.getElementById(liid).style.backgroundImage="url(/img/hs2.jpg)";
 }
 
 
 
 $(function() {
    if ($.browser.msie) {
        $('#SearchKeyWords').bind('propertychange', function() {
            I();
        });
    } else if ($.browser.mozilla) {
        $('#SearchKeyWords').bind('input', function() {
            I();
        });
    }


    $().bind('click', function(e) {
    KeyWords.close(); 
    });

    function I() {
        var sw = $('#SearchKeyWords').val(); 
        if (sw == '') {
            KeyWords.close();
        } else if (KeyWords.lastWords != sw) {
            KeyWords.lastWords = sw;
            KeyWords.getLikely(KeyWords.lastWords);
        }
    }
});
var KeyWords = {
    lastWords: '',
    txtID: 'SearchKeyWords',
    divID: 'divLikely',
    show: function(sArr) { 
        if (document.getElementById(this.divID) == null) { 
            var tip = document.createElement('DIV');
            tip.setAttribute("id", this.divID);
            document.body.appendChild(tip);
            var dv = $('#' + this.divID);
            var sw = $('#' + this.txtID);
            var w = $(sw).width();
            var h = $(sw).height();
            var p = $(sw).offset();
            var _t = p.top + h + 3;
            var _l = p.left + 2;
            var _w = w - 5; 
            $(dv).css('position', 'absolute').css('top', _t).css('width', _w).css('left', _l); 
            $(dv).css('text-align','left');
        }
        var k = '<ul>'
        for (var i = 0; i < sArr.length; i++) {
            k += '<li onclick="KeyWords.setValue(\'' + sArr[i] + '\');" onmouseover="this.style.backgroundColor=\'#36c\'" onmouseout="this.style.backgroundColor=\'#fff\'">' + sArr[i] + '</li>';
        }
        k += '</ul>';
        $('#' + this.divID).html(k);
        if (sArr.length > 0) {
            $('#' + this.divID).css('display', 'block');
        } else {
            this.close();
        }
    },
    getLikely: function(input) {
        var arr = new Array();  
        if (input.replace(/^\s*/, "").replace(/\s*$/, "") != '') {
            //http://182.168.10.177:19993 
            $.post(
                '/XMl/XMLKeyWords.aspx',
                { keywords: input },
                function(xml) {
                    $(xml).find('Item').each(function() {
                        arr[arr.length] = $(this).attr('value'); 
                    });
                    KeyWords.show(arr);
                },
                "xml"
                
            );
        }
        return arr;
    },
    close: function() {
        $('#' + this.divID).css('display', 'none');
    },
    setValue: function(v) {
        this.lastWords = v;
        $('#' + this.txtID).val(v);
        this.close();
    }
};
 