function replayIntro() {
	$('replay').addClassName("vh");
	
	if($('flash-main')){
		var newFlashMain = document.createElement("div");
		newFlashMain.id = 'flash-main';
		newFlashMain.className ='flashcontent';
		$('getflash').removeChild($('flash-main'));
		$('getflash').appendChild(newFlashMain);
	}
	
	var link = document.createElement("a");
			link.href="/healthcare/media/swf/shell_biovideo.swf?fparam=intro";
			link.rel="shadowbox;width=870;height=489;"
			initShadowMovies(link);
}

function closeVideo(){
	if(Shadowbox){
		Shadowbox.close();
		if($('closeBox')){
			s.linkType = "o";
			s.linkName = "NHC_"+ sectionName +"_VideoFinish";
			if(sectionName=="home"){
				s.linkName = "NHC_HealthCareCorps_VideoFinish";
			}
			s.tl($('closeBox'),s.linkType,s.linkName);
		}
	}
}

function hideBio(){
/*	if($('bio-content')){
		$('bio-body').addClassName("vh");
		$('navynav').addClassName("vh");
		$('play-video').className="dn";
	}*/

}

function showBio(){
	if($('bio-content')){
		$('bio-intro').style.height=0;
		$('bio-body').style.visibility="visible";
		$('navynav').style.visibility="visible";
		$('videos-body').style.visibility="visible";
		$('play-video').className="fade"; 
		new Effect.Appear('play-video',{ duration:1.0, from:0.0, to:0.9});
	}
}

function initshadowBox(){

	 var options = {
	 	flvPlayer: "/healthcare/media/swf/mediaplayer.swf",
        resizeLgImages: true,
		handleLgImages: "none",
		initialHeight:489,
		initialWidth:870,
        displayNav: true,
        autoplayMovies: true,
        overlayBgImage: "",
        loadingImage: "/healthcare/images/gui/loading.gif",
		onOpen:function(){
			if($("video-link")){
				s.linkType = "o";
				s.linkName = "NHC_"+ sectionName +"_PlayVideo";
				s.tl($("video-link"),s.linkType,s.linkName);
			}
		},
		onFinish: function(){
			if(swfobject.getFlashPlayerVersion().major<9 || (swfobject.getFlashPlayerVersion().major==9 && swfobject.getFlashPlayerVersion().release<115)){
				var obj= Shadowbox.getCurrent();
				swfobject.embedSWF(obj.content, "shadowbox_content",  "870", "489", version, expressInstall); 
				if($("SWFObjectExprInst")){
					$("SWFObjectExprInst").style.width = "870px";
				}
			}
			if(navigator.userAgent.indexOf("Firefox") != -1){
				if($('shadowbox_body') && $("shadowbox_message") == null){
					$('shadowbox_body').style.width = "870px";
					$('shadowbox_body').style.position = "absolute";
					if($("closeBox")){
						$('closeBox').addClassName("finish");
					}
				}
			}
			if($("closeBox")){
				$('closeBox').onclick = function(){
					s.linkType = "o";
					s.linkName = "NHC_"+ sectionName +"_VideoClose";
					s.tl($("closeBox"),s.linkType,s.linkName);
				};
			}
		},
		onClose: function(){
			if(navigator.userAgent.indexOf("Firefox") != -1){
				if($('shadowbox_body')){
					$('shadowbox_body').style.width = "auto";
					$('shadowbox_body').style.position = "relative";
				}
				if($("closeBox")){
					$('closeBox').removeClassName("finish");
				}
			}
		}
    };

    Shadowbox.init(options);
}


function initShadowMovies(link){
	 var options = {
	 	flvPlayer: "/healthcare/media/swf/mediaplayer.swf",
        resizeLgImages: true,
		handleLgImages: "none",
		initialHeight:489,
		initialWidth:870,
		skipSetup:true,
        displayNav: true,
		handleLgImages: "none",
        autoplayMovies: true,
        overlayBgImage: "",
        loadingImage: "/healthcare/images/gui/loading.gif",
		onOpen:function(){
			s.linkType = "o";
			s.linkName = "NHC_HealthCareCorps_PlayVideo";
			s.tl(link,s.linkType,s.linkName);
		},
		onClose: function(){
			initMovies();
			if($('replay')){
				$('replay').removeClassName("vh");
			}
		},
			
		onFinish: function(){
			if(swfobject.getFlashPlayerVersion().major<9 || (swfobject.getFlashPlayerVersion().major==9 && swfobject.getFlashPlayerVersion().release<115)){
		/*		var regObj = {};
				regObj.id = "shadowbox_content";
				regObj.width = 489;
				regObj.height = 870;
				regObj.expressInstall = "/media/swf/swfobject/expressInstall.swf";
				swfobject.expressInstall(regObj); */
				swfobject.embedSWF(link, "shadowbox_content",  "870", "489", version, expressInstall);
			}			
			if(navigator.userAgent.indexOf("Firefox") != -1){
				if($('shadowbox_body')){
					$('shadowbox_body').style.position = "absolute";
				}
				if($("closeBox")){
					$('closeBox').addClassName("finish");
				}
			}
			if($("closeBox")){
				$('closeBox').onclick = function(){
					s.linkType = "o";
					s.linkName = "NHC_Home_IntroClose";
					s.tl($('closeBox'),s.linkType,s.linkName);
				};
			}
		
		}
    };

    Shadowbox.init(options);
	Shadowbox.open(link);
}

function setUpLinks(){
	var links = $$('a');
	links.each(function(item) {
		if(item.rel){
			if(item.rel.indexOf("NHC_") != -1){
				$(item).observe('click', setOmnitureLink);
			}
			if(item.rel.indexOf("_Exit_") != -1){
				item.target = "_blank";
			}
		}
	});
}

function newPopup(url) {
	var newwmin = window.open(url,'newwmin','menubar=no, toolbar=no, location=no, scrollbars=yes,width=600,height=600,left='+(screen.width-600)/2+',top='+(screen.height-800)/2);
	newwmin.focus();
	return false;
}

function fomatName(name){
	if(typeof name == "string"){
		if(name.endsWith("s")){
			name = name.substring(0, name.length-1);
		}
		name = name.substring(0, 1).toUpperCase()+name.substring(1, name.length);
		return name;
	}else return "";
}


var pageId;
var sectionName;
Event.observe(window,'load',function() {
	pageId = document.body.id;
	sectionName = fomatName(pageId);
	setUpLinks();
	if($("flash-main")){
	//	var currentVersion = getFlashVersion();
		if(swfobject.getFlashPlayerVersion().major < 4){
			if($("flash-main")){
				$("flash-main").addClassName("no-flash");
				var link = document.createElement("a");
				link.href="http://www.adobe.com/go/getflash";
				link.target = "_blank";
				var strong = document.createElement("strong");
				strong.className = "replace";
				strong.appendChild(document.createTextNode("To view the multimedia content on this page, you need to enable JavaScript and have the latest version of the Adobe Flash Player. Please Download the free Flash Player."));
				link.appendChild(strong);
				$("flash-main").appendChild(link);
				
			}
		} else if(swfobject.getFlashPlayerVersion().major < 9 ){
			initMovies();
		} else{
			var link = document.createElement("a");
			link.href="/healthcare/media/swf/shell_biovideo.swf?fparam=intro";
			link.rel="shadowbox;width=870;height=489;"
			initShadowMovies(link);
		}
	}else if($('bio-content')){
		if(swfobject.getFlashPlayerVersion().major < 9 || (swfobject.getFlashPlayerVersion().major==9 && swfobject.getFlashPlayerVersion().release<115) ) {
			$('bio-body').style.visibility="visible";
			$('navynav').style.visibility="visible";
			if (pageId != 'physicians') {
				$('play-video').style.display="block";
			} else {
				$('videos-body').style.visibility="visible";
			}
		};
		initshadowBox();
		initBioMovies();
		
	}
},false);