// JavaScript Document
function checkSubStock(obj){
	var stockCode = $(obj).find("input.stockCode").val();
	//if(stockCode.length==6 && stockCode.replace(/\d{6}/ig,"").length==0) { return true; }
	//else { alert("请输入正确的股票代码");return false; }
	var thisShares = _searchShare(stockCode);
	if (thisShares.length>0) {
		var thisShare=thisShares[0];
		var codeNum = thisShare.code;
		$(obj).find("input.stockCode").val(codeNum);
		return true;
	} else { alert("请输入正确的股票代码"); return false;}
}
$(".hasStockCode").submit(function(){return checkSubStock(this);});
$(".stockCode").focus(function(){
	if ($(this).val()=="股票名称/代码/拼音缩写"){
		$(this).val("");
	}
});
$(".stockCode").blur(function(){
	if ($(this).val()==""){
		$(this).val("股票名称/代码/拼音缩写");
	}
});
$(".tvBtn").click(function(){
	$(this).siblings('#tvFrmType').val('totalview');
	var formObj = $(this).parent("form").get();
	if (checkSubStock(formObj)) { $(formObj).submit(); }
});
$(".ddeBtn").click(function(){
	$(this).siblings('#tvFrmType').val('dde');
	var formObj = $(this).parent("form").get();
	if (checkSubStock(formObj)) { 
		$(formObj).attr("action","http://www.chaoying.org.cn/superview/DDE.asp");
		$(formObj).submit(); 
	}
});
$("form[name='xw']").submit(function(){
	var jgCode = $(this).find("input.jgdm").val();
	if(jgCode.length>2 && jgCode.replace(/[\da-zA-Z]+/ig,"").length==0) { return true; }
	else { alert("请输入正确的席位代码");return false; }
});
$.get("/superview/include/tvDateList.htm",function(data){
		if (data) {
			$("form.hasStockCode").find("select.superview_date").html(data);
		}
	});
$.get("/TotalView/include/tvDateList.htm",function(data){
		if (data) {
			$("form.hasStockCode").find("select.totalview_date").html(data);
		}
	});

//if (!GetCookie("favJS")) {
//	$(window).unload(function(){addfav('中国赢富网：Topview免费查询','http://www.chaoying.org.cn');SetCookie("favJS", "1", 90*24*60*60);});
//}
