function openalwindow(x,y) {
window.open("aliases.php", "aliases","toolbar=no,scrollbars=yes,resizable=no,width="+x+",height="+y);
}
function openalwindow_b(x,y) {
window.open("aliases.php?action=b", "aliases","toolbar=no,scrollbars=yes,resizable=no,width="+x+",height="+y);
}
function openalwindow_m(x,y) {
window.open("aliases.php?action=m", "aliases","toolbar=no,scrollbars=yes,resizable=no,width="+x+",height="+y);
}
function openchat(x,y) {
window.open("irc/irc.php", "irc","toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);
}
function lhelp(x) {
window.open("system.php?action=help&id="+x, "help","toolbar=no,scrollbars=yes,resizable=yes,width=300,height=400");
}

function onw(i,w,h,tl) {
newwin=window.open('','img','width='+w+',height='+h+',resizable=yes,scrollbars=yes,status=no,tollbar=no');
newwin.document.open();
newwin.document.write('\n<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n');
newwin.document.write('<meta http-equiv="Imagetoolbar" content="no" />\n');
newwin.document.write('<title>'+tl+'</title>\n');
newwin.document.write('</head>');
newwin.document.write('<body style="margin:0;padding:0">\n<img src="'+i+'" width="'+w+'" height="'+h+'" />');
newwin.document.write('\n</body></html>');
newwin.document.close();
newwin.focus(); 
}

function updc(id)
{
 var http = getHTTPObject();
 http.open("GET", "ajax2.php?id="+id, true);
 http.onreadystatechange=function(){if(http.readyState==4){}}
 http.send(null);
}

function newwindow() 
{ 
window.open('system.php?action=shoutbox','shout','width=300,height=450,resizable=yes,scrollbars=yes,tollbar=no'); 
} 
function newwindow2() 
{ 
window.open('chat_inv.php?src=<? echo $invrd->inv;  ?>','chat_inv','width=760,height=640,resizable=yes,scrollbars=yes,tollbar=yes'); 
}

function bbcode(myField, myValue,myValue2) {
    if (document.selection) {
        var temp;
        myField.focus();
        sel=document.selection.createRange();
        temp=sel.text.lenght;
        sel.text=myValue+sel.text+myValue2;
        if (myValue.length==0){
            sel.moveStart('character',myValue.length);
            sel.moveEnd('character',myValue.length);
        }
        else {
            sel.moveStart('character',-myValue.length+temp);
        }
        sel.select();
    }
    else if (myField.selectionStart || myField.selectionStart=='0'){
	var currentScroll /*: int*/ = myField.scrollTop;
        var startPos=myField.selectionStart;
        var endPos=myField.selectionEnd;
        myField.value=myField.value.substring(0,startPos)+myValue+myField.value.substring(startPos,endPos)+myValue2+myField.value.substring(endPos,myField.value.length);
	  myField.scrollTop = currentScroll;
        myField.selectionStart=startPos+myValue.length;
        myField.selectionEnd=endPos+myValue.length;      
myField.focus();
    }
    else{
        myField.value+=myValue;
    }
}


var newwindow;

function poptastic(url){

newwindow=window.open(url,'name','height=500,width=240,left=20,top=20,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no');

if (window.focus) {newwindow.focus()}

}

function CheckCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'allbox') && (e.type=='checkbox')) {
      TotalBoxes++;
      if (e.checked) {
       TotalOn++;
      }
    }
  }
  if (TotalBoxes==TotalOn) {
    fmobj.allbox.checked=true;
  }
  else {
   fmobj.allbox.checked=false;
  }
}

function getHTTPObject()
{
 var xmlhttp = false;
 try
 {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
 {
  try
  {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
  catch (e)
  {
   xmlhttp = false;
   }
  }
 if(!xmlhttp && typeof XMLHttpRequest!='undefined')
 {
  try
  {
    xmlhttp = new XMLHttpRequest();
    }
  catch (e)
  {
    xmlhttp = false;
    }
  }
 if(!xmlhttp && window.createRequest)
 {
  try
  {
    xmlhttp = window.createRequest();
    }
  catch (e)
  {
    xmlhttp = false;
    }
  }
 return xmlhttp;
 }

function toggle(id){
    box1 = document.getElementById(id); 
    if (box1){
            if (box1.className == 'closed'){
                    box1.className = "open";
                    }else{
                    box1.className = "closed";
                    }
            }
    }

function toggle_m(id1,id2,id3,id4){
    box1 = document.getElementById(id1);
    box2 = document.getElementById(id2);
    box3 = document.getElementById(id3);
    box4 = document.getElementById(id4);
box1.className = "closed";
box2.className = "closed";
box3.className = "closed";
box4.className = "closed";
box1.className = "open";
    }

function toggle_m3(id1,id2,id3){
    box1 = document.getElementById(id1);
    box2 = document.getElementById(id2);
    box3 = document.getElementById(id3);
    box11 = document.getElementById(id1+'_1');
    box21 = document.getElementById(id2+'_1');
    box31 = document.getElementById(id3+'_1');
box1.className = "closed";
box2.className = "closed";
box3.className = "closed";
box11.className = "closed";
box21.className = "closed";
box31.className = "closed";
box1.className = "open";
box11.className = "open";
    }

function pop(id)
{
 var nm = document.form.cat.value;
 var http = getHTTPObject();
 http.open("GET", "ajax.php?cat="+nm, true);
document.getElementById('popbox').innerHTML = '<select name="destalb" size="5" id="dalb" class="input" style="width:100%"><option value="">Please wait...loading album list.</option></select>';
 http.onreadystatechange=function() {
  if(http.readyState == 4) {
    document.getElementById('popbox').innerHTML = http.responseText;
  }
}
 http.send(null);
 }
