// JScript File

/* -------------------------- REVISED 12/18 because the function was applying to javascript links ("search" button).


function extLinksInNewWindow(){
 for(var i=0;i<document.links.length;i++){
   if(document.links[i] && (document.links[i].href).indexOf('healthfinder')==-1){
    document.links[i].onclick=document.links[i].onkeypress=function(){
     /*var extWin=window.open(this.href,"newWindow","menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes,width=760,height=500,left=300,top=300",true);
     extWin.focus();* /
     HFPopUpWin(this.href);
     return false;
    }
    document.links[i].title="Link will open in a new browser window."
   }
 }
} */
function extLinksInNewWindow(){
 for(var i=0;i<document.links.length;i++){
   if(document.links[i] && document.links[i].href.indexOf('healthfinder')==-1 && document.links[i].href.indexOf('javascript:')==-1){
    document.links[i].onclick=document.links[i].onkeypress=function(){
     /*var extWin=window.open(this.href,"newWindow","menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes,width=760,height=500,left=300,top=300",true);
     extWin.focus();*/
     HFPopUpWin(this.href);
     return false;
    }
    document.links[i].title="Link will open in a new browser window."
   }
 }
}


function HFPopUpWin(url) {
var iMyWidth;
var iMyHeight;
var iSWidth;
var iSHeight;
var iSWidth2;
var iSHeight2;

iSWidth = window.screen.width * 0.90
iSHeight = window.screen.height * 0.50

iSWidth2 = iSWidth / 2
iSHeight2 = iSHeight / 2

//half the screen width minus half the new window width (plus 5 pixel borders).

iMyWidth = (window.screen.width/2) - (iSWidth2 + 10);
//half the screen height minus half the new window height (plus title and status bars).
iMyHeight = (window.screen.height/2) - (iSHeight2 + 50);
//Open the window.
var win2 = window.open(url,"Window2","status=no,height=" + iSHeight + ",width=" + iSWidth + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=yes,scrollbars=yes,location=yes,directories=no");
//win2.focus();
}


function openwin(url, name)
{
  // Set a contstantWidthHeight
  //name = "NewWindow"
  w = 600;
  h = 300;
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=yes, ' +
    'menubar=yes, status=no, toolbar=no, scrollbars=yes, resizable=yes');
  // Just in case width and height are ignored
  // win.resizeTo(w, h);
  // Just in case left and top are ignored
  // win.moveTo(wleft, wtop);
  // win.focus();
}
