﻿<!--
var Code = 0;
var text_enter_url      = "请输入连接网址";
var text_enter_txt      = "请输入连接说明";
var text_enter_image    = "请输入图片网址";
var error_no_url        = "您必须连接网址";
var error_no_txt		= "您必须连接说明";
var error_no_gset       = "必须正确按照各式输入！";
var error_no_gtxt       = "必须输入文字！";
function commentWrite(NewCode) {
	document.getElementById("content").value+=NewCode;
	document.getElementById("content").focus();
	return;
}
function Cbold() 
{
	fontbegin="[B]";
	fontend="[/B]";	
	fontchuli();
}
function doSize()
{
    return true;
}
function Curl() 
{
    var AddTxt;
       txt2=prompt("链接文本显示.\n如果不想使用, 可以为空, 将只显示超级链接地址. ","");
        if (txt2!=null) {
            txt=prompt("超级链接.","http://");
            if (txt!=null) {
                if (txt2=="") {
                    AddTxt="[a]"+txt+"[/a]";
                 } else {
                    AddTxt="[a='"+txt+"' target='_blank']"+txt2+"[/a]";
                 }
            }
        }
    document.getElementById("content").value+=AddTxt;	
	document.getElementById("content").focus();
}
function specialchar(){
	var ret ;
	window.open("/inc/setWords.htm","win","menubar=no,resizable=yes,scrollbars=no,status=no,width=500,height=500,location=no");
}

function AddText(text) {
		if(document.all){
			insertAtCaret(document.getElementById("content"), text);
		} else{
			document.getElementById("content").value +=	text;
		}
		setfocus();
}

function AddPhoto(text) {
		if(document.all){
			insertAtCaret(document.getElementById("content"), text);
		} else{
			document.getElementById("content").value +=	text;
		}
		setfocus();
}

function UpMusicMove(host)
{
    window.open("http://post.music.hexun.com/UploadSpaceCover.aspx?type=2&host="+host,"插入音乐视频", "height=500, width=640, top=150, left=150, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
}

function insertAtCaret (area,	text){
		if (area.createTextRange && area.caretPos){
				var	caretPos = area.caretPos;
				caretPos.text += caretPos.text.charAt(caretPos.text.length - 2)	== ' ' ? text +	' '	: text;
		} else if(area) {
				area.value +=	text;
		} else {
			area.value = text;
		}
}

function setfocus()	{
	document.getElementById("content").focus();
}

function storeCaret	(area){
		if(area.createTextRange){
				area.caretPos	= document.selection.createRange().duplicate();
		}
}
function popwSingleUpload(host)
{
	var a;
	target=window.location.hostname.substring(0,window.location.hostname.indexOf('.hexun.com'));
	a = window.open("http://post.photo.hexun.com/upload/tiebaupload.aspx?url="+target+"&host="+host,"uploadphoto","scrollbars=no,left=100,top=100,height=356,width=600");
}
function FileUpload(host)
{
    var a;
	a = window.open("http://hexun.com/UpLoadExpertFile.aspx?host="+host,"fileupload","scrollbars=no,left=100,top=100,height=356,width=600");
}
function fontchuli()
{
	if ((document.selection)&&(document.selection.type == "Text")) 
	{
		var range = document.selection.createRange();
		var ch_text=range.text;
		range.text = fontbegin + ch_text + fontend;
	} 
	else 
	{
	document.getElementById("content").value=fontbegin+document.getElementById("content").value+fontend;
	document.getElementById("content").focus();
	}
}
function fontchuliurl()
{
	if ((document.selection)&&(document.selection.type == "Text")) 
	{
		var range = document.selection.createRange();
		var ch_text=range.text;
		range.text = fontbegin + ch_text + fontend;
	} 
	else 
	{
	var FoundErrors = '';
	var enterTxT   = prompt(text_enter_txt, "");
	if(!enterTxT)
	   	FoundErrors += error_no_txt;
	if(FoundErrors)
		return;
	var ToAdd = "[URL]"+enterTxT+"[/URL]";
	document.getElementById("content").value+=ToAdd;	
	document.getElementById("content").focus();
	}
}
function funSearch()
{
    if(document.getElementById("sw").value =="")
	{
		alert("必须输入搜索条件！");
		return false;
	}
}
function funCheck()
{
	if(document.getElementById("content").value =="")
	{
		alert("内容必添！");
		return false;
	}
	
	if(document.getElementById("reason").value =="")
	{
		alert("修改原因必添！");
		return false;
	}
	return true;
}
function getValue(){
    //alert(document.getElementById("content").value);//..form1.getElementsByTagName("content"));
    document.pre.pretitle.value = document.getElementById("title").value;  
	document.pre.prelemma.value = document.getElementById("content").value;
	document.pre.pretag.value = document.getElementById("tags").value;
	document.pre.preref.value = document.getElementById("reference").value;
	gotoPreview();
}
function gotoPreview(){
	document.pre.submit();
}
function inFace (emotcode) {
	var current=document.getElementById('content');
	var emot = '[f:'+emotcode+']';
	if (current) {

		if (current.value!='' && current.value!=null) {
			document.getElementById("content").value+=emot;
		}
		else {
			document.getElementById("content").value=emot;
		}
	}
}
//文章引用
function Quote(aID)
{
    //aID文章ID
    document.getElementById('AQuote').value=aID;
    document.form2.content.focus();
    commenttag.innerHTML += '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
}
//评论引用
function CommentQuote(cID)
{
    //评论ID
    document.getElementById('CQuote').value=cID;
    document.form2.content.focus();
    commenttag.innerHTML += '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
}
//基金吧文章引用
function StockQuote(aID)
{
    //aID文章ID
    if(document.all)
    {
        window.frames["a1"].document.getElementById('AQuote').value=aID;
        //window.frames["a1"].editor.focusEditor();
        window.frames["a1"].commenttag.innerHTML = '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
    }
    else
    {
        document.getElementById("a1").contentWindow.document.getElementById("AQuote").value=aID;
        document.getElementById("a1").contentWindow.document.getElementById("content").focus();
        document.getElementById("a1").contentWindow.document.getElementById("commenttag").innerHTML = '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
    }
}
//基金吧评论引用
function StockCommentQuote(cID)
{
    //评论ID
    if(document.all)
    {
        window.frames["a1"].document.getElementById('CQuote').value=cID;
        window.frames["a1"].commenttag.innerHTML = '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
    }
    else
    {
        document.getElementById("a1").contentWindow.document.getElementById("CQuote").value=cID;
        document.getElementById("a1").contentWindow.document.getElementById("content").focus();
        document.getElementById("a1").contentWindow.document.getElementById("commenttag").innerHTML = '【引用评论】<span onclick=cancelquote(); style="cursor:hand; color:ff0000;">【取消引用】</span>'; 
    }
}
//取消引用
function cancelquote()
{
    document.getElementById('AQuote').value='0';
	document.getElementById('CQuote').value='0';
	commenttag.innerHTML = '';
}
//快速回复
function RComment()
{
    document.getElementById("content").focus();
}
//基金吧快速回复
function StockRComment()
{
    if(document.all)
    {
        
    }
    else
    {
        document.getElementById("a1").contentWindow.document.getElementById("content").focus();
    }
}
function popwUnionTopic()
{
	var a;
	var target=window.location.hostname.substring(0,window.location.hostname.indexOf('.hexun.com'));
	//a = window.open("http://post.photo.hexun.com/upload/WikiUpload.aspx?url="+target,"uploadphoto","scrollbars=no,left=100,top=100,height=356,width=600");
	a = window.open("http://bar.hexun.com/TopicUnionList.aspx?TopicID=1234","uploadphoto","scrollbars=no,left=100,top=100,height=180,width=380");
}

function CheckOthers(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
			if (e.checked==false)
			{
				e.checked = true;
			}
			else
			{
				e.checked = false;
			}
	}
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
			e.checked = true
	}
}

function UnCheckIN()
{
    alert("必须登陆才能添加联盟吧");
}

//关闭子窗口并刷新父窗口
function UpdataReloadWindow()
{
    window.opener.location.reload();
    window.close();
}
//收藏到网摘
function bookmarkThis()
{
	t=document.title;
	u=location.href;
	e=document.selection?(document.selection.type!='None'?document.selection.createRange().text:''):(document.getSelection?document.getSelection():'');
	void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&amp;url='+escape(u)+'&amp;excerpt='+escape(e),'HexunBookmark','scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes'));	
}

function copytitle(ArticleID,Title,Url) 
{		
	//var copyText="http://bar.hexun.com/d/"+ArticleID+".html";
	window.clipboardData.setData("Text",Url);
	alert("文章"+ Title + "已经拷贝到剪贴板！\n\n您可以使用（Ctrl+V或鼠标右键）粘贴功能");

}

function copytopic(TopicID,TopicName) 
{		
	var copyText="http://bar.hexun.com/t/"+TopicID+".html";
	window.clipboardData.setData("Text",copyText);
	alert(TopicName + "吧已经拷贝到剪贴板！\n\n您可以使用（Ctrl+V或鼠标右键）粘贴功能");

}

function checksubmit()
{
    a_title = document.form1.title.value;
    a_content = document.form1.content.value;
    document.form1.title.value=f_trim(a_title);
    document.form1.content.value=f_trim(a_content);

    if(document.form1.topicid.value=="")
	{
		alert("请选择要提交的吧！");
		return false;
	}
	
    if(document.form1.title.value=="")
	{
		alert("标题不能为空");
		document.form1.title.focus();
		return false;
	}
	
	if(document.form1.content.value=="")
	{
		alert("内容不能为空!");
		document.form1.content.focus();
		return false;
	}
	if(document.form1.checkimg.value=="")
	{
		alert("验证码不能为空!");
		document.form1.checkimg.focus();
		return false;
	}
    document.getElementById("ArticleSubmit").disabled = "disabled";
}
//验证评论信息
function checkcomment()
{
    bbb = document.getElementById("pageCount").value;
    document.getElementById("CC").value = bbb;
    a_content = form2.content.value;
    form2.content.value=f_trim(a_content);
	if(form2.content.value=="")
	{
		alert("评论内容不能为空!");
		document.form2.content.focus();
		return false;
	}
	var CheckL = strlength(a_content);
    if(CheckL>4000)
    {
	    alert("超过2000的字数上限了，请重新编辑。");
	    return false;
    }
	if(document.form2.checkimg.value=="")
	{
		alert("验证码不能为空!");
		document.form2.checkimg.focus();
		return false;
	}
}
//验证评论信息
function stockcheckcomment()
{
    bbb = window.parent.document.all["pageCount"].value;
    if(document.all)
    {
        insertAtCaret(document.getElementById("CC"),bbb);
        a_content = document.form2.content.value;
        a_content=f_trim(a_content);
        if(a_content=="")
	    {
		    alert("评论内容不能为空!");
		    window.frames["a1"].document.getElementById('content').focus();
		    return false;
	    }
	    if(document.form2.checkimg.value=="")
	    {
		    alert("验证码不能为空!");
		    return false;
	    }
	    document.getElementById("CommentSubmit").disabled = "disabled";
    }
    else
    {
        insertAtCaret(document.getElementById("CC"),bbb);
        a_content = document.getElementById("a1").contentWindow.document.getElementById("content").value;
        a_content = f_trim(a_content);
        if(a_content=="")
	    {
		    alert("评论内容不能为空!");
		    document.getElementById("a1").contentWindow.document.getElementById("content").focus();
		    return false;
	    }
	    if(document.form2.checkimg.value=="")
	    {
		    alert("验证码不能为空!");
		    return false;
	    }
    }
}
function checktopic()
{
	if(document.Form1.GetAllCategory.value=="0")
	{
		alert("请选择分类");
		document.Form1.GetAllCategory.focus();
		return false;
	}
	if(document.Form1.james.value=="")
	{
		alert("请填写验证码");
		document.Form1.james.focus();
		return false;
	}
	return true;
}
function checapply()
{
    if(document.postComment.Co.value=="")
	{
		alert("请填写申请理由");
		document.postComment.Co.focus();
		return false;
	}    
}
function AddText(text) {
		if(document.all){
			insertAtCaret(document.getElementById("content"), text);
		} else{
			document.getElementById("content").value +=	text;
		}
		setfocus();
}

function insertAtCaret (area,	text){
		if (area.createTextRange && area.caretPos){
				var	caretPos = area.caretPos;
				caretPos.text += caretPos.text.charAt(caretPos.text.length - 2)	== ' ' ? text +	' '	: text;
		} else if(area) {
				area.value +=	text;
		} else {
			area.value = text;
		}
}

function setfocus()	{
	document.getElementById("content").focus();
}
function f_trim(inputString) {
    if (typeof inputString != 'string') { return inputString; }
    var retValue = inputString;
    var ch = retValue.substring(0, 1);
    while (ch == ' ' || ch == '\r' || ch == '\n') {
   retValue = retValue.substring(1, retValue.length);
   ch = retValue.substring(0, 1);
    }
    ch = retValue.substring(retValue.length-1, retValue.length);
    while (ch == ' ' || ch == '\r' || ch == '\n') {
   retValue = retValue.substring(0, retValue.length-1);
   ch = retValue.substring(retValue.length-1, retValue.length);
    }
    while (retValue.indexOf('  ') != -1) {
   retValue = retValue.substring(0, retValue.indexOf('  ')) + 
      retValue.substring(retValue.indexOf('  ')+1, retValue.length); 
    }
    return retValue; 
} 
function ArticleProcess(str,id,comt)
{
	var sURL = "";
	var sVars = "";
	//文章置顶
	if(str == "1")
	{
	    sURL = "/Article_OnTop.aspx";
	    sVars = "ArticleID="+id+"&CommType="+comt;
	}
	//锁定文章
	else if(str == "2")
	{
	    sURL = "/Article_AcceptComment.aspx";
	    sVars = "ArticleID="+id+"&CommType="+comt;
	}
	//文章加精
	else if(str == "3")
	{
	    sURL = "/Article_Essential.aspx";
	    sVars = "ArticleID="+id+"&CommType="+comt;
	}
	//删除文章
	else if(str == "4")
	{
	    sURL = "/Article_Delete.aspx";
	    sVars = "ArticleID="+id;
	}
	try
	{
	    var myConn = new XHConn();
        if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
        var fnWhenDone = function (oXML) 
        { 
            var resText = oXML.responseText;
            if(resText == "UnOK")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "取消置顶成功";
                document.all.span1.innerHTML = "<a href=\"#\" onclick=\"ArticleProcess(1,"+id+",'On')\" class='bule2'>置顶</a>";
            }
            else if(resText == "OnOk")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "置顶成功";
                document.all.span1.innerHTML = "<a  href='#' onclick=\"ArticleProcess(1,"+id+",'Un')\" class='bule2'>取消</a>";
            }
            else if(resText == "UAOK")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "解锁成功";
                document.all.span2.innerHTML = "<a href='#' onclick=\"ArticleProcess(2,"+id+",'On')\" class='bule2'>加锁</a>";
            }
            else if(resText == "OAOk")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "加锁成功";
                document.all.span2.innerHTML = "<a href='#' onclick=\"ArticleProcess(2,"+id+",'Un')\" class='bule2'>解锁</a>";
            }
            else if(resText == "EUOK")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "取消精华成功";
                document.all.span3.innerHTML = "<a href='#' onclick=\"ArticleProcess(3,"+id+",'On')\" class='bule2'>加精</a>";
            }
            else if(resText == "EOOk")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "设为精华成功";
                document.all.span3.innerHTML = "<a href='#' onclick=\"ArticleProcess(3,"+id+",'Un')\" class='bule2'>取消</a>";
            }
            else if(resText == "ADOK")
            {
                document.getElementById("MessageDiv").style.display = "block";
                document.getElementById("MessageDiv_Message").innerHTML = "文章已删除";
                //document.all.span4.innerHTML = "<a href=\"#\" class='bule2'>文章已删除</a>&nbsp;";
            }
            else
            {
                document.getElementById("adminmanage").style.display = "none";
                document.getElementById("loginDiv").style.display = "block";
            }
        };
        myConn.connect(sURL, "GET", sVars, fnWhenDone);
    }
    catch(e)
    {
        alert(e);
    }
    return;
}

function XMLHttpRequestComm(str,id,aid,uid)
{
    mesComm = "MesComment"+id;
    span = "span"+id;
    spanall = "spanall"+id;
    document.getElementById(mesComm).innerHTML = "信息正在提交，请等待......";
	document.getElementById(mesComm).style.color = "#808080";
	
	var sURL = "";
	var sVars = "";
	//删除评论
	if(str == "1")
	{
	    sURL = "/CommentDelete.aspx";
	    sVars = "id="+id+"&aid="+aid+"&uid="+uid;
	}
	//删除全部评论
	if(str == "2")
	{
	    sURL = "/CommentAllDelete.aspx";
	    sVars = "id="+id+"&aid="+aid+"&uid="+uid;
	}
	var myConn = new XHConn();
    if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
    var fnWhenDone = function (oXML) 
    { 
        var resText = oXML.responseText;
        if(resText == "CDOK")
        {
            document.getElementById(mesComm).innerHTML = "评论已删除&nbsp;";
            document.getElementById(span).innerHTML = "";
            document.getElementById(spanall).innerHTML = "";
        }
        else
        {
            document.getElementById(mesComm).innerHTML = resText+"&nbsp;";
        }
        
        document.getElementById(mesComm).style.color = "#808080";
    };
    myConn.connect(sURL, "GET", sVars, fnWhenDone);
    return;
}
function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        sMethod(sURL);
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
        
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}
function addfavorite(URL,title)
{
   switch(getOs())
   {
       case 1:window.external.addFavorite(URL,title);break;
       case 2:window.sidebar.addPanel(title, URL, "");break;
       case 0:alert("您的浏览器出现了问题,请将浏览器安全设置还原为默认");break;
   }
}
function getOs()
{
   if(navigator.userAgent.indexOf("MSIE")>0)return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3;   
   if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4;
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5;
   return 0;
}
function InMsg(InMsg)
{
    if(InMsg == "1")
        document.getElementById('sw').value="基金代码/名称/拼音简称";
    else if(InMsg == "2")
        document.getElementById('sw').value="请输入用户名称";
    else if(InMsg == "3")
        document.getElementById('sw').value="基金代码/名称/拼音简称";
    else if(InMsg == "0")
        document.getElementById('sw').value="";
        
}
function GotoPage1(gotopage)
{
    var subProc = true;
	var sub = false;
	if(gotopage.current_page.value == "") {
		window.alert("请输入页数！");
		document.gotopage.current_page.focus();
		subProc = false;
		return false;
	}
	if(subProc == true)
	{
	    if(gotopage.current_page.value>1 || gotopage.current_page.value<1)
	    {
	        window.alert("请输入页数范围内的数字！");
	        document.gotopage.current_page.focus();
		    return false;
	    }
	    else
	    {
	        if(gotopage.current_page.value == 1)
    	    window.location.href="/d/2167331_p"+gotopage.current_page.value+".html";
	    }
	    return false;
	}
	
}
function GotoPage(p){
    var regs = /\d/;
    if(!regs.test(p))
    {
        alert("请输入正确数字");
        return false;
    }
	var s = self.location.href;	
	var u = s.replace(/,p(\d+).html+/,"");
	if(u == s)
	{
	    s = s.replace(/.html+/,"");
	}
	else
	{
	    s = u;
	}	
	if(p>1){
	    s = s+",p"+p+".html";
	} else {
	    s = s+".html";
	}
	self.location.href = s;
}
function GotoPage2(p){
    var regs = /\d/;
    if(!regs.test(p))
    {
        alert("请输入正确数字");
        return false;
    }
	self.location.href = "http://jijinba.hexun.com/funds/jjznt.aspx?current_page=" + p;
}
// -->