var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById) ? true : false;
var ie4 = (document.all) ? true : false;
var ie5 = false;
if (ie4) {
  if (navigator.userAgent.indexOf('MSIE 5')>0) ie5 = true;
  if (ns6) ns6 = false;
}
var activeMenu = 0;

//self.resizeTo(screen.width,screen.height); 
//self.moveTo(-1,-1); 

function PopUp(menuLayerRef, offset) 
{
  var myLeft=((document.body.clientWidth-200)/2)+200;  
  if (activeMenu != menuLayerRef) {
    if (activeMenu) {
      hideMenu("menu" + activeMenu); 
    }
    menuID = "menu" + menuLayerRef;
    activeMenu = menuLayerRef;
    if (ns4) {
      eval('document.'+menuID+'.top='+offset.screenY);
      eval('document.'+menuID+'.left='+myLeft);
    } 
    else if (ns6) {
      eval('document.getElementById("'+menuID+'").style.top="'+offset.pageY+'px"');
      eval('document.getElementById("'+menuID+'").style.left="'+myLeft+'px"');
    }
    else {         
      document.all[menuID].style.pixelTop=offset.y;
      document.all[menuID].style.pixelLeft=myLeft;
    }
    showMenu(menuID);
  }
}

function showMenu(layerID) 
{
  if (ns4) eval('document.'+layerID+'.visibility = "show"');
  else if (ie4) eval(layerID+'.style.visibility = "visible"');
  else if (ns6) eval('document.getElementById("'+layerID+'").style.visibility = "visible"');
}

function hideMenu(layerID) 
{
  if (ns4) eval('document.'+layerID+'.visibility = "hide"');
  else if (ie4) eval(layerID+'.style.visibility = "hidden"');
  else if (ns6) eval('document.getElementById("'+layerID+'").style.visibility = "hidden"');
}

function hideMe() 
{
  if (activeMenu) {
    menuID="menu"+activeMenu;
    hideMenu(menuID);
    activeMenu=0;
  }
}

function ColorBlock(oRegion) 
{
  oRegion.className="LeftNavUp";	
  oRegion.style.cursor="pointer";
  oRegion.style.color="#ffffc0";
  oRegion.style.backgroundColor='gold';
}

function UncolorBlock(oRegion) 
{
  oRegion.style.color="white";
  oRegion.className = "LeftNavOff";
  oRegion.style.backgroundColor='#ffffc0';	
}

function shake(n) {
 if (parent.moveBy) {
  for (i = 10; i > 0; i--) {
   for (j = n; j > 0; j--) {
    parent.moveBy(0,i);
    parent.moveBy(i,0);
    parent.moveBy(0,-i);
    parent.moveBy(-i,0);
   }
  }
 }
}

function popupBaby() {
  // toolbar,location,directories,status,menubar,scrollbars,resizable,copyhistory
  var width=screen.availWidth;
  var height=screen.availHeight;
  var top=(screen.availHeight-height)/2;
  var left=(screen.availWidth-width)/2;
  var winFeatures="width="+width+",height="+height+",top="+top+",left="+left+",scrollbars,resizable,toolbar";
  window.open("","",winFeatures);
}

function PopItUp(width,height,pos,URL) {
 var top,left;
 day=new Date();
 id=day.getTime();
 if (pos==1) { // top-left
  top=0; 
  left=0;
 }
 else if (pos==2) { // top-right
   top=0;
   left=screen.availWidth-width-10;
 } 
 else if (pos==3) { // bottom-left
   top=screen.availHeight-height-30;
   left=0;
 } 
 else if (pos==4) { // bottom-right
   top=screen.availHeight-height-30;
   left=screen.availWidth-width-10;
 } 
 else {
   top=(screen.availHeight-height)/2; 
   left=(screen.availWidth-width)/2;
 }
 eval("page"+id+"=window.open(URL,'"+id+"','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left='+left+',top='+top+'');");
}
