// JavaScript Document


function highlightNav(){
	
	var theNav = document.getElementById('site-nav-links');
	var currentUrl = window.location.href;
	
	//check if this is a CTS link and reduce to CTS folder path
	var isCTS = currentUrl.lastIndexOf('cts-scientific-data/');

	if(isCTS>0 && isCTS+20!=currentUrl.length){
		
			currentUrl=currentUrl.substr(0, (isCTS+20));
	}
	
	var isOtherEvents = currentUrl.lastIndexOf('other-events/');
	
	if(isOtherEvents>0 && isOtherEvents+13!=currentUrl.length){
		
			currentUrl=currentUrl.substr(0, (isOtherEvents+13));
	}
			
	if(theNav){
		
		hideAll(theNav);
		
		var navLinks = theNav.getElementsByTagName('a');
		var activeLink;
		
		for(j=0;j<navLinks.length;j++){
			
			//alert(navLinks[j].href + " : " + location.href);
			//alert(currentUrl.substr(0, currentUrl.length-1));
			
			//set active link
			if(activeLink==undefined &&
			   		(navLinks[j].href == currentUrl || 
						navLinks[j].href == currentUrl.substr(0, currentUrl.length-1) || 
						navLinks[j]+"index.php" == currentUrl || 
						navLinks[j] == currentUrl+"index.php"  ||
						(currentUrl.indexOf("patients/welcome/index-new.php") >= 0 && 
							navLinks[j].href.indexOf("patients/") >= 0) ||
						(currentUrl.indexOf("employment/index-new.php") >= 0 &&
							navLinks[j].href.indexOf("employment/") >= 0)
					)
			){
					activeLink = navLinks[j];
			}
			
		}

		if(activeLink!=undefined){
			if(activeLink.className==""){
				
				activeLink.className="mmhide_active";
			}else{
				activeLink.className+=" mmhide_active";
			}
			showParentsAndChildren(theNav, activeLink);
		}
	}
	
}



function hideAll(theNav){
	
	theLists = theNav.getElementsByTagName('ul');
	
	for(j=0;j<theLists.length;j++){
		theLists[j].style.display='none';	
	}
}

function showParentsAndChildren(theNav, theLink){
	var currentUrl = window.location.href;
	
	theLink.parentNode.id="selected-node";
	
	if(theLink.parentNode.parentNode.id=="site-nav-links"){
		theLink.style.color="black";	
	}
	
	//show parents
	currentNode = theLink.parentNode;
	
	while(currentNode.id!="site-nav-links"){
		currentNode=currentNode.parentNode;
		
		if(currentNode.tagName=='UL'){
			currentNode.style.display='block';			
		}
	}
	
	
	
	//show children
	subLists = theLink.parentNode.getElementsByTagName('ul');
	var tst = (currentUrl.indexOf("patients/welcome/index-new.php") >= 0);

	for(b=0;b<subLists.length;b++){
		
		if(subLists[b].parentNode.id==theLink.parentNode.id || tst){
			subLists[b].style.display='block';	
			
		}
	}

	//hide teaser if not on home page
	var currentPageSplit = window.location.href.split('/');
	while(currentPageSplit[currentPageSplit.length-1]=="index.php" || currentPageSplit[currentPageSplit.length-1]==""){
		currentPageSplit.pop();	
	}
	if(currentPageSplit[currentPageSplit.length-1]!="home")	{
		hideTeaser();
	}
}


function hideTeaser(){
	teaser = document.getElementById('site-nav-teaser');
	if(teaser){
		teaser.style.display="none";	
	}
}

/*
   <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0','width','630','height','474','id','FLVPlayer','src','FLVPlayer_Streaming','flashvars','&MM_ComponentVersion=1&serverName=72.35.95.25&skinName=Corona_Skin_2&appName=mainframe/httpdocs&streamName=Brown_Info_F6_HQ&isLive=false&bufferTime=0&autoPlay=true&autoRewind=false','quality','high','scale','noscale','name','FLVPlayer','salign','lt','pluginspage','www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','FLVPlayer_Streaming' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="630" height="474" id="FLVPlayer">
     <param name="movie" value="FLVPlayer_Streaming.swf" />
     <param name="salign" value="lt" />
     <param name="quality" value="high" />
     <param name="scale" value="noscale" />
     <param name="FlashVars" value="&MM_ComponentVersion=1&serverName=72.35.95.25&skinName=Corona_Skin_2&appName=mainframe/httpdocs&streamName=Brown_Info_F6_HQ&isLive=false&bufferTime=0&autoPlay=true&autoRewind=false" />
     <embed src="FLVPlayer_Streaming.swf" flashvars="&MM_ComponentVersion=1&serverName=72.35.95.25&skinName=Corona_Skin_2&appName=mainframe/httpdocs&streamName=Brown_Info_F6_HQ&isLive=false&bufferTime=0&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="630" height="474" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />   
</object></noscript>
	

*/

function playVideo(fileName, folderName){
	
	/*
	if(folderName){
		document.getElementById('videoswf').SetVariable('folder', folderName);	
	}
	document.getElementById('videoswf').SetVariable('file', fileName);	
	*/
	var so = new SWFObject("/patients/carpal-tunnel-syndrome/videos/images/commercials.swf", "videoswf", "630", "530", "8", "#ffffff");
	if(folderName){
		so.addVariable('folder', folderName);	
	}else{
		so.addVariable('folder','/patients/carpal-tunnel-syndrome/videos/images/');
	}
	
	so.addVariable('file',fileName);
	so.write("video-player");
}

function playPLVideo(file){
	var so = new SWFObject('/patients/carpal-tunnel-syndrome/videos/images/FLVPlayer_Streaming.swf', 
						   'videoswf', '630', '540', '8', '#FFFFFF');
	so.addVariable('MM_ComponentVersion','1');
	so.addVariable('serverName','72.35.95.25');
	so.addVariable('skinName','/patients/carpal-tunnel-syndrome/videos/images/Corona_Skin_2');
	so.addVariable('appName','mainframe/httpdocs');
	so.addVariable('streamName',file);
	so.addVariable('isLive','false');
	so.addVariable('bufferTime','0');
	so.addVariable('autoPlay','true');
	so.addVariable('autoRewind','false');

	so.write("video-player");

}