function print_popup(url)
{ 
 window.open(url,'Print', 'width=650, height=300 ,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,top=10,left=100'); 
}

function help_popup(url)
{ 
 window.open(url,'Help', 'width=700, height=500,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,top=10,left=100'); 
}

function open_popup (url, width, height) {
  window.open(url, 'Image', 'width='+width+',height='+height+', menubar=no, scrollbars=no, toolbar=no, location=no, directories=no, resizable=yes, top=100, left=100');
}

function add_content(txt, what, p){

  myQuery = what || document._form.text;
	myParent = p || document;

   //IE support
	if (myParent.selection) {
	    
 	   	  myQuery.focus();
        sel = myParent.selection.createRange();
        sel.text = txt;
        myParent._form.insert.focus();
  }
  //MOZILLA/NETSCAPE support
  else if (myQuery.selectionStart || myQuery.selectionStart == "0") {
    var startPos = myQuery.selectionStart;
    var endPos = myQuery.selectionEnd;
    var chaineSql = myQuery.value;
 
    myQuery.value = chaineSql.substring(0, startPos) + txt + chaineSql.substring(endPos, chaineSql.length);
		sPos = startPos+(txt.length);
		myQuery.selectionStart = sPos; 
		myQuery.selectionEnd = sPos;
		myQuery.focus();
	}
	else{
	  alert(myQuery);
        myQuery.value += txt;
  }  
}

function add_content_parent(txt)
{
  parent.document._form.text.value  += txt;
  parent.document._form.text.focus();
}

function quoteSelection(author, what)
{
	var txt = '';

  if (window.getSelection)
		txt = window.getSelection();
	else if (document.getSelection)
		txt = document.getSelection();
	else if (document.selection)
		txt = document.selection.createRange().text;
  
  if(txt != '') {
    theSelection='[quote='+author+']' + txt + '[/quote]';
	  add_content(theSelection, what);	
	}
}

function deselect_all()
{
  count = document._form.moderate.length;
  for (i=0; i < count; i++) 
  {
    document._form.moderate.options[i].selected = 0;
  }
}

function showhide(id, themepath)
{
  sw = document.getElementById( 'switch_'+id );
  chngds( 'multi_'+id );

  if(sw.innerHTML.indexOf( "collapse" ) != -1)
  {
    sw.innerHTML = '<img src="'+themepath+'gfx/expand.gif" border="0" alt="">';
  } else {
    sw.innerHTML = '<img src="'+themepath+'gfx/collapse.gif" border="0" alt="">';
  }
}

function chngds(id)
{
  var style = document.getElementById(id).style;
  style.display = style.display == "none"? "inline" : "none";
}

function mail (prefix, suffix)
{
  document.location.href='mailto:' + prefix + '@' + suffix;
}


function screenWH (what) {
  var screenW = 640, screenH = 480;
  if (parseInt(navigator.appVersion)>3) {
    screenW = screen.width;
    screenH = screen.height;
  }
  else if (navigator.appName == "Netscape"  && parseInt(navigator.appVersion)==3   && navigator.javaEnabled()) {
    var jToolkit = java.awt.Toolkit.getDefaultToolkit();
    var jScreenSize = jToolkit.getScreenSize();
    screenW = jScreenSize.width;
    screenH = jScreenSize.height;
  }
  
  if(what=='H')
    return screenH;
  else
    return screenW;
}

var maxW=0;
function scaleImage(im, maxWidth, maxHeight) {
   if(!maxWidth)
     var maxWidth=500;
   if(!maxHeight)
     var maxHeight=0;
   
   maxW=maxWidth;
   
   if (typeof im.naturalWidth == 'undefined') {
     im.naturalWidth = im.width;
	 im.naturalHeight = im.height;
   }
   
   if(maxHeight<=0) {
      if (im.naturalWidth > maxWidth) {
         im.width = maxWidth;
         im.style.maxWidth = im.naturalWidth + 'px';
         im.onclick = unscaleImage;
	  }
   }
   else {
      if (im.naturalHeight > maxHeight) {
         im.height = maxHeight;
         im.style.maxHeight = im.naturalHeight + 'px';
         im.onclick = unscaleImage;
	  }      
   }
}

function unscaleImage()
{
  if (this.width == maxW)
  {
    this.width = this.naturalWidth;
    this.style.borderWidth = '0px';
  }
  else
  {
    this.width = maxW;
    this.style.borderWidth = '1px';
  }
}

