var idx="0";var allEngineXml="js/allEngine.xml";var xmlcity="js/allEngineCity.xml";var isCountry=true;$(function(){$(".tips input").change(function(){if($(this).is(":checked")){hideWebsite($(this).val());return}$("#websites li").show();var a=$(".tips input:checked").length;if(a==0){return}$("#websites li").each(function(b){hideWebsite2($(this))})});$("#searchkey").focus(function(){$("#J_sBgOuter").addClass("focus");$("#searchkeyLabel").removeClass("labelshow")}).blur(function(){$("#J_sBgOuter").removeClass("focus");if($(this).val()==""){$("#searchkeyLabel").addClass("labelshow")}});$("#J_sMenu").hover(function(){$("#J_sBgOuter").addClass("focus");$("#searchkeyLabel").removeClass("labelshow");$("#J_sMenuContainer").show();$("#J_sMenu").addClass("expand");$("#J_sMenu").parent().addClass("expandmenu")},function(){$("#J_sMenuContainer").hide();$("#J_sMenu").removeClass("expand");$("#J_sMenu").parent().removeClass("expandmenu")});$("#J_sMenuSelected").click(function(){$("#J_sBgOuter").addClass("focus");$("#searchkeyLabel").removeClass("labelshow");$("#J_sMenuContainer").toggle();if($("#J_sMenuContainer").is(":visible")){$("#J_sMenu").addClass("expand");$("#J_sMenu").parent().addClass("expandmenu")}else{$("#J_sMenu").removeClass("expand");$("#J_sMenu").parent().removeClass("expandmenu")}});$("#J_sMenuList li a").click(function(b){b.preventDefault();$("#J_sMenuList li").removeClass("selected");$(this).parent().addClass("selected");var a=$(this).text()=="全国";if(a!=isCountry){isCountry=a;toggleCity()}$("#J_sMenuSelected span").text($(this).text());$("#J_sMenuContainer").toggle();$("#J_sMenu").removeClass("expand");$("#J_sMenu").parent().removeClass("expandmenu")});$("#mainContent h2 a").click(function(a){a.preventDefault();var b=$(this).attr("href")=="1"?true:false;$("#websites input").each(function(c){$(this).attr("checked",b)})});$("#menus").hide();$("#websites").hide();loadWebSite();$("#loading").hide();$("#menus").show();$("#websites").show()});function loadWebSite(){$("#websites").html("");var c=allEngineXml;var a=new ActiveXObject("MSXML2.DOMDocument");a.async=false;a.load(c);a.setProperty("SelectionLanguage","XPath");var e="";var f=0;var d;var b=0;$(a).find("engine").each(function(){var h=$(this).attr("k");if(h!="1"){return true}var p=$(this).attr("name");b++;var n=$(this).attr("id");var i=$(this).parent().attr("name");var j=$(this).attr("url");var o=$(this).attr("cfg");var l=$(this).attr("u");var m=$(this).attr("p");var g=$(this).attr("city");if(e==""){e=i;d=$("<ul></ul>")}if(e!=i){$("<div class='title'><span><a href='#' all='1' class='selectAll'>全选</a> <a href='#' all='0' class='selectAll'>全不选</a></span>"+e+"<a name='cate_"+f+"'></a></div>").appendTo($("#websites"));$("<li><a href='#cate_"+f+"'>"+e+"</a></li>").appendTo($("#menus"));f++;d.appendTo($("#websites"));$("<div class='clear-fix'></div>").appendTo($("#websites"));e=i;d=$("<ul></ul>")}var k=$("<li city='"+g+"' ext='"+$(this).attr("ext")+"'><input type='checkbox' id='"+n+"' url='"+j+"' cfg='"+o+"' u='"+l+"' p='"+m+"'><label for='"+n+"'>"+p+"</label></li>");k.appendTo(d)});if(d){$("<div class='title'><span><a href='#' all='1' class='selectAll'>全选</a> <a href='#' all='0' class='selectAll'>全不选</a></span>"+e+"<a name='cate_"+f+"'></a></div>").appendTo($("#websites"));$("<li><a href='#cate_"+f+"'>"+e+"</a></li>").appendTo($("#menus"));d.appendTo($("#websites"));$("<div class='clear-fix'></div>").appendTo($("#websites"));$("a.selectAll").click(function(g){g.preventDefault();var h=$(this).attr("all")=="1"?true:false;$("input",$(this).parent().parent().next()).each(function(j){$(this).attr("checked",h)})})}}function getSelectWebSites(){initArray();$("#websites input:checked").each(function(a){if(!$(this).is(":hidden")){selectUrls.push($(this).attr("url"));selectEngines.push($(this).attr("cfg"));selectIDs.push($(this).attr("id"));selectIsUTF8.push($(this).attr("u"));selectIsPost.push($(this).attr("p"));selectNames.push($(this).next().text())}});$("#websites input").attr("checked",false);return selectNames.length}function getCityValue(){var a=$("#J_sMenuSelected span").text();if(a=="全国"){a=""}return a}function getCityText(){return $("#J_sMenuSelected span").text()}function getSearchKey(){return $("#searchkey").val()}function toggleCity(){if(isCountry){$("#websites li").show();return}$("#websites li[city='0']").hide()}function initArray(){selectUrls.length=0;selectEngines.length=0;selectIDs.length=0;selectNames.length=0;selectIsUTF8.length=0;selectIsPost.length=0}function hideWebsite(a){$("#websites li").each(function(b){if($(this).attr("ext").charAt(a)=="0"){$(this).hide()}})}function hideWebsite2(a){var b=a.attr("ext");$(".tips input:checked").each(function(d){var c=$(this).val();if(b.charAt(c)=="0"){a.hide();return}})};