/**
 * Galeria de imagenes
 * Versión: 1.2 (01 Agosto 2009)
 * Autor: David P. Luna
 * Website: www.dpluna.com
 **/
$(function(){$(".image-scene-close-description").toggle(function(){$(this).html("Abrir");$("#image-scene-description").toggle()},function(){$(this).html("Cerrar");$("#image-scene-description").toggle()});$(".gallery-next").click(nextImage);$(".gallery-prev").click(prevImage);var f=$('#gallery-image-list-layout'),ul=$('#gallery-image-list'),ulPadding=11;var g=f.width();f.css({overflow:'hidden',height:'235px'});ul.css({height:'198px'});var h=ul.find('li:last-child');var i=ul.children("li");var j=i.length*$(i[0]).outerWidth();ul.width(j);setDescriptionWidth($("#gallery-scene-image IMG"));window.onload = function(){setDescriptionWidth($("#gallery-scene-image IMG"));};f.mousemove(function(e){var a=h[0].offsetLeft+h.outerWidth()+ulPadding;var b=(e.pageX-f.offset().left)*(a-g)/g;f.scrollLeft(b)});i.children("A").click(function(a){$("#gallery-image-list").children("LI").children("A").removeClass("current");$(this).addClass("current");var b=$("#gallery-image-list").children("LI").children("A.current").attr("id").split("-")[1];var c=$("#gallery-scene-image IMG").attr("id").split("-")[1];var d=parseInt(b)>parseInt(c);if(b!=c)animateImg((d)?true:false,b)})});function setDescriptionWidth(a){$("#image-description").css("width",a.width())}function getImage(a,b){$("#gallery-scene-image IMG").attr("id","currentThumb-"+a);var c=$("#gallery-image-list").find(".current IMG").attr("alt");var d=$("#gallery-image-list").find(".current IMG").attr("longdesc");var e=$("#gallery-image-list").find(".current IMG").attr("src");$("#image-scene-title").html(c);$("#image-scene-description").html(d);$("#gallery-scene-image IMG").attr("src",e);var f=$("#gallery-scene-image IMG");var g=f.outerWidth();var h=$("#gallery-scene").width();setDescriptionWidth(f);var i=((h-g)/2);$("#gallery-scene-image").animate({marginLeft:"0px"},"normal")}function animateImg(a,b){var c=$("#gallery-scene-image IMG");var d=$("#gallery-scene").width();var e=c.width();var f=d;var g=((d-e)/2);$("#gallery-scene-image").css("margin-left",g);if(!a){$("#gallery-scene-image").animate({marginLeft:"-"+f+"px"},"slow",function(){$("#gallery-scene-image").css("marginLeft",f+"px");getImage(b)})}else{$("#gallery-scene-image").animate({marginLeft:f},"normal",function(){$("#gallery-scene-image").css("marginLeft","-"+f+"px");getImage(b)})}}function nextImage(){currentImg=$("#gallery-image-list").children("LI").children("A.current").children("IMG");currentLI=$(currentImg).parent().parent();currentId=$(currentImg).parent().attr("id").split("-")[1];if($(currentLI).is(":last-child"))nextImg=$("#gallery-image-list").children("LI:first-child");else nextImg=$(currentLI).next();nextId=$(nextImg).children("A").attr("id").split("-")[1];direction=true;if($(currentLI).is(":last-child"))nextId=0;$("#gallery-image-list").children("LI").children("A").removeClass("current");$(nextImg).children().addClass("current");var a=parseInt(nextId)>parseInt(currentId);if(nextId!=currentId)animateImg((a)?true:false,nextId)}function prevImage(){currentImg=$("#gallery-image-list").children("LI").children("A.current").children("IMG");currentLI=$(currentImg).parent().parent();currentId=$(currentImg).parent().attr("id").split("-")[1];if($(currentLI).is(":first-child"))prevImg=$("#gallery-image-list").children("LI:last-child");else prevImg=$(currentLI).prev();prevId=$(prevImg).children("A").attr("id").split("-")[1];direction=true;if($(currentLI).is(":first-child"))prevId=$(prevImg).parent().attr("id").split("-")[1];$("#gallery-image-list").children("LI").children("A").removeClass("current");$(prevImg).children().addClass("current");var a=parseInt(prevId)>parseInt(currentId);if(prevId!=currentId)animateImg((a)?true:false,prevId)}