$(document).ready(function(){
	$('textarea').prettyComments();
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	$('#videos').easySlider(); //portada
	$('#cerca').example('Cerca...');
	
	$('input[type=checkbox],input[type=radio]').prettyCheckboxes();
});
  
 
(function(A){A.fn.example=function(E,C){var D=A.isFunction(E);var B=A.extend({},C,{example:E});return this.each(function(){var F=A(this);if(A.metadata){var G=A.extend({},A.fn.example.defaults,F.metadata(),B)}else{var G=A.extend({},A.fn.example.defaults,B)}if(!A.fn.example.boundClassNames[G.className]){A(window).unload(function(){A("."+G.className).val("")});A("form").submit(function(){A(this).find("."+G.className).val("")});A.fn.example.boundClassNames[G.className]=true}if(A.browser.msie&&!F.attr("defaultValue")&&(D||F.val()==G.example)){F.val("")}if(F.val()==""&&this!=document.activeElement){F.addClass(G.className);F.val(D?G.example.call(this):G.example)}F.focus(function(){if(A(this).is("."+G.className)){A(this).val("");A(this).removeClass(G.className)}});F.blur(function(){if(A(this).val()==""){A(this).addClass(G.className);A(this).val(D?G.example.call(this):G.example)}})})};A.fn.example.defaults={className:"example"};A.fn.example.boundClassNames=[]})(jQuery);

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

(function($){$.prettyPhoto={version:'2.5.4'};$.fn.prettyPhoto=function(settings){settings=jQuery.extend({animationSpeed:'normal',padding:40,opacity:0.30,showTitle:true,allowresize:true,counter_separator_label:'/',theme:'dark_rounded',hideflash:false,modal:false,changepicturecallback:function(){},callback:function(){}},settings);if($.browser.msie&&$.browser.version==6){settings.theme="light_square";}
if($('.pp_overlay').size()==0){_buildOverlay();}else{$pp_pic_holder=$('.pp_pic_holder');$ppt=$('.ppt');}
var doresize=true,percentBased=false,correctSizes,$pp_pic_holder,$ppt,pp_contentHeight,pp_contentWidth,pp_containerHeight,pp_containerWidth,pp_type='image',setPosition=0,$scrollPos=_getScroll();$(window).scroll(function(){$scrollPos=_getScroll();_centerOverlay();_resizeOverlay();});$(window).resize(function(){_centerOverlay();_resizeOverlay();});$(document).keydown(function(e){if($pp_pic_holder.is(':visible'))
switch(e.keyCode){case 37:$.prettyPhoto.changePage('previous');break;case 39:$.prettyPhoto.changePage('next');break;case 27:if(!settings.modal)
$.prettyPhoto.close();break;};});$(this).each(function(){$(this).bind('click',function(){link=this;theRel=$(this).attr('rel');galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var images=new Array(),titles=new Array(),descriptions=new Array();if(theGallery){$('a[rel*='+theGallery+']').each(function(i){if($(this)[0]===$(link)[0])setPosition=i;images.push($(this).attr('href'));titles.push($(this).find('img').attr('alt'));descriptions.push($(this).attr('title'));});}else{images=$(this).attr('href');titles=($(this).find('img').attr('alt'))?$(this).find('img').attr('alt'):'';descriptions=($(this).attr('title'))?$(this).attr('title'):'';}
$.prettyPhoto.open(images,titles,descriptions);return false;});});$.prettyPhoto.open=function(gallery_images,gallery_titles,gallery_descriptions){$('.publicitat').css({ display: "none" });$('.publicitat_h').css({ display: "none" });$('.plantilla_video').css({ display: "none" });if($.browser.msie&&$.browser.version==6){$('select').css('visibility','hidden');};if(settings.hideflash)$('object,embed').css('visibility','hidden');images=$.makeArray(gallery_images);titles=$.makeArray(gallery_titles);descriptions=$.makeArray(gallery_descriptions);if($('.pp_overlay').size()==0){_buildOverlay();}else{$pp_pic_holder=$('.pp_pic_holder');$ppt=$('.ppt');}
$pp_pic_holder.attr('class','pp_pic_holder '+settings.theme);isSet=($(images).size()>0)?true:false;_getFileType(images[setPosition]);_centerOverlay();_checkPosition($(images).size());$('.pp_loaderIcon').show();$('div.pp_overlay').show().fadeTo(settings.animationSpeed,settings.opacity,function(){$pp_pic_holder.fadeIn(settings.animationSpeed,function(){$pp_pic_holder.find('p.currentTextHolder').text((setPosition+1)+settings.counter_separator_label+$(images).size());if(descriptions[setPosition]){$pp_pic_holder.find('.pp_description').show().html(unescape(descriptions[setPosition]));}else{$pp_pic_holder.find('.pp_description').hide().text('');};if(titles[setPosition]&&settings.showTitle){hasTitle=true;$ppt.html(unescape(titles[setPosition]));}else{hasTitle=false;};if(pp_type=='image'){imgPreloader=new Image();nextImage=new Image();if(isSet&&setPosition>$(images).size())nextImage.src=images[setPosition+1];prevImage=new Image();if(isSet&&images[setPosition-1])prevImage.src=images[setPosition-1];pp_typeMarkup='<img id="fullResImage" src="" />';$pp_pic_holder.find('#pp_full_res')[0].innerHTML=pp_typeMarkup;$pp_pic_holder.find('.pp_content').css('overflow','hidden');$pp_pic_holder.find('#fullResImage').attr('src',images[setPosition]);imgPreloader.onload=function(){correctSizes=_fitToViewport(imgPreloader.width,imgPreloader.height);_showContent();};imgPreloader.src=images[setPosition];}else{movie_width=(parseFloat(grab_param('width',images[setPosition])))?grab_param('width',images[setPosition]):"425";movie_height=(parseFloat(grab_param('height',images[setPosition])))?grab_param('height',images[setPosition]):"344";if(movie_width.indexOf('%')!=-1||movie_height.indexOf('%')!=-1){movie_height=($(window).height()*parseFloat(movie_height)/100)-100;movie_width=($(window).width()*parseFloat(movie_width)/100)-100;percentBased=true;}
movie_height=parseFloat(movie_height);movie_width=parseFloat(movie_width);if(pp_type=='quicktime')movie_height+=15;correctSizes=_fitToViewport(movie_width,movie_height);if(pp_type=='youtube'){pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/'+grab_param('v',images[setPosition])+'" /><embed src="http://www.youtube.com/v/'+grab_param('v',images[setPosition])+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+correctSizes['width']+'" height="'+correctSizes['height']+'"></embed></object>';}else if(pp_type=='quicktime'){pp_typeMarkup='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+correctSizes['height']+'" width="'+correctSizes['width']+'"><param name="src" value="'+images[setPosition]+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="'+images[setPosition]+'" height="'+correctSizes['height']+'" width="'+correctSizes['width']+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';}else if(pp_type=='flash'){flash_vars=images[setPosition];flash_vars=flash_vars.substring(images[setPosition].indexOf('flashvars')+10,images[setPosition].length);filename=images[setPosition];filename=filename.substring(0,filename.indexOf('?'));pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+correctSizes['width']+'" height="'+correctSizes['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="'+correctSizes['width']+'" height="'+correctSizes['height']+'"></embed></object>';}else if(pp_type=='iframe'){movie_url=images[setPosition];movie_url=movie_url.substr(0,movie_url.indexOf('iframe')-1);pp_typeMarkup='<iframe src ="'+movie_url+'" width="'+(correctSizes['width']-10)+'" height="'+(correctSizes['height']-10)+'" frameborder="no"></iframe>';}
_showContent();}});});};$.prettyPhoto.changePage=function(direction){if(direction=='previous'){setPosition--;if(setPosition<0){setPosition=0;return;}}else{if($('.pp_arrow_next').is('.disabled'))return;setPosition++;};if(!doresize)doresize=true;_hideContent();$('a.pp_expand,a.pp_contract').fadeOut(settings.animationSpeed,function(){$(this).removeClass('pp_contract').addClass('pp_expand');$.prettyPhoto.open(images,titles,descriptions);});};$.prettyPhoto.close=function(){$('.publicitat').css({ display: "block" });$('.publicitat_h').css({ display: "block" });$('.plantilla_video').css({ display: "block" });$pp_pic_holder.find('object,embed').css('visibility','hidden');$('div.pp_pic_holder,div.ppt').fadeOut(settings.animationSpeed);$('div.pp_overlay').fadeOut(settings.animationSpeed,function(){$('div.pp_overlay,div.pp_pic_holder,div.ppt').remove();if($.browser.msie&&$.browser.version==6){$('select').css('visibility','visible');};if(settings.hideflash)$('object,embed').css('visibility','visible');setPosition=0;settings.callback();});doresize=true;};_showContent=function(){$('.pp_loaderIcon').hide();if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=$(window).height();windowWidth=$(window).width();};projectedTop=$scrollPos['scrollTop']+((windowHeight/2)-(correctSizes['containerHeight']/2));if(projectedTop<0)projectedTop=0+$pp_pic_holder.find('.ppt').height();$pp_pic_holder.find('.pp_content').animate({'height':correctSizes['contentHeight']},settings.animationSpeed);$pp_pic_holder.animate({'top':projectedTop,'left':((windowWidth/2)-(correctSizes['containerWidth']/2)),'width':correctSizes['containerWidth']},settings.animationSpeed,function(){$pp_pic_holder.width(correctSizes['containerWidth']);$pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(correctSizes['height']).width(correctSizes['width']);$pp_pic_holder.find('#pp_full_res').fadeIn(settings.animationSpeed);if(isSet&&pp_type=="image"){$pp_pic_holder.find('.pp_hoverContainer').fadeIn(settings.animationSpeed);}else{$pp_pic_holder.find('.pp_hoverContainer').hide();}
$pp_pic_holder.find('.pp_details').fadeIn(settings.animationSpeed);if(settings.showTitle&&hasTitle){$ppt.css({'top':$pp_pic_holder.offset().top-20,'left':$pp_pic_holder.offset().left+(settings.padding/2),'display':'none'});$ppt.fadeIn(settings.animationSpeed);};if(correctSizes['resized'])$('a.pp_expand,a.pp_contract').fadeIn(settings.animationSpeed);if(pp_type!='image')$pp_pic_holder.find('#pp_full_res')[0].innerHTML=pp_typeMarkup;settings.changepicturecallback();});};function _hideContent(){$pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');$pp_pic_holder.find('.pp_hoverContainer,.pp_details').fadeOut(settings.animationSpeed);$pp_pic_holder.find('#pp_full_res').fadeOut(settings.animationSpeed,function(){$('.pp_loaderIcon').show();});$ppt.fadeOut(settings.animationSpeed);}
function _checkPosition(setCount){if(setPosition==setCount-1){$pp_pic_holder.find('a.pp_next').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_next').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_next').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_next.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('next');return false;});};if(setPosition==0){$pp_pic_holder.find('a.pp_previous').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_previous').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_previous').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_previous.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});};if(setCount>1){$('.pp_nav').show();}else{$('.pp_nav').hide();}};function _fitToViewport(width,height){hasBeenResized=false;_getDimensions(width,height);imageWidth=width;imageHeight=height;windowHeight=$(window).height();windowWidth=$(window).width();if(((pp_containerWidth>windowWidth)||(pp_containerHeight>windowHeight))&&doresize&&settings.allowresize&&!percentBased){hasBeenResized=true;notFitting=true;while(notFitting){if((pp_containerWidth>windowWidth)){imageWidth=(windowWidth-200);imageHeight=(height/width)*imageWidth;}else if((pp_containerHeight>windowHeight)){imageHeight=(windowHeight-200);imageWidth=(width/height)*imageHeight;}else{notFitting=false;};pp_containerHeight=imageHeight;pp_containerWidth=imageWidth;};_getDimensions(imageWidth,imageHeight);};return{width:imageWidth,height:imageHeight,containerHeight:pp_containerHeight,containerWidth:pp_containerWidth,contentHeight:pp_contentHeight,contentWidth:pp_contentWidth,resized:hasBeenResized};};function _getDimensions(width,height){$pp_pic_holder.find('.pp_details').width(width).find('.pp_description').width(width-parseFloat($pp_pic_holder.find('a.pp_close').css('width')));pp_contentHeight=height+$pp_pic_holder.find('.pp_details').height()+parseFloat($pp_pic_holder.find('.pp_details').css('marginTop'))+parseFloat($pp_pic_holder.find('.pp_details').css('marginBottom'));pp_contentWidth=width;pp_containerHeight=pp_contentHeight+$pp_pic_holder.find('.ppt').height()+$pp_pic_holder.find('.pp_top').height()+$pp_pic_holder.find('.pp_bottom').height();pp_containerWidth=width+settings.padding;}
function _getFileType(itemSrc){if(itemSrc.match(/youtube\.com\/watch/i)){pp_type='youtube';}else if(itemSrc.indexOf('.mov')!=-1){pp_type='quicktime';}else if(itemSrc.indexOf('.swf')!=-1){pp_type='flash';}else if(itemSrc.indexOf('iframe')!=-1){pp_type='iframe'}else{pp_type='image';};};function _centerOverlay(){if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=$(window).height();windowWidth=$(window).width();};if(doresize){$pHeight=$pp_pic_holder.height();$pWidth=$pp_pic_holder.width();$tHeight=$ppt.height();projectedTop=(windowHeight/2)+$scrollPos['scrollTop']-($pHeight/2);if(projectedTop<0)projectedTop=0+$tHeight;$pp_pic_holder.css({'top':projectedTop,'left':(windowWidth/2)+$scrollPos['scrollLeft']-($pWidth/2)});$ppt.css({'top':projectedTop-$tHeight,'left':(windowWidth/2)+$scrollPos['scrollLeft']-($pWidth/2)+(settings.padding/2)});};};function _getScroll(){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 _resizeOverlay(){$('div.pp_overlay').css({'height':$(document).height(),'width':$(window).width()});};function _buildOverlay(){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'+settings.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>';$('body').append(toInject);$('div.pp_overlay').css('opacity',0);$pp_pic_holder=$('.pp_pic_holder');$ppt=$('.ppt');$('div.pp_overlay').css('height',$(document).height()).hide().bind('click',function(){if(!settings.modal)
$.prettyPhoto.close();});$('a.pp_close').bind('click',function(){$.prettyPhoto.close();return false;});$('a.pp_expand').bind('click',function(){$this=$(this);if($this.hasClass('pp_expand')){$this.removeClass('pp_expand').addClass('pp_contract');doresize=false;}else{$this.removeClass('pp_contract').addClass('pp_expand');doresize=true;};_hideContent();$pp_pic_holder.find('.pp_hoverContainer, .pp_details').fadeOut(settings.animationSpeed);$pp_pic_holder.find('#pp_full_res').fadeOut(settings.animationSpeed,function(){$.prettyPhoto.open(images,titles,descriptions);});return false;});$pp_pic_holder.find('.pp_previous, .pp_arrow_previous').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});$pp_pic_holder.find('.pp_next, .pp_arrow_next').bind('click',function(){$.prettyPhoto.changePage('next');return false;});$pp_pic_holder.find('.pp_hoverContainer').css({'margin-left':settings.padding/2});};};function grab_param(name,url){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url);if(results==null)
return"";else
return results[1];}})(jQuery);


/* ------------------------------------------------------------------------
	prettyCheckboxes
	
	Developped By: Stephane Caron (http://www.no-margin-for-errors.com)
	Inspired By: All the non user friendly custom checkboxes solutions ;)
	Version: 1.1
	
	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */
	
jQuery.fn.prettyCheckboxes=function(a){a=jQuery.extend({checkboxWidth:17,checkboxHeight:17,className:"prettyCheckbox",display:"list"},a);$(this).each(function(){$label=$('label[for="'+$(this).attr("id")+'"]');$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");if($(this).is(":checked")){$label.addClass("checked")}$label.addClass(a.className).addClass($(this).attr("type")).addClass(a.display);$label.find("span.holderWrap").width(a.checkboxWidth).height(a.checkboxHeight);$label.find("span.holder").width(a.checkboxWidth);$(this).addClass("hiddenCheckbox");$label.bind("click",function(){$("input#"+$(this).attr("for")).triggerHandler("click");if($("input#"+$(this).attr("for")).is(":checkbox")){$(this).toggleClass("checked");$("input#"+$(this).attr("for")).checked=true;$(this).find("span.holder").css("top",0)}else{$toCheck=$("input#"+$(this).attr("for"));$('input[name="'+$toCheck.attr("name")+'"]').each(function(){$('label[for="'+$(this).attr("id")+'"]').removeClass("checked")});$(this).addClass("checked");$toCheck.checked=true}});$("input#"+$label.attr("for")).bind("keypress",function(b){if(b.keyCode==32){if($.browser.msie){$('label[for="'+$(this).attr("id")+'"]').toggleClass("checked")}else{$(this).trigger("click")}return false}})})};checkAllPrettyCheckboxes=function(b,a){if($(b).is(":checked")){$(a).find("input[type=checkbox]:not(:checked)").each(function(){$('label[for="'+$(this).attr("id")+'"]').trigger("click");if($.browser.msie){$(this).attr("checked","checked")}else{$(this).trigger("click")}})}else{$(a).find("input[type=checkbox]:checked").each(function(){$('label[for="'+$(this).attr("id")+'"]').trigger("click");if($.browser.msie){$(this).attr("checked","")}else{$(this).trigger("click")}})}};



/* ------------------------------------------------------------------------
	Pretty Comments
	
	Developped By: Stephane Caron (http://www.no-margin-for-errors.com)
	Inspired By: The facebook textarea :)
	Version: 1.4
	
	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$.C.D=4(b){b=E.F({8:i,o:\'G\',j:H,5:i,p:q},b);$(\'I\').J(\'<t K="1"></t>\');k c=4(a){$("#1").2({\'L\':\'M\',\'N\':-u,\'O\':-u,\'v\':$(a).v(),\'P-0\':$(a).0(),\'l-w\':$(a).2(\'l-w\'),\'l-x\':$(a).2(\'l-x\'),\'z-0\':$(a).2(\'z-0\')});3($.A.Q&&R($.A.S)<7){$("#1").2(\'0\',$(a).0())}};k d=4(a){m=$(a).T(\'U\')||"";m=m.V(/\\n/g,\'<B />\');$("#1").W(m+\'<B />\');3(!b.p){3($("#1").0()>$(a).0()){3($(\'#1\').0()>b.j){$(a).2(\'9-y\',\'r\')}h{$(a).2(\'9-y\',\'s\');e(a)}}h 3($("#1").0()<$(a).0()){3($(\'#1\').0()>b.j){$(a).2(\'9-y\',\'r\')}h{$(a).2(\'9-y\',\'s\');f(a)}}}};k e=4(a){3(b.8&&!b.5){b.5=q;$(a).8({\'0\':$("#1").0()},b.o,4(){b.5=i})}h 3(!b.8&&!b.5){$(a).0($("#1").0())}};k f=4(a){3(b.8&&!b.5){b.5=q;$(a).8({\'0\':$("#1").0()},b.o,4(){b.5=i})}h{$(a).0($("#1").0())}};$(6).X(4(){$(6).2({\'9\':\'s\'}).Y(\'Z\',4(){d($(6))});c(6);d($(6));3($("#1").0()>b.j){$(6).2({\'9-y\':\'r\',\'0\':b.j})}h{$(6).0($("#1").0())};b.p=i})};',62,62,'height|comment_hidden|css|if|function|alreadyAnimated|this||animate|overflow||||||||else|false|maxHeight|var|font|theValue||animationSpeed|init|true|scroll|hidden|div|10000|width|family|size||line|browser|br|fn|prettyComments|jQuery|extend|fast|500|body|append|id|position|absolute|top|left|min|msie|parseFloat|version|attr|value|replace|html|each|bind|keyup'.split('|'),0,{}))



enviarEmail = {
	init : function( id_article, lloc ){
		$('.publicitat').hide();
		$('.publicitat_h').hide();
		$('#youtube').hide();
		
		enviarEmail.buildOverlay( id_article, lloc );

		// Display the current position
		$('div.popup span.currentText').html('<span>' + enviarEmail.setPosition + '</span>' + '/' + enviarEmail.setCount);

		enviarEmail.center();

		$('div.popup #fullResContainer').hide();
		$('.loaderIcon').show();
		
		// Need that small delay for the anim to be nice
		setTimeout('enviarEmail.show()',500);
		
		
		$('div.popupOverlay').css({
			'height':$(document).height(),
			'width':$(window).width()
		});
		
		$(window).scroll(function(){ enviarEmail.center(); });
		$(window).resize(function(){ enviarEmail.center(); })
	},
	center : function(){
		//Make sure the gallery is open
		if($('div.popup').size() > 0){
			
			scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
			scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
			
			$('div.popup').css({
				'top': ($(window).height()/2) + scrollTop - ($('div.popup').height()/2),
				'left': ($(window).width()/2) + scrollLeft - ($('div.popup').width()/2)
			});
		};
	},
	show : function(){
		$('.loaderIcon').hide();
		$('div.popup #fullResContainer').fadeIn('fast');
	},
	buildOverlay : function( id_article, lloc ){
		// Build the background overlay div
		backgroundDiv = "<div class='prettyPhotoOverlay'></div>";
		$('body').append(backgroundDiv);
		$('div.prettyPhotoOverlay').css('height',$(document).height()).bind('click',function(){
			close();
		});
		
		// Basic HTML
		html = '<div class="popup popup_email"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_email"><div class="loaderIcon"></div><div id="fullResContainer">';
		html += '		<h4 class="blau">Enviar article</h4>\n';
		html += '		<input type="hidden" id="id_article" value="'+ id_article +'" />\n';
		html += '		<label for="nom_e">Nom del destinatari</label>\n';
		html += '		<input id="nom_e" type="text" value="" name="nom" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="email_e">Correu electrònic del destinatari</label>\n';
		html += '		<input id="email_e" type="text" value="" name="email" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="r_nom">El teu nom</label>\n';
		html += '		<input id="r_nom" type="text" value="" name="r_nom" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="r_email">El teu correu</label>\n';
		html += '		<input id="r_email" type="text" value="" name="r_email" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="comentari">Comentari</label>\n';
		html += '		<textarea id="comentari" name="comentari"></textarea><br /><br />\n';
		html += '		<input type="hidden" id="url_enviar" value="'+ lloc  +'" />\n';
		html += '		<div style="float: left;"><input type="image" src="/img/contingut/enviar.png" onclick="enviarEmail.enviar()" style="border: none; background-color: transparent; width: 48px" /></div>\n';
		html += '<div style="float: right; padding-top: 5px"><a onclick="enviarEmail.close()"><img src="/img/icones/tancar.png" alt="tancar" /></a></div><br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
		$('body').append(html);

		// Then fade it in
		$('div.prettyPhotoOverlay').css('opacity',0).fadeTo('fast',0.35, function(){
			$('div.popup').css('opacity',0).fadeIn('fast',function(){
				// To fix an IE bug
				$('div.popup').attr('style','left:'+$('div.popup').css('left')+';top:'+$('div.popup').css('top')+';');
			});
		});
	},
	resize : function(width,height){
		// Get the container size, to resize the holder to the right dimensions
		containerHeight = contentHeight + parseFloat($('div.popup .top').height()) + parseFloat($('div.popup .bottom').height());
		containerWidth = parseFloat($('div.popup .content_email').css("padding-left")) + parseFloat($('div.popup .content_email').css("padding-right"));
		
		var newWidth = width;
		var newHeight = height;
		
		if((containerWidth + width) > $(window).width() || (containerHeight + height) > $(window).height()) {
			// Get the original geometry and calculate scales
			var xscale=(width+containerWidth + 100)/$(window).width();
			var yscale=(height+containerHeight + 100)/$(window).height();
		
			// Recalculate new size with default ratio
			if (yscale>xscale){
				newWidth = Math.round(width * (1/yscale));
				newHeight = Math.round(height * (1/yscale));
			} else {
				newWidth = Math.round(width * (1/xscale));
				newHeight = Math.round(height * (1/xscale));
			};
		};

		// Get the container size, to resize the holder to the right dimensions
		containerHeight += newHeight;
		contentHeight += newHeight;
		containerWidth += newWidth;
	
		return {
			width:newWidth,
			height:newHeight
		};
	},
	close : function(){
		$('.publicitat').show();
		$('.publicitat_h').show();
		$('#youtube').show();
		$('#tvadmira').show();
		
		$('div.popup').fadeTo('fast',0, function(){
			$('div.prettyPhotoOverlay').fadeTo('fast',0, function(){
				$('div.prettyPhotoOverlay').remove();
				$('div.popup').remove();
			});
		});
	},
	enviar : function(){
		var email = $("#email_e").val();
		var nom = $("#nom_e").val();
		var r_email = $("#r_email").val();
		var r_nom = $("#r_nom").val();
		var comentari = $("#comentari").val();
		var id_article = $("#id_article").val();
		var url_enviar = $("#url_enviar").val();

		if( email != '' )
		{
			html = '<div class="enviarAmic"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_email"><div class="loaderIcon"></div><div id="fullResContainer">';
			html += '<img src="/img/icones/loading.gif" alt="loader" style="margin: 150px 0px 100px 125px" />';
			html += '<br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
			$(".popup").html( html );
			
			$.post( AJAX, { email: email, nom: nom, r_email: r_email, r_nom: r_nom, id_article: id_article, url_enviar: url_enviar, comentari: comentari, accio: 'enviar_art' },
			function( resposta )
			{
				// Basic HTML
				html = '<div class="enviarAmic"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_email"><div class="loaderIcon"></div><div id="fullResContainer">';
				html += '<h4 class="blau">';
				
				html += '		S\'ha enviat correctament el missatge<br />\n';

				html += '</h4>\n';
				html += '<br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
				
				$('.popup').html(html);
				$('.popup .content_email').css({height: "25px"})
				
				setTimeout('enviarEmail.close()',3000)
			});
		}
		else
		{
			alert("Falta posar el teu correu electrònic");
		}
	}
}

enviarAbus = {
	init : function( id_comentari, lloc ){
		$('.publicitat').hide();
		$('.publicitat_h').hide();
		
		enviarAbus.buildOverlay( id_comentari, lloc );

		// Display the current position
		$('div.popup span.currentText').html('<span>' + enviarAbus.setPosition + '</span>' + '/' + enviarAbus.setCount);

		enviarAbus.center();

		$('div.popup #fullResContainer').hide();
		$('.loaderIcon').show();
		
		// Need that small delay for the anim to be nice
		setTimeout('enviarAbus.show()',500);
		
		
		$('div.popupOverlay').css({
			'height':$(document).height(),
			'width':$(window).width()
		});
		
		$(window).scroll(function(){ enviarAbus.center(); });
		$(window).resize(function(){ enviarAbus.center(); })
	},
	center : function(){
		//Make sure the gallery is open
		if($('div.popup').size() > 0){
			
			scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
			scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
			
			$('div.popup').css({
				'top': ($(window).height()/2) + scrollTop - ($('div.popup').height()/2),
				'left': ($(window).width()/2) + scrollLeft - ($('div.popup').width()/2)
			});
		};
	},
	show : function(){
		$('.loaderIcon').hide();
		$('div.popup #fullResContainer').fadeIn('fast');
	},
	buildOverlay : function( id_comentari, lloc ){
		// Build the background overlay div
		backgroundDiv = "<div class='prettyPhotoOverlay'></div>";
		$('body').append(backgroundDiv);
		$('div.prettyPhotoOverlay').css('height',$(document).height()).bind('click',function(){
			close();
		});
		
		// Basic HTML
		html = '<div class="popup popup_email"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_abus"><div class="loaderIcon"></div><div id="fullResContainer">';
		html += '		<h4 class="blau">Notificació de comentari inadequat</h4>\n';
		html += '		<input type="hidden" id="id_comentari" value="'+ id_comentari +'" />\n';
		html += '		<input type="hidden" id="lloc" value="'+ lloc +'" />\n';
		html += '		<label for="a_nom">El teu nom</label>\n';
		html += '		<input id="a_nom" type="text" value="" name="a_nom" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="a_email">La teva adreça electrònica</label>\n';
		html += '		<input id="a_email" type="text" value="" name="a_email" />\n';
		html += '		<br class="p" />\n';
		html += '		<label for="a_comentari">Motiu</label>\n';
		html += '		<textarea id="a_comentari" name="a_comentari"></textarea><br /><br />\n';
		html += '		<div style="float: left;"><input type="image" src="/img/contingut/enviar.png" onclick="enviarAbus.enviar()" style="border: none; background-color: transparent; width: 54px" /></div>\n';
		html += '<div style="float: right; padding-top: 5px"><a onclick="enviarAbus.close()"><img src="/img/icones/tancar.png" alt="tancar" /></a></div><br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
		$('body').append(html);

		// Then fade it in
		$('div.prettyPhotoOverlay').css('opacity',0).fadeTo('fast',0.35, function(){
			$('div.popup').css('opacity',0).fadeIn('fast',function(){
				// To fix an IE bug
				$('div.popup').attr('style','left:'+$('div.popup').css('left')+';top:'+$('div.popup').css('top')+';');
			});
		});
	},
	resize : function(width,height){
		// Get the container size, to resize the holder to the right dimensions
		containerHeight = contentHeight + parseFloat($('div.popup .top').height()) + parseFloat($('div.popup .bottom').height());
		containerWidth = parseFloat($('div.popup .content_email').css("padding-left")) + parseFloat($('div.popup .content_email').css("padding-right"));
		
		var newWidth = width;
		var newHeight = height;
		
		if((containerWidth + width) > $(window).width() || (containerHeight + height) > $(window).height()) {
			// Get the original geometry and calculate scales
			var xscale=(width+containerWidth + 100)/$(window).width();
			var yscale=(height+containerHeight + 100)/$(window).height();
		
			// Recalculate new size with default ratio
			if (yscale>xscale){
				newWidth = Math.round(width * (1/yscale));
				newHeight = Math.round(height * (1/yscale));
			} else {
				newWidth = Math.round(width * (1/xscale));
				newHeight = Math.round(height * (1/xscale));
			};
		};

		// Get the container size, to resize the holder to the right dimensions
		containerHeight += newHeight;
		contentHeight += newHeight;
		containerWidth += newWidth;
	
		return {
			width:newWidth,
			height:newHeight
		};
	},
	close : function(){
		$('.publicitat').show();
		$('.publicitat_h').show();
		
		$('div.popup').fadeTo('fast',0, function(){
			$('div.prettyPhotoOverlay').fadeTo('fast',0, function(){
				$('div.prettyPhotoOverlay').remove();
				$('div.popup').remove();
			});
		});
	},
	enviar : function(){
		var email = $("#a_email").val();
		var nom = $("#a_nom").val();
		var comentari = $("#a_comentari").val();
		var id_comentari = $("#id_comentari").val();
		var lloc = $("#lloc").val();

		if( comentari != '' )
		{
			html = '<div class="enviarAmic"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_abus"><div class="loaderIcon"></div><div id="fullResContainer">';
			html += '<img src="/img/icones/loading.gif" alt="loader" style="margin: 150px 0px 100px 125px" />';
			html += '<br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
			$(".popup").html( html );
			
			$.post( AJAX, { email: email, nom: nom, id_comentari: id_comentari, lloc: lloc, comentari: comentari, accio: 'votar_abus' },
			function( resposta )
			{
				// Basic HTML
				html = '<div class="enviarAmic"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_email"><div class="loaderIcon"></div><div id="fullResContainer">';
				html += '<h4 class="blau">';
				
				html += '		S\'ha enviat correctament el missatge<br />\n';

				html += '</h4>\n';
				html += '<br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
				
				$('.popup').html(html);
				$('.popup .content_email').css({height: "25px"})
				
				setTimeout('enviarAbus.close()',3000)
			});
		}
		else
		{
			alert("Falta posar el motiu");
		}
	}
}

previsualitzar = {
	init : function(){
		previsualitzar.buildOverlay();

		// Display the current position
		$('div.popup span.currentText').html('<span>' + previsualitzar.setPosition + '</span>' + '/' + previsualitzar.setCount);

		previsualitzar.center();

		$('div.popup #fullResContainer').hide();
		$('.loaderIcon').show();
		
		// Need that small delay for the anim to be nice
		setTimeout('previsualitzar.show()',500);
		
		
		$('div.popupOverlay').css({
			'height':$(document).height(),
			'width':$(window).width()
		});
		
		$(window).scroll(function(){ previsualitzar.center(); });
		$(window).resize(function(){ previsualitzar.center(); })
	},
	center : function(){
		//Make sure the gallery is open
		if($('div.popup').size() > 0){
			
			scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
			scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0;
			
			$('div.popup').css({
				'top': ($(window).height()/2) + scrollTop - ($('div.popup').height()/2),
				'left': ($(window).width()/2) + scrollLeft - ($('div.popup').width()/2)
			});
		};
	},
	show : function(){
		$('.loaderIcon').hide();
		$('div.popup #fullResContainer').fadeIn('fast');
	},
	buildOverlay : function(){
		// Build the background overlay div
		backgroundDiv = "<div class='prettyPhotoOverlay'></div>";
		$('body').append(backgroundDiv);
		$('div.prettyPhotoOverlay').css('height',$(document).height()).bind('click',function(){
			close();
		});
		
		var nom = $("#nom").val();
		var comentari = $("#comentari").val();
		
		// Basic HTML
		html = '<div class="popup popup_previsualitzar"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content_previsualitzar"><div class="loaderIcon"></div><div id="fullResContainer">';
		html += '		<h4 class="blau">Previsualització</h4>\n';
		
		if( comentari )
		{
			var regX = /\n/gi ;
			comentari2 = new String(comentari);
			comentari2 = comentari2.replace(regX, "<br /> \n");

			html += '		<strong class="blau">Nom:</strong> '+ nom +'<br /><br />\n';
			html += '		<strong class="blau">Comentari:</strong><br />'+ comentari2 +'<br /><br />\n';
		}
		else
		{
			html += '		<br />No hi ha cap comentari per previsualitzar<br /><br /><br />\n';
		}
		
		html += '<div style="float: right; padding-top: 5px"><a onclick="previsualitzar.close()"><img src="/img/icones/tancar.png" alt="tancar" /></a></div><br class="p" /></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';
		$('body').append(html);
		
		
		// Then fade it in
		$('div.prettyPhotoOverlay').css('opacity',0).fadeTo('fast',0.35, function(){
			$('div.popup').css('opacity',0).fadeIn('fast',function(){
				// To fix an IE bug
				$('div.popup').attr('style','left:'+$('div.popup').css('left')+';top:'+$('div.popup').css('top')+';');
			});
		});
	},
	resize : function(width,height){
		// Get the container size, to resize the holder to the right dimensions
		containerHeight = contentHeight + parseFloat($('div.popup .top').height()) + parseFloat($('div.popup .bottom').height());
		containerWidth = parseFloat($('div.popup .content_previsualitzar').css("padding-left")) + parseFloat($('div.popup .content_previsualitzar').css("padding-right"));
		
		var newWidth = width;
		var newHeight = height;
		
		if((containerWidth + width) > $(window).width() || (containerHeight + height) > $(window).height()) {
			// Get the original geometry and calculate scales
			var xscale=(width+containerWidth + 100)/$(window).width();
			var yscale=(height+containerHeight + 100)/$(window).height();
		
			// Recalculate new size with default ratio
			if (yscale>xscale){
				newWidth = Math.round(width * (1/yscale));
				newHeight = Math.round(height * (1/yscale));
			} else {
				newWidth = Math.round(width * (1/xscale));
				newHeight = Math.round(height * (1/xscale));
			};
		};

		// Get the container size, to resize the holder to the right dimensions
		containerHeight += newHeight;
		contentHeight += newHeight;
		containerWidth += newWidth;
	
		return {
			width:newWidth,
			height:newHeight
		};
	},
	close : function(){
		$('div.popup').fadeTo('fast',0, function(){
			$('div.prettyPhotoOverlay').fadeTo('fast',0, function(){
				$('div.prettyPhotoOverlay').remove();
				$('div.popup').remove();
			});
		});
	}
}




function FeedMenu( sLinkSelector, sClass ){
    
    var jqoFeedMenu = $('<span class="feed_menu"><select></select></span>');
    var jqoSelect = jqoFeedMenu.find('select');
    
    if( sClass ){
    	jqoFeedMenu.addClass( sClass );
    }
    
    //feed links
    var defaults = { links: sLinkSelector || 'link[type*=rss],link[type*=atom]' };
    
    /*
    *
    *	Function build	
    *	
    *	@description	
    *
    *	This function builds the feed menu by ripping RSS|Atom feed
    *	content and creating links for those.						
    *							
    */
    this.build = function( mFeedLinks ) {
    	
    	mFeedLinks = mFeedLinks || defaults.links;
    	
    	var oAtom 	= $('<optgroup label="Sindicació dels municipis"></optgroup>');
    	var oRSS 	= $('<optgroup label="Sindicació dels continguts"></optgroup>'); 
    	var oAll    = [];
    	
    	$(mFeedLinks).each(
    		function(){
   			var titol = $(this).attr('title');
   			var titol2 = titol.substring(0,8);
    			
    			if ( titol2 == 'Municipi' )
    				var sFeedType = "atom";
    			else
     				var sFeedType = "rss";

    		//	var sFeedType = $(this).is('link[type*=rss]')? "rss" : $(this).is('link[type*=atom]')?"atom":null;
    			var sFeedTitle= $(this).is('link')? $(this).attr('title') : '';
    			
    			var oOption = $('<option></option>')
    					.html( sFeedTitle )
    					.attr('value', $(this).attr('href') )
    					.click(
    						function(){
    							document.location.href = $(this).attr('value');
    							jqoFeedMenu.removeClass('feed_menu_focused');
    						}
    					);
    			
    			if( sFeedType == 'atom' ) {
    				oAtom.append(oOption);
    			} else if ( sFeedType == 'rss' ) {
    				oRSS.append(oOption);
    			}
    			oAll.push(oOption);
    			
    		}
    	);
    	
    	//if there were RSS or Atom feeds found, append them
    	if ( oAtom.find('option').length > 1 ) {
    		if( $.browser.opera){
    			jqoSelect.append( oRSS.find('option') );
    		}else{
    			jqoSelect.append( oRSS );
    		}
    	}	
    	if ( oRSS.find('option').length > 1 ) {
    		if( $.browser.opera){
    			jqoSelect.append( oAtom.find('option') );
    		}else{
    			jqoSelect.append( oAtom );
    		}
    	} else {
    		for( opt in oAll){
    			jqoSelect.append( oAll[opt] );
    		}
    	}
    	
    	//setup the event handlers
    	/*jqoFeedMenu
    		.click(
    			function(){
    				$('.feed_menu select')
    					.not($(this).find('select'))
    					.blur();
    			}
    		);
    		*/
    	jqoSelect
    		.blur( 	function(){ 
    					if( $.browser.msie || $.browser.safari || $.browser.opera ){
    						this.selectedIndex = -1;
    					
    					}
    					jqoFeedMenu.removeClass('open'); 
    				} 
    		)
    		.focus( function(){
    					if( $.browser.msie || $.browser.safari || $.browser.opera ){
    						this.selectedIndex = -1;
    					
    					}
    					jqoFeedMenu.addClass('open'); 
    				} 
    		)
    		.change(
    			function(){
    				if( $.browser.msie || $.browser.safari || $.browser.opera ){
 		   				var i = this.selectedIndex;
 		   				this.selectedIndex = -1;
 		   				if ( i > -1 ) {
 		   					var o = this.options[i];
 		   					this.selectedIndex = -1;
 		   					document.location.href = $(o).attr('value');
 		   				}
    				}
    			}
    		)
    		.get(0).selectedIndex=-1;
    }
    
    /*
    *
    *	Function feedMenu.write	
    *	
    *	@description	
    *
    *	This function takes a jQuery selector and appends the 
    *	feed menu in that DOM node. If no nodes are found, it
    *	is not written.  If no selector was specified, this
    *	function automatically places the feeds menu as the
    *	last child of the body.
    *	
    *	@param	mTarget	A mixed type variable: string or jQuery or null	
    *
    */
    this.write = function( mTarget ) {
    	
    	//target for the menu is defaulted to the page body
    	mTarget = mTarget || 'body';
    	
    	//build the feed menu options
    	this.build();
    	
    	//shove the feed menu in the target item
    	$(mTarget).append( jqoFeedMenu );
    	
    }

}






/*
 * 	Easy Slider 1.5 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
(function($) {
	$.fn.easySlider = function(options){
		// default configuration properties

		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',
			nextText: 		'Next',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',
			lastText: 		'Last',
			lastShow:		false,
			vertical:		false,
			speed: 			800,
			auto:			false,
			pause:			2000,
			continuous:		false
		};

		var options = $.extend(defaults, options);

		this.each(function() {
			var obj = $(this);
			var s = $("li", obj).length;
			
			var w = $("li", obj).width() + 25;
			
			var h = $("li", obj).height();
// 			obj.width(w);
// 			obj.height(h);
			obj.css("overflow","hidden");
			var ts = s-1;
			
 			$("ul", obj).css('width',s*w);

			var t = 0;
			if(options.controlsShow){
				var html_esquerra = ' <div id="'+ options.prevId +'"><a href=\"javascript:void(0);\"><img src="/img/icones/fletxae.png" alt="anterior" /></a></div>';
				$(obj).prepend(html_esquerra);
				var html_dreta = ' <div id="'+ options.nextId +'"><a href=\"javascript:void(0);\"><img src="/img/icones/fletxad.png" alt="seguent" /></a></div>';
				$(obj).append(html_dreta);
			};
			$("a","#"+options.prevId).hide();

			$("a","#"+options.nextId).click(function(){
				animate("next",true);
			});
			$("a","#"+options.prevId).click(function(){
				animate("prev",true);
			});
			$("a","#"+options.firstId).click(function(){
				animate("first",true);
			});
			$("a","#"+options.lastId).click(function(){
				animate("last",true);
			});
			
			function animate(dir,clicked){
				var ot = t;		
				switch(dir){
					case "next":
						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;
						break;
					case "prev":
						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
						break;
					case "first":
						t = 0;
						break;
					case "last":
						t = ts;
						break;
					default:
						break;
				};
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;
				if(!options.vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p },
						speed
					);		
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p },
						speed
					);
				};

				if(!options.continuous && options.controlsFade){
					if( t==ts-2 ) {
						$("a","#"+options.nextId).hide();
						$("a","#"+options.lastId).hide();
					} else {
						$("a","#"+options.nextId).show();
						$("a","#"+options.lastId).show();
					};
					if(t==0){
						$("a","#"+options.prevId).hide();
						$("a","#"+options.firstId).hide();
					} else {
						$("a","#"+options.prevId).show();
						$("a","#"+options.firstId).show();
					};
				};

				if(clicked) clearTimeout(timeout);
				if(options.auto && dir=="next" && !clicked){;
					timeout = setTimeout(function(){
						animate("next",false);
					},diff*options.speed+options.pause);
				};

			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};

// 			if(!options.continuous && options.controlsFade){
// 				$("a","#"+options.prevId).hide();
// 				$("a","#"+options.firstId).hide();
// 			};
			
		});
	  
	};

})(jQuery);





/*
Copyright (c) 2006, Webframeworks LLC. All rights reserved.
Code licensed under the BSD License:
http://dev.webframeworks.com/dist/JSOC-license.txt
version: 0.12.0
*/

/*/  
 *  JSOC - An object Cache framework for JavaScript
 *  version 0.12.0 [beta]
/*/


JSOC = function(){
    var Cache = {};
    return {
        "get":function(n){
            var obj = {}, val = Cache[n];
            obj[n] = val;
            if(val) return obj;
        },
        "getMulti":function(l){
            var a = [];
            for (var k in l) a.push(this.get(l[k]));
            return a;
        },
        "getType":function(t){
            var a = [];
            for (var o in Cache) if(typeof(Cache[o])==t.toLowerCase()){a.push(this.get(o))}
            return a;
        },
        "set":function(n,v){
            if(Cache[n]) delete(Cache[n]);
            Cache[n]=v;
            if (arguments[2]){
                var ttl = arguments[2].ttl || null;
                if(ttl) var self = this, to = setTimeout(function(){self.remove(n)}, ttl);
            }
            return (Cache[n])?1:0;
        },
        "add":function(n,v){
            if(!Cache[n]){
                Cache[n]=v;
                if (arguments[2]){
                    var ttl = arguments[2].ttl || null;
                    if(ttl) var self = this, to = setTimeout(function(){self.remove(n)}, ttl);
                }
                return (Cache[n])?1:0;
            }
        },
        "replace":function(n,v){
            if(Cache[n]){
                delete(Cache[n]);
                Cache[n]=v;
                if (arguments[2]){
                    var ttl = arguments[2].ttl || null;
                    if(ttl) var self = this, to = setTimeout(function(){self.remove(n)}, ttl);
                }
                return (Cache[n])?1:0;
            }
        },
        "remove":function(n){
            delete(Cache[n]);
            return (!Cache[n])?1:0;
        },
        "flush_all":function(){
            for(var k in Cache) delete(Cache[k]);
            return 1;
        }
    }
}


/**************************************
Tooltips functions
***************************************/
/**
  Stronglky modified, onky works with DOM2 compatible browsers.
  	Ricardo Galli
  From http://ljouanneau.com/softs/javascript/tooltip.php
 */

if (typeof(JSOC) != "undefined") {
	// create the tooltip object
	function tooltip(){}
	// setup properties of tooltip object
	tooltip.id="tooltip";
	tooltip.main=null;
	tooltip.offsetx = 10;
	tooltip.offsety = 10;
	tooltip.shoffsetx = 8;
	tooltip.shoffsety = 8;
	tooltip.x = 0;
	tooltip.y = 0;
	tooltip.tooltipShadow=null;
	tooltip.tooltipText=null;
	tooltip.title_saved='';
	tooltip.saveonmouseover=null;
	tooltip.timeout = null;
	tooltip.active = false;

	tooltip.cache = new JSOC();

	tooltip.ie = (document.all)? true:false;		// check if ie
	if(tooltip.ie) tooltip.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0);
	else tooltip.ie5 = false;
	tooltip.dom2 = ((document.getElementById) && !(tooltip.ie5))? true:false; // check the W3C DOM level2 compliance. ie4, ie5, ns4 are not dom level2 compliance !! grrrr >:-(
}


/**
* Open ToolTip. The title attribute of the htmlelement is the text of the tooltip
* Call this method on the mouseover event on your htmlelement
* ex :  <div id="myHtmlElement" onmouseover="tooltip.show(this)"...></div>
*/

tooltip.show = function (event, text) {
      // we save text of title attribute to avoid the showing of tooltip generated by browser
	if (this.dom2  == false ) return false;
	if (this.tooltipShadow == null) {
		this.tooltipShadow = document.createElement("div");
		this.tooltipShadow.setAttribute("id", "tooltip-shadow");
		document.body.appendChild(tooltip.tooltipShadow);

		this.tooltipText = document.createElement("div");
		this.tooltipText.setAttribute("id", "tooltip-text");
		document.body.appendChild(this.tooltipText);
	}
	this.saveonmouseover=document.onmousemove;
	document.onmousemove = this.mouseMove;
	this.mouseMove(event); // This already moves the div to the right position
	this.setText(text);
	this.tooltipText.style.visibility ="visible";
	this.tooltipShadow.style.visibility ="visible";
	this.active = true;
	return false;
}


tooltip.setText = function (text) {
	tooltip.tooltipShadow.style.width = 0+"px";
	tooltip.tooltipShadow.style.height = 0+"px";
	this.tooltipText.innerHTML=text;
	setTimeout('tooltip.setShadow()', 1);
	return false;
}

tooltip.setShadow = function () {
	tooltip.tooltipShadow.style.width = tooltip.tooltipText.clientWidth+"px";
	tooltip.tooltipShadow.style.height = tooltip.tooltipText.clientHeight+"px";
}


/**
* hide tooltip
* call this method on the mouseout event of the html element
* ex : <div id="myHtmlElement" ... onmouseout="tooltip.hide(this)"></div>
*/
tooltip.hide = function (event) {
	if (this.dom2  == false) return false;
	document.onmousemove=this.saveonmouseover;
	this.saveonmouseover=null;
	if (this.tooltipShadow != null ) {
		this.tooltipText.style.visibility = "hidden";
		this.tooltipShadow.style.visibility = "hidden";
		this.tooltipText.innerHTML='';
	}
	this.active = false;
}



// Moves the tooltip element
tooltip.mouseMove = function (e) {
   // we don't use "this", but tooltip because this method is assign to an event of document
   // and so is dreferenced

	if (tooltip.ie) {
		tooltip.x = event.clientX;
		tooltip.y = event.clientY;
	} else {
		tooltip.x = e.pageX;
		tooltip.y = e.pageY;
	}
	tooltip.moveTo( tooltip.x +tooltip.offsetx , tooltip.y + tooltip.offsety);
}

// Move the tooltip element
tooltip.moveTo = function (xL,yL) {
	if (this.ie) {
		xL +=  document.documentElement.scrollLeft;
		yL +=  document.documentElement.scrollTop;
	}
	if (this.tooltipText.clientWidth > 0  && document.documentElement.clientWidth > 0 && xL > document.documentElement.clientWidth * 0.55) {
		xL = xL - this.tooltipText.clientWidth - 2*this.offsetx;
	}
	this.tooltipText.style.left = xL +"px";
	this.tooltipText.style.top = yL +"px";
	xLS = xL + this.shoffsetx;
	yLS = yL + this.shoffsety;
	this.tooltipShadow.style.left = xLS +"px";
	this.tooltipShadow.style.top = yLS +"px";
}

// Show the content of a given comment
tooltip.c_show = function (event, element, lloc, id_article) {
      // we save text of title attribute to avoid the showing of tooltip generated by browser
	if (this.dom2  == false ) return false;
    target_text = 'comentari-' + id_article;
    target = document.getElementById(target_text);
    if (!target ) {
	this.ajax_delayed(event, 'ajax.php?accio=comentari_replica&element=' + element +'&lloc='+ lloc, id_article );
	return;
    }
    text = target.innerHTML;
    
    return this.show(event, text);
}

tooltip.clear = function(event) {
    if (this.timeout != null) {
	clearTimeout(this.timeout);
	this.timeout = null;
    }
    this.hide(event);
}

tooltip.ajax_delayed = function(event, script, id, maxcache) {
    maxcache = maxcache || 0;// 600000; // 10 minutes in cache
    if (this.active)
	return false;
    if ((object = this.cache.get(script + id)) != undefined) {
	tooltip.show(event, object[script + id]);
    } else {
	this.show(event, 'carregant...'); // Translate this to your language:
	// it's "loading..." ;-)
	this.timeout = setTimeout("tooltip.ajax_request('" + script + "', '"
		+ id + "', " + maxcache + ")", 100);
    }
}

tooltip.ajax_request = function(script, id, maxcache) {
    var url = 'ajax/' + script + '&id=' + id;
    tooltip.timeout = null;
    $.ajax( {
	url :url,
	dataType :"html",
	success : function(html) {
	    tooltip.cache.set(script + id, html, {
		'ttl' :maxcache
	    });

	    tooltip.setText(html);
	}
    });
}




/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * Version 1.1
 * Demo: http://www.texotela.co.uk/code/jquery/numeric/
 *
 */
 
/*
 * Allows only valid characters to be entered into input boxes.
 * Note: does not validate that the final text is a valid number
 * (that could be done by another script, or server-side)
 *
 * @name     numeric
 * @param    decimal      Decimal separator (e.g. '.' or ',' - default is '.')
 * @param    callback     A function that runs if the number is not valid (fires onblur)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $(".numeric").numeric();
 * @example  $(".numeric").numeric(",");
 * @example  $(".numeric").numeric(null, callback);
 *
 */
jQuery.fn.numeric = function(decimal, callback)
{
	decimal = decimal || ".";
	callback = typeof callback == "function" ? callback : function(){};
	this.keypress(
		function(e)
		{
			var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
			// allow enter/return key (only when in an input box)
			if(key == 13 && this.nodeName.toLowerCase() == "input")
			{
				return true;
			}
			else if(key == 13)
			{
				return false;
			}
			var allow = false;
			// allow Ctrl+A
			if((e.ctrlKey && key == 97 /* firefox */) || (e.ctrlKey && key == 65) /* opera */) return true;
			// allow Ctrl+X (cut)
			if((e.ctrlKey && key == 120 /* firefox */) || (e.ctrlKey && key == 88) /* opera */) return true;
			// allow Ctrl+C (copy)
			if((e.ctrlKey && key == 99 /* firefox */) || (e.ctrlKey && key == 67) /* opera */) return true;
			// allow Ctrl+Z (undo)
			if((e.ctrlKey && key == 122 /* firefox */) || (e.ctrlKey && key == 90) /* opera */) return true;
			// allow or deny Ctrl+V (paste), Shift+Ins
			if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
			|| (e.shiftKey && key == 45)) return true;
			// if a number was not pressed
			if(key < 48 || key > 57)
			{
				/* '-' only allowed at start */
				if(key == 45 && this.value.length == 0) return true;
				/* only one decimal separator allowed */
				if(key == decimal.charCodeAt(0) && this.value.indexOf(decimal) != -1)
				{
					allow = false;
				}
				// check for other keys that have special purposes
				if(
					key != 8 /* backspace */ &&
					key != 9 /* tab */ &&
					key != 13 /* enter */ &&
					key != 35 /* end */ &&
					key != 36 /* home */ &&
					key != 37 /* left */ &&
					key != 39 /* right */ &&
					key != 46 /* del */
				)
				{
					allow = false;
				}
				else
				{
					// for detecting special keys (listed above)
					// IE does not support 'charCode' and ignores them in keypress anyway
					if(typeof e.charCode != "undefined")
					{
						// special keys have 'keyCode' and 'which' the same (e.g. backspace)
						if(e.keyCode == e.which && e.which != 0)
						{
							allow = true;
						}
						// or keyCode != 0 and 'charCode'/'which' = 0
						else if(e.keyCode != 0 && e.charCode == 0 && e.which == 0)
						{
							allow = true;
						}
					}
				}
				// if key pressed is the decimal and it is not already in the field
				if(key == decimal.charCodeAt(0))
				{
					if(!this.containsDecimal)
					{
						allow = true;
						this.containsDecimal = true;
					}
					else
					{
						allow = false;
					}
				}
			}
			else
			{
				allow = true;
			}
			return allow;
		}
	)
	.blur(
		function()
		{
			var val = jQuery(this).val();
			if(val != "")
			{
				var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
				if(!re.exec(val))
				{
					callback.apply(this);
				}
			}
		}
	);
	return this;
}




