$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
	
$("#titulars").jCarouselLite({  
	vertical: true,  
	visible: 1,  
	auto:500,  
	speed:5000  
	});

var galeta_idioma = Get_Cookie('idioma');

var lang_nav = navigator.userAgent;

if (!galeta_idioma)
{	
	$.fn.popOpen = function(){
		
		popID = $(this).attr('rel'); //Get Popup Name
		popURL = $(this).attr('href'); //Get Popup href to define size
		
		//Pull Query & Variables from href URL
		query= popURL.split('?');
		dim= query[1].split('&');
		popWidth = dim[0].split('=')[1]; //Gets the first query string value
		
		
		//Fade in the Popup and add close button
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"></a>');
		
		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;
		
		//Apply Margin to Popup
		$('#' + popID).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		//Fade in Background
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
		
	};

	//When you click on a link with class of poplight and the href starts with a # 
	$('a.poplight[href^=#]').click(function() {
		$(this).popOpen(); //Run popOpen function on click
		return false;
	});
	
	$('a.poplight[href=#?w=350]').popOpen(); //Run popOpen function once on load
	
	//Close Popups and Fade Layer
	$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
	  	$('#fade , .popup_block').fadeOut(); //fade them both out
		$('#fade').remove();
		return false;
	});
}

});

/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.5
------------------------------------------------------------------------- */

(function(a){a.prettyPhoto={version:"2.5"};a.fn.prettyPhoto=function(t){t=jQuery.extend({animationSpeed:"normal",padding:40,opacity:0.8,showTitle:true,allowresize:true,counter_separator_label:"/",theme:"light_rounded",callback:function(){}},t);if(a.browser.msie&&a.browser.version==6){t.theme="light_square"}if(a(".pp_overlay").size()==0){u()}else{o=a(".pp_pic_holder");x=a(".ppt")}var d=true,h=false,s,o,x,t,m,n,r,v,e="image",c=0,j=f();a(window).scroll(function(){j=f();i()});a(window).resize(function(){i();q()});a(document).keydown(function(y){switch(y.keyCode){case 37:a.prettyPhoto.changePage("previous");break;case 39:a.prettyPhoto.changePage("next");break;case 27:a.prettyPhoto.close();break}});a(this).each(function(){a(this).bind("click",function(){link=this;theRel=a(this).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);images=new Array(),titles=new Array(),descriptions=new Array();if(theGallery){a("a[rel*="+theGallery+"]").each(function(y){if(a(this)[0]===a(link)[0]){c=y}images.push(a(this).attr("href"));titles.push(a(this).find("img").attr("alt"));descriptions.push(a(this).attr("title"))})}else{images=a(this).attr("href");titles=(a(this).find("img").attr("alt"))?a(this).find("img").attr("alt"):"";descriptions=a(this).attr("title")}a.prettyPhoto.open(images,titles,descriptions);return false})});a.prettyPhoto.open=function(A,z,y){if(a.browser.msie&&a.browser.version==6){a("select").css("visibility","hidden")}a("object,embed").css("visibility","hidden");if(A){images=a.makeArray(A)}if(z){titles=a.makeArray(z)}if(y){descriptions=a.makeArray(y)}if(a(".pp_overlay").size()==0){u()}else{o=a(".pp_pic_holder");x=a(".ppt")}o.attr("class","pp_pic_holder "+t.theme);isSet=(a(images).size()>0)?true:false;w(images[c]);i();g(a(images).size());a(".pp_loaderIcon").show();a("div.pp_overlay").show().fadeTo(t.animationSpeed,t.opacity,function(){o.fadeIn(t.animationSpeed,function(){o.find("p.currentTextHolder").text((c+1)+t.counter_separator_label+a(images).size());if(descriptions[c]){o.find(".pp_description").show().html(unescape(descriptions[c]))}else{o.find(".pp_description").hide().text("")}if(titles[c]&&t.showTitle){hasTitle=true;x.html(unescape(titles[c]))}else{hasTitle=false}if(e=="image"){imgPreloader=new Image();nextImage=new Image();if(isSet&&c>a(images).size()){nextImage.src=images[c+1]}prevImage=new Image();if(isSet&&images[c-1]){prevImage.src=images[c-1]}pp_typeMarkup='<img id="fullResImage" src="" />';o.find("#pp_full_res")[0].innerHTML=pp_typeMarkup;o.find(".pp_content").css("overflow","hidden");o.find("#fullResImage").attr("src",images[c]);imgPreloader.onload=function(){s=l(imgPreloader.width,imgPreloader.height);_showContent()};imgPreloader.src=images[c]}else{movie_width=(parseFloat(b("width",images[c])))?b("width",images[c]):"425";movie_height=(parseFloat(b("height",images[c])))?b("height",images[c]):"344";if(movie_width.indexOf("%")!=-1||movie_height.indexOf("%")!=-1){movie_height=(a(window).height()*parseFloat(movie_height)/100)-100;movie_width=(a(window).width()*parseFloat(movie_width)/100)-100;h=true}movie_height=parseFloat(movie_height);movie_width=parseFloat(movie_width);if(e=="quicktime"){movie_height+=13}s=l(movie_width,movie_height);if(e=="youtube"){pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+s.width+'" height="'+s.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/'+b("v",images[c])+'" /><embed src="http://www.youtube.com/v/'+b("v",images[c])+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+s.width+'" height="'+s.height+'"></embed></object>'}else{if(e=="quicktime"){pp_typeMarkup='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+s.height+'" width="'+s.width+'"><param name="src" value="'+images[c]+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="'+images[c]+'" height="'+s.height+'" width="'+s.width+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>'}else{if(e=="flash"){flash_vars=images[c];flash_vars=flash_vars.substring(images[c].indexOf("flashvars")+10,images[c].length);filename=images[c];filename=filename.substring(0,filename.indexOf("?"));pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+s.width+'" height="'+s.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+filename+"?"+flash_vars+'" /><embed src="'+filename+"?"+flash_vars+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+s.width+'" height="'+s.height+'"></embed></object>'}else{if(e=="iframe"){movie_url=images[c];movie_url=movie_url.substr(0,movie_url.indexOf("iframe")-1);pp_typeMarkup='<iframe src ="'+movie_url+'" width="'+(s.width-10)+'" height="'+(s.height-10)+'" frameborder="no"></iframe>'}}}}_showContent()}})})};a.prettyPhoto.changePage=function(y){if(y=="previous"){c--;if(c<0){c=0;return}}else{if(a(".pp_arrow_next").is(".disabled")){return}c++}if(!d){d=true}k();a("a.pp_expand,a.pp_contract").fadeOut(t.animationSpeed,function(){a(this).removeClass("pp_contract").addClass("pp_expand");a.prettyPhoto.open()})};a.prettyPhoto.close=function(){o.find("object,embed").css("visibility","hidden");a("div.pp_pic_holder,div.ppt").fadeOut(t.animationSpeed);a("div.pp_overlay").fadeOut(t.animationSpeed,function(){a("div.pp_overlay,div.pp_pic_holder,div.ppt").remove();if(a.browser.msie&&a.browser.version==6){a("select").css("visibility","visible")}a("object,embed").css("visibility","visible");c=0;t.callback()});d=true};_showContent=function(){a(".pp_loaderIcon").hide();if(a.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=a(window).height();windowWidth=a(window).width()}projectedTop=j.scrollTop+((windowHeight/2)-(s.containerHeight/2));if(projectedTop<0){projectedTop=0+o.find(".ppt").height()}o.find(".pp_content").animate({height:s.contentHeight},t.animationSpeed);o.animate({top:projectedTop,left:((windowWidth/2)-(s.containerWidth/2)),width:s.containerWidth},t.animationSpeed,function(){o.width(s.containerWidth);o.find(".pp_hoverContainer,#fullResImage").height(s.height).width(s.width);o.find("#pp_full_res").fadeIn(t.animationSpeed);if(isSet&&e=="image"){o.find(".pp_hoverContainer").fadeIn(t.animationSpeed)}else{o.find(".pp_hoverContainer").hide()}o.find(".pp_details").fadeIn(t.animationSpeed);if(t.showTitle&&hasTitle){x.css({top:o.offset().top-20,left:o.offset().left+(t.padding/2),display:"none"});x.fadeIn(t.animationSpeed)}if(s.resized){a("a.pp_expand,a.pp_contract").fadeIn(t.animationSpeed)}if(e!="image"){o.find("#pp_full_res")[0].innerHTML=pp_typeMarkup}})};function k(){o.find(".pp_hoverContainer,.pp_details").fadeOut(t.animationSpeed);o.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden");o.find("#pp_full_res").fadeOut(t.animationSpeed,function(){a(".pp_loaderIcon").show()});x.fadeOut(t.animationSpeed)}function g(y){if(c==y-1){o.find("a.pp_next").css("visibility","hidden");o.find("a.pp_arrow_next").addClass("disabled").unbind("click")}else{o.find("a.pp_next").css("visibility","visible");o.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("next");return false})}if(c==0){o.find("a.pp_previous").css("visibility","hidden");o.find("a.pp_arrow_previous").addClass("disabled").unbind("click")}else{o.find("a.pp_previous").css("visibility","visible");o.find("a.pp_arrow_previous.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("previous");return false})}if(y>1){a(".pp_nav").show()}else{a(".pp_nav").hide()}}function l(z,y){hasBeenResized=false;p(z,y);imageWidth=z;imageHeight=y;windowHeight=a(window).height();windowWidth=a(window).width();if(((v>windowWidth)||(r>windowHeight))&&d&&t.allowresize&&!h){hasBeenResized=true;notFitting=true;while(notFitting){if((v>windowWidth)){imageWidth=(windowWidth-200);imageHeight=(y/z)*imageWidth}else{if((r>windowHeight)){imageHeight=(windowHeight-200);imageWidth=(z/y)*imageHeight}else{notFitting=false}}r=imageHeight;v=imageWidth}p(imageWidth,imageHeight)}return{width:imageWidth,height:imageHeight,containerHeight:r,containerWidth:v,contentHeight:m,contentWidth:n,resized:hasBeenResized}}function p(z,y){o.find(".pp_details").width(z).find(".pp_description").width(z-parseFloat(o.find("a.pp_close").css("width")));m=y+o.find(".pp_details").height()+parseFloat(o.find(".pp_details").css("marginTop"))+parseFloat(o.find(".pp_details").css("marginBottom"));n=z;r=m+o.find(".ppt").height()+o.find(".pp_top").height()+o.find(".pp_bottom").height();v=z+t.padding}function w(y){if(y.match(/youtube\.com\/watch/i)){e="youtube"}else{if(y.indexOf(".mov")!=-1){e="quicktime"}else{if(y.indexOf(".swf")!=-1){e="flash"}else{if(y.indexOf("iframe")!=-1){e="iframe"}else{e="image"}}}}}function i(){if(a.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=a(window).height();windowWidth=a(window).width()}if(d){$pHeight=o.height();$pWidth=o.width();$tHeight=x.height();projectedTop=(windowHeight/2)+j.scrollTop-($pHeight/2);if(projectedTop<0){projectedTop=0+$tHeight}o.css({top:projectedTop,left:(windowWidth/2)+j.scrollLeft-($pWidth/2)});x.css({top:projectedTop-$tHeight,left:(windowWidth/2)+j.scrollLeft-($pWidth/2)+(t.padding/2)})}}function f(){if(self.pageYOffset){scrollTop=self.pageYOffset;scrollLeft=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){scrollTop=document.documentElement.scrollTop;scrollLeft=document.documentElement.scrollLeft}else{if(document.body){scrollTop=document.body.scrollTop;scrollLeft=document.body.scrollLeft}}}return{scrollTop:scrollTop,scrollLeft:scrollLeft}}function q(){a("div.pp_overlay").css({height:a(document).height(),width:a(window).width()})}function u(){toInject="";toInject+="<div class='pp_overlay'></div>";toInject+='<div class="pp_pic_holder"><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><div class="pp_content"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_loaderIcon"></div><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res"></div><div class="pp_details clearfix"><a class="pp_close" href="#">Close</a><p class="pp_description"></p><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0'+t.counter_separator_label+'0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div>';toInject+='<div class="ppt"></div>';a("body").append(toInject);a("div.pp_overlay").css("opacity",0);o=a(".pp_pic_holder");x=a(".ppt");a("div.pp_overlay").css("height",a(document).height()).hide().bind("click",function(){a.prettyPhoto.close()});a("a.pp_close").bind("click",function(){a.prettyPhoto.close();return false});a("a.pp_expand").bind("click",function(){$this=a(this);if($this.hasClass("pp_expand")){$this.removeClass("pp_expand").addClass("pp_contract");d=false}else{$this.removeClass("pp_contract").addClass("pp_expand");d=true}k();o.find(".pp_hoverContainer, #pp_full_res, .pp_details").fadeOut(t.animationSpeed,function(){a.prettyPhoto.open()});return false});o.find(".pp_previous, .pp_arrow_previous").bind("click",function(){a.prettyPhoto.changePage("previous");return false});o.find(".pp_next, .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");return false});o.find(".pp_hoverContainer").css({"margin-left":t.padding/2})}};function b(e,d){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c="[\\?&]"+e+"=([^&#]*)";var g=new RegExp(c);var f=g.exec(d);if(f==null){return""}else{return f[1]}}})(jQuery);



(function($) {                                          // Compliant with jquery.noConflict()
$.fn.jCarouselLite = function(o) {
    o = $.extend({
        btnPrev: null,
        btnNext: null,
        btnGo: null,
        mouseWheel: false,
        auto: null,
        hoverPause: false,

        speed: 200,
        easing: null,

        vertical: false,
        circular: true,
        visible: 1,
        start: 0,
        scroll: 1,

        beforeStart: null,
        afterEnd: null
    }, o || {});

    return this.each(function() {                           // Returns the element collection. Chainable.

        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";
        var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;

        if(o.circular) {
            ul.prepend(tLi.slice(tl-v+1).clone())
              .append(tLi.slice(0,o.scroll).clone());
            o.start += v-1;
        }

        var li = $("li", ul), itemLength = li.size(), curr = o.start;
        div.css("visibility", "visible");

        li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});
        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
        div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});

        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation
        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)
        var divSize = liSize * v;                           // size of entire div(total length for just the visible items)

        li.css({width: li.width(), height: li.height()});
        ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));

        div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images

        if(o.btnPrev) {
            $(o.btnPrev).click(function() {
                return go(curr-o.scroll);
            });
            if(o.hoverPause) {
                $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});
            }
        }


        if(o.btnNext) {
            $(o.btnNext).click(function() {
                return go(curr+o.scroll);
            });
            if(o.hoverPause) {
                $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});
            }
        }

        if(o.btnGo)
            $.each(o.btnGo, function(i, val) {
                $(val).click(function() {
                    return go(o.circular ? o.visible+i : i);
                });
            });

        if(o.mouseWheel && div.mousewheel)
            div.mousewheel(function(e, d) {
                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);
            });

        var autoInterval;

        function startAuto() {
          stopAuto();
          autoInterval = setInterval(function() {
                  go(curr+o.scroll);
              }, o.auto+o.speed);
        };

        function stopAuto() {
            clearInterval(autoInterval);
        };

        if(o.auto) {
            if(o.hoverPause) {
                div.hover(function(){stopAuto();}, function(){startAuto();});
            }
            startAuto();
        };

        function vis() {
            return li.slice(curr).slice(0,v);
        };

        function go(to) {
            if(!running) {

                if(o.beforeStart)
                    o.beforeStart.call(this, vis());

                if(o.circular) {            // If circular we are in first or last, then goto the other end
                    if(to<0) {           // If before range, then go around
                        ul.css(animCss, -( (curr + tl) * liSize)+"px");
                        curr = to + tl;
                    } else if(to>itemLength-v) { // If beyond range, then come around
                        ul.css(animCss, -( (curr - tl) * liSize ) + "px" );
                        curr = to - tl;
                    } else curr = to;
                } else {                    // If non-circular and to points to first or last, we just return.
                    if(to<0 || to>itemLength-v) return;
                    else curr = to;
                }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                running = true;

                ul.animate(
                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
                    function() {
                        if(o.afterEnd)
                            o.afterEnd.call(this, vis());
                        running = false;
                    }
                );
                // Disable buttons when the carousel reaches the last/first, and enable when not
                if(!o.circular) {
                    $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                    $( (curr-o.scroll<0 && o.btnPrev)
                        ||
                       (curr+o.scroll > itemLength-v && o.btnNext)
                        ||
                       []
                     ).addClass("disabled");
                }

            }
            return false;
        };
    });
};

function css(el, prop) {
    return parseInt($.css(el[0], prop)) || 0;
};
function width(el) {
    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
};
function height(el) {
    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
};




})(jQuery);