function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=720,height=500');");
}

function popUpSize(URL, w, h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h + "');");
}

function refreshPage(vPage){
    if(vPage == ""){
        window.location.href = window.location.href;
    }else{
	    window.location.href = vPage;
    }
}

// Position finder
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  //Handles hide/show of display areas with buttons
  //uses the container name, and _hide and _show to toggle the buttons
  
  var containerTimers = new Object();
  
  function hideArea(baseName){
    var container = $(baseName);
    if(container != undefined){
        if(checkAreaTimer(baseName) == false){
            return;
        }
        Effect.BlindUp(baseName, {'afterFinish' : function(){clearAreaTimer(baseName)}});
        $(baseName + "_hide").hide();
        $(baseName + "_show").show();
    }
  }
  
  function showArea(baseName){
    var container = $(baseName);
    if(container != undefined){
        if(checkAreaTimer(baseName) == false){
            return;
        }
        Effect.BlindDown(baseName, {'afterFinish' : function(){clearAreaTimer(baseName)}});
        $(baseName + "_hide").show();
        $(baseName + "_show").hide();
    }
  }
  function toggleArea(baseName){
    var container = $(baseName);
    if(container.getStyle('display') == 'none'){
        showArea(baseName);
        return 'show';
    }else{
        hideArea(baseName);
        return 'hide';
    }
  }
  
  function checkAreaTimer(baseName){
    //get the value
    var d = new Date();
    if(containerTimers[baseName] != undefined){
        //use padded time of 3 seconds to check 'in use'
        if((containerTimers[baseName] + 3000) > d.getTime()){
            //still "in use"
            return false;
        }
    }
    //save it
    containerTimers[baseName] = d.getTime();
    return true;    
  }
  //clear the timer since we are done
  function clearAreaTimer(baseName){
    containerTimers[baseName] = undefined;
  }