// JavaScript Document
/**
 * @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);

//#header ul.acti li.parc.on a,
//#header ul.acti li.parc a:hover {background: transparent url(../images/bkg_menu_parc.png) repeat-y 0 0;}
$(document).ready(function(){
																		  
		//Fade image
		$("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("a img").hover(function(){
		$(this).fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$(this).fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
	
	//Menu Background animation
	//$('#header ul.acti li.parc a, #header ul.acti li.viaf a, #header ul.acti li.esca a, #header ul.acti li.cany a, #header ul.acti li.vtt a, #header ul.grup li a, #header ul.info li a')
	$('#header ul.acti li.parc a, #header ul.acti li.viaf a, #header ul.acti li.esca a, #header ul.acti li.cany a, #header ul.acti li.vtt a, #header ul.grup li a')
	.css( {backgroundPosition: "0 0"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(250px 0)"}, 
			{duration:500})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:500})
		})	
	$('#header ul.info li a')
	.css( {backgroundPosition: "0 0"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(164px 0)"}, 
			{duration:500})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:500})
		})	
	
		//External Links
		$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    	});
		
		//Home Links
		$("div#home_parc a img").mouseover(function (){$("#home_parc p a").addClass("on");});
		$("div#home_parc a img").mouseout(function (){$("#home_parc p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_parc a").hover(function(){
		$("#home_parc img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_parc img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		$("div#home_viaf a img").mouseover(function (){$("#home_viaf p a").addClass("on");});
		$("div#home_viaf a img").mouseout(function (){$("#home_viaf p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_viaf a").hover(function(){
		$("#home_viaf img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_viaf img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		$("div#home_esca a img").mouseover(function (){$("#home_esca p a").addClass("on");});
		$("div#home_esca a img").mouseout(function (){$("#home_esca p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_esca a").hover(function(){
		$("#home_esca img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_esca img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		$("div#home_cany a img").mouseover(function (){$("#home_cany p a").addClass("on");});
		$("div#home_cany a img").mouseout(function (){$("#home_cany p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_cany a").hover(function(){
		$("#home_cany img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_cany img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		$("div#home_vtt a img").mouseover(function (){$("#home_vtt p a").addClass("on");});
		$("div#home_vtt a img").mouseout(function (){$("#home_vtt p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_vtt a").hover(function(){
		$("#home_vtt img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_vtt img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		$("div#home_coll a img").mouseover(function (){$("#home_coll p a").addClass("on");});
		$("div#home_coll a img").mouseout(function (){$("#home_coll p a").removeClass("on");});																	 $("a img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade down to 60% when the page loads
		$("div#home_coll a").hover(function(){
		$("#home_coll img").fadeTo("slow", 0.6); // This should set the opacity to 100% on hover
		},function(){
		$("#home_coll img").fadeTo("slow", 1.0); // This should set the opacity back to 60% on mouseout
		});
		
 });


