<!--
/*
  Common JScript Routines.
  Copyright PAC & VNA 2000-2002

  Use:
  Put this in the <head>:
  <SCRIPT language='JavaScript' SRC='../JScripts/JScriptCommonLib.js'></SCRIPT>

*/
var WinChild; // global child 
var WinSale = null; // global stock check window
var BirdMan = "<a href='mailto:" + unescape( '%62%69%72%64%69%6E%67%69%6D%61%67%65%73%40%76%69%78%65%6E%61%6D%65%72%69%63%61%2E%63%6F%6D' ) + "'>Submit</a> birding images taken with Vixen equipment.";

// Script Accessible?
function bCommonLibAlive()
{
  return true;
}

// Function closes a non-frames browser window
function CloseWindow 
(
  linkText,  // hyperlink text
  CursorTip  // mouse-over tip
)
/*
   Purpose: Closes window when user clicks hyperlink text
     Notes: Accomplishes same as following HTML:
      <a href="javascript:window.close()" title="Cursor Tip">Close Window</a>
   Returns: nothing
    History: PAC 2000 Aug 18 Consolidated existing function into this lib.

*/
{
  linkText = (linkText == null) ? "Close Window" : linkText;
  CursorTip = (CursorTip == null) ? "Close&nbsp;this&nbsp;Window" : CursorTip;
  document.write("<a href='javascript:top.close()' title=" 
                    + CursorTip + ">" + linkText + "</a>");
}    

// Function opens a new browser window for images, resizes to fit image
function OpenResizeWindow
(
 image_name, // image file name
 win_name, // unique name for id, does not show, MUST NOT HAVE SPACES
 win_title // title bar
) 
/*
  Purpose: Takes image filename and window name, opens new window resized to image.
    Notes: more features than OpenWindow().
  Returns: nothing
  History: Aug. 12/13, 2003
*/
{
  if (WinChild != null) {WinChild.close();}
  WinChild = window.open("",win_name,"top=0,left=0,scrollbars,resizable")
  WinChild.document.write("<HTML><HEAD></HEAD><BODY>")
  WinChild.document.write("<img border='0' src='" + image_name   + "' onLoad='javascript:window.resizeTo(Math.min(this.width+50,screen.width),Math.min(this.height+65, screen.height));return false;'>");
  WinChild.document.write("</BODY></HTML>")
  WinChild.document.title = win_title;
  WinChild.focus();
}

// Function opens a new browser window
function OpenWindow
(
  file,       // document file name
  unique,     // unique name for id, does not show, MUST NOT HAVE SPACES
  parameters  // optional parameters to set
)
/* 
  Purpose: Will open browser with file and bring it to front. 
    Notes: Allowed parameters: 
              toolbar, location, directories, status, menubar, scrollbars, 
              resizable, width=x, height=x
              
           Common usage examples:
           1) Simple
            a) Put this in the <body>:
           <a href="sample.htm" target="_blank" onclick="OpenWindow('sample.htm','unique_nm','width=540,height=480,scrollbars,resizable');return false;">Target Text</a>

           2) Complicated 
            a) Put this in the <body>:            
           <SCRIPT><!-- execute this if JS is enabled:
             document.write('<a href="javascript:OpenWindow(\'http://sample.htm\',\'unique_nm\',
                            \'width=300,height=200,scrollbars,resizable\');">');
           // else execute the following --></SCRIPT>
           <NOSCRIPT> 
             <a href="test%20text.htm" title="Non-Java Click" target="_blank">
           </NOSCRIPT>
           Target Text</a> <!-- In any case the target text is needed -->
  Returns: nothing
  History: PAC 2000 Aug 18 Consolidated existing function into this lib.
           PAC 2003 June 20 Changed default parameters
*/
{
  //parameters = (parameters == null) ? "resizable" : parameters;
  parameters = (parameters == null) ? 'width=' + (screen.width - 50) + ',height=' + (screen.height - 50) + ',left=0,top=0,resizable,scrollbars' : parameters;
  WinObj = window.open(file, unique, parameters);  // open browser
  WinObj.focus();                           // bring to top
}

// Opens Wish List
function SeeWishList
(
  ItemNo,   // item number
  ItemDesc, // item description
  ItemPrice // item price
)
/*
  Purpose: Display product wish list, add and subtract products from list
    Notes: Must put in subtract. Must grab positional info before closing and reopening
  Returns: nothing
  History: PAC 2006 NOV 29 started work
*/
{
  var sWishPage = "WishList.asp";

  // If parameters passed in: add them to query string of WishList page
  if (ItemNo != null) 
  {
    sWishPage += "?" + "ItemNo=" + ItemNo + "&ItemDesc=" + ((ItemDesc != null) ? ItemDesc : "") + "&ItemPrice=" + ((ItemPrice != null) ? ItemPrice : "");}
    if (ItemPrice != null && ItemPrice.substring(0,1) != "-") { alert("Adding to Vixen Direct Wishlist\n" + ItemNo + ": " + ((ItemDesc != null) ? ItemDesc : "") + ". Price: " + ((ItemPrice != null) ? ItemPrice : "" )); // only display add
    if (WinSale && WinSale.open) {WinSale.close(); WinSale = null;} // force reopen below
  }
  
  // Open new wishlist if it is closed ...
  if (!(WinSale && WinSale.open) || WinSale.closed) 
  {
    WinSale = OpenWindow(sWishPage,'VXWISH','width=300, height=' + (screen.height - 50) + ',left=0,top=0,resizable,scrollbars');
  } else // ... or bring open window to top
  {
    if (windows.focus) {WinSale.location.href = WinSale.location.href; WinSale.focus();} // if focus method supported   
  }

  return false;
}



// -->

