var agent = navigator.userAgent;
/*window.onerror = function(){return true;}*/
String.prototype.trim = function()
	{
		return this.replace(/(^[\s]*)|([\s]*$)/g, "");
	};
String.prototype.inc = function(k1, k2)
	{
		return k2 == null ? this.indexOf(k1) > -1 ? true : false : (k2 + this + k2) .indexOf(k2 + k1 + k2) > -1 ? true : false;
	};
String.prototype.toArray=function(key)
	{
		var l = this, v;
		if(key == null) key = "|";
		v = key;
		if(key == "n")
		{
			l = l.replace(/\r/g,"");
			v = "\n";
		}
		l = l.replace(new RegExp("(\\"+key+")+","g"), v).replace(new RegExp("^[\\" + key + "]*|[\\" + key + "]+$","g"), "");
		return l == "" ? new Array() : l.split(v);		
	};
Array.prototype.add = function(key)
{
	this[this.length] = key;
};
var is_Opr = agent.inc("Opera");
var is_IE = agent.inc("IE") && !is_Opr;
var is_IE4 = agent.inc("IE 4");
var is_IE5 = agent.inc("IE 5") || agent.inc("IE 4");
var is_IE5_5 = agent.inc("IE 5.5");
var is_IE6 = is_IE && !is_IE5;
var is_Moz = agent.inc("Mozilla") && !is_Opr && !is_IE;
function oo(obj){
	return typeof(obj) != "string" ? obj : (is_IE5 ? document.all(obj) : document.getElementById(obj));
}

function co(elm){
	return document.createElement(elm);
}
function doSelectForm(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "boxfiles")
       //e.checked = form.chkAll.checked;
	e.checked=!e.checked;
    }
}

//check domain begin
var dURL = window.location.href.toLowerCase();
if(dURL.indexOf("bestgo.com") <0 && window.location.href.indexOf("teapub")<0 && window.location.href.indexOf("localhost")<0){
	var path = document.location.pathname
}
//check domain end
function drop_mouseover(pos){
	try{window.clearTimeout(timer);}catch(e){}
}
function drop_mouseout(pos){
	var posSel=oo(pos+"Sel").style.display;
	if(posSel=="block"){
		timer = setTimeout("drop_hide('"+pos+"')", 2000);
	}
}
function drop_hide(pos){
	oo(pos+"Sel").style.display="none";
}
function search_show(pos,searchType,href){
    oo(pos+"SearchType").value=searchType;
    oo(pos+"Sel").style.display="none";
    oo(pos+"Slected").innerHTML=href.innerHTML;
    oo(pos+'q').focus();
    var sE = oo("searchExtend");
    if(sE != undefined && searchType == "bar" && pos=="head"){
    	sE.style.display="block";
    }else if(sE != undefined){
    	sE.style.display="none";
    }
	try{window.clearTimeout(timer);}catch(e){}
	return false;
}
function show_tab(n,m,tab_name,con_name,cls_name,cls_con)
{
	//alert(oo(tab_name+"_"+n).className);
	for(i=1;i<=m;i++){
		oo(tab_name+"_"+i).className=con_name;
		oo(tab_name+"_con_"+i).className="hidden";
	}
	oo(tab_name+"_"+n).className=cls_name;
	oo(tab_name+"_con_"+n).className=cls_con+' block';
}
function addFavorite()
{ 
   if (document.all) 
   { 
      window.external.addFavorite('http://www.bestgo.com','好股网-免费提供Topview数据T+1查询,机构增仓减仓查询,机构席位查询,主力动向查询,大智慧DDX排名及股票公式开发的交互平台'); 
   } 
   else if (window.sidebar)
   { 
      window.sidebar.addPanel('好股网-免费提供Topview数据T+1查询,机构增仓减仓查询,机构席位查询,主力动向查询,大智慧DDX排名及股票公式开发的交互平台', 'http://www.bestgo.com', ""); 
   } 
   return false;
}
function SearchTV()
{
	var $stkcode = oo('stockcode');
	if ($stkcode.value=='股票代码/名称/拼音')
	{
		alert('请输入股票代码/名称/拼音');
		return false;
	}else if ($stkcode.value.length<2 || $stkcode.value.length>8)
	{
		alert('请输入正确的股票代码');
		return false;
	}else{
		oo("tvfrm").action = "http://www.bestgo.com/topview/"+$stkcode.value+".html";
		oo("tvfrm").submit();
		return true;
	}
}
function SearchNews()
{
	if ($("#keywords").attr("value").length==0)
	{
		alert('请输入要查询的关键字');
		return false;
	}
	$("#newsform").attr("action","/search.asp");
	$("#newsform").bind("submit");
}
