﻿var postSubmited = false;
function ctlent(obj) {
	if(postSubmited == false && (event.ctrlKey && window.event.keyCode == 13) || (event.altKey && window.event.keyCode == 83)) {
			if(this.document.input.topicsubmit) this.document.input.topicsubmit.disabled = true;
			if(this.document.input.replysubmit) this.document.input.replysubmit.disabled = true;
			if(this.document.input.editsubmit) this.document.input.editsubmit.disabled = true;
			postSubmited = true;
			this.document.input.submit();
	}
}

var flag=false; 
function DrawImage(ImgD){ 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width>=490){  //680
			ImgD.width=490; 
			ImgD.height=(image.height*490)/image.width; 
		}else{ 
			ImgD.width=image.width; 
			ImgD.height=image.height; 
		}  
	} 
} 

//显示隐藏主题
function TopicShow(e,TopicID){
if (e.className=="textbox-TopvE" || e.className=="textbox-TopvC"){
 e.className=(e.className=="textbox-TopvC")?"textbox-TopvE":"textbox-TopvC"}
if (document.getElementById(TopicID).style.display==""){
 document.getElementById(TopicID).style.display=(e.className=="textbox-TopvC")?"":"none"
}else{
 document.getElementById(TopicID).style.display=(e.className=="textbox-TopvE")?"none":""
}
 //ReImgSize()
}

/*function showIntro(objID) 
{
	if (document.getElementById(objID).style.display == "none") {
		document.getElementById(objID).style.display = "";
	}else{
		document.getElementById(objID).style.display = "none";
	}
}*/

function winconfirm(confirmMSG,confirmURL){
	question = confirm(confirmMSG);
	if (question != "0"){
		window.location=confirmURL;
	}
}

function CopyText(obj) {
	ie = (document.all)? true:false
	if (ie){
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		rng.scrollIntoView();
		rng.select();
		rng.execCommand("Copy");
		rng.collapse(false);
	}
}

function UBBShowObj(strType,strID,strURL,intWidth,intHeight)
{
	var varHeader="V";
	var tmpstr="";
	var bSwitch = false;
	bSwitch = document.getElementById(varHeader+strID).value;
	bSwitch	=~bSwitch;
	document.getElementById(varHeader+strID).value = bSwitch;
	if(bSwitch){
		document.getElementById(strID).innerHTML = "本影音源文件地址已隐藏，请点上面的显示连接直接播放欣赏";
	}else{
		switch(strType.toUpperCase()){
			case "SWF":
				tmpstr="<object codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+intWidth+"' height='"+intHeight+"'><param name='movie' value='"+strURL+"'><param name='quality' value='high'><param name='AllowScriptAccess' value='never'><embed src='"+strURL+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+intWidth+"' height='"+intHeight+"'>'"+strURL+"'</embed></OBJECT>";
				break;
			case "WMA":
				tmpstr="<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'  id='MediaPlayer' width='"+intWidth+"' height='"+intHeight+"'><param name='ShowStatusBar' value='-1'><param name='AutoStart' value='True'><param name='Filename' value='"+strURL+"'></object>";
				break;
			case "WMV":
				tmpstr="<object classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' width='"+intWidth+"' height='"+intHeight+"'><param name='ShowStatusBar' value='-1'><param name='AutoStart' value='Ture'><param name='Filename' value='"+strURL+"'></object>";
				break;
			case "RM":
				tmpstr="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' height='"+intHeight+"' id='Player' width='"+intWidth+"' viewastext><param name='_ExtentX' value='12726'><param name='_ExtentY' value='8520'><param name='AUTOSTART' value='0'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='CONTROLS' value='ImageWindow'><param name='CONSOLE' value='_master'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='"+strURL+"'><param name='BACKGROUNDCOLOR' value='#000000'></object><br><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' height='32' id='Player' width='"+intWidth+"' VIEWASTEXT><param name='_ExtentX' value='18256'><param name='_ExtentY' value='794'><param name='AUTOSTART' value='-1'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='CONTROLS' value='controlpanel'><param name='CONSOLE' value='_master'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='0'><param name='BACKGROUNDCOLOR' value='#000000'><param name='SRC' value='"+strURL+"'></object>";
				break;
			case "QT":
				tmpstr="<embed src='"+strURL+"' autoplay='true' Loop='false' controller='true' playeveryframe='false' cache='false' scale='TOFIT' bgcolor='#000000' kioskmode='false' targetcache='false' pluginspage='http://www.apple.com/quicktime/'>";
				break;
			case "RA":
				tmpstr="<object classid='clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' id='RAOCX' width='"+intWidth+"' height='"+intHeight+"'><param name='_ExtentX' value='6694'><param name='_ExtentY' value='1588'><param name='AUTOSTART' value='0'><param name='SHUFFLE' value='0'><param name='PREFETCH' value='0'><param name='NOLABELS' value='0'><param name='SRC' value='"+strURL+"'><param name='CONTROLS' value='StatusBar,ControlPanel'><param name='LOOP' value='0'><param name='NUMLOOP' value='0'><param name='CENTER' value='0'><param name='MAINTAINASPECT' value='0'><param name='BACKGROUNDCOLOR' value='#000000'><embed src='"+strURL+"' width='253' autostart='true' height='60'></embed></object>"
		}
		document.getElementById(strID).innerHTML = tmpstr;
	}
}

function AutoSizeDIV(objID){
	var obj=document.getElementById(objID);
	if (obj.scrollHeight < obj.offsetHeight){
		obj.style.height = obj.scrollHeight+2;
	}
}

//定义一个运行代码的函数，
function runCode(o)
{
    ie = (document.all)? true:false
    if (ie)
    {
        var code=o.innerText;//即要运行的代码。
        var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
        newwin.opener = null // 防止代码对论谈页面修改
        newwin.document.write(code);  //向这个打开的窗口中写入代码code，这样就实现了运行代码功能。
        newwin.document.close();
    }
}

function saveCode(obj) {
         ie = (document.all)? true:false
    if (ie)
    {
	var winname = window.open('', '_blank', 'top=10000');
	var code=obj.innerText;
                  winname.opener = null
	winname.document.write(code);
	winname.document.execCommand('saveas','','code.htm');
	winname.close();
}
}

function initAd() {
document.all.AdLayer.style.posTop = -200;
document.all.AdLayer.style.visibility = 'visible'
MoveLayer('AdLayer');
}

function MoveLayer(layerName) {
if (screen.width==1024)
{
var x = 893; 
var y = 500; 
}
else
{
var x=748;
var y=380;
}
var diff = (document.body.scrollTop + y - document.all.AdLayer.style.posTop)*.40;
var y = document.body.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posLeft = x");
setTimeout("MoveLayer('AdLayer');", 100);
}

function showHideSidebar(){
  try{
    var objSidebar=document.getElementById("sidebar");
    var objContent=document.getElementById("content");
    if(objSidebar.className!="sidebar-hide"){
      objSidebar.className="sidebar-hide";
      objSidebar.style.display="none";
      objContent.className="content-wide";
    }else{
      objSidebar.className="sidebar";
      objSidebar.style.display="block";
      objContent.className="content";
    }
  }catch(e){}
}

function showLogin(){
  try{
    var panel=document.getElementById("panel_User");
    /*if(panel){*/
      if(panel.style.display=='none'){
        panel.style.display='block';
      }else{
        panel.style.display='none';
      }
    /*}else{
      document.location="logging.asp?action=logout";
    }*/
  }catch(e){}
}

// {{{ frame protection 框架保护
/*try {
	if (top.document.domain != self.document.domain
	 && is.ie && is.v < 6) {
		top.location.replace(self.location.href);
	}
} catch(e) {
	if (top != self) {
		top.location.replace(self.location.href);
	}
}*/

//更改字体大小 2005-09-15
function setFontSize(pt){
  try{
    var t=document.getElementById("textboxContent");
    if(t){
      t.style.fontSize=pt+"pt";
    }
  }catch(e){}
}

//无刷新换肤 2005-10-22 iMoso's skinsjs.js
//---------------------------------------------------
//Author: kaichun
//Last Update: 2005年5月31日 20:44:19
//---------------------------------------------------
function setActiveStyleSheet(title){
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
	document.getElementById("logo").src="styles/"+title+"/images/logo.gif";
}

function getActiveStyleSheet(){
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getPreferredStyleSheet(){
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title"))
			return a.getAttribute("title");
	}
	return null;
}

function createCookie(nm,val,y){
	var exp="";
	if(y){ 
		var dt=new Date(); 
		dt.setTime(dt.getTime()+(y*86400000)); 
		exp="; expires="+dt.toGMTString();
	} 
	document.cookie=nm+"="+escape(val)+exp+";path=/"; 
}

function readCookie(nm){ 
	var m; 
	if(window.RegExp){ 
		var re=new RegExp(";\\s*"+nm+"=([^;]*)","i"); 
		m=re.exec(';'+document.cookie); 
	} 
	return(m?unescape(m[1]):"");
}

window.onload = function(e){
	var cookie = readCookie("styles");
	var title = cookie ? cookie : getPreferredStyleSheet();
	var styleList=document.getElementById("stylelist");
	var flag=true;
	if(styleList){
		for(var i=0;i<styleList.options.length;i++){
			if(title==styleList.options[i].value){
				flag=false;
			}
		}
		if(flag){
			title=styleList.options[0].value;
		}
		styleList.value=title;
	}
	setActiveStyleSheet(title);
}

window.onunload = function(e){
	var title = getActiveStyleSheet();
	createCookie("styles", title, 365);
}

function init(){
	var cookie = readCookie("styles");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}
//无刷新换肤 2005-10-22 iMoso's skinsjs.js  结束//

//转换剪切板数据 //
function html_trans(str) {
        str = str.replace(/\r/g,"");
        str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
        str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");
        
        str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"[url=$1]$2[/url]");
        
        str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
        
        str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"[img]$1[/img]");
        
        str = str.replace(/<([\/]?)b>/ig,"[$1b]");
        str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
        str = str.replace(/<([\/]?)u>/ig,"[$1u]");
        str = str.replace(/<([\/]?)i>/ig,"[$1i]");
        
        str = str.replace(/ /g," ");
        str = str.replace(/&/g,"&");
        str = str.replace(/"/g,"\"");
        str = str.replace(/&lt;/g,"<");
        str = str.replace(/&gt;/g,">");
        
        str = str.replace(/<br>/ig,"\n");
        str = str.replace(/<[^>]*?>/g,"");
        str = str.replace(/\[url=([^\]]+)\](\[img\]\1\[\/img\])\[\/url\]/g,"$2");

        
        return str;
}

function trans(){
        var str = "";
        xydwcopy.focus();
        xydwcopy.document.body.innerHTML = "";
        xydwcopy.document.execCommand("paste");
        str = xydwcopy.document.body.innerHTML;
        if(str.length == 0) {
                alert("剪切版不存在超文本数据！");
                return "";
        }
        return html_trans(str);
}
//转换剪切板数据 结束//