// 加入收藏
function AddFavor() {  
    try {
        window.external.addFavorite(window.location.href, window.document.title);  
    }catch (e){  
        try{  
            window.sidebar.addPanel(window.document.title, window.location, "");  
        }catch (e) {
			alert("加入收藏失败，请使用Ctrl+D进行添加");  
        }  
    }  
}
// 设为首页
function SetHome(obj,url1){ //obj:this 
	try{  
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(url1);  
	}catch(e){  
		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',window.location);  
		 }  
	}  
}

function dcookies(sName){
	var date = new Date();
	document.cookie = "dcusername=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuserinfo=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcusermingchen=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuserpass=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuserpubinfo=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuserpubs=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuserkeys=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_name=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_info=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_mingchen=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_pass=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_pubinfo=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_pubs=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "dcuser_keys=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "puser_pname=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "puser_pinfo=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
	document.cookie = "pi=;path=/;domain=eastmoney.com;expires=" + date.toGMTString();
}

function LogOut(){
	dcookies();
	self.location.reload();
}
function getCookie(key)
{
	 var cookieArray = document.cookie.split(";"); 
	 for(var i = 0; i < cookieArray.length; i++)
	 { 
	   var arr = cookieArray[i].split("="); 
	   if(arr[0].replace(" ","") == key)
	      return unescape(decodeURI(arr[1]));
	 }
	 return ""; 
}

function getnick()
{
	 var cVal = getCookie("pi");
	 if(cVal && cVal!=null && cVal!="")
	 {
		 var cVals = cVal.split(";");
		 return cVals[2].substring(0,12);
	 }
	 else
	 {
		 return "";
	 }
}

function search_tishi(str)
{
    var obj=document.getElementById('ghskeyword').value;
    if(obj=="请输入基金代码"||obj=="请输入证券代码"||obj=="请输入吧名关键字"||obj=="请输入标题关键字"||obj=="请输入作者名称"||obj=="输代码、名称或拼音缩写")
    {
        document.getElementById('ghskeyword').value=str;
    }
}

function shuaxin1(url)
{
    document.getElementById("quoteimg").src="http://hqpicr.eastmoney.com/mrchart/"+url+".gif?"+Math.random();
}

function shuaxin(url)
{
    document.getElementById("quoteimg").src="http://j1.dfcfw.com/chart/d3/"+url+".png?"+Math.random();
}

function search1()
{
    var bb=document.getElementById("form_2");
	var search_content=escape(document.getElementById("ghskeyword").value);	
	var search_type;
	var url="http://fund2.eastmoney.com/search.aspx";
	if(bb.search_type[1].checked){url='http://fund2.eastmoney.com/search1.aspx';}
	if(bb.search_type[0].checked)
	{
		if(search_content.indexOf("%u57FA%u91D1")>-1||search_content.indexOf("%u540D%u79F0")>-1||search_content=="")
		{
		    //alert("请输入证券代码!");
		    window.open('http://fund2.eastmoney.com/');
		}
		else
		{
		    if(search_content>'aaa')
		    {
		    window.open('http://quote.eastmoney.com/search.html?stockcode='+search_content+'&toba=1');
		    }
		    else
		    {
		    window.open('http://fund2.eastmoney.com/topic,'+search_content+'.html');
		    }
		}
		return false;
	}	
	if(bb.search_type[0].checked){search_type=bb.search_type[0].value;}
	if(bb.search_type[1].checked){search_type=bb.search_type[1].value;}
	if(bb.search_type[2].checked){search_type=bb.search_type[2].value;}
	if(bb.search_type[3].checked){search_type=bb.search_type[3].value;}
	window.open(url+"?search_content="+search_content+"&search_type="+escape(search_type));
	return false;
}

function search2(aa)
{
    aa1=escape(aa.value);
    if(aa1.indexOf("%u57FA%u91D1")>-1||aa1.indexOf("%u540D%u79F0")>-1)
    {
        window.open("http://fund.eastmoney.com/fund.html");
    }
    else
    {
	    window.open("http://fundacc2.eastmoney.com/fundsearch.aspx?search_type=%BB%F9%BD%F0%BE%BB%D6%B5&search_content="+aa1);
	}
}
