var i=0;
var kj=1;
var is_max=1;
function del(){if(confirm("確定要刪除嗎？")){return true;}return false;}
function msd(para_URL){var URL=new String(para_URL);window.open(URL,'','height=171,width=300')}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function goto(para_URL) {var URL=new String(para_URL); window.location = "URL"; }
function checklength(theform) {alert("你的文章已經有 "+theform.content.value.length+" 字。");}
function inputs(str)
{document.form.content.value=document.form.content.value+str;}
var i=0;
function formCheck(){i++;if (i>1) {alert('正在處理資料，請耐心等候！');return false;}}
function presskey(eventobject){if(event.ctrlKey && window.event.keyCode==13){i++;if (i>1) {alert('文章正在發送，請耐心等候！');return false;}this.document.form.submit();}}
helpstat = false; stprompt = true; basic = false;
function AddText(NewCode) {document.getElementById('word_content').value+=NewCode}
function bold() {
if (helpstat) {alert("加粗標記\n使文字加粗.\n使用方式: [b]這是加粗的文字[/b]");
} else if (basic) {AddTxt="[b][/b]";AddText(AddTxt);} else {txt=prompt("文字將被變粗.","文字");
if (txt!=null) {AddTxt="[b]"+txt;AddText(AddTxt);AddTxt="[/b]";AddText(AddTxt);}}
}
function italicize() {
if (helpstat) {alert("斜體標記\n使文字字型樣式變為斜體.\n使用方式: [i]這是斜體字[/i]");} else if (basic) {
AddTxt="[i][/i]";AddText(AddTxt);} else { txt=prompt("文字將變斜體","文字");
if (txt!=null) {AddTxt="[i]"+txt;AddText(AddTxt);AddTxt="[/i]";AddText(AddTxt);}}
}
function strike() {
if (helpstat) {alert("刪除線標記\n使文字加上刪除線.\n使用方式: [strike]這是加上刪除線的字[/strike]");} else if (basic) {
AddTxt="[strike][/strike]";AddText(AddTxt);} else { txt=prompt("文字將加上刪除線","文字");
if (txt!=null) {AddTxt="[strike]"+txt;AddText(AddTxt);AddTxt="[/strike]";AddText(AddTxt);}}
}
function center() {
if (helpstat) {alert("置中標記\n使文字置中.\n使用方式: [center]這是置中的字[/center]");} else if (basic) {
AddTxt="[center][/center]";AddText(AddTxt);} else { txt=prompt("文字將置在中央","文字");
if (txt!=null) {AddTxt="[center]"+txt;AddText(AddTxt);AddTxt="[/center]";AddText(AddTxt);}}
}
function hyperlink() {
if (helpstat) {alert("超連結標記\n插入一個超連結標記\n使用方法: [url]http://penhk.com[/url]\n使用方式: [url=http://penhk.com]連結文字[/url]");
} else if (basic) {AddTxt="[url][/url]";AddText(AddTxt);} else { txt2=prompt("連結文字顯示.\n如果不想使用, 可以為空, 將只顯示超連結位址. ",""); 
if (txt2!=null) {txt=prompt("超連結.","http://");if (txt!=null) {
if (txt2=="") {AddTxt="[url]"+txt;AddText(AddTxt);AddTxt="[/url]";AddText(AddTxt);} else {AddTxt="[url="+txt+"]"+txt2;AddText(AddTxt);AddTxt="[/url]";AddText(AddTxt);}}}}
}
function image() {
if (helpstat){alert("圖片標記\n插入圖片\n使用方式： [img]http://penhk.com/logo.gif[/img]");} else if (basic) {AddTxt="[img][/img]";AddText(AddTxt);} else { txt=prompt("圖片的 URL","http://download.johnnyshiu.com/");
if(txt!=null) { AddTxt="[img]"+txt;AddText(AddTxt);AddTxt="[/img]";AddText(AddTxt);}}
}
function underline() {
if (helpstat) {alert("底線標記\n給文字加底線.\n使用方式: [u]要加底線的文字[/u]");} else if (basic) {
AddTxt="[u][/u]";AddText(AddTxt);} else { txt=prompt("底線文字.","文字");
if (txt!=null) { AddTxt="[u]"+txt;AddText(AddTxt);AddTxt="[/u]";AddText(AddTxt);}}
}
function checkall(form) {
	for(var i = 0;i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.name != 'all') {
			e.checked = form.all.checked;
		}
	}
}

function changeFontSize(aa,bb){
var oDiv=document.all(aa);
with (document.all(bb)) var sValue=options[selectedIndex].value;
oDiv.style.fontSize=sValue;
}

function fixPng() {
  var arVersion = navigator.appVersion.split("MSIE")
  var version = parseFloat(arVersion[1])

  if ((version >= 5.5 && version < 7.0) && (document.body.filters)) {
    for(var i=0; i<document.images.length; i++) {
      var img = document.images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.indexOf(".PNG") > 0) {
        var width = img.width;
        var height = img.height;
        var sizingMethod = (img.className.toLowerCase().indexOf("scale") >= 0)? "scale" : "image"; 
        img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
        img.src = "./image/blank.gif";
        img.width = width;
        img.height = height;
        }
      }
    }
  }
  
  var bgsleight	= function() {
	
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}
	
	function fnLoadPngs() {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
		for (var i = document.all.length - 1, obj = null; (obj = document.all[i]); i--) {
			if (itsAllGood && obj.currentStyle.backgroundImage.match(/\.png/i) != null) {
				fnFixPng(obj);
				obj.attachEvent("onpropertychange", fnPropertyChanged);
			}
		}
	}

	function fnPropertyChanged() {
		if (window.event.propertyName == "style.backgroundImage") {
			var el = window.event.srcElement;
			if (!el.currentStyle.backgroundImage.match(/x\.gif/i)) {
				var bg	= el.currentStyle.backgroundImage;
				var src = bg.substring(5,bg.length-2);
				el.filters.item(0).src = src;
				el.style.backgroundImage = "url(x.gif)";
			}
		}
	}

	function fnFixPng(obj) {
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		obj.style.backgroundImage = "url(x.gif)";
	}
	
	
	
	
	return {
		
		init: function() {
			
			if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
				addLoadEvent(fnLoadPngs);
			}
			
		}
	}
	
}();

//bgsleight.init();
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function GetCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function disableAlert(){
	SetCookie('checkBro', 123, 100000);
	document.getElementById('alert').style.display='none';
}

function checkAlert(){
	var Abc = GetCookie('checkBro');
	if(Abc != ''){
		document.getElementById('alert').style.display='none';
	}
}