/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

jQuery(function(){
	jQuery('.paginainicial a')
		.css( {backgroundPosition: "0 -29px"} )
		.bind("mouseenter", function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -54px)"}, {duration:200});
		})
	jQuery('.paginainicial')
		.bind("mouseleave", function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -29px)"}, {duration:200});
		})
	jQuery('.eventos a')
		.css( {backgroundPosition: "-105px -29px"} )
		.bind("mouseenter", function(){
			jQuery(this).stop().animate({backgroundPosition:"(-105px -54px)"}, {duration:200});
		})
	jQuery('.eventos')
		.bind("mouseleave", function(){
			jQuery(this).children('a').stop().animate({backgroundPosition:"(-105px -29px)"}, {duration:200});
		})

	jQuery('.quemsomos a')
		.css( {backgroundPosition: "-182px -29px"} )
		.bind("mouseenter", function(){
			jQuery(this).stop().animate({backgroundPosition:"(-182px -54px)"}, {duration:200});
		})
	jQuery('.quemsomos')
		.bind("mouseleave", function(){
			jQuery(this).children('a').stop().animate({backgroundPosition:"(-182px -29px)"}, {duration:200});
		})
	jQuery('.recursos a')
		.css( {backgroundPosition: "-283px -29px"} )
		.bind("mouseenter", function(){
			jQuery(this).stop().animate({backgroundPosition:"(-283px -54px)"}, {duration:200});
		})
	jQuery('.recursos')
		.bind("mouseleave", function(){
			jQuery(this).children('a').stop().animate({backgroundPosition:"(-283px -29px)"}, {duration:200});
		})
	jQuery('.contacto a')
		.css( {backgroundPosition: "-366px -29px"} )
		.bind("mouseenter", function(){
			jQuery(this).stop().animate({backgroundPosition:"(-366px -54px)"}, {duration:200});
		})
	jQuery('.contacto')
		.bind("mouseleave", function(){
			jQuery(this).children('a').stop().animate({backgroundPosition:"(-366px -29px)"}, {duration:200});
		})



	jQuery('.ssmenu1 a')
		.css( {backgroundPosition: "0 -228px"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-248px -228px)"}, {duration:200});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -228px)"}, {duration:200});
		})
	jQuery('.ssmenu2 a')
		.css( {backgroundPosition: "0 -276px"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-248px -276px)"}, {duration:200});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -276px)"}, {duration:200});
		})

	jQuery('.ssmenu3 a')
		.css( {backgroundPosition: "0 -324px"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-248px -324px)"}, {duration:200});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -324px)"}, {duration:200});
		})
	jQuery('.ssmenu4 a')
		.css( {backgroundPosition: "0 -372px"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-248px -372px)"}, {duration:200});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -372px)"}, {duration:200});
		})
	jQuery('.ssmenu5 a')
		.css( {backgroundPosition: "0 -420px"} )
		.mouseover(function(){
			jQuery(this).stop().animate({backgroundPosition:"(-248px -420px)"}, {duration:200});
		})
		.mouseout(function(){
			jQuery(this).stop().animate({backgroundPosition:"(0 -420px)"}, {duration:200});
		})

});


jQuery(document).ready(function() {
	jQuery('.submenu').hide();
	jQuery('.menu li').bind("mouseenter",function(){
		jQuery(this).children('.submenu').stop().animate({height:'35px'},{queue:false, duration:400, easing: ''})
	});
	jQuery('.menu li').bind("mouseleave", function(){
		jQuery(this).children('.submenu').stop().animate({height:'0'},{queue:false, duration:400, easing: ''})
	});


	jQuery('.submenu a,.submenu2 a').mouseover(function() {
		jQuery(this).children('img').stop().animate({marginTop:'-15px'}, {duration:130});
	});
	jQuery('.submenu a,.submenu2 a').mouseout(function() {
		jQuery(this).children('img').stop().animate({marginTop:'0'}, {duration:230});
	});


	jQuery('.submenu2').hide();
	jQuery('.menu li').bind("mouseenter",function(){
		jQuery(this).children('.submenu2').stop().animate({height:'100px'},{queue:false, duration:400, easing: ''})
	});
	jQuery('.menu li').bind("mouseleave", function(){
		jQuery(this).children('.submenu2').stop().animate({height:'0'},{queue:false, duration:400, easing: ''})
	});

});

jQuery(document).ready(function() {
	jQuery('.fadeThis').append('<span class="hover"></span>').each(function () {
	  var $span = jQuery('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(200, 1);
	  }, function () {
	    $span.stop().fadeTo(500, 0);
	  });
	});
});



