/**
* From http://labnol.blogspot.com/2006/01/add-to-favorites-ie-bookmark-firefox.html
* FRAME-91
**/
function showEnlargeImage(id) {
	var obj = document.getElementById(id);
	
	
	obj.style.display = "block";
}
 function overlayclose(id) 	{
   	var oldoverlay = document.getElementById(id);
	oldoverlay.style.display="none";

}
function bookmarkThisPage(url, title) { 
	//if no title is specified don't bookmark
	if (title == null) {
		return;
	}
	if ( navigator.appName.indexOf('Netscape') != -1 && window.sidebar) { 
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if ( navigator.appName.indexOf('Microsoft') != -1 && window.external ) { 
		// IE Favorite
		window.external.AddFavorite( url, title); 
	} else if (window.opera && window.print) { 
		// Opera Hotlist
		return true; 
	}	
}

function newWin(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, WinSCROLL, WinTOOLBAR)

{	

	/*	variables passed by the link calling the function	*/

	var URL = WinURL;
	var WINDOW_NAME = WinNAME;
	var POPUP_WIDTH = WinWIDTH;
	var POPUP_HEIGHT = WinHEIGHT;
	var POPUP_RESIZE = WinRESIZE;
	var POPUP_SCROLL = WinSCROLL;
	var POPUP_TOOLBAR = WinTOOLBAR;



	/*	window properties that determine the window attributes depending on what values are passed by the link calling the function	*/

	var window_toolbar = POPUP_TOOLBAR;
	var window_resize = POPUP_RESIZE;
	var window_scroll = POPUP_SCROLL;
	var window_width = POPUP_WIDTH;
	var window_height = POPUP_HEIGHT;
	var screen_balance_w = ((screen.width)-(window_width))/2;
	var screen_balance_h = ((screen.height)-(window_height))/2;
	var set_top = screen_balance_h;
	var set_left = screen_balance_w;	

	win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + ',top=' +  set_top + ',left=' + set_left + '');
	win.focus();
}
function newWin(WinURL, WinNAME, WinWIDTH, WinHEIGHT, WinRESIZE, WinSCROLL, WinTOOLBAR)

{	

	/*	variables passed by the link calling the function	*/

	var URL = WinURL;
	var WINDOW_NAME = WinNAME;
	var POPUP_WIDTH = WinWIDTH;
	var POPUP_HEIGHT = WinHEIGHT;
	var POPUP_RESIZE = WinRESIZE;
	var POPUP_SCROLL = WinSCROLL;
	var POPUP_TOOLBAR = WinTOOLBAR;



	/*	window properties that determine the window attributes depending on what values are passed by the link calling the function	*/

	var window_toolbar = POPUP_TOOLBAR;
	var window_resize = POPUP_RESIZE;
	var window_scroll = POPUP_SCROLL;
	var window_width = POPUP_WIDTH;
	var window_height = POPUP_HEIGHT;
	var screen_balance_w = ((screen.width)-(window_width))/2;
	var screen_balance_h = ((screen.height)-(window_height))/2;
	var set_top = screen_balance_h;
	var set_left = screen_balance_w;	



	win = window.open(URL,WINDOW_NAME,'resizable=' + window_resize + ',toolbar=' + window_toolbar + ',scrollbars=' + window_scroll + ',width=' + window_width + ',height=' + window_height + ',top=' +  set_top + ',left=' + set_left + '');
	win.focus();

}

	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function JSFX_FloatDiv(id, sx, sy,height)
	{	
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		var px = document.layers ? "" : "px";
		window[id + "_obj"] = el;
		if(d.layers)el.style=el;
		el.cx = el.sx = sx;
		el.cy = el.sy = sy;
		el.sP=function(x,y){
		
		this.style.left=x+px;
		this.style.top=y+px;
		
		
	  };
	
		el.floatIt=function()
		{
			var pX, pY;
			pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
			document.documentElement && document.documentElement.clientWidth ? 
			document.documentElement.clientWidth : document.body.clientWidth;
			pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
			document.documentElement.scrollTop : document.body.scrollTop;
			if(this.sy<0) 
			pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
			document.documentElement.clientHeight : document.body.clientHeight;
			this.cx += (pX + this.sx - this.cx)/7;
			this.cy += (pY + this.sy - this.cy)/7;
			var newdivheight=height;
			var sPath = window.location.pathname;
 			var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
 			if(sPage.charAt(0)=="h")
 			{
 				newdivheight=newdivheight-700;
 			}
 			else
 			{
 				newdivheight=newdivheight-850;
 			}
 			if(this.cy < (newdivheight))
			this.sP(this.cx, this.cy);
			/*setTimeout(this.id + "_obj.floatIt()", 40);*/
		}
		
		return el;
	}
	
	matchHeight=function(){
     var divs,contDivs,maxHeight,divHeight,d;
     // get all <div> elements in the document
     divs=document.getElementsByTagName('div');
	 contDivs=[];
     // initialize maximum height value
     maxHeight=0;
    // highlighting the links 
    var sPath = window.location.pathname;
 	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
 	var anchors = document.getElementById("left-nav-links").getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        var href = anchor.href;
        var hPage = href.substring(href.lastIndexOf('/') + 1);
        
        if(sPage.length==0){
        	anchor.className="link-select";
        	document.getElementById("healthcare").className="hcp-link-select";
        	break;
        }else if(hPage==sPage){
           anchor.className="link-select";
         }
         
         if(sPage.substring(0,2)=="hc" )
         {
         document.getElementById("healthcare").className="hcp-link-select";
         }
         else if(sPage.substring(0,2)=="tm")
         {
         document.getElementById("treatment-educators").className="te-link-select";
         }
         else if(sPage.substring(0,2)=="pt")
         {
         document.getElementById("patients").className="pt-link-select";
         }
         else if(sPage.substring(0,3)=="spt")
         {
          document.getElementById("pacientes").className="spt-link-select";
         }
         
      } 
     // iterate over all <div> elements in the document
     for(var i=0;i<divs.length;i++){
          // make collection with <div> elements with class attribute 'container'
          if(/\bcontent-right-container\b/.test(divs[i].className)){
                d=divs[i];
                contDivs[contDivs.length]=d;
               // determine height for <div> element
               if(d.offsetHeight){
                     divHeight=d.offsetHeight;
                }
                else if(d.style.pixelHeight){
                     divHeight=d.style.pixelHeight;
                }
                // calculate maximum height
                maxHeight=Math.max(maxHeight,divHeight);
                /*JSFX_FloatDiv("contentleft", 0,0,maxHeight).floatIt();*/
          }
     }
  

}

// execute function when page loads
window.onload=function(){
     if(document.getElementsByTagName){
          matchHeight();
     }
} 

function OutsideLink(URL)	
	{
   		var writeURL = URL;
   		var thisSite="www.TheGRACEStudy.com";
	   	if (URL.length > 60)
	   	{
		   writeURL = URL.substr(0, 60) + "...";
	   	}
	   	if (confirm("\nThank you for visiting " + thisSite + ".\n\nBy clicking 'OK' you will be taken to: \n\n" + writeURL +"\n\nA Web site to which our Privacy Policy \ndoes not apply.\n\nYou are solely responsible for your \ninteractions with such Web sites.\n\n"))
	   	{
		   window.open(URL,"_blank");
	   	}
	}