var popupHandle = null;

function displayPopup(url,name,height,width,pos,evnt,options) {
  var properties;
  var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt, fordisplay;

  //put in height and width and whether to display options or not
  if(!options) {
    properties = "location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,height=";
  }
  else {
    properties = "location=1,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1,height=";
  }
  properties = properties + height;
  properties = properties + ",width=" + width;

  if (options) {
    height = height + 100;
  }

  screenX = window.screen.width;
  screenY = window.screen.height;
  if (!evnt)
	{
	  cursorX = 0;
		cursorY = 0;
	}
	else
	{
	  cursorX = evnt.screenX;
    cursorY = evnt.screenY;
	}
  //cursorX = cursorX - window.pageXOffset;
  //if(navigator.appName == "Microsoft Internet Explorer") {
    padAmtX = 10;
    padAmtY = 10;
    if(cursorX < (screenX / 2.0)) {
      // Put Window to far right side of screen
      leftprop = screenX-width-20 - pos*25;
  	}
    else {
  	  leftprop = 0 + pos*25;
    }
    if(cursorY < (screenY / 2.0))	{
      // Put Window to bottom of screen
      topprop = screenY-height-75 - pos*25;
    }
    else {
  	  topprop = 0 + pos*25;
    }
  
  
  if(evnt != null) {
    properties = properties + ",left=" + leftprop;
    properties = properties + ",top=" + topprop;
  }
	
	popupHandle = open(url,name,properties);
  popupHandle.focus();
	
	return popupHandle;
}


function refreshParent() {
	var indexOfPound = window.opener.location.href.indexOf("#");
	if (indexOfPound > -1)
	{
	  window.opener.location.href = window.opener.location.href.substring(0,indexOfPound);
	}
	else
	{
	  try
		{
  		window.opener.location.href = window.opener.location.href;
		}
		catch (e)
		{
		  //I don't care, but please continue execution!
		}
	}
}

