// JavaScript Document

function fadeIn(opacity,speed) 
{	
if (document.getElementById) 
	{
		if (opacity <= 100) 
		{
	      setOpacity(opacity);
	      opacity += 3;
	      window.setTimeout("fadeIn("+opacity+")", "+speed+");
	    }
  	}
}


function fadeIn2(opacity,speed) 
{	
if (document.getElementById) 
	{
		if (opacity <= 100) 
		{
	      setOpacity3(opacity);
	      opacity += 3;
	      window.setTimeout("fadeIn2("+opacity+")", "+speed+");
	    }
  	}
}


function fadeOut(opacity,speed) 
{	
if (document.getElementById) 
	{
		if (opacity >= 0) 
		{
	      setOpacity(opacity);
  //	      setOpacity2(opacity);
	      opacity -= 3;
	      window.setTimeout("fadeOut("+opacity+")", "+speed+");
	    }
  	}
}

function PubFade(opacity, speed)
{
	if (opacity >= 0) 
		{
	opacity = (opacity < 0)?0:opacity;
	document.AOR.style.opacity = opacity/100;
	document.AOR.style.filter = "alpha(opacity="+(opacity)+")";
	document.AOR.style.KHTMLOpacity = (opacity/100);
	document.AOR.style.MozOpacity = (opacity/100);

	document.RMButton.style.opacity = opacity/100;
	document.RMButton.style.filter = "alpha(opacity="+(opacity)+")";
	document.RMButton.style.KHTMLOpacity = (opacity/100);
	document.RMButton.style.MozOpacity = (opacity/100);

	document.CSButton.style.opacity = opacity/100;
	document.CSButton.style.filter = "alpha(opacity="+(opacity)+")";
	document.CSButton.style.KHTMLOpacity = (opacity/100);
	document.CSButton.style.MozOpacity = (opacity/100);

	document.TeamButton.style.opacity = opacity/100;
	document.TeamButton.style.filter = "alpha(opacity="+(opacity)+")";
	document.TeamButton.style.KHTMLOpacity = (opacity/100);
	document.TeamButton.style.MozOpacity = (opacity/100);
	
	document.ContactButton.style.opacity = opacity/100;
	document.ContactButton.style.filter = "alpha(opacity="+(opacity)+")";
	document.ContactButton.style.KHTMLOpacity = (opacity/100);
	document.ContactButton.style.MozOpacity = (opacity/100);

	document.LogoButton.style.opacity = opacity/100;
	document.LogoButton.style.filter = "alpha(opacity="+(opacity)+")";
	document.LogoButton.style.KHTMLOpacity = (opacity/100);
	document.LogoButton.style.MozOpacity = (opacity/100);

	opacity -= 3;
	window.setTimeout("PubFade("+opacity+")", "+speed+");
	}
	
	if(opacity==0)
	{
			prompt("done");
			document.TeamButton.style.visible = "hidden";
	}
}

//AOR
//RMButton
//CSButton
//PubButton
//TeamButton
//C/ontactButton
//LogoButton

function fademainscreen()
{
	fadeLoad(100,10);
	window.location="main.html"
//	document.container2.style.maxwidth="1px";
//	document.container2.style.maxheight="1px";

	
}

function fadeLoad(opacity,speed)
{
	if (opacity >= 0) 
		{
	   	document.fadeblank.style.opacity = opacity/100;
	document.fadeblank.style.filter = "alpha(opacity="+(opacity)+")";
    // Safari<1.2, Konqueror
	document.fadeblank.style.KHTMLOpacity = (opacity/100);
    // Older Mozilla and Firefox
	document.fadeblank.style.MozOpacity = (opacity/100);
	      opacity -= 3;
	      window.setTimeout("fadeLoad("+opacity+")", "+speed+");
	    }
  	
}

function setOpacity(opacity) 
{

	opacity = (opacity == 100)?99.999:opacity;
	document.bigimage.style.opacity = opacity/100;

	// IE/Win
	document.bigimage.style.filter = "alpha(opacity="+(opacity)+")";
    // Safari<1.2, Konqueror
	document.bigimage.style.KHTMLOpacity = (opacity/100);
    // Older Mozilla and Firefox
	document.bigimage.style.MozOpacity = (opacity/100);
    // Safari 1.2, newer Firefox and Mozilla, CSS3
//	document.bigimage.opacity = (opacity/100);
	//		document.bigimage.style.opacity= 0.5;
}

function setOpacity3(opacity) 
{

	opacity = (opacity == 100)?99.999:opacity;
	document.teamimage.style.opacity = opacity/100;

	// IE/Win
	document.teamimage.style.filter = "alpha(opacity="+(opacity)+")";
    // Safari<1.2, Konqueror
	document.teamimage.style.KHTMLOpacity = (opacity/100);
    // Older Mozilla and Firefox
	document.teamimage.style.MozOpacity = (opacity/100);
    // Safari 1.2, newer Firefox and Mozilla, CSS3
//	document.bigimage.opacity = (opacity/100);
	//		document.bigimage.style.opacity= 0.5;
}

function restore() 
{
	if(document.body.id !="Main") 
　　 { 
	document.body.id = "Main";
	document.getElementById("boxstatic").style.border = "1px solid #000000";
	document.images["bigimage"].src="assets/dangbig.gif"; 
	fadeIn(0,10);
	return;
	}
}

function ShowAwards()
{
	if(document.body.id =="Education")
	{
		document.body.id ="Awards";
		document.images["teamimage"].src="assets/teamdetails2.png"; 
		document.images["link"].src="assets/educ.png"; 
		fadeIn2(0,10);
		return;
	}

	if(document.body.id =="Awards")
	{
		document.body.id ="Education";
		document.images["teamimage"].src="assets/teamdetails.png"; 
		document.images["link"].src="assets/awards.png"; 
		fadeIn2(0,10);
		return;
	}

	
}

function LeaveRegenMedicine　() 
{
document.body.id ="RegenMedicine";
}
	
function RegenMedicine　() 
{ 
	if(document.body.id !="RegenMedicine") 
　　 { 
		document.body.id ="RegenMedicine";
		document.getElementById("boxstatic").style.border = "1px solid #FFFFFF";
		document.images["bigimage"].src="assets/regenpic.jpg"; 
		fadeIn(0,10);
	} 
	
	pic18=new Image(804,434); 
  pic18.src="assets/rm-content.png";

	
}
　　 

function LeaveComputationalScience() 
{ 
　　 document.body.id ="ComputationalScience";
}

function ComputationalScience() 
{ 
　　 if(document.body.id !="ComputationalScience") 
　　 { 
		document.body.id = "ComputationalScience";
		document.images["bigimage"].src="assets/spine3D.jpg"; 
		fadeIn(0,10);
		document.getElementById("boxstatic").style.border = "1px solid #FFFFFF";
		
		
  pic17=new Image(804,434); 
  pic17.src="assets/cs-content.png";

　　 } 
} 

function Publications() 
{ 
　　 if(document.body.id !="Publications") 
　　 { 
		document.body.id = "Publications";
		document.images["bigimage"].src="assets/papers.jpg"; 
		fadeIn(0,10);
		document.getElementById("boxstatic").style.border = "1px solid #FFFFFF";
　　 } 

	pic19=new Image(804,434); 
  pic19.src="assets/ps-content.png";

} 

function ContactUs() 
{ 
　　 if(document.body.id !="ContactUs") 
　　 { 
		document.body.id = "ContactUs";
		document.images["bigimage"].src="assets/contact.jpg"; 
		fadeIn(0,10);
		document.getElementById("boxstatic").style.border = "1px solid #FFFFFF";
　　 } 
} 

function OurTeam() 
{ 
　　 if(document.body.id !="OurTeam") 
　　 { 
		document.body.id = "OurTeam";
		document.images["bigimage"].src="assets/team.gif"; 
		fadeIn(0,10);
		document.getElementById("boxstatic").style.border = "1px solid #FFFFFF";
　　

  pic12=new Image(794,34); 
  pic12.src="assets/team_top.png";
  
  pic13=new Image(794,327); 
  pic13.src="assets/teamdetails.png";

  pic14=new Image(794,327); 
  pic14.src="assets/teamdetails2.png";
 
 pic15=new Image(166,10);
 pic15.src="assets/awards.png";
 
 pic16=new Image(170,10);
 pic16.src="assets/menu.png";
 
 } 
 
} 


function AboutLogo()
{ 
　　 if(document.body.id !="LogoInfo") 
　　 { 
		document.body.id = "LogoInfo";
		document.images["bigimage"].src="assets/dangbig.gif"; 
		fadeIn(0,10);
		document.getElementById("boxstatic").style.border = "1px solid #000000";
　　 } 
} 
/*
function onMouseLeave( pTarget, pAction ) {
  
   pTarget.realLeaveFunction = pAction; //store action
   pTarget.leaveFunction = function() { pTarget.realLeaveFunction(); }

   //Save previous mouseout and reuse later
   if (pTarget.onmouseout) pTarget.onmouseoutSave1 = pTarget.onmouseout;
   pTarget.onmouseout = function() {
       if (pTarget.onmouseoutSave1) pTarget.onmouseoutSave1();
       this.ltimer = setTimeout(this.leaveFunction.bind(this),100);
   }
  
   //Save previous mouseover and reuse later
   if (pTarget.onmouseover) pTarget.onmouseoverSave1 = pTarget.onmouseover;
   pTarget.onmouseover = function() {
       if (pTarget.onmouseoverSave1) pTarget.onmouseoverSave1();
       clearTimeout(this.ltimer);
   }

}

function onMouseEnter( pTarget, pAction ) {
  
   pTarget.enterFunction = pAction; //store action
  
   pTarget.stepPattern = function() { this.epattern = -1; } //reset pattern

   if (pTarget.onmouseover) pTarget.onmouseoverSave2 = pTarget.onmouseover;
   pTarget.onmouseover = function() {
       if (pTarget.onmouseoverSave2) pTarget.onmouseoverSave2();
       if (this.epattern == 1) { this.epattern = 0; clearTimeout(this.etimer); }
           else { (this.epattern = 0); this.enterFunction(); }
   }
  
   if (pTarget.onmouseout) pTarget.onmouseoutSave2 = pTarget.onmouseout;
   pTarget.onmouseout = function() {
       if (pTarget.onmouseoutSave2) pTarget.onmouseoutSave2();
       if (this.epattern == 0) this.epattern = 1;
       this.etimer = setTimeout(this.stepPattern.bind(this),100);
   }
}
*/

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}