var winPage = null
var popupNames = new Array()
var popupWindows = new Array()

//Add basePath for MAC bug.  Basically, get the path from current page 
//and use it to refernce popup window html
var basePopupPath;

//First check for a ? in the path and get rid of it and everything to the right
idx = location.href.indexOf("?")
if (idx < 0) {
  basePopupPath = location.href;
} else {
  basePopupPath = location.href.substring(0,idx);
}
//Now truncate up to last slash
basePopupPath = basePopupPath.substring(0,basePopupPath.lastIndexOf("/")+1)

function getPopupWindow(popupName)
{
  var i
  for (i=0; i<popupNames.length;i++)
  {
    if (popupNames[i] == popupName)
     return popupWindows[i]
  }
  return null
}

function addPopupWindow(popupName,popupWindow)
{
  var idx
  idx = popupNames.length;
  popupNames[idx] = popupName
  popupWindows[idx] = popupWindow
}


function popupPage(title,page,w, h) {
  var purl = new String(page);

  x = (screen.availWidth - w)/2
  y = (screen.availHeight -h)/2
  if (purl.charAt(0) != "/" && purl.indexOf("http://")!=0)
  {
    page = basePopupPath + page;
  }
  winPage=makePopupWindowPos(winPage, title, page,w,h,x,y)
}

function popupExploreWindowTopLeft(winName,winURL,width,height)
{
  //First lookup name in list of available windows.
  //If it already exists and is not closed then just
  //bring it to the front.  If not, then create it and
  //add it to the list.
  win = getPopupWindow(winName)
  if (win != null && ! win.closed) {
    win.focus()
  } else {
    x = 0;
    y = 0;
    newWin = window.open(winURL,winName,"resizable=no,height="+height+",width="+width+",scrollbars=no"+",left="+x+",top="+y)
    addPopupWindow(winName,newWin)
  }
}

function popupExploreWindow(winName,winURL,width,height)
{
  var win;
  //First lookup name in list of available windows.
  //If it already exists and is not closed then just
  //bring it to the front.  If not, then create it and
  //add it to the list.
  win = getPopupWindow(winName)
//  if (win != null && ! win.closed) {
// 	alert("found "+winName+"url="+win.location.pathname+" newuRL="+winURL)
//  }
  if (win != null && ! win.closed && (win.location.pathname == winURL)) {
//	alert("found "+winName+"url="+win.location.pathname+" newuRL="+winURL)
    win.focus()
  } else {
    x = (screen.availWidth - width)/2
    y = (screen.availHeight -height)/2
    newWin = window.open(winURL,winName,"resizable=no,height="+height+",width="+width+",scrollbars=no"+",left="+x+",top="+y)
    addPopupWindow(winName,newWin)
	newWin.focus();
  }
}


function popComingsoon() {
	popupPage('ComingSoon','comingsoon.htm',545,390);
}