// JavaScript Document

/****** YOU ARE HERE ******/
function onbodyload() {
	youarehere();
}
function youarehere() {
	    var section, prevSection;
	    var splits =  window.location.pathname.split('/');
		
		if (splits[1] == 'about') section='1'; 
		if (splits[1] == 'clinicals') section='3'; 
		if (splits[1] == 'contact') section='6'; 
		if (splits[1] == 'news') section='4'; 
		if (splits[1] == 'products') section='2'; 
		if (splits[1] == 'publications') section='5'; 
		prevSection=section-1;
		
		if (section != 6)
		{
			document.getElementById('nav'+section+'here').style.borderRightWidth='1px';
			document.getElementById('nav'+section+'here').style.borderRightStyle='solid';
			document.getElementById('nav'+section+'here').style.borderRightColor='#C2C3C3';
			document.getElementById('nav'+section).style.borderRight='none';
		}
		if (section != 1)
		{
			document.getElementById('nav'+prevSection+'here').style.borderRightWidth='1px';
			document.getElementById('nav'+prevSection+'here').style.borderRightStyle='solid';
			document.getElementById('nav'+prevSection+'here').style.borderRightColor='#C2C3C3';
			document.getElementById('nav'+prevSection).style.borderRight='none';
		}		
			
		document.getElementById('nav'+section+'here').style.backgroundColor='#FFF3D2';
		/*
		// this code finds the section name and changes its color
		var parent=document.getElementById('nav'+section);
		var child=parent.firstChild;
		while (child.id == undefined)
		{
			child = child.nextSibling;
		}
		child.style.color='#009AD8';*/
		
		// change the color of the current link in the second and third navigation sections
		// get the url, and split and join to form  pathnames of the appropriate length for each section
		var arrURL = window.location.href.split('/');
		var level2Link = window.location.href;
		var level3Link = window.location.href;

		if (arrURL.length > 5) level2Link = arrURL.slice(0,5).join('/');
		if (arrURL.length > 6) level3Link = arrURL.slice(0,6).join('/');
		var links = document.getElementsByTagName('a');
		
		var found=false;
		
		for (i=0;i<links.length;i++)
		{
			if (links[i].href == level2Link || links[i].href == level2Link + '/')
			{  
			  // highlight the link only if it is in the correct nav section
			   var par = links[i].parentNode.parentNode;
			   if (par.id == 'nav'+section) {
				   links[i].style.color='#009AD8';
				   found=true;
			   }
			}
			if (links[i].href == level3Link || links[i].href == level3Link + '/')  {
				links[i].style.color='#009AD8';
				found=true;
			}
		}
		
		if (!found) {
			for (i=0; i<links.length; i++) {
				if (window.location.href.indexOf(links[i].href)>=0) {
					links[i].style.color='#009AD8';
				}
			}
		}
}

function displayDate(style,thisdate)
{
  months = new Array(12);
  months[0] = "January";
  months[1] = "February";
  months[2] = "March";
  months[3] = "April";
  months[4] = "May";
  months[5] = "June";
  months[6] = "July";
  months[7] = "August";
  months[8] = "September";
  months[9] = "October";
  months[10] = "November";
  months[11] = "December";

  if (thisdate) now = new Date(thisdate);
  else now = new Date();
  
  year = now.getYear();
  
  if (year < 1000) year = year + 1900;
   
  ayear = year.toString();
   
  if (style==1) document.write(now.getMonth()+1,"/",now.getDate(),"/",ayear.substring(ayear.length-2,ayear.length));
  else if (style == 2) document.write(months[now.getMonth()]," ",now.getDate(),", ",ayear);
  else if (style == 3) document.write(months[now.getMonth()],", ",ayear);
}

/****** MailMe ******/
function MailMe(name,subj,body)
{
  var domain = 'synapsebiomedical.com';
  var q = ((subj||body)?'?':'');
  if (subj) q=q+'subject='+subj;
  if (subj&&body) q=q+'&';
  if (body) q=q+'body='+body;
  window.location = 'mai' + 'lto:' + name + '@' + domain + q;
}
function MailMePP(name,subj,body)
{
  var domain = 'phenixpublicity.com';
  var q = ((subj||body)?'?':'');
  if (subj) q=q+'subject='+subj;
  if (subj&&body) q=q+'&';
  if (body) q=q+'body='+body;
  window.location = 'mai' + 'lto:' + name + '@' + domain + q;
}
/*** Usage: <a href="javascript:void(0);" onClick="MailMe('contact','subject','body');">Contact Us</a> ***/
