$.fn.imgFade = function(image, alt) { var current = $("#portrait").attr("src"); if(current != image) { $("#portrait").fadeOut("slow", function(){ $("#portrait").attr("src", image).attr("alt", alt); }); $("#portrait").fadeIn("slow"); } } $.fn.adjustLineHeight = function() { $('#members li p').animate({lineHeight: "25px"},600); $(this).animate({lineHeight: "49px"},600); } $().ready(function() { var _images = ["img/people/kev.jpg", "img/people/matej.jpg", "img/people/usty.jpg", "img/people/pepe.jpg", "img/people/prandy.jpg", "img/people/bene.jpg", "img/people/ruman.jpg","img/people/mrak.jpg"]; var gotime = _images.length; $.each(_images,function(e) { $(new Image()).attr('src',this); }) var curr = 6; $('#members').kwicks({ min : 25, spacing : 7, isVertical : true, sticky : true, event : 'click', defaultKwick: 6 }); var init_image = 'img/people/kev.jpg'; var init_alt = ''; switch (curr) { case 1: init_image = 'img/people/kev.jpg'; init_alt = 'Ondřej Kašpařík'; break; case 0: init_image = 'img/people/matej.jpg'; init_alt = 'Matěj Slovák'; break; case 2: init_image = 'img/people/usty.jpg'; init_alt = 'Honza Ustohal'; break; case 3: init_image = 'img/people/pepe.jpg'; init_alt = 'Pepe Černý'; break; case 4: init_image = 'img/people/prandy.jpg'; init_alt = 'Ondřej Hlušička'; break; case 5: init_image = 'img/people/bene.jpg'; init_alt = 'Veronika Benešová'; break; case 6: init_image = 'img/people/ruman.jpg'; init_alt = 'Roman Šedivý'; break; case 7: init_image = 'img/people/mrak.jpg'; init_alt = 'Martin Doubek'; break; } $("#portrait").fadeOut("slow", function(){ $("#portrait").attr("src", init_image).attr("alt", init_alt); }); $("#portrait").fadeIn("slow"); $("#members li.active p").animate({lineHeight: "49px"},600); $("li#kev").click(function(){ $(this).imgFade('img/people/kev.jpg', 'Ondřej Kašpařík'); $(this).children("p").adjustLineHeight(); }); $("li#matej").click(function(){ $(this).imgFade('img/people/matej.jpg', 'Matěj Slovák'); $(this).children("p").adjustLineHeight(); }); $("li#usty").click(function(){ $(this).imgFade('img/people/usty.jpg', 'Honza Ustohal'); $(this).children("p").adjustLineHeight(); }); $("li#pepe").click(function(){ $(this).imgFade('img/people/pepe.jpg', 'Pepe Černý'); $(this).children("p").adjustLineHeight(); }); $("li#prandy").click(function(){ $(this).imgFade('img/people/prandy.jpg', 'Ondřej Hlušička') $(this).children("p").adjustLineHeight(); }); $("li#bene").click(function(){ $(this).imgFade('img/people/bene.jpg', 'Veronika Benešová'); $(this).children("p").adjustLineHeight(); }); $("li#ruman").click(function(){ $(this).imgFade('img/people/ruman.jpg', 'Roman Šedivý'); $(this).children("p").adjustLineHeight(); }); $("li#mrak").click(function(){ $(this).imgFade('img/people/mrak.jpg', 'Martin Doubek'); $(this).children("p").adjustLineHeight(); }); });