var b_open = 0;var i_open = 0;var u_open = 0;var s_open = 0;var indent_open = 0;var left_open = 0;var right_open = 0;var center_open = 0;var quote_open = 0;var code_open = 0;var bbtags   = new Array();var myAgent   = navigator.userAgent.toLowerCase();var myVersion = parseInt(navigator.appVersion);var is_ie   = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));var is_win = ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
function isAlphaNumeric(val){if (val.match(/^[a-zA-Z0-9]+$/)){return true;}else{return false;}}
function CheckAddnews(){var A1 = document.t_post_form.title.value;var A2 = document.t_post_form.t_mes.value;if (A1.length < 1) {alert("Please enter your title at least 1 characters.");document.t_post_form.title.focus();return false;}else if (A2.length < 5) {alert("Please enter your messages at least 5 characters.");document.t_post_form.t_mes.focus();return false;}else return true;}
function CheckAddprivilege(){var A1 = document.Addprivilege.account.value;if (A1.length < 1) {alert("Please enter account ID at least 1 characters.");document.Addprivilege.account.focus();return false;}else return true;}
function CheckAddreport(){var A1 = document.Addreport.poster.value;var A2 = document.Addreport.report.value;if (A1.length < 4 || A1.length > 24) {alert("Please enter your name between 4 - 24 characters.");document.Addreport.poster.focus();return false;}else if (A2.length < 5 || A2.length > 512) {alert("Please enter your messages between 5 to 512 characters.");document.Addreport.report.focus();return false;}else {document.Addreport.Submit.disabled=true;return true;}}
function CheckPostmessage(x){var A1 = document.getElementById(x).t_title.value;var A2 = document.getElementById(x).t_mes.value;if (A1.length < 3) {alert("You must enter messages of Topic Title at least 3 characters to post.");document.getElementById(x).t_title.focus();return false;}else if (A2.length < 3) {alert("You must enter messages at least 3 characters to post.");document.getElementById(x).t_mes.focus();return false;}else {if(document.getElementById(x).newpoll.value=='1') {return CheckPoll();}document.getElementById(x).Submit.disabled=true;return true;}}
function CheckReplymessage(x){var A1 = document.getElementById(x).t_mes.value;if (A1.length < 3) {alert("You must enter messages at least 3 characters to post.");document.getElementById(x).t_mes.focus();return false;}else {document.getElementById(x).Submit.disabled=true;return true;}}
function CheckEdittopic(x){var A1 = document.Edit_Topic_Form.t_title.value;if (A1.length < 3) {alert("You must enter messages of Topic Title at least 3 characters to post.");document.Edit_Topic_Form.t_title.focus();return false;}else {document.Edit_Topic_Form.Submit.disabled=true;return true;}}
function CheckPostlength(x,maxlength) {var A1 = document.getElementById(x).t_mes.value.length;if(A1 > maxlength) {alert('Please input your post messages less than '+maxlength+' characters ['+A1+']'); document.getElementById(x).t_mes.focus(); return false;} return true;}
function CheckMod(){if (document.topic_option.code.value == '00') return false; else return true;}
function CheckRank(){var R1 = document.Ranking_Sort.job.value;var R2 = document.Ranking_Sort.ptype.value;var R3 = document.Ranking_Sort.key.value;var R4 = document.Ranking_Sort.status.value;var R5 = document.Ranking_Sort.rows.value;var R6 = document.Ranking_Sort.charname.value;var R7 = document.Ranking_Sort.ctype.value;if (R5 < 1 || R5 > 100) {alert("Please input 1-100 row(s) only");return false;} else {document.Ranking_Sort.Button.disabled=true;window.location.href='index.php?act=p_rank&charname='+R6+'&ctype='+R7+'&job='+R1+'&ptype='+R2+'&key='+R3+'&status='+R4+'&rows='+R5+'&st=0';return true;}}
function hide_menu(x,name) {if (document.getElementById(x).style.display == "") {document.getElementById(x).style.display = "none";var ExpDate = new Date();ExpDate.setTime (ExpDate.getTime()+60*60*24*30);document.cookie = " "+name+""+"="+1+";expires="+ExpDate.toGMTString()+";path=/ ";}else {document.getElementById(x).style.display = "";var ExpDate = new Date();ExpDate.setTime (ExpDate.getTime()-60*60*24*30);document.cookie = ""+name+""+"="+1+";expires="+ExpDate.toGMTString()+";path=/";}}
function adds_tags(x,ibTag, ibClsTag, isSingle) {var isClose = false;var obj_ta = document.getElementById(x).t_mes;var myAgent   = navigator.userAgent.toLowerCase();var myVersion = parseInt(navigator.appVersion);var is_ie   = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));var is_win   =  ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));if ( (myVersion >= 4) && is_ie && is_win) {if(obj_ta.isTextEdit){obj_ta.focus();var sel = document.selection;var rng = sel.createRange();rng.colapse;if((sel.type == "Text" || sel.type == "None") && rng != null){if(ibClsTag != "" && rng.text.length > 0)ibTag += rng.text + ibClsTag;else if(isSingle)isClose = true;rng.text = ibTag;}}else{if(isSingle)isClose = true;obj_ta.value += ibTag;}}else{if(isSingle)isClose = true;obj_ta.value += ibTag;}obj_ta.focus();return isClose;}
function hyperlink(URL) {window.location.href=''+URL+'';}
function tag_url(x) {var url = window.prompt('Enter the complete URL for the hyperlink','http://');var urlname = window.prompt('Enter the title of the webpage','My Webpage');if (url == 'http://') { alert('Error! You must enter a URL'); return false; }if(url) adds_tags(x,'[url='+ url +']'+ urlname +'[/url]', '', false);}
function tag_image(x) {var img = window.prompt('Enter the complete URL for the the image','http://');if (img == 'http://') { alert('Error! You must enter a URL'); return false; }if(img) adds_tags(x,'[img]'+ img +'[/img]', '', false);}
function tag_email(x) {var email = window.prompt('Enter the email address','');if (email == '') { alert('You must enter an email address'); return false; }if(email) adds_tags(x,'[email]'+ email +'[/email]', '', false);}
function tag_list(x,i) {if(i) var type='=1';else var type='';adds_tags(x,'[list'+type+']\n', '', false); adds_list(x);}
function adds_list(x) {var list = window.prompt('Enter a list item','');if (list == '' || list == null) { adds_tags(x,'[/list]', '', false); return false; }if(list) {adds_tags(x,'[*]'+list+'\n', '', false);adds_list(x);}}
function emotion(x,emotion){adds_tags(x,' '+emotion+' ','',false);}
function openwindows(url,menubar,scrollbars,width,height){window.open(''+url+'','','menubar='+menubar+',scrollbars='+scrollbars+',width='+width+',height='+height+'');}
function page_jump(URL,per_page,last_page) {var page = window.prompt('Please enter a page number to jump to between 1 and '+last_page+'','2');if(page>0) window.location.href=''+URL+'&st='+per_page*(page-1)+'';}
function page_jump_(x,get,per_page,last_page) {var page = window.prompt('Please enter a page number to jump to between 1 and '+last_page+'','2');if(page>0) page_select(''+x+'',''+get+'st='+per_page*(page-1)+'');}
function delete_post(theURL) {if (confirm('Are you sure you want to delete this message?')) {window.location.href=theURL;} else { alert ('Ok, no action has been taken'); } }
function link_to_post(URL) {window.prompt("Manually copy the direct link to this post below to store the link in your computer's clipboard",""+URL+"");}
setInterval("x()",10);function x(){window.status='';}
function change_page(){var A1=document.Adminmenu.admin_options.value; window.location.href=A1;}
var prompt_start= "Enter the text to be formatted";
function hstat(msg){}
function cstat(){var c = stacksize(bbtags);if ( (c < 1) || (c == null) ) {c = 0;}if ( ! bbtags[0] ) {c = 0;}}
function stacksize(thearray){for (i = 0 ; i < thearray.length; i++ ) {if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') ) {return i;}}return thearray.length;}
function pushstack(thearray, newval){arraysize = stacksize(thearray);thearray[arraysize] = newval;}
function get_easy_mode_state(){return false;}
function popstack(thearray){arraysize = stacksize(thearray);theval = thearray[arraysize - 1];delete thearray[arraysize - 1];return theval;}
function simpletag(x,thetag){var tagOpen = eval(thetag + "_open");if( get_easy_mode_state() ){inserttext = prompt(prompt_start + "\n[" + thetag + "]xxx[/" + thetag + "]");if ( (inserttext != null) && (inserttext != "") ){doInsert(x,"[" + thetag + "]" + inserttext + "[/" + thetag + "] ", "", false);}}else {if (tagOpen == 0){if(doInsert(x,"[" + thetag + "]", "[/" + thetag + "]", true)){eval(thetag + "_open = 1");eval("document.getElementById(x)." + thetag + ".value += '*'");pushstack(bbtags, thetag);cstat();hstat('click_close');}}else {lastindex = 0;for (i = 0 ; i < bbtags.length; i++ ){if ( bbtags[i] == thetag ){lastindex = i;}}while (bbtags[lastindex]){tagRemove = popstack(bbtags);doInsert("x,[/" + tagRemove + "]", "", false);if ( (tagRemove != 'FONT') && (tagRemove != 'SIZE') && (tagRemove != 'COLOR') ){eval("document.getElementById(x)." + tagRemove + ".value = ' " + tagRemove + " '");eval(tagRemove + "_open = 0");}}cstat();}}}
function doInsert(x,ibTag, ibClsTag, isSingle){var isClose = false;var obj_ta = document.getElementById(x).t_mes;if ( (myVersion >= 4) && is_ie && is_win){if(obj_ta.isTextEdit){obj_ta.focus();var sel = document.selection;var rng = sel.createRange();rng.colapse;if((sel.type == "Text" || sel.type == "None") && rng != null){if(ibClsTag != "")ibTag += rng.text + ibClsTag;else if(isSingle)isClose = true;rng.text = ibTag;}}else{if(isSingle)isClose = true;obj_ta.value += ibTag;}}else{var sel_start = obj_ta.selectionStart;var sel_end = obj_ta.selectionEnd;var text_selection = obj_ta.value.substr(sel_start,sel_end-sel_start);ibTag += text_selection + ibClsTag;obj_ta.value=obj_ta.value.substr(0,sel_start)+ibTag+obj_ta.value.substr(sel_end);}obj_ta.focus();return isClose;}
function alterfont(x,theval, thetag){if (theval == 0)return;if(doInsert(x,"[" + thetag + "=" + theval + "]", "[/" + thetag + "]", true))pushstack(bbtags, thetag);cstat();}
function ShowHide(x) {if(x=='hide_bbcode') {document.getElementById('ffont').style.visibility = "hidden";document.getElementById('fsize').style.visibility = "hidden";document.getElementById('fcolor').style.visibility = "hidden";} else {if (document.getElementById(x).style.visibility == "hidden") {document.getElementById(x).style.visibility = "visible";} else {document.getElementById(x).style.visibility = "hidden";}}}
function menu_build_menu(id,width,menu) {
var src_menu = "";
var old_src = document.getElementById(id).innerHTML;
for (var i=0;menu[i]!=null;i++) {
	src_menu += "<tr><td style='padding-bottom:5px;font-family:Verdana;font-size:8pt'><img src='theme/"+theme+"/images/menu_item.gif' border='0'>&nbsp;"+menu[i]+"</td></tr>";
}
document.getElementById(id).onclick = function() {
				ShowHide(''+id+'_menu');
				return false;
			}
document.getElementById(id).innerHTML = "<span style='position:relative;padding:0px;'>"+old_src+"<span id='"+id+"_menu' class='rte-menu-hidden' style='width:"+width+";visibility:hidden;text-decoration:none;'><table border='0' cellspacing='0' cellpadding='0' align='left' style='padding-top:5px;'>"+src_menu+"</table></span></span>";
}