var ie = (document.all)? true:false
if (ie)
{
	function fastPost(eventobject)
	{
		if(event.ctrlKey && window.event.keyCode==13)
		{
			var o=window.document.PostTopic;
			if(ie && o.BackupContent.checked) window.clipboardData.setData("Text",o.Message.value);
			o.submit();
		}
	}
}
function DisableEvent(){return false;}

function doEncrypt(o)
{
	var sel;
	sel=document.getElementById('Ratings');
	if (o.checked)
	{
		sel.disabled=false;
		sel.selectedIndex=1;
	}else{
		sel.disabled=true;
	}
}

function zoomImg()
{
	var o;
	o = event.srcElement;
    if (o.tagName!='IMG')
		return true;
	else
	{
		if (event.altKey == true)
		{
			var zoom = parseInt(o.style.zoom, 10) || 100;
			zoom += event.wheelDelta / 12;
			if (zoom > 0) 
				o.style.zoom = zoom + '%';
			return false;
		}
		else
			return true;
	}
}

var currentpos,timer; 
function initialize(){timer=setInterval("scrollwindow()",16);} 
function sc(){clearInterval(timer);} 
function scrollwindow()
{ 
	currentpos=document.body.scrollTop; 
	window.scroll(0,++currentpos); 
	if (currentpos != document.body.scrollTop) 
	sc(); 
} 
document.onmousedown=sc;
document.ondblclick=initialize;
document.onmousewheel=zoomImg;

function runCode()

{
  var code=event.srcElement.parentElement.children[0].value;
  var newwin=window.open('','','');
  newwin.opener = null;
  newwin.document.write(code);
  newwin.document.close();

}

function fitSize(o){
	if(o.width>screen.width-333) {
		o.width=screen.width-333;
		//apply hyperlink to large image,by 我佛山人 of 5D.CN
		//o.attachEvent("onclick",function(){window.open(o.src)});
		//o.title="单击查看完整图像";
		//o.style.cursor="hand";
		//another solution,by janlay of 5D.CN
		o.outerHTML="<a href="+o.src+" target=_blank><img src="+o.src+" width="+(screen.width-333)+" alt='按Alt+滚轮缩放图片，单击查看完整图片' border=0></a>"
	}
}
function PostMessage(){
	var o=event.srcElement;
	//window.event.returnValue = false;
	o.Submit.value="正在提交 ...";
	o.Submit.disabled=true;
	o.Cancel.disabled=true;
	if(ie && o.BackupContent.checked) window.clipboardData.setData("Text",o.Message.value);
	//window.setTimtout(function(){o.submit()},10);
	//o.onsubmit=DisableEvent;
}
function cancelSubmit(){if(window.confirm("确实要取消操作吗？\n\n　·按“确定”取消本次操作\n　·按“取消”离开这个对话框"))history.back();}

function gotoReply(url)
{
	var o=document.PostTopic;
	if(o.Message.value.length>0 && o.BackupContent.checked)
	{
		window.clipboardData.setData("Text",o.Message.value);
		window.alert("您在正文区输入的内容已经复制到剪贴板");
	}
	var re,s;
	s=o.action;
	re=/&action=postreply&/i
	s=s.replace(re,"&action=reply&");
	window.location.href=s+"&TopicSubject="+escape(o.TopicSubject.value);
}

function getActiveText(o){o.currPos = document.selection.createRange().duplicate();}

function SelectAll(b){
	var form=document.forms[0];
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox') e.checked = b;
	}
}

function addText(str) {
	var o=document.PostTopic.Message;
	if (o.createTextRange && o.currPos) {      
		var currPos = o.currPos;      
		currPos.text = str;
	}
	else o.value += str;
	//o.focus(currPos);
	o.focus();
}

var strBegin,strEnd
function addTag()
{
	if ((document.selection) && (document.selection.type == "Text"))
	{
		var range = document.selection.createRange();
		addText(strBegin + range.text + strEnd);
	} 
	else
	{
		addText(strBegin + strEnd);
	}
}

function showfont(font) {strBegin="[font="+font+"]";strEnd="[/font]";addTag();}
function showsize(size) {strBegin="[size="+size+"]";strEnd="[/size]";addTag();}
function showcolor(color) {strBegin="[color="+color+"]";strEnd="[/color]";addTag();}
function bold() {strBegin="[b]";strEnd="[/b]";addTag();}
function italicize() {strBegin="[i]";strEnd="[/i]";addTag();}
function underline() {strBegin="[u]";strEnd="[/u]";addTag();}
function hyperlink() {strBegin="[url=]";strEnd="[/url]";addTag();}
function email(){strBegin="[email]";strEnd="[/email]";addTag();}
function quote() {strBegin="\r[quote]";strEnd="[/quote]";addTag();}
function center() {strBegin="\r[center]";strEnd="[/center]";addTag();}
function image() {strBegin="[img]";strEnd="[/img]";addTag();}
function showcode() {strBegin="[code]";strEnd="[/code]";addTag();}
function list() {strBegin="[*]";strEnd="";addTag();}
function setsmiley(what) {addText(" "+what);} 
function smilieopen() {var MainWindow = window.open ('smiles.htm',"_blank","toolbar=no,location=no,menubar=no,scrollbars=yes,width=400,height=400,resizeable=yes,status=no");}
function viewubb() {msg=window.open("ubbcode.htm","","height=500,width=500,left=5,top=5,scrollbars=yes,toolbar=no,directories=no,status=no,menubar=no,resizable=yes");}
function afp() {msg=window.open("afp.htm","","height=315,width=420,left=5,top=5,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,resizable=yes");}