if(typeof Grifols==="undefined")var Grifols={};if(typeof Grifols.Plasma==="undefined")Grifols.Plasma={};if(typeof Grifols.Plasma.Parallax==="undefined"){Grifols.Plasma.Parallax={};Grifols.Plasma.debug=false}Grifols.Plasma.Parallax.followSection;Grifols.Plasma.Parallax.menuTop;
Grifols.Plasma.Parallax.init=function(followSection){Grifols.Plasma.Parallax.followSection=followSection;$(document).ready(function(){if(Grifols.Plasma.debug)console.log("init");Grifols.Plasma.Parallax.keyboardNavigation();Grifols.Plasma.Parallax.loadResponsiveImages();Grifols.Plasma.Parallax.menuTop=parseInt($("#menu-column").css("top").replace("px",""));$(".nav-sections li a").click(function(){var href=$(this).attr("href");Grifols.Plasma.Parallax.scrollToSection(href);return false});$("#nav-responsive li a").click(function(){var href=
$(this).attr("href");Grifols.Plasma.Parallax.scrollToSection(href);return false});$("#nav li.open ul li a").click(function(){var href=$(this).attr("href");Grifols.Plasma.Parallax.scrollToSection(href);return false});$(window).scroll(function(){Grifols.Plasma.Parallax.setActiveSection();Grifols.Plasma.Parallax.setBackgroundPosition()});var timeout;$(window).resize(function(){clearTimeout(timeout);timeout=setTimeout(Grifols.Plasma.Parallax.loadResponsiveImages,250)})})};
Grifols.Plasma.Parallax.setNavigationMenu=function(){var sectionCount=0;$(".parallax .nav-sections li").each(function(){var sectionName=$(this).attr("name");var menuElement=$("#nav li.open ul li").get(sectionCount);$(menuElement).attr("name",sectionName);$(menuElement).find("a").attr("href","#"+sectionName);if(sectionCount===0)$(menuElement).css("display","none");sectionCount++});Grifols.Plasma.Parallax.setActiveSection(true)};
Grifols.Plasma.Parallax.setActiveSection=function(){var navigationMenu=$("#menu-column");var navigationMenuResponsive=$("#nav-responsive");var cutoff=$(window).scrollTop()+1;var currentPage=$(".parallax .nav-sections li.act").attr("name");if(currentPage==undefined)currentPage=$(".parallax .nav-sections li.first").attr("name");var pageEnd=$(document).height()-$(window).height()-10;var parallaxTop=$(".parallax").offset().top;var parallaxBottom=parallaxTop+$(".parallax").height()-navigationMenu.height()-
Grifols.Plasma.Parallax.menuTop;if($(window).scrollTop()<=parallaxTop){navigationMenu.css("position","absolute");navigationMenuResponsive.css("position","absolute");navigationMenu.css("bottom","auto")}else if($(window).scrollTop()>=parallaxBottom){navigationMenu.css("position","absolute");navigationMenuResponsive.css("position","absolute");navigationMenu.css("top","auto");navigationMenu.css("bottom","")}else{navigationMenu.css("position","fixed");navigationMenuResponsive.css("position","fixed");navigationMenu.css("top",
"");navigationMenu.css("bottom","auto")}if(Grifols.Plasma.Parallax.followSection){$(".parallax li").removeClass("act");$(".parallax li a").removeClass("act")}else{$(".parallax .nav-sections li").removeClass("act");$(".parallax .nav-sections li a").removeClass("act")}var sectionId=null;if($(window).scrollTop()>=pageEnd)sectionId=$('section[data-type\x3d"parallax"]').last().attr("id");else $('section[data-type\x3d"parallax"]').each(function(){if(sectionId==null&&$(this).offset().top+$(this).height()>
cutoff)sectionId=$(this).attr("id")});if(sectionId!=null){if(Grifols.Plasma.Parallax.followSection)if(sectionId===$('section[data-type\x3d"parallax"]').first().attr("id"))$(".parallax li[name\x3d'"+sectionId+"']").parents("li").find("a.open").addClass("act");else{$(".parallax li[name\x3d'"+sectionId+"']").parents("li").find("a.open").removeClass("act");$(".parallax li[name\x3d'"+sectionId+"']").addClass("act");$(".parallax li[name\x3d'"+sectionId+"'] a").addClass("act")}else{$(".parallax .nav-sections li[name\x3d'"+
sectionId+"']").addClass("act");$(".parallax .nav-sections li[name\x3d'"+sectionId+"'] a").addClass("act")}if(sectionId!=currentPage){if(Grifols.Plasma.debug)console.log("setActiveSection");Grifols.Plasma.Parallax.pushUrl("#"+sectionId)}}};
Grifols.Plasma.Parallax.setBackgroundPosition=function(){if(!Grifols.Plasma.utils.isTouchDevice)$('section[data-type\x3d"parallax"]').each(function(){var $bgobj=$(this);var parallaxSpeed=1;if($bgobj.data("speed")!="")parallaxSpeed=$bgobj.data("speed");var yPos=-(($(window).scrollTop()-$bgobj.offset().top)/parallaxSpeed);var coords="50% "+yPos+"px";$bgobj.css("backgroundPosition",coords)});else $('section[data-type\x3d"parallax"]').each(function(){var $bgobj=$(this);if($bgobj.css("backgroundAttachment")===
"fixed")$bgobj.css("backgroundAttachment","scroll")})};
Grifols.Plasma.Parallax.pushUrl=function(sectionId){if(Grifols.Plasma.debug)console.log("pushUrl: "+sectionId);var url=Liferay.ThemeDisplay.getLayoutURL().substring(0,Liferay.ThemeDisplay.getLayoutURL().lastIndexOf("/"))+"/"+$(sectionId).attr("id");if(typeof ga!="undefined"){ga("send","pageview",url);if(Grifols.Plasma.debug)console.log("ga('send', 'pageview', "+url+")")}if(history.pushState){var pageTitle=$(sectionId).attr("title");history.pushState(sectionId,pageTitle,url);if(Grifols.Plasma.debug)console.log("I am HTML5! -\x3e URL: "+
url)}return false};Grifols.Plasma.Parallax.scrollToSection=function(sectionId){if(Grifols.Plasma.debug)console.log("scrollToSection : "+sectionId);var cacheHtml=$("html, body");if($(sectionId).length>0)if($(".nav-sections li[name\x3d'"+sectionId.replace("#","")+"']").hasClass("first"))cacheHtml.animate({scrollTop:0},1E3);else cacheHtml.animate({scrollTop:$(sectionId).offset().top},1E3)};
Grifols.Plasma.Parallax.scrollToURLSection=function(){if(Grifols.Plasma.debug)console.log("scrollToURLSection");var currentUrl=window.location.href.replace(/;jsessionid=(.*)$/,"");var lastParam=currentUrl.substring(currentUrl.lastIndexOf("/")+1);Grifols.Plasma.Parallax.scrollToSection("#"+lastParam)};
Grifols.Plasma.Parallax.keyboardNavigation=function(){var nextPageKeys=[34,39];var previousPageKeys=[33,37];$(document).keydown(function(e){if(jQuery.inArray(e.keyCode,nextPageKeys)>=0||jQuery.inArray(e.keyCode,previousPageKeys)>=0){if(Grifols.Plasma.debug)console.log("Recognized key pressed \x3e keycode: "+e.keyCode);e.preventDefault();var activeSection=$(".parallax .nav-sections li.act");var sectionIndex=activeSection.parent().children().index(activeSection);var targetIndex=sectionIndex;if(jQuery.inArray(e.keyCode,
nextPageKeys)>=0&&targetIndex!=$(".parallax .nav-sections li").length-1)targetIndex=targetIndex+1;else if(jQuery.inArray(e.keyCode,previousPageKeys)>=0&&targetIndex!=0)targetIndex=targetIndex-1;else targetIndex=-1;if(targetIndex>=0)Grifols.Plasma.Parallax.scrollToSection("#"+$(".parallax .nav-sections li").get(targetIndex).getAttribute("name"))}})};
Grifols.Plasma.Parallax.loadResponsiveImages=function(){if(Grifols.Plasma.debug)console.log("loadResponsiveImages");$('section[data-type\x3d"parallax"]').each(function(){var backgroundImage="";var sectionHeight="";if($(document).width()>1023){backgroundImage=$(this).data("background_desktop");sectionHeight=$(this).data("height_desktop")}else if($(document).width()>700){backgroundImage=$(this).data("background_tablet");sectionHeight=$(this).data("height_tablet")}else{backgroundImage=$(this).data("background_mobile");
sectionHeight=$(this).data("height_mobile")}if(backgroundImage!=""&&$(this).css("background-image")!=backgroundImage){$(this).css("background-image","none");$(this).css("background-image","url("+backgroundImage+")")}if(sectionHeight!=""){$(this).css("height",sectionHeight);$(this).css("min-height",sectionHeight)}Grifols.Plasma.Parallax.setBackgroundPosition()});Grifols.Plasma.Parallax.scrollToURLSection()};if(typeof Grifols.Plasma.FAQs==="undefined")Grifols.Plasma.FAQs={};
Grifols.Plasma.FAQs.toggleFAQ=function(element){var faqSymbol=$(element).find(".faq-symbol");faqSymbol.toggleClass("faq-expand");faqSymbol.toggleClass("faq-collapse");$(element).find(".dark-text").slideToggle(400)};if(typeof Grifols.Plasma.utils==="undefined")Grifols.Plasma.utils={};
$(document).ready(function(){Grifols.Plasma.utils.isIPad=navigator.userAgent.match(/iPad/i)!=null;Grifols.Plasma.utils.isIPhone=(navigator.userAgent.match(/iPhone/i)!=null||navigator.userAgent.match(/iPod/i)!=null)&&Grifols.Plasma.utils.isIPad===false;Grifols.Plasma.utils.isTouchDevice="ontouchstart"in window||navigator.msMaxTouchPoints>0;$("a.interstitial").click(function(e){e.preventDefault();var linkHref=$(this).attr("href");Grifols.Plasma.utils.openInterstitial(linkHref);return false});Grifols.Plasma.utils.shareParams()});
Grifols.Plasma.utils.equalHeight=function(selector){$(document).ready(function(){if($(selector).length>0){var maxHeight=0;$(selector).each(function(){if($(this).height()>maxHeight)maxHeight=$(this).height()});$(selector).height(maxHeight)}});$(window).resize(function(){if($(selector).length>0){$(selector).height("auto");var maxHeight=0;$(selector).each(function(){if($(this).height()>maxHeight)maxHeight=$(this).height()});$(selector).height(maxHeight)}})};
Grifols.Plasma.utils.moveRightColumnToBottom=function(){$(document).ready(function(){if($(document).width()<1024){if($(".portlet-layout").last().find("#bottom-column").length===1)$("#bottom-column").insertBefore("#contentright")}else if($(".portlet-layout").last().find("#bottom-column").length===0)$("#bottom-column").appendTo($(".portlet-layout").last())});$(window).resize(function(){if($(document).width()<1024){if($(".portlet-layout").last().find("#bottom-column").length===1)$("#bottom-column").insertBefore("#contentright")}else if($(".portlet-layout").last().find("#bottom-column").length===
0)$("#bottom-column").appendTo($(".portlet-layout").last())})};Grifols.Plasma.utils.closeModal=function(){top.document.getElementById("closethick").click()};var interstitialTitle=null;var interstitialContentNode=null;
Grifols.Plasma.utils.openInterstitial=function(linkHref){AUI().use("aui-dialog",function(A){if(interstitialTitle==null)interstitialTitle=A.one("#interstitial-content .dialog-title").text();if(interstitialContentNode==null)interstitialContentNode=A.one("#interstitial-content");var thisInterstitialContentNode=interstitialContentNode.html().replace("LINK_URL",linkHref);(new A.Dialog({bodyContent:thisInterstitialContentNode,id:"interstitial-modal",centered:true,draggable:false,resizable:false,title:interstitialTitle,
modal:true,constrain2view:true,destroyOnClose:true})).render()})};var shareTitle=null;var shareContentNode=null;Grifols.Plasma.utils.sharePage=function(){AUI().use("aui-dialog",function(A){if(shareTitle==null)shareTitle=A.one("#share-content .dialog-title").text();if(shareContentNode==null)shareContentNode=A.one("#share-content");(new A.Dialog({bodyContent:shareContentNode,id:"share-page-modal",centered:true,draggable:false,resizable:false,title:shareTitle,modal:true,constrain2view:true,destroyOnClose:true})).render()})};
Grifols.Plasma.utils.shareParams=function(){var shareHtml=$("ul.share-links").html();if(shareHtml!=undefined){var pageTitle=$(document).attr("title").replace(" | GRIFOLS","");while(shareHtml.indexOf("PAGE_NAME")>0)shareHtml=shareHtml.replace("PAGE_NAME",encodeURIComponent(pageTitle));while(shareHtml.indexOf("PAGE_URL")>0)shareHtml=shareHtml.replace("PAGE_URL",$(location).attr("href"));$("ul.share-links").each(function(){$(this).html(shareHtml)})}};
