///////////////////////////////////////////////////////////////////////////////
// These are for popup windows                                               //
///////////////////////////////////////////////////////////////////////////////

function windowad()
{
  window.open('ads/new.html','windowad','width=409,height=460,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no,top=10,left=10');
}

function CardiacPopup(whichImg) {
	window.open(whichImg,'','width=432,height=373,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no');
}
function openPrintWindow(pageID) {
	window.open('\/usercontrols\/printVersion.aspx?pageID='+pageID,'','width=600,height=800,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no');
}
function openPrintWindow(pageOverRide,pageID) {
    if (pageOverRide=='1')
    {
        window.print();
    }
    else
    {
    	window.open('\/usercontrols\/printVersion.aspx?pageID='+pageID,'','width=600,height=800,menubar=no,toolbar=no,location=no,scrollbars=no,resizable=no,status=no,directories=no');
	}
}

///
///
///       BROWSER SNIFFER
///
///

var browser = new Browser();


//functions
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}
///
///
///       END BROWSER SNIFFER
///
///


///////////////////////////////////////////////////////////////////////////////
//          This is for selecting a random graphic on the homepage           //
///////////////////////////////////////////////////////////////////////////////

function randomBanner(){

	if(!document.getElementById("h_pic_l")) return false;
	var r_div = document.getElementById("h_pic_l");
	
	var r_html = new Array(
		"<a href='home-page-left-feature/laser-slt.aspx'><img src='/images/home/glaucoma.jpg' border='0' alt='glaucoma surgery' /></a>", "<a href='home-page-left-feature/heart-valve-surgery.aspx'><img src='/images/home/openheart.jpg' border='0' alt='heart surgery' /></a>","<a href='/home-page-left-feature/deuce-knee.aspx'><img src='/media/86892/knee_replacement.jpg' border='0' alt='knee replacement' /></a>");

	var r_num = Math.floor(Math.random()*r_html.length);	
	var whichBanner = r_html[r_num];
	
	r_div.innerHTML = whichBanner;
}


function randomSidePromo(){
	if(!document.getElementById("s_pic")) return false;
	var s_div = document.getElementById("s_pic");
	
	var s_html = new Array("<a href='sportsmedicine/default-sports-medicine.aspx'><img src='/media/82849/logo_bcsm.jpg' alt='bcsm' border='0' /></a>");
	
	var s_num = Math.floor(Math.random()*s_html.length);
	var sideBanner = s_html[s_num];
	
	s_div.innerHTML = sideBanner;
}



//tooltip code

// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi, wS) {if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); if (al) return wS ? document.all[oi].style: document.all[oi]; if (an) return document.layers[oi];}
function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
function popUp(evt,oi) {if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!an) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";}}}