// ***********************************************************
// WSAVA.js is copyrighted Veterinary Information Network 2002
// ***********************************************************

//Start Version/Browser Detector
var agt = navigator.userAgent.toUpperCase();
var BrowserVersion = parseInt(navigator.appVersion);
if (agt.indexOf('MSIE 5')) BrowserVersion = 5;
var IsMac = ((agt.indexOf('MAC_') != -1) || (agt.indexOf('MACINTOSH') != -1));
var IsAOL = (agt.indexOf('AOL') != -1);
var IsIE  = (navigator.appName.indexOf('Microsoft') != -1);
var IsNS  = (navigator.appName.indexOf('Netscape') != -1);
var IsNS4 = (IsNS && (BrowserVersion >= 4));
var IsIE4 = (IsIE && (BrowserVersion >= 4));
var IsIE5  = (IsIE && (BrowserVersion >= 5));
//End Version/Browser Detector

// CONSTANTS
var CtrlTxt = (IsMac) ? 'Command' : 'CTRL';
var FavoriteTxt = (IsIE) ? 'Favorite' : 'Bookmark';

// Get Current Date
var Months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
var Days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var CurDate = new Date();
var WeekDay = CurDate.getDay();
var Day = CurDate.getDate();
var Month = CurDate.getMonth();
var Year = CurDate.getYear();
Year = (Year < 1900) ? Year + 1900 : Year;

// Print the current page
function PrintPage() {
  if (((IsNS4 || IsIE5)) && (window.print)) window.print();
  else alert('You may print this page using '+CtrlTxt+'-P.');
}

// Save the current page
function SavePage() {
  if (IsIE4 && !IsMac) document.execCommand('SaveAs', true, document.title);
  else alert('You may save this page by selecting the Save As option from the File menu.');
}

// Go back one page
function BackPage() {
  history.back();
}

// Bookmark current page
function BookmarkPage() {
   if (IsAOL) alert('Please click the red heart to favorite this page.');
   else if (IsIE4 && !IsMac) window.external.AddFavorite(window.location.href, document.title);
   else alert('You may '+FavoriteTxt+' this page using '+CtrlTxt+'-D.');
}

// This function provides positioning code to center a window of a specified size
function GetCenterPos(BWidth, BHeight) {
  var PosX = (screen.availWidth - 10)/2 - BWidth/2;
  var PosY = (screen.availHeight - 30)/2 - BHeight/2;
  return ('width='+BWidth+',height='+BHeight+',left='+PosX+',top='+PosY);
}

// This function will open a sized window
function ShowSizedWindow(URL, Width, Height) {
  var args = 'width='+Width+',height='+Height+',menubar=no,status=no,location=no,directories=no,toolbar=no';
  window.open(URL, '_blank', args); 
}

// This function will open a sized window (or not) without any browser toolbars
function OpenNewWindow(URL, Width, Height) {
  var args = 'menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes';
  if (Width && Height) args = 'width='+Width+',height='+Height + ',' + args;
  window.open(URL, '_blank', args);
}

// This function will open a sized window (or not) with browser toolbars
function OpenNewBrowser(URL, Width, Height) {
  var args = '';
  if (Width && Height) args = 'width='+Width+',height='+Height;
  window.open(URL, '_blank', args);
}

// This function will open a properly sized window with the picture in it
function ShowPicture(ImgPath, ImgWidth, ImgHeight) {
  var ScrollBar = "no";
  ImgWidth += 20;
  ImgHeight += 50;
  if ((ImgWidth - 20) > screen.availWidth) {ImgWidth = screen.availWidth - 20; ScrollBar = "yes";}
  if ((ImgHeight - 40) > screen.availHeight) {ImgHeight = screen.availHeight - 40; ScrollBar = "yes";}
  var URL = "/Tools/ShowPicture.plx?URL="+ImgPath;
  var args = GetCenterPos(ImgWidth, ImgHeight)+",menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars="+ScrollBar+",resizable="+ScrollBar;
  window.open(URL, "", args); 
}

// Show the feedback form
function ShowFeedback() {
  var URLValue = "/Members/Help/FeedbackPopup.asp";
  var args = "width=370,height=370,menubar=no,status=no,location=no,directories=no,toolbar=no";
  window.open(URLValue, "_blank", args); 
}
