// ---------------------------------------------------------
//	GLOBAL VARIABLES
//----------------------------------------------------------
var popWin;
var popWinType;
var ie;

ie = (document.all) ? true : false;

/* -----------------------------------------------
FUNCTION: quotePop
DESC: Creates a pop up window with the Quote Page dimensions.
ARGS:
      hrefTarget - url to be opened
-------------------------------------------------*/
function quotePop(hrefTarget)
{
  // Set Variables
  var name, width, height;
  name = "quotePop";
  width="463";
  height="500";
  scrollbars="yes";
  // Pop up the window
  popWindow(hrefTarget,name,width,height,scrollbars);
}


/* -----------------------------------------------
FUNCTION: imgPop
DESC: Creates a pop up window with the Image Gallery dimensions.
ARGS:
      hrefTarget - url to be opened
-------------------------------------------------*/
function imgPop(hrefTarget)
{
  // Set Variables
  var name, width, height;
  name = "imgPop";
  width="650";
  height="550";
  scrollbars="yes";
  // Pop up the window
  popWindow(hrefTarget,name,width,height,scrollbars);
}


/* -----------------------------------------------
FUNCTION: infoPop
DESC: Creates a pop up window with the More Info dimensions.
ARGS:
      hrefTarget - url to be opened
-------------------------------------------------*/
function infoPop(hrefTarget)
{
  // Set Variables
  var name, width, height;
  name = "infoPop";
  width="263";
  height="300";
  scrollbars="no";
  // Pop up the window
  popWindow(hrefTarget,name,width,height,scrollbars);
}


/* -----------------------------------------------
FUNCTION: popWindow
DESC: Opens a window and positions it on the screen
ARGS:
      hrefTarget - url to be opened
      name - name of popup window (becomes popupType)
      width - width of the pop up window
      height - height of the pop up window
-------------------------------------------------*/
function popWindow(hrefTarget,name,width,height,resizable,scrollbars)
{
  // Create offset
  if (document.all)
  {
    xMax = screen.width, yMax = screen.height;
  }

  else
  {
    if(document.layers)
    {
      xMax = window.outerWidth, yMax = window.outerHeight;
    }
    
    else
    {
      xMax = 640, yMax=480;
    }
  }

  var xOffset = (xMax - 586)/2, yOffset = (yMax - 700)/2;
  // Check if pop up exists
  if(!popWin||popWin.closed)
  {
    // no pop up exists set the popWinType to the current type
    popWinType = name;
    // open pop up window
    popWin = window.open(hrefTarget,name,'width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+', top='+yOffset+',left='+xOffset+',scrollbars=yes,menubar=yes,resizable=yes');
  }

  else
  {
    // Check if the pop up is the same type
    if(popWinType != name)
    {
      // it is not the same type so close the current pop up
      popWin.close();
      // set the popWinType to the current type
      popWinType = name;
      // open pop up window
      popWin = window.open(hrefTarget,name,'width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+', top='+yOffset+',left='+xOffset+',scrollbars=yes,menubar=yes,resizable=yes');
      return;
    }

    // Bring pop up to the foreground
    popWin.focus();
    // Change the location of the pop up to the location being requested
    popWin.location = hrefTarget;
  }
}

