Team:Valencia UPV/generaljs2

/*! Image Map Resizer (imageMapResizer.min.js ) - v1.0.3 - 2016-06-16

*  Desc: Resize HTML imageMap to scaled image.
*  Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net
*  License: MIT
*/

!function(){"use strict";function a(){function a(){function a(a,c){function d(a){var c=1===(e=1-e)?"width":"height";return Math.floor(Number(a)*b[c])}var e=0;i[c].coords=a.split(",").map(d).join(",")}var b={width:k.width/k.naturalWidth,height:k.height/k.naturalHeight};j.forEach(a)}function b(a){return a.coords.replace(/ *, */g,",").replace(/ +/g,",")}function c(){clearTimeout(l),l=setTimeout(a,250)}function d(){(k.width!==k.naturalWidth||k.height!==k.naturalHeight)&&a()}function e(){k.addEventListener("load",a,!1),window.addEventListener("focus",a,!1),window.addEventListener("resize",c,!1),window.addEventListener("readystatechange",a,!1),document.addEventListener("fullscreenchange",a,!1)}function f(){return"function"==typeof h._resize}function g(){i=h.getElementsByTagName("area"),j=Array.prototype.map.call(i,b),k=document.querySelector('img[usemap="#'+h.name+'"]'),h._resize=a}var h=this,i=null,j=null,k=null,l=null;f()?h._resize():(g(),e(),d())}function b(){function b(a){if(!a.tagName)throw new TypeError("Object is not a valid DOM element");if("MAP"!==a.tagName.toUpperCase())throw new TypeError("Expected <MAP> tag, found <"+a.tagName+">.")}function c(c){c&&(b(c),a.call(c),d.push(c))}var d;return function(a){switch(d=[],typeof a){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(a||"map"),c);break;case"object":c(a);break;default:throw new TypeError("Unexpected data type ("+typeof a+").")}return d}}"function"==typeof define&&define.amd?define([],b):"object"==typeof module&&"object"==typeof module.exports?module.exports=b():window.imageMapResize=b(),"jQuery"in window&&(jQuery.fn.imageMapResize=function(){return this.filter("map").each(a).end()})}(); //# sourceMappingURL=imageMapResizer.map


var wh = $(window).height(); var ww = $(window).width();

//preloader

 $(window).load(function() {
    $('#loading').hide();
 });

function isScrolledIntoView(elem) {

   var docViewTop = $(window).scrollTop();
   var docViewBottom = docViewTop + $(window).height();
   var elemTop = $(elem).offset().top;
   var elemBottom = elemTop + $(elem).height();
   return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));

}

var body = $("html, body"); $('#goToTopLink').click(function(){ body.stop().animate({scrollTop:0}, '500', 'swing'); });


$(document).on('scroll',function(){ if(isScrolledIntoView($('.footer-logo'))){

  $('.side-nav').slideUp('fast');

}else{

  $('.side-nav').slideDown('fast');

}

if ($(this).scrollTop() > 150) {

             $('#goToTop').fadeIn('fast');
             $('.side-nav').removeClass('margin-top-30');
             $('.side-nav').css({"margin-top":"-230px"});
         } else {
             $('#goToTop').fadeOut('fast');
             $('.side-nav').addClass('margin-top-30');
         }

if(window.location.href == "https://2016.igem.org/Team:Valencia_UPV/Hardware"){hardwareScroll();} })


function hardwareScroll(){ if ($(this).scrollTop() > 150) {

             $('#goToTop').fadeIn('fast');
             $('.side-nav').removeClass('margin-top-30');
             $('.side-nav').css({"margin-top":"-38em"});
         } else {
             $('#goToTop').fadeOut('fast');
             $('.side-nav').addClass('margin-top-30');
         }

}

var myIndex = 0; var myIndex1 = 0; carousel(); carousel1();

function carousel() {

   var i;
   var x = document.getElementsByClassName("mySlides");
   for (i = 0; i < x.length; i++) {
      x[i].style.display = "none";
   }
   myIndex++;
   if (myIndex > x.length) {myIndex = 1}
   $(x[myIndex-1]).fadeIn('slow');
   setTimeout(carousel, 2500); 

} function carousel1() {

   var i;
   var x = document.getElementsByClassName("mySlides1");
   for (i = 0; i < x.length; i++) {
      x[i].style.display = "none";
   }
   myIndex1++;
   if (myIndex1 > x.length) {myIndex1 = 1}
   $(x[myIndex1-1]).fadeIn('slow');
   setTimeout(carousel, 2500); 

} /*DOCUMENT READY*/ $(document).ready(function(){

   if ($(window).width() <= 992){
   $('.nav-main').slideUp('fast');
   $('#topNav ul.dropdown-menu.pull-right').css("cssText","display: none !important");
   }

}); /*DOCUMENT READY*/


/*MOBILE PATCH*/ var open = false; $('.btn-mobile').click(function(){

   if(!open){
     $('.nav-main').slideDown('slow');
     open = true;
   }else{
     $('.nav-main').slideUp('slow');
     open = false;
   }

});

var openedSub = false; $('.dropdown-toggle').click(function(event){

   if ($(window).width() <= 992){	
   var element = $(event.target);
   element = $(element).parent();
   $('#topNav ul.dropdown-menu.pull-right').css("cssText","display: none !important");
   $(':nth-child(2)', element).slideDown();
   }

});