function popupwin(oW, oH, oURL) {
  var posX    = event.screenX;
  var posY    = event.screenY + 20;
  var screenW = screen.width;        // screen size
  var screenH = screen.height - 20;  // take taskbar into account
  if (posX + 460 > screenW) { 
    posX = posX - 460 - 40; 
  } // if mouse too far right
  if (posY + 164 > screenH) { 
	posY = posY - 460 - 40; 
  } // if mouse too far down
  
  var wPosition = "dialogLeft:" +posX+ "; dialogTop:" +posY;
  var oldFileN = "";
  var newFileN = showModalDialog(oURL, oldFileN,
                                   "dialogWidth:"+oW+"px; dialogHeight: "+oH+"px; "
                                   + "resizable: no; help: no; status: no; scroll: no; "
                                   + wPosition);
  if (newFileN != null) { 
    return newFileN;
  }
}

// this function trims the string - called as a subroutine later
function Trim(arg) {
    var trimvalue = "";
    arglen = arg.length;
    if (arglen < 1) {
        return trimvalue;
    }
    // trim from the left
    i = 0;
    pos = -1;
    while (i < arglen) {
        if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) {
            pos = i;
            break;
        }
        i++;
    }

   // trim from the right
    var lastpos = -1;
    i = arglen;
    while (i >= 0) {
        if (arg.charCodeAt(i) != 32 && !isNaN(arg.charCodeAt(i))) {
            lastpos = i;
            break;
        }
        i--;
    }
    // return the trimmed value
    trimvalue = arg.substring(pos,lastpos + 1);
    return trimvalue;
}

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all && document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar" && hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(ctitle, picwin){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
  
  document.getElementById("colortitle").innerHTML = ctitle;
  document.thePic.src = picwin;
}

function printURL(sHref) {
  if(document.getElementById && document.all && sHref) {
    if(!self.oPrintElm) {
      var aHeads = document.getElementsByTagName('HEAD');
      if(!aHeads || !aHeads.length) {
        return false;
      }
      if(!self.oPrintElm) {
        self.oPrintElm = document.createElement('LINK');
      }
      self.oPrintElm.rel = 'alternate';
      self.oPrintElm.media = 'print';
      aHeads[0].appendChild(self.oPrintElm);
    }
    self.oPrintElm.href = sHref;
    self.focus();
    self.print();

    return true;
  }
  else {
    return false;
  }
}
