﻿
function AttachEvent(type, target, handler)
{
    var eventHandler = handler;
    
    if(window.document.all)
            target.attachEvent("on" + type, eventHandler );
    else
            target.addEventListener(type, eventHandler, false);
            
}

function Exist(src){
    if(src && src!=undefined && src!="undefined"){
        return true;
    }
    else{
        return false;
    }
}


function copyToClipBoard(){
    try{
    window.clipboardData.setData("Text",top.location.href);
    alert("成功复制网址，您可以黏贴到QQ或者MSN中推荐给好友！");
    }catch(e){}
}	

function SetButtonToWaite(src,second){
    src.disabled = "true";
    src.value="发表评论("+second+")";
    
    var interval=window.setInterval(IntervalFundtion,1000);
    
    function IntervalFundtion(){
        if(second>0){
            src.value="发表评论("+second+")";
            second--;
        }else{
            src.value="发表评论";
            src.disabled = "";
            window.clearInterval(interval);
            
        }
    }
}

function FindNextSibling(){
    
}

var __ClientID__Pre__="";

function CloneValue(fromSrc,toSrc){
    document.getElementById(toSrc).value=document.getElementById(fromSrc).value;
}
function BoardLinkOnChange(){
    var src=document.getElementById("BoardLink");
    var option=src.options[src.selectedIndex];
    if(option.value!=""){
        window.location.href=option.value;
    }
}




    function addFavorite(title,url) {
	    if ( window.sidebar && window.sidebar.addPanel ) {
				        window.sidebar.addPanel( title , url, "" );
				    }
				    else {
				        window.external.addFavorite( url , title );
				    }
	}			    
				
	function setHomePage(url)
	{
		if(document.all) {
				        window.setHomePage( url);
		}
		else {
		    if(window.netscape) {
				try {
				      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
				    }
				catch (e) {
				     alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
				    }
			}
		var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
				            prefs.setCharPref("browser.startup.homepage",url);
	     }
     }
				    
        
        
   function Show(bar,company,fundBar,fundCompany)
        {
           document.getElementById(fundBar).style.display = "";
           document.getElementById(bar).style.cursor = "hand";
           document.getElementById(bar).className = "m_l";
           
           document.getElementById(fundCompany).style.display = "none"; 
           document.getElementById(company).style.cursor = "hand";
           document.getElementById(company).className = "m_2";
        }
        
    function GoSearch()
        {
            var str=document.getElementById("content").value;
            if(str==""){
            
                alert("输入关键字");
                document.getElementById("content").focus();
                return;
            }
            
            var condition = document.getElementById("select").value;
            
            if(condition == "1")
                window.open('/TitleSearch.aspx?Keywords='+ escape(str) +'&condition='+condition);
            else if(condition == "3")
                window.open('/UserPost.aspx?UserName='+ escape(str) );
            else
            {}
                           
                            
        }       
        
    function AutoScroolSelect(objSelect, evt)
    {
	    var KeywordList = "b|宝|c|长|d|大|f|富|g|工|h|海|j|嘉|n|南|p|鹏|r|融|s|上|t|泰|w|万|x|新|y|易|z|招";
	    var arrKeyItem;
	    arrKeyItem = KeywordList.split("|");
    	
	    var keyCode = String.fromCharCode(evt.keyCode);
	    keyCode = keyCode.toLowerCase();

	    var Keyword = "";
	    for (var i = 0; i < arrKeyItem.length; i += 2)
	    {
		    if (keyCode == arrKeyItem[i])
		    {
			    Keyword = arrKeyItem[i + 1];
    			
			    for (i = 0; i < objSelect.length; ++i)
			    {	
				    if (0 == objSelect.options[i].text.indexOf(Keyword))
				    {
					    objSelect.selectedIndex = i;
					    break;
				    }
			    }
			    break;
		    }
	    }
    } 
    
    function AutoMatchSelect(objSelect)
    {
	    var KeywordList = "b|宝|c|长|d|大|f|富|g|工|h|海|j|嘉|n|南|p|鹏|r|融|s|上|t|泰|w|万|x|新|y|易|z|招";
	    var arrKeyItem;
	    arrKeyItem = KeywordList.split("|");
    
	    var Keyword = "";var keyCode = "";
	    for (var i = 0; i < arrKeyItem.length; i += 2)
	    {
		    Keyword = arrKeyItem[i + 1];
    		
    		for (j = 0; j < objSelect.length; ++j)
			{	
				if (0 == objSelect.options[j].text.indexOf(Keyword))
				{
					keyCode = arrKeyItem[i];
				}
				
				objSelect.options[j].text = keyCode + "-" + objSelect.options[j].text;
			}
			
			    
	    }
    } 
    
    function ShowGG(gg1,gg2)
    {
        document.getElementById(gg1).style.display = "none";
        document.getElementById(gg2).style.display = "";
    } 
    
    function XhChangeValue()
    {
        var Word = "null";
        var _word = "";
        var CurrWord = "";
        var aOption = document.getElementById("FundCompany").options;
        var Interval = "";
        
        if(document.attachEvent)
            Interval = "&nbsp;&nbsp;&nbsp;";
        else
            Interval = "&nbsp;&nbsp;";
        
        for(var i=1; i<aOption.length; i++)
        {
            _word = aOption[i].text;
            
            CurrWord = Find(_word);
            if(CurrWord == "null")
            {
                aOption[i].innerHTML = Interval + aOption[i].text;
                Word = "null";
            }
            else if(Word != CurrWord)
            {
                aOption[i].text = CurrWord.toUpperCase() + "-" + aOption[i].text;
                Word = CurrWord;
            }
            else
            {
                aOption[i].innerHTML = Interval + aOption[i].text;
                
            }               
        }
    }
    var ValueWord = new Array("宝","长","大","富","工","海","嘉","南","鹏","融","上","泰","万","新","易","招");
    var KeyWord = new Array("b","c","d","f","g","h","j","n","p","r","s","t","w","x","y","z");
    
    function Find(Name)
    {
        var OneWord = Name.substring(0,1);        
        for(var i = 0; i < 16; i++)
        {
            if(OneWord == ValueWord[i])
            {
                return KeyWord[i];
                break;
            }
        } 
        return "null";
    }    
    
    
    
    