﻿/*
JQuery extension para la galeria de imagenes. 
Posicionamos las flechas de derecha e izquierda
*/
(function($) {
	$(document).ready(
	    function()
	    {
	        //$("#gallery").css({'background-color':'#ececec','border-radius':'10px','-moz-border-radius':'10px','-moz-box-shadow':'0px 0px 10px #333','-webkit-box-shadow':'0px 0px 10px #333','box-shadow':'0px 0px 10px #333'});
	        
	        $("#gallery").css({'overflow':'hidden','background-color':'transparent'});
	        $("#gallery img").each(function()
            {
                var img1 = new Image(); 
                img1.src = this.getAttribute("src"); 
                var height = img1.height;
                var width = img1.width;
                var proportionalheight = ($("#gallery").width() * height) / width;
                this.setAttribute('width',$("#gallery").width());
                this.setAttribute('height',proportionalheight);
            });
	        
            $("#gallery").hover(function(event){
                $("#left").css({'position':'absolute','width':'32px','height':'34px','z-index':'3333','background-image':'url("../imagenes/arrows.png")','background-repeat':'no-repeat','background-position': '0px 0px'});
                $("#right").css({'position':'absolute','width':'32px','height':'34px','z-index':'3333','background-image':'url("../imagenes/arrows.png")','background-repeat':'no-repeat','background-position': '-32px 0px'});
                var position = $("#gallery").position();
                var margin = 20;
                var topposition = ($("#gallery").height() / 2);
                var Topleftposition = $("#gallery").width() - margin;
                
                var Ltop = topposition + 'px';
                var Lleft = margin + 'px';
                var Tleft = Topleftposition + 'px';
                
                $("#left").css({'left':Lleft,'top':topposition});
                $("#right").css({'left':Tleft,'top':topposition});
                
                isHover = true;
                
                event.preventDefault();
            },function(event){isHover = false;}
        );
     });
})(jQuery);
