/***************************************************
 * Checkbox checking/unchecking/inverting functions
 **************************************************/
function warned(text) {
	    text = '' + text + '';
        var txtarea = document.postCm.message;
        if (txtarea.createTextRange && txtarea.caretPos) {
                var caretPos = txtarea.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? caretPos.text + text + ' ' : caretPos.text + text;
                txtarea.focus();
        } else {
                txtarea.value  += text;
                txtarea.focus();
        }
}
function storeCaret(textEl) {
        if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function checkAll(id){
   var f = document.getElementById(id);
   var inputs = f.getElementsByTagName("input");
   for(var t = 0;t < inputs.length;t++){
     if(inputs[t].type == "checkbox")
       inputs[t].checked = true;
   }
 }
 function uncheckAll(id){
   var f = document.getElementById(id);
   var inputs = f.getElementsByTagName("input");
   for(var t = 0;t < inputs.length;t++){
     if(inputs[t].type == "checkbox")
       inputs[t].checked = false;
   }
 }
 function invertAll(id){
   var f = document.getElementById(id);
   var inputs = f.getElementsByTagName("input");
   for(var t = 0;t < inputs.length;t++){
     if(inputs[t].type == "checkbox")
       inputs[t].checked = !inputs[t].checked;
   }
 }
 
 
/***************************************************
 * Hide/Show Divs
 **************************************************/
function hideDiv(div) {
    if (!document.getElementById) return;
    obj = document.getElementById(div);
    obj.style.display="none";
}
function showDiv(div) {
    if (!document.getElementById) return;
    obj = document.getElementById(div);
    obj.style.display="block";
}

/***************************************************
 * Flash Uploader
 **************************************************/
function getFileName(file) {
	document.upload.filename_fl.value = file;
}

function changeText() {
	if(document.upload.title.value != "" && document.upload.description.value != "" && document.upload.tags.value != "") {
		document.uploader.SetVariable("filledOut", true);
	}
}

<!--
function PopUp(aaa,zz,xx,scrb){

var wsss = eval (screen.width/2 - zz/2);
var hsss = eval(screen.height/2 - xx/2);

helpWin = window.open(aaa,"imageWin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scrb+",resizable=0,width="+ zz +",height="+ xx +",left="+ wsss +",top="+ hsss +"");

}

var selektion;

function insertAtCursor(myField, myValue, bbCode1, bbCode2, endOfLine) {
var bbb;
if(bbCode1=='[url=null]') { bbCode1=''; bbCode2=''; }
if(bbCode1=='[imgs]' && myValue==null) { bbCode1=''; bbCode2=''; myValue=''; }
if(bbCode1=='[imgs=null]') { bbCode1=''; bbCode2=''; myValue=''; }
if(bbCode2=='null[/imgs]') { bbCode2='[/imgs]'; myValue=''; }

if (document.selection) {
//IE support
var str = document.selection.createRange().text;
myField.focus();
sel = document.selection.createRange();
sel.text = bbCode1 + myValue + bbCode2 + endOfLine;
if(myValue=='') {
bbb=bbCode2.length;
if(bbCode1.substring(0,4)=='[img' ) bbb=0; else bbb=-bbb;
sel.moveStart('character',bbb); sel.moveEnd('character',bbb);
}
sel.select();
return;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
var bbb2, bbV, eoll;
if(myValue=='') myValue = myField.value.substring(startPos, endPos);
//alert(myValue);
myField.value = myField.value.substring(0, startPos) + bbCode1 + myValue + bbCode2 + endOfLine + myField.value.substring(endPos, myField.value.length);
if(myValue=='') {

if(bbCode1.substring(0,4)=='[img' ){
bbb=bbCode1.length + myValue.length + bbCode2.length;
myField.selectionStart=startPos+bbb; myField.selectionEnd=startPos+bbb;
}
else{
bbb=bbCode1.length;
myField.selectionStart=startPos+bbb;
myField.selectionEnd=endPos+bbb;
}

}
else {
bbb=bbCode1.length;
bbb2=bbCode2.length;
bbV=myValue.length;
eoll=endOfLine.length;
myField.selectionStart=startPos+bbV+bbb+bbb2+eoll;
myField.selectionEnd=myField.selectionStart;
}
myField.focus();
myField.scrollTop=myField.scrollHeight;

return;
} else {
myField.value += myValue;
return;
}
}

function paste_strinL(strinL, isQuote, bbCode1, bbCode2, endOfLine, User){
if((isQuote==1 || isQuote==2) && strinL=='') alert(l_quoteMsgAlert);
else{
if (isQuote==1) {
bbCode1='[quote=' + User + ']'; bbCode2='[/quote]'; endOfLine='\n';
}
if (isQuote==2) {
bbCode1='[b]'; bbCode2='[/b]'; endOfLine='\n';
}
var isForm=document.getElementById('postCm');
if (isForm) {
var input=document.getElementById('message');
//var input=document.forms["postCm"].elements["message"];
insertAtCursor(input, strinL, bbCode1, bbCode2, endOfLine);
}
else alert(l_accessDenied);
}
}

function pasteSel() {
selektion='';
if(window.getSelection) {
this.thisSel=window.getSelection()+'';
selektion=this.thisSel.toString();
}
else if(document.getSelection) selektion=document.getSelection()+'';
else if(document.selection) selektion=document.selection.createRange().text;
}


function trimTxt(s) {
while (s.substring(0,1) == ' ') {
s = s.substring(1,s.length);
}
while (s.substring(s.length-1,s.length) == ' ') {
s = s.substring(0,s.length-1);
}
return s;
}

function submitForm(){
// custom - anonymous postings solution
if(anonPost==1 && !checkIt()) return false;
var pf=document.forms['postCm'];
var ftitle=false, ftext=false, flogin=false, fpass=false, user_usr='', user_pwd='', topicTitle='', message='', fsubmit=true;
if(pf.elements['user_usr']) { flogin=true; user_usr=trimTxt(pf.elements['user_usr'].value); }
if(pf.elements['user_pwd']) { fpass=true; user_pwd=trimTxt(pf.elements['user_pwd'].value); }
if(pf.elements['message']) { ftext=true; message=trimTxt(pf.elements['message'].value); }
if(pf.elements['topicTitle']) { ftitle=true; topicTitle=trimTxt(pf.elements['topicTitle'].value); }
if(pf.elements['CheckSendMail'] && pf.elements['CheckSendMail'].checked) { tlength=0; }

if(flogin && fpass && user_usr!='' && user_pwd!='') fsubmit=true;
else if(flogin && fpass && anonPost==0 && user_pwd=='') fsubmit=false;
else if(ftext && message.length<tlength) fsubmit=false;
else if(ftitle && topicTitle.length<tlength) fsubmit=false;

if(fsubmit) { pf.elements['subbut'].disabled=true; document.forms['postCm'].submit(); } else { alert(l_accessDenied); return; }
}

//preview
function previewMessage(){
var modeChs;

window.open('', 'cWin2', 'resizable=yes, scrollbars=yes, width=500, height=300, top=0, left=300');
document.forms['postCm'].target='cWin2';
document.forms['postCm'].elements['prevForm'].value=1;
if(document.forms['postCm'].elements['mode']) {
document.forms['postCm'].elements['mode'].value='';
modeChs=true;
}
var prevEnc=document.forms['postCm'].encoding;
if(prevEnc=='multipart/form-data') document.forms['postCm'].encoding='application/x-www-form-urlencoded';
document.forms['postCm'].submit();
document.forms['postCm'].target='_self';
if(prevEnc=='multipart/form-data') document.forms['postCm'].encoding=prevEnc;
document.forms['postCm'].elements['prevForm'].value=0;
if(modeChs) document.forms['postCm'].elements['mode'].value='login';
return;
}
//eof preview

//disable anonymous postings solution //
var names=new Array('anon', 'guest', '@', '.com', '.net', 'org');

function checkIt(){
var ret=true;
var pf=document.forms['postCm'];
var nLow, sLow, a;

if (pf.elements['user_usr']!=undefined){
if (pf.elements['user_usr'].value.length>2 && pf.elements['user_usr'].value.length<15){

var nLn=names.length;
strL=pf.elements['user_usr'].value.length;
sLow=pf.elements['user_usr'].value.toLowerCase();

for (var i=0; i<nLn; i++){

nLnL=names[i].length;
nLow=names[i].toLowerCase();

if(nLnL>strL) {}
else{

if(sLow.indexOf(nLow)>=0) {
ret=false;
break;
}

}

}

}
else ret=false;
}
if(!ret) {
alert('Please enter something containing between 3 and 14 symbols in the Username box!\nEmpty or forbidden usernames are disallowed.');
pf.elements['user_usr'].focus();
}
return ret;
}
// eof disable anonymous postings solution //

function decision(message, url){
if(confirm(message)) location.href = url;
}