wmtt = null;
document.onmousemove = updateWMTT;

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) {
wmtt = document.getElementById(id);
wmtt.style.visibility = "visible";
wmtt.style.display = "block";
}

function hideWMTT() {
wmtt.style.visibility = "hidden";
wmtt.style.display = "none";
}

function showhide(obj){
    if(obj == 'none') return 'inline';
    else return 'none';
}

function news_preview()
{
 window.open('modules/news/preview.php','Preview','resizable=yes,scrollbars=yes,menubar=no,status=no,location=no,width=640,height=480');
}

function cont_preview()
{
 window.open('modules/content/preview.php','Preview','resizable=yes,scrollbars=yes,menubar=no,status=no,location=no,width=640,height=480');
}



  function checktag(tag){
    tag=tag.substring(0,tag.length-1).toLowerCase(); //Extract tag
    if (tag=="br") return "\n";

    if (tag=="b") return "[b]";
    if (tag=="/b") return "[/b]";
    if (tag=="i") return "[i]";
    if (tag=="/i") return "[/i]";
    if (tag=="u") return "[u]";
    if (tag=="/u") return "[/u]";
    
    if (tag=="div class=quote") return "[quote]";
    if (tag=="/div") return "[/quote]";
    return '';
  }

function checktag2(tag){

 tag=tag.replace(/&lt;/g,'<');
 tag=tag.replace(/&gt;/g,'>');

return tag;
}

function getSel() {
    if (window.getSelection)
       return window.getSelection();
    else if (document.selection)
       return document.selection.createRange().text;
    else if (document.getSelection)
       return document.getSelection();
    else return '';
}


  function quotmsg(id) {
    var m=document.all['quot_'+id].innerHTML;
    var a=document.all['aut_'+id].innerHTML;
    var b="";
    var tag="";
    var c=true;
  
    for (var i=0; i < m.length; i++) {
      if (m.charAt(i)=='<') {
        c=false;
        tag="";
        continue;
      }
  
      if (c) b+=m.charAt(i); else if (m.charAt(i)!='"') tag+=m.charAt(i);
  
      if (m.charAt(i)=='>') {
        c=true;
        //b+=checktag(tag); //Replace tag
      }
    }
    
    ins("\n[quote][b]"+a+" ïèñàë(à):[/b]\n"+b+"[/quote]\n");
  }

function ins2(txt1,txt2) {
    var txtarea;
    txtarea=document.newmsg.user_text;
    txtarea.focus();

    if (document.selection) {
      theSelection = document.selection.createRange().text; // Get text selection
      document.selection.createRange().text = txt1 + theSelection + txt2;
      theSelection = '';
      return;
    }
    else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
      mozWrap(txtarea, txt1, txt2);
    else txtarea.value=txtarea.value+txt1+txt2;
}

function copyQ(name) {
txt=''
if (document.getSelection) {txt=document.getSelection()}
else if (document.selection) {txt=document.selection.createRange().text;}
}

function ins(txt){
    ins2(txt,'');
}

function quote(id){
    var a=document.all['aut_'+id].innerHTML;
    if (txt!='')
      ins("\n[quote][b]"+a+":[/b]\n"+txt+"[/quote]\n");
    else quotmsg(id);
}

function insertext(text1,text2,area){
    var b=getSel();
    theSelection = document.selection.createRange().text;
    if(area=="short"){if (!theSelection) { document.newmsg.text_news_short.focus(); document.newmsg.text_news_short.value += text1 + text2; document.newmsg.text_news_short.focus(); return; } else {document.newmsg.text_news_short.focus(); document.selection.createRange().text = text1 + b + text2; document.newmsg.text_news_short.focus(); return; } }
    if(area=="full"){if (!theSelection) { document.newmsg.text_news.focus(); document.newmsg.text_news.value += text1 + text2; document.newmsg.text_news.focus(); return; } else {document.newmsg.text_news.focus(); document.selection.createRange().text = text1 + b + text2; document.newmsg.text_news.focus(); return; } }
    if(area=="shortc"){if (!theSelection) { document.newmsg.con_short.focus(); document.newmsg.con_short.value += text1 + text2; document.newmsg.con_short.focus(); return; } else {document.newmsg.con_short.focus(); document.selection.createRange().text = text1 + b + text2; document.newmsg.con_short.focus(); return; } }
    if(area=="fullc"){if (!theSelection) { document.newmsg.con_full.focus(); document.newmsg.con_full.value += text1 + text2; document.newmsg.con_full.focus(); return; } else {document.newmsg.con_full.focus(); document.selection.createRange().text = text1 + b + text2; document.newmsg.con_full.focus(); return; } }

}

function mozWrap(txtarea, open, close)
  {
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    if (selEnd == 1 || selEnd == 2)
      selEnd = selLength;
  
    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = s1 + open + s2 + close + s3;
    return;
}

function smile(icon)
{
opener.document.newmsg.user_text.value = document.newmsg.user_text.value + icon + ' ';
opener.document.newmsg.user_text.focus();
}

function code(icon)
{
var b=getSel();
document.newmsg.user_text.focus();
document.selection.createRange().text = '[' + icon + ']' + b + '[/' + icon + ']';
document.newmsg.user_text.focus();
}

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(theform,thelimit){
var limit_text='<font size=1 face=Verdana><b><span id="'+theform.toString()+'">'+thelimit+'</span></b></font>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

// Code to display window every time broser opens this page language="JavaScript1.2"

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"
var lpos

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<lpos)
crossobj.top=parseInt(crossobj.top)+25+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
function delay(x)
{
var d=new Date()
d=d.getSeconds()+x
if (d>=60) d=d-60
while (true)
{
var d1=new Date()
if(d==d1.getSeconds())
break;
}
}



function DropIn(main_bgcolor,main_texttype,main_textsize,main_textcolor,textbar,height,width,top,left,bordercolor,borderstyle,borderwidth,sec)
{
lpos = top
ans="no"
//delay(sec)
var chkshow=false;



if(!chkshow)
{ 
if (ns4)
{
templayer=document.layers[0]
templayer.left=left
templayer.top=top
templayer.width=width
templayer.height=height
}
else if (ns6)
{
document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
document.getElementById("dragtext").innerHTML=textbar

document.getElementById("dropin").style.height=height +'px'
document.getElementById("dropin").style.width =width +'px'
document.getElementById("dropin").style.left =left +'px'
document.getElementById("dropin").style.top =top +'px'
document.getElementById("dragtext").style.backgroundColor=main_bgcolor
document.getElementById("dragtext").style.color = main_textcolor
document.getElementById("dragtext").style.fontFamily = main_texttype
document.getElementById("dragtext").style.fontSize = main_textsize+'px'
}
else 
{
document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
document.getElementById("dragtext").innerHTML=textbar

document.getElementById("dropin").style.height=height +'px'
document.getElementById("dropin").style.width =width +'px'
document.getElementById("dropin").style.left =left +'px'
document.getElementById("dropin").style.top =top +'px'
document.getElementById("dragtext").style.backgroundColor=main_bgcolor
document.getElementById("dragtext").style.color = main_textcolor
document.getElementById("dragtext").style.fontFamily = main_texttype
document.getElementById("dragtext").style.fontSize = main_textsize+'px'
}
setTimeout("initbox()",(sec*1000));
}
}

function submit_form(SpecialAct){
	document.adminForm.act.value=SpecialAct;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

function id_form(SpecialID){
	document.adminForm.id.value=SpecialID;
}

function checkAll( n ) {

	var f = document.adminForm;
	var c = f.checker.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		box = eval( 'f.' + 'box' + '_' + i );
		if (box) {
			box.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}



function c_quote( value ) {
document.getElementById('red_comtxt').value=document.getElementById('red_comtxt').value + '\r\n[quote]' + value + '[/quote]\r\n';
}

      var lat=new Array("jo","zh","i'","ch","sh","xh","je","ju","ja","a","b","v","g","d","e","z","i","k","l","m","n","o","p","r","s","t","u","f","x","c","'","y","`","j","h");
      var cyr=new Array("¸","æ","é","÷","ø","ù","ý","þ","ÿ","à","á","â","ã","ä","å","ç","è","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","ü","û","ú","æ","õ");

      var latcap=new Array("JO","Jo","ZH","Zh","I'","Ch","CH","Sh","SH","Xh","XH","Je","JE","Ju","JU","Ja","JA","A","B","V","G","D","E","Z","I","K","L","M","N","O","P","R","S","T","U","F","X","C","Y","J","H");
      var cyrcap=new Array("¨","¨","Æ","Æ","É","×","×","Ø","Ø","Ù","Ù","Ý","Ý","Þ","Þ","ß","ß","À","Á","Â","Ã","Ä","Å","Ç","È","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","Û","Æ","Õ");


      function translate(tex)
      {
      var buf=tex;
      var i;
      for (i=0;i<latcap.length;i++)
        {
        buf=replace(buf,latcap[i],cyrcap[i],1,0);
        }

      for (i=0;i<lat.length;i++)
        {
        buf=replace(buf,lat[i],cyr[i],1,0);
        }

      tex=buf;
      return tex;
      }

      function replace(target,oldTerm,newTerm,caseSens,wordOnly) {

        var work = target;
        var ind = 0;
        var next = 0;

        if (!caseSens) {
          oldTerm = oldTerm.toLowerCase();
          work = target.toLowerCase();
        }

        while ((ind = work.indexOf(oldTerm,next)) >= 0) {
          if (wordOnly) {
            var before = ind - 1;
            var after = ind + oldTerm.length;
            if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
              next = ind + oldTerm.length;
              continue;
            }
          }
          target = target.substring(0,ind) + newTerm +
          target.substring(ind+oldTerm.length,target.length);
          work = work.substring(0,ind) + newTerm +
          work.substring(ind+oldTerm.length,work.length);
          next = ind + newTerm.length;
          if (next >= work.length) { break; }
        }

        return target;

      }

      function detr_mozWrap(txtarea)
        {
          var selLength = txtarea.textLength;
          var selStart = txtarea.selectionStart;
          var selEnd = txtarea.selectionEnd;
          if (selEnd == 1 || selEnd == 2)
            selEnd = selLength;

          var s1 = (txtarea.value).substring(0,selStart);
          var s2 = (txtarea.value).substring(selStart, selEnd)
          var s3 = (txtarea.value).substring(selEnd, selLength);
          txtarea.value = s1 + translate(s2) + s3;
          return;
      }
