var form = 'post'; var textarea = 'message'; var which=null; function AddTag(open, close, content) { if(typeof(document.forms[form].elements[textarea])=='undefined'){ if(which==null){ var textfield = document.forms[form].elements['message[0]']; } else{ var textfield = which; } } else{ var textfield = document.forms[form].elements[textarea]; } textfield.focus(); if(typeof document.selection != 'undefined') { var range = document.selection.createRange(); if(content == ''){ var toinsert = range.text; } else{ toinsert = content; } range.text = open + toinsert + close; range = document.selection.createRange(); if (toinsert.length == 0) { range.move('character', -close.length); } else { range.moveStart('character', open.length + toinsert.length + close.length); } range.select(); } else if(typeof textfield.selectionStart != 'undefined') { var start = textfield.selectionStart; var end = textfield.selectionEnd; if(content == ''){ var toinsert = textfield.value.substring(start, end); } else{ toinsert = content; } textfield.value = textfield.value.substr(0, start) + open + toinsert + close + textfield.value.substr(end); var pos; if (toinsert.length == 0) { pos = start + open.length; } else { pos = start + open.length + toinsert.length + close.length; } textfield.selectionStart = pos; textfield.selectionEnd = pos; } else { if(content == ''){ var toinsert=open + close; } else{ toinsert=open + content + close; } textfield.innerHTML+=toinsert; } } // insert [img] tag function AddImg() { AddTag('[IMG]', '[/IMG]', ''); } // insert [url] or [email] tag function AddLink(thetype) { AddTag("[" + thetype + "]", "[/" + thetype + "]", ''); } // insert html list function AddList() { type = prompt(language_array['bbcode']['listguide'], ""); if((type == "a") || (type == "1")) { list = "[LIST=" + type + "]\n"; listend = "[/LIST=" + type + "]"; } else { list = "[LIST]\n"; listend = "[/LIST]"; } entry = "start"; while ((entry != "") && (entry != null)) { entry = prompt(language_array['bbcode']['listpoint'], ""); if ((entry != "") && (entry != null)) list = list + "[*]" + entry + "[/*]\n"; } if(list != "[LIST]\n" && list !="[LIST=" + type + "]\n"){ addtext = list + listend; AddTag('', '', addtext); } } // insert code from another window function AddCodeFromWindow(thecode) { if(typeof(opener.document.forms[form].elements[textarea])=='undefined'){ if(which==null){ var textfield = opener.document.forms[form].elements['message[0]']; } else{ var textfield = which; } } else{ var textfield = opener.document.forms[form].elements[textarea]; } textfield.focus(); textfield.focus(); if(typeof opener.document.selection != 'undefined') { var range = opener.document.selection.createRange(); range.text = thecode; range = opener.document.selection.createRange(); range.moveStart('character', thecode.length); range.select(); } else if(typeof textfield.selectionStart != 'undefined') { var start = textfield.selectionStart; var end = textfield.selectionEnd; textfield.value = textfield.value.substr(0, start) + thecode + textfield.value.substr(end); var pos; pos = start + thecode.length; textfield.selectionStart = pos; textfield.selectionEnd = pos; } else { var pos; var re = new RegExp('^[0-9]{0,3}$'); while(!re.test(pos)) { pos = prompt(language_array['bbcode']['addcode']+" (0.." + textfield.value.length + "):", "0"); } if(pos > textfield.value.length) { pos = textfield.value.length; } textfield.value = textfield.value.substr(0, pos) + thecode + textfield.value.substr(pos); } } // insert [b] tag function AddB() { AddTag('[B]', '[/B]', ''); } // insert [U] tag function AddU() { AddTag('[U]', '[/U]', ''); } // insert [I] tag function AddI() { AddTag('[I]', '[/I]', ''); } // insert [S] tag function AddS() { AddTag('[S]', '[/S]', ''); } // insert [quote] tag function AddQuote() { AddTag('[quote]', '[/quote]', ''); } // insert [code] tag function AddCodetag() { AddTag('[code]', '[/code]', ''); } // insert [Toggle] tag function AddToggle() { AddTag("[toggle="+language_array['bbcode']['read_more']+"]", "[/toggle]", ''); } // toggle function - read more function Toggle(id, multi) { spanid1 = "ToggleRow_"+id; spanid2 = "ToggleImg_"+id; if(multi == true) { elements = document.getElementsByName(spanid1); val = document.getElementsByName(spanid1)[0].style.display; for (var i=0;i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&iymax) { document.getElementById("ws_image_" + name).height=ymax; document.getElementById("ws_imagediv_" + name).style.display = "block"; } if(xsize>xmax) { document.getElementById("ws_image_" + name).width=xmax; document.getElementById("ws_imagediv_" + name).style.display = "block"; } } function AddText(addtext) { AddTag('', '', addtext); } function AddCode(code) { AddText(code); } /* tooltip */ wmtt = null; function updateWMTT(e) { x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX; y = (document.all) ? window.event.y + document.body.scrollTop : e.pageY; if (wmtt != null) { wmtt.style.left = (x + 20) + "px"; wmtt.style.top = (y + 20) + "px"; } } function showWMTT(id) { document.onmousemove = updateWMTT; wmtt = document.getElementById(id); wmtt.style.display = "block"; } function hideWMTT() { wmtt.style.display = "none"; document.onmousemove = "none"; } //ajax functions function postRequest(strURL,id,action) { var xmlHttp; if (window.XMLHttpRequest) { var xmlHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlHttp.open('POST', strURL, true); xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { updatepage(xmlHttp.responseText,id,action); } } xmlHttp.send(strURL); } //update target function updatepage(str,id,action){ if (action == "add"){ document.getElementById(id).innerHTML+=str; } else if (action == "replace"){ document.getElementById(id).innerHTML=str; } else if (action == "formfield"){ document.getElementById(id).value =trim(str); } else if (action == "return"){ return str; } else if (action == "execute"){ eval(str); } } //fetch data for onclick/onchange events function eventfetch(url,id,action){ postRequest(url,id,action); } //fetch data for timebased events function timefetch(url,id,action,milliseconds) { eventfetch(url,id,action); setTimeout(function () { timefetch(url,id,action,milliseconds); },milliseconds); } //generic fetch function, accepts 5 parameters (first 4 mandatory). //url = script to access on the server //id = html id (for example of a div, a form field etc.., works with all tags which accept an id) //action = add, replace, return or formfield, add adds up content at the end of the original content in the id element, replace replaces the complete content in the id element, formfield replaces a form field value, return simply returns the fetched data //base = time or event, time based means script will autoexecute itself every amount of milliseconds specified via the 5th parameter, event based means you are calling the funtion with something like onclick, onchange, onmouseover or directly in a script //milliseconds = time in milliseconds till the script should autoexecute itself again (only needed when base==time) function fetch(url,id,action,base,milliseconds){ if(base == "event"){ eventfetch(url,id,action); } else if(base == "time"){ timefetch(url,id,action,milliseconds); } } //search & overlay functions function search(table,column,identifier,search,searchtemp,id,action,exact,searchtype){ exact = typeof(exact) != 'undefined' ? exact : 0; searchtype = typeof(searchtype) != 'undefined' ? searchtype : 0; searchrequest="../asearch.php?table="+table+"&column="+column+"&identifier="+identifier+"&search="+search+"&searchtemp="+searchtemp+"&div="+id+"&exact="+exact+"&searchtype="+searchtype; eventfetch(searchrequest,id,action); } function getposOffset(overlay, offsettype){ var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop; var parentEl=overlay.offsetParent; while (parentEl!=null){ totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; } function overlay(curobj, subobjstr, opt_position){ if (document.getElementById){ var subobj=document.getElementById(subobjstr) subobj.style.display="block" var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0) subobj.style.left=xpos+"px" subobj.style.top=(ypos+15)+"px" return false } else return true } function overlayclose(subobj){ document.getElementById(subobj).style.display="none" } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function formcheck_onsend(id){ valuestring=document.getElementById(id).value; if(trim(valuestring)==''){ return false; } else{ return true; } } //bbcode checker function validbbcode(txt){ searchregexp = /\[(B|\/B|U|\/U|I|\/I|S|\/S|code|\/code|LIST|LIST[a1=]*|\/LIST[a1=]*|\*|\/\*|\/LIST|EMAIL[a-zA-Z0-9=#@\._-]*|\/EMAIL|URL[a-zA-Z0-9=#,+@&?%:\/\._-]*|\/URL|IMG|\/IMG|QUOTE[^\]]*|\/QUOTE|TOGGLE[^\]]*|\/TOGGLE|SIZE=[1-5]{1}|\/SIZE|COLOR[^\]]*|\/COLOR|ALIGN[^\]]*|\/ALIGN|FONT[^\]]*|\/FONT)\]/ig; resulttemp=txt.match(searchregexp); if(null==resulttemp){ resulttemp=new Array(); } result=new Array(); ocode=0; putincounter=0; for(c=0;c0){ starttest=result[0].split('='); if(!(arraylength % 2)){ if(starttest[0].indexOf('/')==-1){ openingtagcounter=0; closingtagcounter=0; for(i=0;i