	function $(id) {
		return document.getElementById(id);
	}
	function GetObjValue(objName)
{
	if(document.getElementById)
	{
		return eval('document.getElementById("'+objName+'")');
	}
	else
	{
		return eval('document.all.'+objName);
	}
}

	function gotoLookupN_0() {
		var value = $("no").value.replace(/s[hz]/, "");
		if (value != "股票代码/名称/拼音" && value != "") {
		    var stringUrl = "";
			var stringUrl = "http://chaguwang.cn/showtp.php?no=@CODE@&date="+GetObjValue("date").value;
			window.open(stringUrl.replace("@CODE@", value),"_self");
		}
	}

	var suggestStock_0 = new Suggest("no", "股票代码/名称/拼音", astock_suggest, null, StockSuggestConfiguration, gotoLookupN_0);
	suggestStock_0.options[12] = false;
if ($("countrySelect_0") !=undefined)
{
	$("countrySelect_0").value = "stock";
}
if ($("suggest_radio_lookupn") !=undefined)
{
	$("suggest_radio_lookupn").checked = true;
}
	
	var suggestStock_tuijian = new Suggest("i_mark_target", "股票代码/名称/拼音", astock_suggest, null, StockSuggestConfiguration);
	suggestStock_tuijian.options[12] = false;

var RecommondStock = {
optionUrl : "http://mark.sina.com.cn/v2/GetData.php?p_mark=jgdc" ,
			weekUrl : "http://mark.sina.com.cn/v2/GetTopDataList.php?p_mark=jgdc&need=week_num|info_name&num=6&order_by=week_num&all_num=week_num",
			pool : new Array(),
			tagArr : {},
			init : function(){
				var loader = new IO.Script();
				loader.load(this.weekUrl , this.checkTop.Bind(this));
				$("i_mark_target_form").onsubmit = this.checkStock.BindForEvent(this);
			},
checkTop : function(){
			   this.pool = new Array();
			   this.tagArr = {};
			   var user_num = week_num;
			   for( key in user_num){
				   this.pool.push(parseInt(user_num[key]));
				   this.tagArr[key] = false;
			   }
			   this.pool = this.pool.sort(function (a, b) {
					   if (a < b) {
					   return -1;
					   }
					   else if (a > b) {
					   return 1;
					   }
					   else {
					   return 0;
					   }
					   });
			   this.getTop(user_num , all_num , info_name);

		   },
				 /*<tr>
				 </tr>
				 */
getTop : function(user_num , all_num , info_name){
			 for(var i=this.pool.length-1;i>=0;i--){
				 for(key in user_num){
					 if(user_num[key] == this.pool[i] && this.tagArr[key]==false){
						 var rate = (parseFloat(user_num[key]/all_num)).toFixed(4)*100;
						 var row = $("pool").insertRow(-1);
						 var nameCell = row.insertCell(-1);
						 nameCell.innerHTML = "<a href='http://biz.finance.sina.com.cn/suggest/lookup_n.php?country=stock&q="+ info_name[key] +"' target='_blank'>" + info_name[key] + "</a>";
						 var botCell = row.insertCell(-1);
						 botCell.className = "ctdBar";
						 botCell.innerHTML = '<div class="cbarBorder"><div class="cbar" style="width:'+rate+'%"></div></div>';
						 var numCell = row.insertCell(-1);
						 numCell.className = "ctdNum";
						 numCell.innerHTML = user_num[key]+"票";
						 this.tagArr[key] = true;
					 }
				 }
			 }
		 },
checkStock : function( obj){
 if (suggestStock_tuijian) {
  var result = suggestStock_tuijian .getData($("i_mark_target").value);
  if (result != null) {
   if (result.length == 2 && result[0].join(",") == result[1].join(",")) {
	result = result[0];
   }
   $("i_mark").value = result[1].replace(/s[hz]/, "");
   $("stockName").value = result[2];
   return true;
  }
 }
 var pattern = /^\d{6}$/i;
 if($("i_mark_target").value.length>0 && $("i_mark_target").value.match(pattern)==null){
  alert("股票代码只能是六位数字");
  return false;
 }
 else{
  $("i_mark").value = $("i_mark_target").value;
  //这里是把股票的汉字简称赋值给stockName隐藏字段
  //$("stockName").value = $("i_mark_target").value;
 }
 return true;
},
clear : function(){
			$("i_mark_target").value='';
		}
};

	RecommondStock.init();
