
jQuery('document').ready(function() {
	jQuery('#searchtext').attr("autocomplete","off");
	jQuery("#searchtext").focus().autocomplete('/wwhf/include/getstocks.php',{
		minChars: 2,
		dataType: "json",
		max:20,
		delay:400,
		mustMatch :false,
		selectFirst :true,
		matchContains: "word",
		autoFill: false,
		parse: function(data) {
			return jQuery.map(data, function(row) {
				return {
					data: row,
					value: row.name,
					result: row.to
				};
			});
		},
		formatItem: function(item) {
			return item.name;
		},
		formatMatch: function(item) {
			return item.name;
		},
		formatResult: function(item) {
			return item.to;
		}
	});
		
	jQuery('#searchtext').focus(function(){	
		if(jQuery(this).val()=="请输入股票简称/股票代码/拼音缩写"){
			jQuery(this).select();
			jQuery(this).css("color","black");	
		}
	}).click(function(){	
		if(jQuery(this).val()=="请输入股票简称/股票代码/拼音缩写"){
			jQuery(this).val("");
			jQuery(this).css("color","black");	
		}
	})
	.blur(function(){
		if(jQuery(this).val()==""){
			jQuery(this).val("请输入股票简称/股票代码/拼音缩写");
			jQuery(this).css("color","#908F8F");	
		}else if (jQuery(this).val()!="请输入股票简称/股票代码/拼音缩写"){
//			jQuery(this).search();
		}
	}).keypress(function(event){
		 if(event.keyCode==13)
			 jQuery('#btnGo').click();
	});
	jQuery('#btnGo').click(function() {
		var key = jQuery('#searchtext').val();
        if(key=="请输入股票简称/股票代码/拼音缩写")return false;
        jQuery.getJSON('/bbs/wwgp/baike_search.php?jsoncallback=?',{ 'key': key }, retInfo);
		return false;	
     });
	jQuery('#btnSearch').click(function() {
         if(jQuery('#searchtext').val()=="请输入股票简称/股票代码/拼音缩写")return false;
         //jQuery('#searchform').attr('action','/wiki/index.php?search-fulltext');
         jQuery('#searchtext').attr('name','srchtxt');//论坛搜索使用
         jQuery('#searchform').attr('action','/bbs/bbs_search.php');
         jQuery('#searchform').submit();
     });
	jQuery(".c2_title :img").click(function(){			
		$ul=jQuery(this).parent().next();
		if($ul.is(":visible"))
		{ $ul.hide(); jQuery(this).attr("src","/supesite/templates/default/images/san2.gif"); }
		
		else{ $ul.show(); jQuery(this).attr("src","/supesite/templates/default/images/san1.gif");}
	});
  });
  function retInfo(data) {  // 
      if (data[0].count >= 1) {
    	  jQuery("#searchtext").val(data[0].key);            
      }
      jQuery('#searchform').submit();
 }
  
 function addHome()
 {      
      if(document.all){
          document.body.style.behavior='url(#default#homepage)';
          document.body.setHomePage('http://www.wwgupiao.com/');
      }else if (window.sidebar){
          if(window.netscape){
              try{
                  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
              }catch (e){
                  alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
              }
          }
          var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
          prefs.setCharPref('browser.startup.homepage','http://www.wwgupiao.com/');
      }
  }
 
 
 
