Difference between revisions of "Team:Munich"

Line 1: Line 1:
  
<html>
 
 
<head>
 
<head>
  

Revision as of 17:02, 24 August 2017

<head>

   <meta name="viewport" content="width=device-width" />
   <script src = "https://2017.igem.org/Template:Munich/Javascript?action=raw&ctype=text/javascript"></script>
   <link rel="stylesheet" type="text/css" href="https://2017.igem.org/Template:Munich/CSS?action=raw&ctype=text/css">


<style type="text/css">

   #home_logo, #sideMenu { display:none; }
   #sideMenu, #top_title, .patrollink  {display:none;}
   #content { width:100%; padding:0px;  margin-top:-7px; margin-left:0px;}
   body {background-color:white; }
   #bodyContent h1, #bodyContent h2, #bodyContent h3, #bodyContent h4, #bodyContent h5 { margin-bottom: 0px; }
   .navigation-bar{
 background-color: white !important;

}

  #HQ_page p{
  color: rgb(147,149,152);
  font-family: Helvetica, Arial, sans-serif;
  font-size: initial;  
 }

.ui.secondary.menu.navigation-bar > div.ui.item{

 padding: 0;

}


.cascaid{

 width: 150px;
 height: auto;

}

section{

 width: 66%;
 margin: auto;

}

  1. introduction{
 margin-bottom: 10vh;

}

.mybutton{

 border-radius: 5px;
 color: white;
 border-color: transparent;

}

h1.myHeader1{

 font-size: 4vw;
 text-align: center;
 margin-top: 10vh;

}

  1. introImgContainer{
 text-align: center;

}

img.introImg{

 width: 70%;
 height: auto;
 margin-top: 10vh; /*Changed in comparision to the main structure, since there is no title here, but instead just an img*/

}

.text{

 color: rgb(147,149,152) !important;

} .myImg{

 width: 100%;
 height: auto;

}

p.myParagraph{

 text-align: justify;


}

.topicContainer > .figureContainer{

 width: 66%;
 margin: auto;
 margin-top: 5vh;
 margin-bottom: 5vh;

}


.float-right.figureContainer{

 width: 33%;
 border: 2px solid black;
 margin: 1rem;
 padding: 1rem;

}

p.introP{

 margin-top: 5vh;
 margin-bottom: 5vh;

}

.float-right{

 float: right;

}

/* Lightbox CSS*/ .lightbox{

 display: none;
 width: 100%;
 height: 100%;
 background-color: rgba(0,0,0,.7);
 position: fixed;
 top: 0;
 left: 0;
 z-index: 102;
 padding-top: 30px;
 box-sizing: border-box;

}

.lightboxContainer{

 position: relative;
 top: 50%;
 transform: translateY(-50%);


}

.lightbox img{

 display: block;
 margin: auto;
 max-width: 33vw;

}

.lightbox .caption{

 margin: 15px auto;
 width: 50%;
 text-align: center;
 font-size: 1em;
 line-height: 1.5;
 font-weight: 700;
 color: #eee;

}

.tooltip-line{

     stroke: rgb(147,149,152);
   }
 .myvisible{
   -webkit-animation: myvisible 1s linear;
   -webkit-animation-fill-mode: forwards;
 }
 @keyframes myvisible{
   0%{
     opacity: 0;
   }
   100%{
     opacity: 1;
   }
 }
 .colorNegative{
   -webkit-animation: colorNegative 2s linear;
   -webkit-animation-fill-mode: forwards;
 }
 @keyframes colorNegative{
   0%{
     fill: white;
   }
   100%{
     fill: rgb(0,174,239);
   }
 } /* Because CSS is such a wonderful language, it is imperative to have the colorNegative definitions AFTER the visible one; otherwise the visible overwrites the colorNegative and the circles expand at the end, but don't change color.*/


 .invisible{
   opacity: 0;
 }
 .appear{
   -webkit-animation: appear 1s linear;
 }
 @keyframes appear {
   0%{
     opacity: 0;
   }
   100%{
     opacity: 1;
   }
 }
 .white{
   -webkit-animation: white 1s linear;
   -webkit-animation-fill-mode: forwards;
 }
 @keyframes white{
   0%{
     fill: rgb(255,149,152);
   }
   100%{
     fill: white;
   }
 }

.colorPositive{

   -webkit-animation: colorPositive 2s linear;
   -webkit-animation-fill-mode: forwards;
 }
 @keyframes colorPositive{
   0%{
     fill:white;
   }
   100%{
     fill: rgb(100,255,0);
   }
 }

.explanation{

   /*border-width: 30px;
     border-radius: 10%; For when there is svg canvas in the divs */
     border-radius: 30px;
     border: 5px solid rgb(147,149,152);
     padding: 10px;
     margin-left: -1rem;    
     color: rgb(147,149,152);
     position: absolute;
     top: 0;
     left:0;
     background-color: white;
     max-width: 40vw;
     display: flex;      
 }

.explanation-text{

 max-width: 25vw;

}

 .pretty-picture{
   width: auto;
   height: 20vh;
 }
 button{
     font-family: Helvetica, Arial, sans-serif !important;
     position: absolute;
     right: 16.67%;
     z-index: 41;
 }


 line{
   stroke: rgb(147,149,152);
 }
 .skip-animation{
   background-color: rgb(0,174,239) !important;
 }

@media screen and (max-width: 992px){

 h1.myHeader1{
   font-size: 40px;
   
 }
 .float-right.figureContainer{
   width: 100%;
   padding: 1rem;
   margin: 0;
 }


 .topicContainer> .figureContainer{
   width: 100%;
   padding: 1rem;
   margin: 0;
 }
 .float-right{
   float: none;
 }


 .mybutton{
   
 }

} @media screen and (max-width: 769px){

 .lightbox img{
   max-width: 90vw;
 }
 .lightbox .caption{
   width: 90vw;
 }
 .explanation-text{
   display: none;
 }
 .pretty-picture{
   width: auto;
   height: 7vh;
 } 
 .explanation{
   border-width: 2px;
   border-radius: 3px;
 }

}


</style>

</head> <body onresize="renderDevice();calculateEndsteps();skipAnimation()">

<section id="introduction">

   <img class="myImg introImg" src="739px-T--Munich--Logo_Final.svg.png"/ alt="intro Picture">

CascAID stands for Cas13a Controlled Assay for Infectious Diseases. Our goal this year is to create a novel paper-based microfluidic device for the detection of specific RNA sequences. Nowadays, there is a trend among medical practitioners to prescribe antibiotics when bacterial infections are suspected without a laboratory confirmation as a way for speeding up recovery. This has led to an increase in antibiotic-resistant bacteria that makes it difficult to treat infected patients. Nucleic acid-based detection methods could allow for faster diagnosis. Therefore, we seek to develop a method that allows to report the presence of a specific pathogen within hours. For this reason, we will use the CRISPR effector Cas13a, which is able to target specific single-stranded RNA. This system allows for the simple and fast design of new sequence targets, being an ideal tool for detecting fast mutating pathogens. In the long term, we see our device as an easy-to-use and fast diagnostic tool in developing countries as well as an instrument in developed countries for discerning between bacterial and viral infections, that could help reducing antibiotics prescription.

</section>

 <button onclick="skipAnimation()" class ="mybutton skip-animation" >
     Skip animation
 </button>
   <svg id="svg-canvas" >
     <circle fill="rgb(147,149,152)" id="top-circle" class="circle" />
     
     
   
     <line class="line-vertical" id="top-line" y1="-3"/>
     <line class="line-vertical" id="bottom-line1" y1="-1"/>
     <line class="line-vertical" id="bottom-line2" y1="-1"/>
     <line class="line-vertical" id="bottom-line3" y1="-1"/>     
     <rect fill="rgb(0,174,239)" rx="10" ry="10" id="device-body" fill="rgb(147,149,152)"/> 
     <line class="line-horizontal" id="horizontal-line1"/>
     <line class="line-horizontal" id="horizontal-line2"/>
     <line class="line-vertical2" id="bottom-line4" y1="-1"/>
     <line class="line-vertical2" id="bottom-line5" y1="-1"/>
     <circle fill="rgb(147,149,152)" id="bottom-circle1" class="circlebottom" />
     <circle fill="rgb(147,149,152)" id="bottom-circle2" class="circlebottom" />
     <circle fill="rgb(147,149,152)" id="bottom-circle3" class="circlebottom" />


     <line class="tooltip-line" id="tooltip-line2" />


     <line class="tooltip-line" id="tooltip-line3" />


     <line class="tooltip-line" id="tooltip-line4" />


     <line class="tooltip-line" id="tooltip-line5" />
     <circle class="pulse" fill="rgb(255,149,152)" id="pulse" />
     <circle class="sample" fill="rgb(255,149,152)" id="sample" />
     <circle class="invisible pulse" fill="white" id="pulse2" />
     <circle class="invisible sample"  fill="white" id="sample2" />
     <circle class="invisible pulse"  fill="white" id="pulse3" />
     <circle class="invisible sample"  fill="white" id="sample3" />


     <line class="tooltip-line" id="tooltip-line1" />  
   </svg>



   <script>

//This script configures the svg-image to have a proportional size relative to the window-size

 var animationstep;
 var pulsestep;
 var shiftcanvas;
 var canvaswidth;
 var devicewidth;
 var circleradius;
 var cycircle;
 var linewidth;
 var linelength;
 var deviceheight;
 var linelengthHor;
 var tooltipradius;
 var tooltiplinelength;
 var heightexplanation;
 var svgheight;
 var baserightLinelength; //This variable is responsible for setting a baselength for the tooltip lines. Changing it changes all tooltip lines, but keeping their ratios.
 var firstrender = true; //Boolean to differentiate whether it is the first time the device is being rendered or resizing is taking place.
 renderDevice();



 function renderDevice(){
   var hola;
   if(!firstrender){
     
     hola = $("#sample").attr("cy")/svgheight;  
   }


   deviceheightbefore = deviceheight //deviceheightbefore is only there to save a value before the resizing, so the elements of the device can be positioned accordingly.
   canvaswidth = window.innerWidth*0.80;
   
   shiftcanvas = canvaswidth*0.1; //Shift canvas is there so make it easy to horizontally move the whole construct of svg-canvas and explanation
   devicewidth = window.innerWidth*0.0534;    //Defining the width of the deviece-rectangle, around which the whole desing is based.
   circleradius = devicewidth*0.5;
   circleradiusbottom = circleradius * 0.7;
   linewidth = devicewidth*0.1;
   linelength = devicewidth*0.33;
   if(window.innerWidth <= 768){
     deviceheight = window.innerHeight*0.6;
     tooltiplinelength = canvaswidth;
     baserightLinelength = linelength*4.5;  
   } else {
     deviceheight = window.innerHeight*0.9;
     tooltiplinelength = canvaswidth*0.1;
     baserightLinelength = linelength*2;  
   } 
   linelengthbottom = linelength*2.3;     
   linelengthHor = linelength*2.5;
   tooltipradius = circleradius*0.20;


   heightexplanation = parseInt($(".explanation").css("height")); 


   svgheight = deviceheight+devicewidth*6; 
   cycircle = svgheight*0.05;
   animationstep = Math.ceil(9000/deviceheight); //Time in ms that each step of the animation needs. Increasing makes the animation slower.
   pulsestep = Math.ceil(2563/circleradius); //Time of the step in the pulse animation. Has to be different to animationstep, because the pulse cycle should be the same regardless of deivce size.
 $("#svg-canvas").attr("height",svgheight); //This two lines are to make sure the footer stays relatively close to the end of the device.


 $("#svg-canvas").attr("width",canvaswidth+);  //The Width of the canvas is defined


 $(".circle").attr("r",circleradius);    
 $(".circlebottom").attr("r",circleradiusbottom); //The radius of the circles are defined.
 $("#top-circle").attr("cx",canvaswidth*0.1+);
 $("#top-circle").attr("cy",cycircle+);            //The position of the top-circle is defined.



 $("#sample").attr("cx",canvaswidth*0.1);
 if(firstrender) $("#sample").attr("cy",cycircle);               //The sample circle is defined.  
 $("#sample").attr("r",circleradius);


 $("#pulse").attr("r",Math.max(circleradius*0.04,1)); 
   $("#pulse").attr("cx",canvaswidth*0.1);
   if(firstrender) $("#pulse").attr("cy",cycircle);                //The inital size and position of the pulse circle are defined.

firstrender = false;




 $("line").css("stroke-width",linewidth+); //The width of the lines is defined.
 
 $(".line-vertical").attr("y2",linelength+1+); //The length of the vertical lines is defined. +1 is needed due to roundig errors.
 $(".line-vertical2").attr("y2",linelengthbottom+); //The length of the other bottom lines is defined
 $("#top-line").css("transform","translate("+canvaswidth*0.1+"px,"+(cycircle+circleradius)+"px)"); //The top line is correctly positioned.


 $("#device-body").attr("width",devicewidth);
 $("#device-body").attr("height",deviceheight);
 $("#device-body").attr("x",canvaswidth*0.1-devicewidth*0.5+);
 $("#device-body").attr("y",cycircle+circleradius+linelength+);          //The width and position of the device-rectangle are defined.
 $("#sample2").attr("r",parseInt(circleradius*0.15));
 $("#sample2").attr("cx",canvaswidth*0.1);
 $("#sample2").attr("cy",parseInt(cycircle+linelength+circleradius+0.65*deviceheight)+1);
 $("#pulse2").attr("r",circleradius*0.04);
 $("#pulse2").attr("cx",canvaswidth*0.1);
 $("#pulse2").attr("cy",parseInt(cycircle+linelength+circleradius+0.65*deviceheight)+1);
 
 $("#sample3").attr("r",parseInt(circleradius*0.15));
 $("#sample3").attr("cx",canvaswidth*0.1);
 $("#sample3").attr("cy",parseInt(cycircle+linelength+circleradius+0.65*deviceheight)+1);
 $("#pulse3").attr("r",circleradius*0.04);
 $("#pulse3").attr("cx",canvaswidth*0.1);
 $("#pulse3").attr("cy",parseInt(cycircle+linelength+circleradius+0.65*deviceheight)+1); //Defining the two other circles that will show later in the animation.
 


 $("#bottom-line1").css("transform","translate("+parseInt(canvaswidth*0.1-0.3*devicewidth)+"px,"+(cycircle+deviceheight+linelength+circleradius)+"px)"); 
 $("#bottom-line2").attr("y2",linelength+linelengthbottom); //The line of the seconds line is increased
 $("#bottom-line2").css("transform","translate("+(canvaswidth*0.1)+"px,"+(cycircle+deviceheight+linelength+circleradius)+"px)");
 $("#bottom-line3").css("transform","translate("+parseInt(canvaswidth*0.1+0.3*devicewidth)+"px,"+(cycircle+deviceheight+linelength+circleradius)+"px)"); //The position of the three bottom lines is defined.


 $(".line-horizontal").attr("x2",linelengthHor);
 $("#horizontal-line1").css("transform","translate("+(parseInt(canvaswidth*0.1-0.3*devicewidth)-linelengthHor+0.5*linewidth)+"px,"+(cycircle+deviceheight+2*linelength+circleradius)+"px)");
 $("#horizontal-line2").css("transform","translate("+(parseInt(canvaswidth*0.1+0.3*devicewidth)-0.5*linewidth)+"px,"+(cycircle+deviceheight+2*linelength+circleradius)+"px)"); //The two horizontal lines are defined and positioned.
 $("#bottom-line4").css("transform","translate("+(parseInt(canvaswidth*0.1-0.3*devicewidth)-linelengthHor+linewidth)+"px,"+(cycircle+deviceheight+2*linelength+circleradius)+"px)");
 $("#bottom-line5").css("transform","translate("+(parseInt(canvaswidth*0.1+0.3*devicewidth)+linelengthHor-linewidth)+"px,"+(cycircle+deviceheight+2*linelength+circleradius)+"px)"); //The two other vertical lines positioned.
 
 $("#bottom-circle1").css("transform","translate("+(parseInt(canvaswidth*0.1-0.3*devicewidth)-linelengthHor+linewidth)+"px,"+(cycircle+deviceheight+2*linelength+linelengthbottom+circleradius+circleradiusbottom-1)+"px)");
 $("#bottom-circle2").css("transform","translate("+canvaswidth*0.1+"px,"+(cycircle+deviceheight+2*linelength+linelengthbottom+circleradius+circleradiusbottom-1)+"px)");
 $("#bottom-circle3").css("transform","translate("+(parseInt(canvaswidth*0.1+0.3*devicewidth)+linelengthHor-linewidth)+"px,"+(cycircle+deviceheight+2*linelength+linelengthbottom+circleradius+circleradiusbottom-1)+"px)"); //The three bottom circles are positioned.



 if(window.innerWidth <= 768){
   $(".tooltip-line").css("stroke-width",2);  
 } else {
   $(".tooltip-line").css("stroke-width",5);
 } 
 
   
 $(".tooltip-line").attr("x2",tooltiplinelength);  //The width and length of the tooltip lines are defined.
 $(".tooltip-line").attr("stroke-linecap","round");
 


 $("#tooltip-line1").css("transform","translate("+(canvaswidth*0.1+circleradius-1)+"px,"+cycircle+"px)");
 $("#tooltip-line1").attr("x2",0); 
 $("#tooltip-line2").css("transform","translate("+(canvaswidth*0.1+circleradius-1)+"px,"+(cycircle+circleradius+linelength+0.225*deviceheight)+"px)");
 $("#tooltip-line2").attr("x2",0);
 $("#tooltip-line3").css("transform","translate("+(canvaswidth*0.1+circleradius-1)+"px,"+(cycircle+circleradius+linelength+0.55 *deviceheight)+"px)");
 $("#tooltip-line3").attr("x2",0);   
 $("#tooltip-line4").css("transform","translate("+(canvaswidth*0.1+circleradius-1)+"px,"+(cycircle+circleradius+linelength+0.85*deviceheight)+"px)");
 $("#tooltip-line4").attr("x2",0);
 $("#tooltip-line5").css("transform","translate("+(canvaswidth*0.1+circleradius+linelengthHor+circleradiusbottom-0.3*devicewidth)+"px,"+(cycircle+deviceheight+2*linelength+linelengthbottom+circleradius+circleradiusbottom)+"px)");
 $("#tooltip-line5").attr("x2",0);       //Depending whether the line point right or left, either x1 or x2 is changed to match the other value so the inial length of the lines is 0, rendering them invisible. This is later changed through the extendLine() function.

//Here we configure the tip boxes with javascript, because CSS sucks. //Important: unless every explanation has the same height, this won't work;

 $("#tip1").css("left",(canvaswidth*0.1+circleradius-1)+baserightLinelength+shiftcanvas+11); // For whatever reason, +11 alings the line with the
 $("#tip1").css("top",cycircle-heightexplanation*0.5);
 $("#tip2").css("left",(canvaswidth*0.1+circleradius-1)+baserightLinelength*5+shiftcanvas);
 $("#tip2").css("top",(cycircle+circleradius+linelength+0.225*deviceheight)-heightexplanation*0.5);
 $("#tip3").css("left",(canvaswidth*0.1+circleradius-1)+baserightLinelength*2.5+shiftcanvas+11);
 $("#tip3").css("top",(cycircle+circleradius+linelength+0.55 *deviceheight)-heightexplanation*0.5);
 $("#tip4").css("left",(canvaswidth*0.1+circleradius-1)+baserightLinelength*6+shiftcanvas);
 $("#tip4").css("top",(cycircle+circleradius+linelength+0.85*deviceheight)-heightexplanation*0.5);
 $("#tip5").css("left",(canvaswidth*0.1+circleradius+linelengthHor+circleradiusbottom-0.3*devicewidth)+baserightLinelength*2+shiftcanvas);
 $("#tip5").css("top",(cycircle+deviceheight+2*linelength+linelengthbottom+circleradius+circleradiusbottom)-heightexplanation*0.5);
 $(".button-container").css("left",$(".header-container").css("margin-left"));//Change this so it is calculated faster.
 $(".button-container").css("top",cycircle-0.5*heightexplanation); //I literally don't know where to put the button...
 $("#svg-canvas").css("transform","translate("+shiftcanvas+"px,"+0);
 }


var animatinoCounter = 0; //This counter saves the number of animation that have already been triggered. If an animation is not triggering, check if the counter-count is done propertly. var accu = 0;

$(window).on("scroll",checkPosition); //Checks on every scroll whether a certain animation should be triggered or not.

var finalshrink = parseInt(circleradius*0.15); //This variable is here so the shrink function doesn't have to evaluate parseIn(etc) every single time.


var startMovement = false; //This variable is the responsible for triggering the first moveCircleY. It's declared here so it is within scoope of all functions.


var endstep1; //This variable tells the first set of animations where they should end. var endstep2; //This variable tells the second set of animations where they should end. var endstep3;

var endstep4;

var endstep5;

var endstep6;

calculateEndsteps();

function calculateEndsteps(){

 finalshrink = parseInt(circleradius*0.15);
 endstep1 = (cycircle+linelength+circleradius+0.1*deviceheight);
 endstep2 = endstep1+0.25*deviceheight;;
 endstep3 = endstep2+0.30*deviceheight;
 endstep4 = (endstep3+0.25*deviceheight);
 endstep5 = endstep4 +linelength +0.1*deviceheight;
 endstep6 = parseInt(endstep5 + linelengthbottom + circleradiusbottom);

}

function checkPosition(){

 var yOffSet = window.pageYOffset;
 if(and(animatinoCounter == 0, yOffSet > 0)){        //First animation-round: circle shrinks, first tip appears and circle moves to inside the device
   animatinoCounter = 1;
   var id = setInterval(function(){
     shrink("sample",id,finalshrink);
     startMovement = $("#sample").attr("r") == finalshrink;    //After every call of shrink, startMovement is refreshed to check if the trigger condition is already met.
   },animationstep*3);            //The shrinking is triggered immediatly after scrolling down.



   var id2 = setInterval(function(){
     if(startMovement){
       moveCircleY("sample",id2,endstep1,4);
       moveCircleY("pulse",id2,endstep1,4);
     } 
   },animationstep);            //Once the shrinking is done, both the sample and pulse start moving down.
   var id32 = setInterval(function(){
     if(startMovement){
       accu++;
       pulse("pulse",accu,id32,circleradius*0.45,$("#sample3").attr("cx") >= parseInt(canvaswidth*0.1+0.3*devicewidth));  //$("#sample").attr("cy") == endstep3
       
     }
   },pulsestep);            //After the shrinkage is done, the pulsing starts. Doesn't end.
   
   var id3 = setInterval(function(){
     extendLineRight("tooltip-line1",(baserightLinelength),id3);
     if($("#tooltip-line1").attr("x2") >= baserightLinelength){
       appear("tip1");
     };
   },animationstep);
 }
 if(and(animatinoCounter == 4, yOffSet > 100) ){ //Second round of animation: circle turns white, goes down and second tip appears
   animatinoCounter = 5;
   var id = setInterval(function(){
     moveCircleY("sample",id,endstep2,7);
     if($("#sample").attr("cy") >= (cycircle+circleradius+linelength+0.20*deviceheight));{
       clearcolor("sample");
     }
   },animationstep);
   var id2 = setInterval(function(){
     moveCircleY("pulse",id2,endstep2,7);
     if($("#pulse").attr("cy") >- (cycircle+circleradius+linelength+0.20*deviceheight));{
       clearcolor("pulse");
     }
   },animationstep);
     var id3 = setInterval(function(){
     extendLineRight("tooltip-line2",baserightLinelength*5+4,id3);
     if($("#tooltip-line2").attr("x2") >= (baserightLinelength+4)){
       appear("tip2");
     };
   },Math.floor(animationstep*0.2));
 }
 if(and(animatinoCounter == 7, yOffSet > 200)){    //Third round of animations: Third tip appears and circle past the mid point and stips 3/4 of the device length
   animatinoCounter = 8;
   var id = setInterval(function(){
     var id22;
     moveCircleY("sample",id,endstep3,10);
   },animationstep);
   var id2 = setInterval(function(){
     moveCircleY("pulse",id2,endstep3,10);
   },animationstep);
   var id3 = setInterval(function(){
     extendLineRight("tooltip-line3",(baserightLinelength*2.5),id3);
     if($("#tooltip-line3").attr("x2") >= baserightLinelength){
       appear("tip3");
     };
   },Math.floor(animationstep*0.01));
 }
 if(and(animatinoCounter == 10, yOffSet > 300)){   //Fourth round of animations: circle divides into three and goes down. Fourth tip appears
   animatinoCounter = 11;
   $("#sample2").removeClass("invisible");
   $("#sample2").addClass("myvisible");
   $("#pulse2").removeClass("invisible");
   
   
   $("#sample3").addClass("myvisible");
   $("#sample3").removeClass("invisible");
   $("#pulse3").removeClass("invisible");
   
   
   var id = setInterval(function(){
     moveCircleX("sample3",id,canvaswidth*0.1+0.3*devicewidth,true,19);
     moveCircleX("pulse3",id,canvaswidth*0.1+0.3*devicewidth,true,19);
     moveCircleX("sample2",id,canvaswidth*0.1-0.3*devicewidth,false,19);
     moveCircleX("pulse2",id,canvaswidth*0.1-0.3*devicewidth,false,19);
     


   },animationstep*5);
   var hola = false
   var id2 = setInterval(function(){
     if( and(animatinoCounter == 19,(hola || (accu % 20) - 1 == 0 ))  ){
       hola = true;
       moveCircleY("sample",id2,endstep4,21);
       moveCircleY("pulse",id2,endstep4,21);
       moveCircleY("sample2",id2,endstep4,21);
       moveCircleY("pulse2",id2,endstep4,21);
       moveCircleY("sample3",id2,endstep4,21);
       moveCircleY("pulse3",id2,endstep4,21);
     }
   },animationstep);
   var adios = false;
   var id3= setInterval(function(){
     if(and($("#sample2").attr("cx") <= canvaswidth*0.1-0.3*devicewidth, (adios || (accu % 20) - 1 == 0 ))){
       adios =true ;
       accu++;
       pulse("pulse",accu,id3,circleradius*0.45,false);
       pulse("pulse2",accu, id3,circleradius*0.45,false);
       pulse("pulse3",accu, id3,circleradius*0.45,false);
     }
   },pulsestep);
     var id3 = setInterval(function(){
     extendLineRight("tooltip-line4",baserightLinelength*6,id3);
     if($("#tooltip-line4").attr("x2") >= (baserightLinelength+4)){
       appear("tip4");
     };
   },Math.floor(animationstep*0.1));
 }
 
 if(and(animatinoCounter ==21, yOffSet > 300)){      //Fifth round of animations: 
   animatinoCounter = 22;
   var id = setInterval(function(){
     moveCircleY("sample",id,endstep5,28);
     moveCircleY("pulse",id,endstep5,28);
     moveCircleY("sample2",id,endstep5,28);
     moveCircleY("pulse2",id,endstep5,28);
     moveCircleY("sample3",id,endstep5,28);
     moveCircleY("pulse3",id,endstep5,28);
   },animationstep);
 }
 
 if(and(animatinoCounter == 28, yOffSet > 300)){
   animatinoCounter = 29;
   var id = setInterval(function(){
     moveCircleX("sample2",id,canvaswidth*0.1-0.3*devicewidth-linelengthHor+linewidth,false,33);
     moveCircleX("pulse2",id,canvaswidth*0.1-0.3*devicewidth-linelengthHor+linewidth,false,33);
     moveCircleX("sample3",id,canvaswidth*0.1+0.3*devicewidth+linelengthHor-linewidth,true,33);
     moveCircleX("pulse3",id,canvaswidth*0.1+0.3*devicewidth+linelengthHor-linewidth,true,33);
   },animationstep);
 }
 if(and(animatinoCounter == 33, yOffSet >300)){
   animatinoCounter = 34;
   var id = setInterval(function(){
     moveCircleY("sample",id,endstep6,40);
     moveCircleY("pulse",id,endstep6,40);
     moveCircleY("sample2",id,endstep6,40);
     moveCircleY("pulse2",id,endstep6,40);
     moveCircleY("sample3",id,endstep6,40);
     moveCircleY("pulse3",id,endstep6,40);
   },animationstep);
 }


 if(and(animatinoCounter == 40, yOffSet > 300)){
   animatinoCounter = 41;
   var id = setInterval(function(){
     expandNegative("sample2",id,parseInt(circleradiusbottom)+2);
   },animationstep*5);
   var id2 = setInterval(function(){
     if(animatinoCounter == 42){
       expandPositive("sample",id2,parseInt(circleradiusbottom)+2);
     }
   },animationstep*5);
   var id3 = setInterval(function(){
     if(animatinoCounter == 43){
       expandNegative("sample3",id3,parseInt(circleradiusbottom)+2); 
     }
   },animationstep*5);
   var id4 = setInterval(function(){
     extendLineRight("tooltip-line5",baserightLinelength*2+4,id4);
     if($("#tooltip-line5").attr("x2") >= baserightLinelength){
       appear("tip5");
     };
   },Math.floor(animationstep*0.5));
 }
 

}

function shrink(circle, id, rfinal){

 var r = parseInt($("#"+circle).attr("r"));
 if(r != rfinal){
   $("#"+circle).attr("r",r-1);
 } else {
   animatinoCounter++;
   clearInterval(id);
   
 }

} //This function shrinks a circle to a final radius.


function appear(elementId){

 $("#"+elementId).addClass("appear");
 $("#"+elementId).removeClass("invisible");

} //this function makes an element gradually change its opacity to 1 by adding the appear class in css and removing the invisible class. See style for class descriptions.

function extendLineRight(line,finalvalue,id){

 var value = parseInt($("#"+line).attr("x2"));
 if(value < finalvalue){
   $("#"+line).attr("x2",value+1);
 } else {
   clearInterval(id);
 }

} //This function extends a line by increasing the x2 value until the final value is reached. To be used in conjuction with setInterval.

function clearcolor(circle){

 $("#"+circle).addClass("white");

} //This function changes the color of an Element to white using css transitions. See white class for class definition.

function animation(){

 expand("sample");

}

function expandNegative(circle,id,rfinal){

 $("#"+circle).addClass("colorNegative");
 var r = parseInt($("#"+circle).attr("r"));
 if(r != rfinal + 1 ){
   
   $("#"+circle).attr("r",r+1);
 } else {
   animatinoCounter++;
   clearInterval(id);
   
 }

}

function expandPositive(circle,id,rfinal){

 $("#"+circle).addClass("colorPositive");
   var r = parseInt($("#"+circle).attr("r"));
 if(r != rfinal + 1 ){
   
   $("#"+circle).attr("r",r+1);
   
 } else {
   animatinoCounter++;
   clearInterval(id);
   
 }

}

function moveCircleY(circle, id, cyfinal, setcounter){

 var cy = parseInt($("#"+circle).attr("cy"));
 if( cy <= cyfinal){
   
   $("#"+circle).attr("cy", cy+1);
 } else{
   animatinoCounter = setcounter;
   clearInterval(id);


 }

} //Moves a circle to cyfianl by and upon finishing clears id. Set counter is needed to propertly coordinate the animation counters so different screen sizes (which result in slightly different values) don't ruin the animation triggerin.


function moveCircleX(circle, id, cxfinal, plus, setcounter){

 var cx = parseInt($("#"+circle).attr("cx"));
 if(plus == true){
   if(cx <= cxfinal){
     $("#"+circle).attr("cx",cx+1);
   } else{
     
     animatinoCounter = setcounter;
     clearInterval(id);


   }
 } else {
   if(cx >= cxfinal){
     $("#"+circle).attr("cx",cx-1);
   } else {
     
     animatinoCounter = setcounter;
     clearInterval(id);
   }
 }
 

}


function pulse(circle,accu,id,maxr,endcondition){

   if(and(endcondition, ((accu % maxr) - 1 == 0))){
           accu =0;
                       clearInterval(id);
     
   } else{
                       $("#"+circle).css("opacity",(1-((accu % maxr)/100)+));
     $("#"+circle).attr("r",(2 + (accu % maxr))+);
   }

} //This function takes a circle and changes periodically its opacity and radius. An accumualtor is needed for it to work propertly.


function and(a, b){

 return (!(!(a || a) || !(b || b)));

} //Calculates the value of a and b, because why should the && operator work?


$sample = $("#sample"); $pulse = $("#pulse"); $sample2 = $("#sample2"); $pulse2 = $("#pulse2"); $sample3 = $("#sample3"); $pulse3 = $("#pulse3"); function skipAnimation(){

 animatinoCounter=-99;   //Just to be sur
   var id = setInterval(function(){
     extendLineRight("tooltip-line1",(baserightLinelength-3),id);
     if($("#tooltip-line1").attr("x1") >= baserightLinelength){
       appear("tip1");
     };
   },animationstep);
     var id2 = setInterval(function(){
     extendLineRight("tooltip-line2",baserightLinelength*5+4,id2);
     if($("#tooltip-line2").attr("x2") >= (baserightLinelength+4)){
       appear("tip2");
     };
   },animationstep*0.2);
   var id3 = setInterval(function(){
     extendLineRight("tooltip-line3",(baserightLinelength*2.5-3),id3);
     if($("#tooltip-line3").attr("x2") >= baserightLinelength){
       appear("tip3");
     };
   },animationstep*0.4);
     var id4 = setInterval(function(){
     extendLineRight("tooltip-line4",baserightLinelength*6+4,id4);
     if($("#tooltip-line4").attr("x2") >= (baserightLinelength+4)){
       appear("tip4");
     };
   },animationstep*0.1);
   var id5 = setInterval(function(){
     extendLineRight("tooltip-line5",baserightLinelength*2,id5);
     if($("#tooltip-line5").attr("x2") >= baserightLinelength){
       appear("tip5");
     };
   },animationstep*0.5);


   $sample.attr("cy",endstep6);
   $sample.attr("cx",canvaswidth*0.1)
   $sample.removeClass("white");
   $sample.css("fill","rgb(100,255,0)");
   $sample.attr("r",circleradiusbottom+1);
   $pulse.remove();
   $sample.removeAttr("id");


   $sample2.attr("cx",parseInt(canvaswidth*0.1-0.3*devicewidth-linelengthHor+linewidth));
   $sample2.attr("cy",endstep6);
   $sample2.attr("r",circleradiusbottom+1);
   $sample2.css("fill","rgb(0,174,239)");
   $pulse2.attr("cx",parseInt(canvaswidth*0.1-0.3*devicewidth-linelengthHor+linewidth));
   $pulse2.attr("cy",endstep6+2);
   $sample2.removeAttr("id");
   $pulse2.removeAttr("id");  //This is a patch work solution to force stop the animation when it's cancelled while the cirlces are moving horizontally. Change if needed.


   $sample3.attr("cx",parseInt(canvaswidth*0.1+0.3*devicewidth+linelengthHor-linewidth));
   $sample3.attr("cy",endstep6);
   $sample3.attr("r",circleradiusbottom+1)
   $sample3.css("fill","rgb(0,174,239)");
   $pulse3.attr("cx",parseInt(canvaswidth*0.1+0.3*devicewidth+linelengthHor-linewidth));
   $pulse3.attr("cy",endstep6+2);
   $pulse3.removeAttr("id");
   $sample3.removeAttr("id"); //This is a patch work solution to force stop the animation when it's cancelled while the cirlces are moving horizontally. Change if needed.
   $(".sample").css("opacity","1");
 }


var id = setInterval(function() {

  if(and(($(window).scrollTop() + $(window).height()) / $(document).height() >= 0.9,animatinoCounter >0)) {
      checkPosition();
  }

},100); //This part here makes it so the animation continues without the need to scroll if the view port is at the bottom of the document.

   </script>
   <script>



$('.dropdown').dropdown({on:'hover',

                    action: 'nothing'
                         });
 $('.ui.accordion')
   .accordion()
 ;
 // Create a lightbox
 (function() {
var $lightbox = $(""); var $container = $("<div class='lightboxContainer'
");
   var $img = $("<img>");
var $caption = $("

");
   // Add image and caption to lightbox
   $container
     .append($img)
     .append($caption);
   $lightbox
     .append($container);
   // Add lighbox to document
   $('body').append($lightbox);
   $('.lightboxAble').parent().click(function(e) {
     e.preventDefault();
     // Get image link and description
     var $imgelement = $(this).children("img");
     var src = $imgelement.attr("src");
     var cap = $imgelement.attr("alt");
     // Add data to lighbox
     $img.attr('src', src);
     $caption.append(cap);
     // Show lightbox
     $lightbox.fadeIn('fast');
     $lightbox.click(function() {
       $lightbox.fadeOut('fast', function(){
         $caption.empty();
       });
     });
   });
 }());
   </script>

</body>