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>=518){ 
			ImgD.width=518; 
			ImgD.height=(image.height*518)/image.width; 
		}else{ 
			ImgD.width=image.width; 
			ImgD.height=image.height; 
		}  
	} 
} 

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 = "影音文件源地址：<a href='"+strURL+"' target='_blank'>"+strURL+"</a>";
	}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 popnew(url,title,width,height){
    var w = 260;
    var h = 320;

    if (document.all || document.layers){
        w = screen.availWidth;
        h = screen.availHeight;
    }

    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);

    window.open(url,title,"width="+width+",height="+height+",top="+topPos+",left="+leftPos+",scrollbars=yes,resizable=no,status=no")
}

function AutoSizeDIV(objID){
	var obj=document.getElementById(objID);
	if (obj.scrollHeight < obj.offsetHeight){
		obj.style.height = obj.scrollHeight+2;
	}
}

function rewindow(url, width, height){
	var Win = window.open(url,"rewindow",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no' );
}

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);
}

function gbcount(message,total,used,remain)  
{  
	var max;  
	max = total.value;  
	if (message.value.length > max) {  
	message.value = message.value.substring(0,max);  
	used.value = max;  
	remain.value = 0;  
	alert("系统提示：\n\n对不起，出错了，内容超过限定的字数，谢谢合作!");  
	}  
	else {  
	used.value = message.value.length;  
	remain.value = max - used.value;  
	}  
} 


//-------------背单词------------
var En=new Array()
var Ch=new Array()
var Ei=0
function showE(first){
if (first!=1) SEng.filters[0].apply();
SEng.innerHTML="<img src='images/zd.gif' align='absmiddle'> <span class=EnText>"+En[Ei]+"</span><div class=ChText>"+Ch[Ei]+"</div>"
if (first!=1) SEng.filters[0].play();
Ei++
if (Ei==En.length) {Ei=0}
}
/*
纯粹手写板 V1.2
提供: 纯粹空间 http://www.softpure.com
作者: 暖阳
*/
var spcodeChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
function spcode_dec(c,spcodeChars){ //纯粹码转为数字
	c = c.split('');
	return spcodeChars.indexOf(c[0])*spcodeChars.length + spcodeChars.indexOf(c[1]);
}

function createShapes(code,win){
	try{	
		win.teller = 0;
		code = code.replace(/(^\s*\[whitepad\])|(\[\/whitepad\]\s*$)/gim,'').replace(/\*(\d+)\//g,function(a,b){var i,s='';for(i=0;i<b;i++) s+='*';return s}).replace(/\*/g,"*;");
		if(!code) return true;

		var allowShapes = "shape;oval;rect;roundrect";
		var props = ('tagName=shape;style.left=0;style.top=0;style.width=1600;style.height=1200;coordsize=1600,1200;fillcolor=;strokecolor=black;strokeweight=1.5;path').split(';');
		var lastValues = new Array(props.length);

		var shapes = code.split('|');
		for(i=0;i<shapes.length;i++){
			var shape = shapes[i].split(';');
			var node = null;			
			for(j=0;j<props.length;j++){
				var prop_arr = props[j].split('=',2);
				if(i==0 && (prop_arr[1]||prop_arr[1]==='')) lastValues[j] = prop_arr[1];
				var prop = prop_arr[0];
				var value = shape[j];
				if(value=='*') value = lastValues[j];
				else lastValues[j] = value;
				if(prop=='tagName' && value){
					var re =  new RegExp("(^|;)("+value+")(;|$)","i");
					if(allowShapes.match(re))
						node = win.document.createElement('<v:'+value+' id="nr'+(win.teller+1)+'" style="POSITION:absolute;"></v:'+value+'>');
				}else if(node && value){
					if(prop=='path' && value.match(/^\w+$/)){
						value = value.replace(/(\w{2})/g,function(a){return ','+spcode_dec(a,spcodeChars)}).replace(/^(,)(\d+)(,)(\d+)(,)(\d+)/g,"m$2$3$4 l$6")+' e';
					}
					eval("node."+prop+" = \""+value+"\";");
				}
				else if(prop=='fillcolor' && !value) node.filled = false;
				else if(prop=='strokecolor' && !value) node.stroked=false;
			}
			if(node){
				win.teller ++;
				node.style.zIndex = win.teller ;
				win.document.body.insertBefore(node);
			}
		}
		return true;
	}catch(e){
		return false;
	}
}

function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}

function AutoSizeDIV(objID){
	var obj=document.getElementById(objID);
	if (obj.scrollHeight < obj.offsetHeight){
		obj.style.height = obj.scrollHeight+2;
	}
}

//for default.asp tabs
function getObject(objectId) {
     if(document.getElementById && document.getElementById(objectId)) {
    // W3C DOM
       return document.getElementById(objectId);
     } 
     else if (document.all && document.all(objectId)) {
    // MSIE 4 DOM
       return document.all(objectId);
     } 
     else if (document.layers && document.layers[objectId]) {
    // NN 4 DOM.. note: this won't find nested layers
       return document.layers[objectId];
     } 
     else {
       return false;
    }
} 
function TabNews(n,tagid,x){//首页n=5个tab的时候，预留n=7个tab的div
    for (var i=1;i<=n;i+=2) {
         if (i == x) {
            getObject(tagid+i).className="tabactive"+i;
            getObject(tagid+"_"+(i)).style.display="block";
            if(i!=1){
               getObject(tagid+(i-1)).style.display="none";               
               if(i!=5){
                  getObject(tagid+(i+1)).style.display="none";
               }                 
            }
            if(i==1){
               getObject(tagid+"2").style.display="none";
            } 
        }
        else
        {
            getObject(tagid+i).className="";
            getObject(tagid+"_"+(i)).style.display="none";
            if(i!=n){
               getObject(tagid+(i+1)).style.display="block";
            }             
        }         
   }
}