var pp_activecover = 0; var pp_maxcover = 9; var timer = 5000; function overCover(){ var index = $("#titles li").index(this); pp_activecover=index; showCover(index); } function outCover(){ setTimer(true); } function showCover(show){ var cover = $("#covers li").eq(show); var title = $("#titles li").eq(show); var related = ""; cover.stop().fadeTo("normal",1); hideOtherCovers(show,"fade"); title.addClass("selected"); $('#headline').empty(); $('#headline').removeClass('black-bg green-bg top'); if (title.find('h3').data('headline') === undefined) { $('#headline').addClass('black-bg'); $('#headline').html('
'); $("#headline .title").html(''+$("h3",title).html()+''); $("#headline .subtitle").html($(".subtitle",title).html()); related = $(".related",title).html(); if (related) { $("#headline .related").html(related); $("#headline .related").show(); } else { $("#headline .related").hide(); } } else { $('#headline').addClass('green-bg'); $('#headline').html(''); if (title.find('h3').data('position') !== '') { $('#headline').addClass('top'); } if (title.find('h3').data('size') !== '') { $('#headline .title').addClass('big'); } $('#headline .title').text(title.find('h3').data('headline')); } }; function hideOtherCovers(show,mode){ $("#covers li").each(function(index){ if (index!=show && index!=pp_activecover) { if (mode=="fade") $(this).stop().fadeOut(); else $(this).stop().hide(); var title = $("#titles li").eq(index); title.removeClass("selected"); }; }); }; function initTitles(){ var margin = 20; var maxHeight = $('#titles').outerHeight() - margin; var titlePosition = 0; $("#titles li").each(function(index){ $(this).hover(overCover); titlePosition = $(this).position().top + $(this).outerHeight(); if (titlePosition > maxHeight) { $(this).hide(); pp_maxcover = pp_maxcover - 1; }; }); $("#headline").show(); }; function cycleCover(){ pp_activecover = (pp_activecover < pp_maxcover - 1) ? pp_activecover + 1 : 0; showCover(pp_activecover); }; function setTimer(mode){ if (mode) $("#prima_pagina").everyTime(timer, cycleCover); else $("#prima_pagina").stopTime(); }; function initPrima(){ pp_maxcover = $("#titles li").length; initTitles(); hideOtherCovers(0,"hide"); showCover(0); setTimer(true); $('#prima_pagina').hover(function () { setTimer(false); }, function () { setTimer(true); }); };