var theshowerrormsgopacity = 0;	// 透明度
// 使用方法：標題，內容，寬度，高度，回調函數（如果沒有的話傳null）
// exp1:msgwindow.showmsg('testtitle','bhjbjhb',320,200,null);
// exp2:msgwindow.showmsg('testtitle','bhjbjhb',320,200,tf);
// exp3:$debug('test');
var msgwindow=function(){
	this.theshowerrormsgopacity=0;
	this.callback=null;
};
// 創建顯示div
msgwindow.showmsg=function(title, content, width, height, callback) {
	if($('theshowerrormsg')){
	}else{
	hidehandle();
	if (!width) {
		width = 320;
	}
	if (!height) {
		height = 200;
	}
	var eldiv = document.createElement("div");
	eldiv.id = "theshowerrormsg";
	eldiv.style.backgroundColor = "#000000";
	eldiv.style.top = 0;
	eldiv.style.left = 0;
	var wwidth=document.documentElement.scrollWidth;
	var hheight=document.documentElement.scrollHeight;
	try{
		if(document.documentElement.clientWidth>=wwidth){
			wwidth=document.documentElement.clientWidth;
		}
		if(document.documentElement.clientHeight>=hheight){
			hheight=document.documentElement.clientHeight;
		}
	}catch(e){};
	eldiv.style.width = wwidth+"px";
	eldiv.style.height = hheight+"px";
	eldiv.style.position = "absolute";
	eldiv.style.display = "";
	eldiv.style.zIndex = "65534";
	var str = "";
	if (callback) {
		str = "<button onclick=\"msgwindow.removeerrormsg(true)\">確定</button>";
		msgwindow.callback=callback;
	}
	var errorstr = "<div onmouseup='upDrag()' class='dragAble' onmousedown='initDrag(event)' style=\"background-color:#ffffff;width:" + width + "px;height:" + height + "px;top:" + (height/2 +150+document.documentElement.scrollTop) + "px;left:" + ((document.documentElement.scrollWidth - width) / 2) + "px;z-index:65535;border:solid 1px #63f7fb;position:absolute\"><div style=\"cursor: move;font-weight:bolder;color:#FFCC00;height:18px;padding:2px;font-size:14px;margin-bottom:3px;padding-left:5px;word-break: break-all;background-color:#11478d;\">" + title + "</div><div style=\"margin:10px;word-break: break-all;\">" + content + "</div><div align=\"center\" style=\"height:20px;vertical-align: bottom;margin:5px;\">" + str + "<button style=\"border:1px #000 solid;background-color:#11478d;color:#fc0;\" onclick=\"msgwindow.removeerrormsg(false)\">";
	if (callback){
		errorstr+="取消";
	}else{
		errorstr+="確定";
	}
	errorstr+="</button></div></div>";
	eldiv.innerHTML = errorstr;
	eldiv.style.filter = "alpha(Opacity=0)";
	eldiv.style.opacity = "0";
	document.body.appendChild(eldiv);
	eldiv.timer = window.setInterval(this.displaytheshowerrormsg, 150);
	}
}
// 隱藏所有select
function hidehandle(){
	var els=document.getElementsByTagName("select");
	for(var i=0;i<els.length; i+=1){
		var objTemp = els[i];
		objTemp.style.display="none";
	}
}
// 顯示所有select
function showhandle(){
	var els=document.getElementsByTagName("select");
	for(var i=0;i<els.length; i+=1){
		var objTemp = els[i];
		objTemp.style.display="";
	}
}
// 移除
msgwindow.removeerrormsg=function(temp) {
	var el = $("theshowerrormsg");
	if (temp) {
		this.callback.call();
	}
	el.timer = window.setInterval(this.disappeartheshowerrormsg, 150);
}
// 漸顯
msgwindow.displaytheshowerrormsg=function() {
	var eldiv = $("theshowerrormsg");
	this.theshowerrormsgopacity += 25;
	if (this.theshowerrormsgopacity >= 85) {
		window.clearInterval(eldiv.timer);
	} else {
		eldiv.style.opacity = "0." + this.theshowerrormsgopacity;
		eldiv.style.filter = "alpha(Opacity=" + this.theshowerrormsgopacity + ")";
	}
}
// 漸隱
msgwindow.disappeartheshowerrormsg=function() {
	var eldiv = $("theshowerrormsg");
	this.theshowerrormsgopacity -= 45;
	if (this.theshowerrormsgopacity <= 0) {
		window.clearInterval(eldiv.timer);
		document.body.removeChild(eldiv);
		showhandle();
	} else {
		eldiv.style.opacity = "0." + this.theshowerrormsgopacity;
		eldiv.style.filter = "alpha(Opacity=" + this.theshowerrormsgopacity + ")";
	}
}
// pic
// distype 1:60*60;2:280*200
msgwindow.showpic=function(str ,distype){
	var imgstr="";
	if(distype){
		if(distype==1){
			imgstr="<img src=\""+str+"\"/ height='60' width='60'>";
			msgwindow.showmsg('show thepic',imgstr,120,80,null);
		}	
	}else{
		imgstr="<img src=\""+str+"\"/ height='200' width='280'>";
		msgwindow.showmsg('show thepic',imgstr,305,260,null);
	}
}
// getElementById();
function $(element) {
	if (typeof element == "string") {
		element = document.getElementById(element);
	}
	return element;
}
// debug
// type可以為div、input和不寫，不寫的話直接輸出（對象也可以、但對象信息應該顯示不全），input輸出value，div輸出innerHTML
function $debug(str,type) {
	var debugstr="";
	var awidth="80%";
	var aheight="100%";
	if(!type){
		debugstr=str;
		try{
			if(typeof str != "string"){
				debugstr="<textarea cols='70' rows='30'>";
				for(var i in str){
					var property=str[i];
					debugstr+=i+" = "+property+"\n";
				}
			}
			debugstr+="</textarea>";
			awidth=640;
			aheight=480;
		}catch(ex){}
	}else if(type=="div"){
		debugstr=str.innerHTML;
	}else if(type=="input"){
		debugstr=str.value;
	}
	msgwindow.showmsg("debug", debugstr, awidth, aheight, null);
}
// 得到元素left值
function getLeft(el) {
	return !el ? 0 : (el.offsetLeft + getLeft(el.offsetParent));
}   
// 得到元素top值
function getTop(el) {
	return !el ? 0 : (el.offsetTop + getTop(el.offsetParent));
}
// 鼠標拖動
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var y,x;
var oDragObj;
var oZindex;
function myMoveMouse(evt) {
	if (isdrag) {
		evt = evt || window.event;
		oDragObj.style.top  =  (nTY + evt.clientY - y)+"px";
		oDragObj.style.left  =  (nTX + evt.clientX - x)+"px";
		return false;
	} 
} 
function initDrag(evt) {
 	var oDragHandle = nn6 ? evt.target : event.srcElement;
	while (oDragHandle.tagName != "HTML" && oDragHandle.className != "dragAble") {
		oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;
	} 
	if (oDragHandle.className=="dragAble") {
		isdrag = true;
		if(!oDragObj){
			oZindex = oDragHandle.style.zIndex;
			oDragHandle.style.zIndex = 100;
		}
		if (oDragObj && oDragHandle!=oDragObj){
			oDragObj.style.zIndex = oZindex;
			oZindex = oDragHandle.style.zIndex;
			oDragHandle.style.zIndex = 100;
		}
		nTY = parseInt(oDragHandle.style.top+0);
		y = nn6 ? evt.clientY : event.clientY;
		nTX = parseInt(oDragHandle.style.left+0);
		x = nn6 ? evt.clientX : event.clientX;
		oDragObj = oDragHandle;
		document.onmousemove=myMoveMouse;
		return false;
	}
} 
function upDrag(){
	isdrag=false;
}
// 用,來分隔數字
function outputComma(number) {
    number = '' + number
    if (number.length > 3) {
        var mod = number.length%3;
        var output = (mod > 0 ? (number.substring(0,mod)) : '');
        for (i=0 ; i < Math.floor(number.length/3) ; i+=1) {
            if ((mod ==0) && (i ==0))
                output+= number.substring(mod+3*i,mod+3*i+3);
            else
                output+= ',' + number.substring(mod+3*i,mod+3*i+3);
        }
        return (output);
    }
    else return number;
}
//單開頁預覽type 0:str;1:pic
function previewpage(str,type){
	var xx=window.open('', '預覽', 'menubar=null,width=600,height=300,resizable=yes');
	if(type==1){
		str="<img src='"+str+"'/>";
	}
	xx.document.writeln(str);
}
// 左上箭頭提示
// example:<input type="text" id="ttttttt" onmouseover="left_up_tip(this,-100,30,'fsdfsdfsdfsdfds',200)" onmouseout="close_tip()"/>
function left_up_tip(tsrc,tleft,ttop,tstr,twidth){
	if($('the_up_tip')){
	}else{
		var eldiv = document.createElement("div");
		if (!twidth) {
			twidth = 320;
		}
		eldiv.id = "the_up_tip";
		eldiv.style.top = getTop(tsrc)+ttop+"px";
		eldiv.style.left = getLeft(tsrc)+tleft+"px";
		eldiv.style.width = twidth+"px";
		eldiv.style.position = "absolute";
		eldiv.style.zIndex = "65535";
		eldiv.style.marginLeft="200px";
		eldiv.style.fontSize="12px";
		eldiv.style.lineHeight="18px"; 
		tstr="<div style=\"width:"+twidth+"px; position: relative; top:1px;\"><img src=\"/fstw/web/images/tips/tip1.png\" style=\"display:block;\" /></div><div style=\"border:1px solid #999; background:#f7fae3; width:"+(twidth-10)+"px; font-size:12px; padding:8px;\">"+tstr+"</div>";
		eldiv.innerHTML=tstr;
		document.body.appendChild(eldiv);
	}
}
// 左下箭頭提示
// example:<input type="text" id="ttttttt" onmouseover="left_down_tip(this,-200,-58,'fsdfsdfsdfsdfds',200)" onmouseout="close_tip()"/>
function left_down_tip(tsrc,tleft,ttop,tstr,twidth){
	if($('the_up_tip')){
	}else{
		var eldiv = document.createElement("div");
		if (!twidth) {
			twidth = 320;
		}
		eldiv.id = "the_up_tip";
		eldiv.style.top = getTop(tsrc)+ttop+"px";
		eldiv.style.left = getLeft(tsrc)+tleft+"px";
		eldiv.style.width = twidth+"px";
		eldiv.style.position = "absolute";
		eldiv.style.zIndex = "65535";
		eldiv.style.marginLeft="200px";
		eldiv.style.fontSize="12px";
		eldiv.style.lineHeight="18px"; 
		tstr="<div style=\"border:1px solid #999; background:#f7fae3; width:"+(twidth-10)+"px; font-size:12px; padding:8px;\">"+tstr+"</div><div style=\"width:"+twidth+"px; position: relative; top:-1px\"><img src=\"/fstw/web/images/tips/tip2.png\" style=\"display:block;\" /></div>";
		eldiv.innerHTML=tstr;
		document.body.appendChild(eldiv);
	}
}
// 關閉提示
function close_tip(){
	try{
		document.body.removeChild($('the_up_tip'));
	}catch(e){}
}
// 單開新頁顯示圖片
function openPic() {window.open(this.src, "", "");}
//通用圖片處理大小，按寬度等比例縮小,type：不寫是按寬度，高度；1：寬度；2：高度
function pic_resizer(picname,picwidth,picheight,type){
	var pic_name=picname;
	var pic_width=picwidth;
	var pic_height=picheight;
	var vtype=null;
	if(type){
		vtype=type;
	}
	var elpics=null;
	if(pic_name){
		elpics=document.getElementsByName(pic_name);
	}else{
		elpics=document.getElementsByTagName("img");
	}
	for(var i=0;i<elpics.length;i++){
		elpics[i].onload=function (){
			if(vtype){
				if(vtype==1 && this.width>pic_width){
					this.height=this.height*pic_width/this.width;
					this.width=pic_width;
					this.style.cursor='pointer';
					this.onclick=openPic;
						this.style.display="block";
				}
				if(vtype==2 && this.height>pic_height){
					this.width=this.width*pic_height/this.height;
					this.height=pic_height;
					this.style.cursor='pointer';
					this.onclick=openPic;
						this.style.display="block";
				}
			}else{
				if(this.width>pic_width || this.height>pic_height){
					var rate1=this.width/pic_width;
					var rate2=this.height/pic_height;
					if(rate1>rate2){
						this.height=this.height*pic_width/this.width;
						this.width=pic_width;
						this.style.cursor='pointer';
						this.onclick=openPic;
						this.style.display="block";
					}else{
						this.width=this.width*pic_height/this.height;
						this.height=pic_height;
						this.style.cursor='pointer';
						this.onclick=openPic;
						this.style.display="block";
					}
				}
			}
		};
	}
}
function bookmark(){
	var title=document.title
	var url=document.location.href
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
	else if( window.opera && window.print ){
	var mbm = document.createElement('a');
	mbm.setAttribute('rel','sidebar');
	mbm.setAttribute('href',url);
	mbm.setAttribute('title',title);
	mbm.click();}
	else if( document.all ) window.external.AddFavorite( url, title);
}
// blog 左側開關
function blog_o_c_l(el){
	if(el.src.indexOf("/fstw/web/images/blog/one/left_2.jpg")!=-1){
		$('div_'+el.id).style.display="none";
		el.src="/fstw/web/images/blog/one/left_1.jpg";
	}else{
		$('div_'+el.id).style.display="";
		el.src="/fstw/web/images/blog/one/left_2.jpg";
	}
}
//剪貼板
function copytoclip(str){
	window.clipboardData.setData("Text",str);
}
// 跳轉頁面
function goto_page(str,value){window.location=str+value;}
// blog 評論開關
function blog_o_c_r(el){
	if(el.src.indexOf("/fstw/web/images/blog/one/blog_pl_1.jpg")!=-1){
		$('div_'+el.id).style.display="none";
		el.src="/fstw/web/images/blog/one/blog_pl_2.jpg";
	}else{
		$('div_'+el.id).style.display="";
		el.src="/fstw/web/images/blog/one/blog_pl_1.jpg";
	}
}
function checkclick(msg){if(confirm(msg)){try{event.returnValue=true;}catch(e){return true;}}else{try{event.returnValue=false;}catch(e){return false;}}}
function shw_reputation(num){
	$("re_div_"+num).style.display="";
}
function dis_reputation(num){
	$("re_div_"+num).style.display="none";
}

function copyurltoclip(atitle){
var clipBoardContent="";clipBoardContent+="推薦給你一篇不錯的文章";clipBoardContent+="\n";clipBoardContent+=atitle;clipBoardContent+="\n";clipBoardContent+=document.location;window.clipboardData.setData("Text",clipBoardContent);alert("復制成功，已經把該網址復制到剪貼板，可以打開QQ或者MSN的對話框，然後使用（Ctrl+V或鼠標右鍵）粘貼功能給你的好友");
}
function dignews(newsid){var url = '/fstw/news/dignews.action?id='+newsid;var loader1=new net.ContentLoader(url,dignewsb,onerrors,"POST","");}
function dignewsb(){var strText = this.req.responseText;$('the_newsdignum').innerHTML=strText;}