// Popup window

var newWin = null;

// Check to see if the pop-up window is open before doing anything
// If a previous pop-up window is open then close it

function closeWin()
{
  if (newWin && !newWin.closed && newWin.open)
  {
    newWin.close();
    newWin=null;
  }  
}  

// Center the pop-up window for 4.0+ browsers 
// Make sure to account for browser chrome when doing the subtraction.

function openWin(url,wide,high)
{
  closeWin();

  if (document.getElementById || document.all || document.layers)
  {
    var screenWidth = screen.availWidth;
    var screenHeight = screen.availHeight;
    var newWidth = screenWidth - (wide-10);
    var newHeight = screenHeight - (high-40);
    var xPos = newWidth/2;
    var yPos = newHeight/2;

    newWin = window.open(url,'popup','height='+ high +',width='+ wide +',toolbar=no,menubar=no,status=no,location=no,scrollbars=yes,left=' + xPos + ',top=' + yPos + ',screenX=' + xPos + ',screenY=' + yPos + '');
  }
  else
  {
    newWin = window.open(url,'popup','height='+ high +',width='+ wide +',toolbar=no,menubar=no,status=no,location=no,scrollbars=yes,left=' + xPos + ',top=' + yPos + ',screenX=' + xPos + ',screenY=' + yPos + '');
  }

  if (newWin.opener == null) newWin.opener = window;
  newWin.opener.name = "opener";
}


// Popup Window with no scroll bar
// Make sure to account for browser chrome when doing the subtraction.
function openWin2(url,wide,high)
{
  closeWin();

  if (document.getElementById || document.all || document.layers)
  {
    var screenWidth = screen.availWidth;
    var screenHeight = screen.availHeight;
    var newWidth = screenWidth - (wide-10);
    var newHeight = screenHeight - (high-40);
    var xPos = newWidth/2;
    var yPos = newHeight/2;

    newWin2 = window.open(url,'popup','height='+ high +',width='+ wide +',toolbar=no,menubar=no,status=no,location=no,scrollbars=no,left=' + xPos + ',top=' + yPos + ',screenX=' + xPos + ',screenY=' + yPos + '');
  }
  else
  {
    newWin2 = window.open(url,'popup','height='+ high +',width='+ wide +',toolbar=no,menubar=no,status=no,location=no,scrollbars=no,left=' + xPos + ',top=' + yPos + ',screenX=' + xPos + ',screenY=' + yPos + '');
  }

  if (newWin2.opener == null) newWin2.opener = window;
  newWin2.opener.name = "opener";
}


// Close the Popup window and reload the parent window
function redirect()
{
  setTimeout('self.close()',50);
}


// Clear Search field on onclick  
function clearDefault(el)
{
  if (el.defaultValue==el.value) el.value = "";
}

function restoreDefault(el, txt)
{
  if (el.value == "") el.value = txt;
}
