jQuery(document).ready( function(){

	/* Incremento e riduzione della dimensione del testo */
	var originalFontSize = parseFloat( jQuery('.itemFullText').css('font-size'));
	var size_backup = originalFontSize;
	var sizeMax = 16;
	var sizeMin = 9;

	jQuery("#fontDecrease").click( function(){
		originalFontSize -= 1;
		if( originalFontSize < sizeMin ) originalFontSize = sizeMin;
		if( originalFontSize > sizeMax ) originalFontSize = sizeMax;
		jQuery('.itemFullText').css({'font-size' : originalFontSize});
	});

	jQuery("#fontIncrease").click( function(){
		originalFontSize += 1;
		if( originalFontSize < sizeMin ) originalFontSize = sizeMin;
		if( originalFontSize > sizeMax ) originalFontSize = sizeMax;
		jQuery('.itemFullText').css({'font-size' : originalFontSize});
	});

	jQuery(".fontNormal").click( function(){
		originalFontSize = size_backup;
		jQuery('.itemFullText').css({'font-size' : originalFontSize});
	});
	/* ------------------------*/

	/* Stampa della pagina */
	jQuery(".itemPrintLink").click( function(){
		window.print();
	});
	/* ------------------------*/
});

window.addEvent("domready", function(){
	$$('.nsp_main').each(function(module){
		var id = module.getProperty('id');
		var $G = $Gavick[id];
		var arts_actual = 0;
		var list_actual = 0;
		var arts_block_width = $E('.nsp_arts', module) ? $E('.nsp_arts', module).getSize().size.x : null;
		var links_block_width = $E('.nsp_links ul', module) ? $E('.nsp_links ul', module).getSize().size.x : null;
		var arts = $ES('.nsp_art', module);
		var links = $ES('.nsp_links .list li', module);
		var arts_per_page = $G['news_column'] * $G['news_rows'];
		var pages_amount = Math.ceil(arts.length / arts_per_page);
		var links_pages_amount = Math.ceil(links.length / $G['links_amount']);
		var auto_anim = module.hasClass('autoanim');
		var hover_anim = module.hasClass('hover');
		var anim_speed = $G['animation_speed'];
		var anim_interval = $G['animation_interval'];
		var animation = true;

		if(arts.length > 0){
			for(var i = 0; i < pages_amount; i++){
				var div = new Element('div',{"class" : "nsp_art_page"});
				div.setStyles({ "width" : arts_block_width+"px", "float" : "left" });
				div.injectBefore(arts[0]);
			}

			var j = 0;
			for(var i = 0; i < arts.length; i++) {
				if(i % arts_per_page == 0 && i != 0) { j++; }
				if(window.ie) arts[i].setStyle('width', (arts[i].getStyle('width').toInt() - 0.2) + "%");
				arts[i].injectInside($ES('.nsp_art_page',module)[j]);
				if(arts[i].hasClass('unvisible')) arts[i].removeClass('unvisible');
			}

			var main_scroll = new Element('div',{"class" : "nsp_art_scroll1" });
			main_scroll.setStyles({ "width" : arts_block_width + "px", "overflow" : "hidden" });
			main_scroll.innerHTML = '<div class="nsp_art_scroll2"></div>';
			main_scroll.injectBefore($E('.nsp_art_page',module));
			var long_scroll = $E('.nsp_art_scroll2',module);
			long_scroll.setStyle('width','100000px');
			$ES('.nsp_art_page',module).injectInside(long_scroll);
			var art_scroller = new Fx.Scroll(main_scroll, {duration:$G['animation_speed'], wait:false, wheelStops:false});
		}

		if(links.length > 0){
			for(var i = 0; i < links_pages_amount; i++){
				var ul = new Element('ul');
				ul.setStyles({ "width" : links_block_width+"px", "float" : "left" });
				ul.setProperty("class","list");
				ul.injectTop($E('.nsp_links',module));
			}

			var k = 0;
			for(var i = 0; i < links.length; i++) {
				if(i % $G['links_amount'] == 0 && i != 0) { k++; }
				links[i].injectInside($ES('.nsp_links ul.list',module)[k]);
				if(links[i].hasClass('unvisible')) links[i].removeClass('unvisible');
			}
			$ES('.nsp_links ul.list',module)[$ES('.nsp_links ul.list',module).length - 1].remove();
			var link_scroll = new Element('div',{"class" : "nsp_link_scroll1" });
			link_scroll.setStyles({ "width" : links_block_width + "px", "overflow" : "hidden" });
			link_scroll.innerHTML = '<div class="nsp_link_scroll2"></div>';
			link_scroll.injectTop($E('.nsp_links',module));
			var long_link_scroll = $E('.nsp_link_scroll2',module);
			long_link_scroll.setStyle('width','100000px');
			$ES('.nsp_links ul.list',module).injectInside(long_link_scroll);
			var link_scroller = new Fx.Scroll(link_scroll, {duration:$G['animation_speed'], wait:false, wheelStops:false});
		}

		// top interface
		nsp_art_list(0, module, 'top');
		nsp_art_list(0, module, 'bottom');
		nsp_art_counter(0, module, 'top', pages_amount);
		nsp_art_counter(0, module, 'bottom', links_pages_amount);

		if($E('.nsp_top_interface .pagination', module)){
			$E('.nsp_top_interface .pagination', module).getElementsBySelector('li').each(function(item,i){
				item.addEvent(hover_anim ? 'mouseenter' : 'click', function(){
					art_scroller.scrollTo(i*arts_block_width, 0);
					arts_actual = i;

					if(window.opera){
			 			new Fx.Style($ES('.nsp_art_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * arts_actual * arts_block_width);
					}

					nsp_art_list(i, module, 'top');
					nsp_art_counter(i, module, 'top', pages_amount);
					animation = false;
					(function(){animation = true;}).delay($G['animation_interval'] * 0.8);
				});
			});
		}
		if($E('.nsp_top_interface .prev', module)){
			$E('.nsp_top_interface .prev', module).addEvent("click", function(){
				if(arts_actual == 0) arts_actual = pages_amount - 1;
				else arts_actual--;
				art_scroller.scrollTo(arts_actual * arts_block_width, 0);

				if(window.opera){
			 		new Fx.Style($ES('.nsp_art_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * arts_actual * arts_block_width);
				}

				nsp_art_list(arts_actual, module, 'top');
				nsp_art_counter(arts_actual, module, 'top', pages_amount);
				animation = false;
				(function(){animation = true;}).delay($G['animation_interval'] * 0.8);
			});
		}

		if($E('.nsp_top_interface .next', module)){
			$E('.nsp_top_interface .next', module).addEvent("click", function(){
				if(arts_actual == pages_amount - 1) arts_actual = 0;
				else arts_actual++;
				art_scroller.scrollTo(arts_actual * arts_block_width, 0);

				if(window.opera){
			 		new Fx.Style($ES('.nsp_art_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * arts_actual * arts_block_width);
				}

				nsp_art_list(arts_actual, module, 'top');
				nsp_art_counter(arts_actual, module, 'top', pages_amount);
				animation = false;
				(function(){animation = true;}).delay($G['animation_interval'] * 0.8);
			});
		}
		// bottom interface
		if($E('.nsp_bottom_interface .pagination', module)){
			$E('.nsp_bottom_interface .pagination', module).getElementsBySelector('li').each(function(item,i){
				item.addEvent(hover_anim ? 'mouseenter' : 'click', function(){
					link_scroller.scrollTo(i*links_block_width, 0);
					list_actual = i;

					if(window.opera){
			 			new Fx.Style($ES('.nsp_link_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * list_actual * links_block_width);
					}

					nsp_art_list(i, module, 'bottom', links_pages_amount);
				});
			});
		}
		if($E('.nsp_bottom_interface .prev', module)){
			$E('.nsp_bottom_interface .prev', module).addEvent("click", function(){
				if(list_actual == 0) list_actual = links_pages_amount - 1;
				else list_actual--;
				link_scroller.scrollTo(list_actual * links_block_width, 0);

				if(window.opera){
		 			new Fx.Style($ES('.nsp_link_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * list_actual * links_block_width);
				}

				nsp_art_list(list_actual, module, 'bottom', links_pages_amount);
				nsp_art_counter(list_actual, module, 'bottom', links_pages_amount);
			});
		}
		if($E('.nsp_bottom_interface .next', module)){
			$E('.nsp_bottom_interface .next', module).addEvent("click", function(){
				if(list_actual == links_pages_amount - 1) list_actual = 0;
				else list_actual++;
				link_scroller.scrollTo(list_actual * links_block_width, 0);

				if(window.opera){
 					new Fx.Style($ES('.nsp_link_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * list_actual * links_block_width);
				}

				nsp_art_list(list_actual, module, 'bottom', links_pages_amount);
				nsp_art_counter(list_actual, module, 'bottom', links_pages_amount);
			});
		}

		if(auto_anim){
			(function(){
				if($E('.nsp_top_interface .next', module)){
					if(animation) $E('.nsp_top_interface .next', module).fireEvent("click");
				}else{
					if(arts_actual == pages_amount - 1) arts_actual = 0;
					else arts_actual++;
					art_scroller.scrollTo(arts_actual * arts_block_width, 0);

					if(window.opera){
				 		new Fx.Style($ES('.nsp_art_scroll2',module)[0], 'margin-left', {duration:$G['animation_speed'], wait:false}).start(-1 * arts_actual * arts_block_width);
					}
					nsp_art_list(arts_actual, module, 'top');
					nsp_art_counter(arts_actual, module, 'top', pages_amount);
				}
			}).periodical($G['animation_interval']);
		}
	});

	function nsp_art_list(i, module, position){
		if($E('.nsp_'+position+'_interface .pagination', module)){
			$E('.nsp_'+position+'_interface .pagination', module).getElementsBySelector('li').setProperty('class', '');
			$E('.nsp_'+position+'_interface .pagination', module).getElementsBySelector('li')[i].setProperty('class', 'active');
		}
	}

	function nsp_art_counter(i, module, position, num){
		if($E('.nsp_'+position+'_interface .counter', module)){
			$E('.nsp_'+position+'_interface .counter span', module).innerHTML =  (i+1) + ' / ' + num;
		}
	}
});

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}('O.2i=O.12.1O({1P:8(a,b){$(a).R(\'2j\',\'2k\');U.1Q(a,\'1R\',b)},1S:8(){7 a=U.1F.1T(\'1R\').1U();1v(a>0)?U.Q(a,0):U.Q(0,U.1F.1V)},1W:8(){1v U.1X(U.1F.1V)}});O.18=O.12.1O({1P:8(a,b){U.1Y=1;U.1Q(a,\'1Z\',b)},1S:8(){1v(U.1Y>0)?U.Q(1,0):U.Q(0,1)},1W:8(){1v U.1X(1)}});1w.T("2l",8(){$$(".2m").13(8(q){7 r=q.X("2n");7 s=$(r);7 t=$2o[r];7 u=t[\'2p\'];7 v=t[\'2q\'];7 w=t[\'2r\'];7 y=t[\'2s\'];7 z=t[\'2t\'];7 A=t[\'2u\'];7 B=t[\'2v\'];7 C=t[\'1j\'];7 D=t[\'1G\'];7 E=t[\'1H\'];7 F=t[\'2w\'];7 G=t[\'1Z\'];7 H=[];7 I=[];7 J=[];7 K=($E(\'.1I\',s))?1x:1k;9($E(\'.1I\',s)){7 L=[];$1J(\'.20\',s).13(8(a,i){J.21(a.X(\'22\'));7 b=P 2x(\'2y\',{"2z":a.1l,"23":a.X(\'22\'),"V":a.X(\'V\'),"24":a.X(\'24\')});L.21(b);b.2A(a);a.2B()});7 M=(8(){7 b=0;L.13(8(a,i){9(a.2C)b++});9(b==L.W){$16(M);K=b;(8(){P O.18($E(\'.1I\',s)).Q(1,0)}).1c(2D)}}).1m(2E)}7 N=(8(){9(K){$16(N);9(1w.2F){9($E(".1y",s))$E(".1y",s).25(G.2G())}s.1d(".20").13(8(a,i){H[i]=a;9(t[\'2H\']==1){a.T("17",8(){1w.26=a.X(\'23\')});a.R("2I","2J")}});H.13(8(a,i){9(i!=0)a.25(0)});7 c=[];9($E(\'.2K\',s)){$1J(\'.Y\',s).13(8(a,x){c[x]=a;a.T("17",8(){1n(j,r,s,H,I,u,x,z,y,t,c)})});c[0].1o("V",(c[0].X("V")).1p(\'Y\',\'Y 1q\'))}9(s.1d(".1y").W>0){7 d=s.1d(".1y")[0];s.1d(".2L").13(8(a,i){I[i]=a.1l});9($E(\'.27\',s)){7 f=$E(\'.27\',s);7 g=$E(\'.2M\',f.28());7 h=$E(\'.2N\',f.28());7 j=$1J(\'.2O\',f);7 k=0;j[0].1r({"1e":C+"19 1f "+D});j.13(8(a,i){a.T("17",8(){1n(j,r,s,H,I,u,i,z,y,t,c)})});9((j.W*(A+(2*B)+(2*C)))<d.Z().10.x){g.R("1a","1h");h.R("1a","1h");f.R("29",d.Z().10.x+"19")}1s{7 l=2P.2Q((f.1T("29").1U()-(2*B))/(A+(2*B)+(2*C)))-1;7 m=P O.2R(f,{2S:O.2T.2U,S:1K});7 n,1t;7 o=0;g.T("2a",8(){9(o>0){n=(8(){9(o>0){o-=5;m.2b(o,0)}1s{$16(n);o=0;m.2V()}}).1m(1K)}});h.T("2a",8(){7 a=$E(".2W",f).Z().10.x;9(o<a){1t=(8(){9(o<a){o+=5;m.2b(o,0)}1s{$16(1t);o=a;m.2X()}}).1m(1K)}});g.T("2c",8(){$16(n);$16(1t)});h.T("2c",8(){$16(1t);$16(n)})}j.13(8(b,i){b.T("17",8(){j.13(8(a){a.R("1e",C+"19 1f "+E)});b.R("1e",C+"19 1f "+D)})})}}9($E(".2d",s)){$E(".2d",s).T("17",8(e){7 a=P 1z(e);a.1A();1n(j,r,s,H,I,u,((t[\'6\']>0)?t[\'6\']-1:H.W-1),z,y,t,c)})}9($E(".2e",s)){$E(".2e",s).T("17",8(e){7 a=P 1z(e);a.1A();1n(j,r,s,H,I,u,((t[\'6\']<H.W-1)?t[\'6\']+1:0),z,y,t,c)})}9($E(".1g",s)){$E(".1g",s).T("17",8(e){7 a=P 1z(e);a.1A();1L(s,H,I,j,r,v,u,"1B",1k,z,y,t,c);$E(".1g",s).R("1a","1h");$E(".11",s).R("1a","2f")})}9($E(".11",s)){$E(".11",s).T("17",8(e){7 a=P 1z(e);a.1A();11(r,t)})}9($E(".2g",s)){$E(".2g",s).T("17",8(){1w.26.2Y=J[t[\'6\']]})}7 p=I.W-1;t[\'6\']=0;9(s.1d(".1M")[0])s.1d(".1M")[0].1l=I[0];9(w==1){1L(s,H,I,j,r,v,u,"1B",1k,z,y,t,c);9($E(".1g",s))$E(".1g",s).R("1a","1h")}1s{9($E(".11",s))$E(".11",s).R("1a","1h")}}}).1m(2Z)})});8 1N(a,b,c,d,e){7 f=a.1d(".1M")[0];9(f){9(d==0){P O.18(f,{S:e/2}).Q(1,0);(8(){P O.18(f,{S:e/2}).Q(0,1);f.1l=b[c]}).1c(e)}1s f.1l=b[c]}}8 1L(b,c,d,e,f,g,h,i,j,k,l,m,n){7 o=c.W-1;9(!m[\'1C\']){m[\'1C\']=(8(){9(i=="1i")7 a=(m[\'6\']==0)?0:m[\'6\'];9(i=="1B")7 a=(m[\'6\']==o)?o:m[\'6\'];9(i=="1i")(m[\'6\']==0)?m[\'6\']=o:m[\'6\']-=1;9(i=="1B")(m[\'6\']==o)?m[\'6\']=0:m[\'6\']+=1;c[m[\'6\']].R("z-1D",o+1);P O.18(c[a],{S:h}).Q(1,0);m[\'1u\']=1k;P O.18(c[m[\'6\']],{S:h}).Q(0,1);1N(b,d,m[\'6\'],k,h);2h(l){14 0:15;14 1:P O.12(c[m[\'6\']],\'1b-1E\',{S:h}).Q((-1)*c[m[\'6\']].Z().10.y,0);15;14 2:P O.12(c[m[\'6\']],\'1b-1i\',{S:h}).Q((-1)*c[m[\'6\']].Z().10.x,0);15;14 3:P O.12(c[m[\'6\']],\'1b-1E\',{S:h}).Q(c[m[\'6\']].Z().10.y,0);15;14 4:P O.12(c[m[\'6\']],\'1b-1i\',{S:h}).Q(c[m[\'6\']].Z().10.x,0);15}9(e)e[a].1r({"1e":m[\'1j\']+"19 1f "+m[\'1H\']});9(e)e[m[\'6\']].1r({"1e":m[\'1j\']+"19 1f "+m[\'1G\']});9(n.W>0)n[a].1o("V",(n[a].X("V")).1p(\'Y 1q\',\'Y\'));9(n.W>0)n[m[\'6\']].1o("V",(n[m[\'6\']].X("V")).1p(\'Y\',\'Y 1q\'));(8(){c[m[\'6\']].R("z-1D",m[\'6\'])}).1c(h);(8(){m[\'1u\']=1x}).1c(h)}).1m(h+g);(8(){9(!j)11(f,m)}).1c(h+g)}}8 1n(a,b,c,d,e,f,g,h,i,j,k){7 l=d.W-1;9(!j[\'1u\']&&g!=j[\'6\']){7 m=j[\'6\'];j[\'6\']=g;d[j[\'6\']].R("z-1D",l+1);P O.18(d[m],{S:f}).Q(1,0);j[\'1u\']=1k;P O.18(d[j[\'6\']],{S:f}).Q(0,1);1N(c,e,j[\'6\'],h,f);2h(i){14 0:15;14 1:P O.12(d[j[\'6\']],\'1b-1E\',{S:f}).Q((-1)*d[j[\'6\']].Z().10.y,0);15;14 2:P O.12(d[j[\'6\']],\'1b-1i\',{S:f}).Q((-1)*d[j[\'6\']].Z().10.x,0);15;14 3:P O.12(d[j[\'6\']],\'1b-1E\',{S:f}).Q(d[j[\'6\']].Z().10.y,0);15;14 4:P O.12(d[j[\'6\']],\'1b-1i\',{S:f}).Q(d[j[\'6\']].Z().10.x,0);15}9(a)a[m].1r({"1e":j[\'1j\']+"19 1f "+j[\'1H\']});9(a)a[j[\'6\']].1r({"1e":j[\'1j\']+"19 1f "+j[\'1G\']});9(k.W>0)k[m].1o("V",(k[m].X("V")).1p(\'Y 1q\',\'Y\'));9(k.W>0)k[j[\'6\']].1o("V",(k[j[\'6\']].X("V")).1p(\'Y\',\'Y 1q\'));(8(){d[j[\'6\']].R("z-1D",j[\'6\'])}).1c(f);(8(){j[\'1u\']=1x}).1c(f);11(b,j)}}8 11(a,b){7 c=$(a);$16(b[\'1C\']);b[\'1C\']=1x;9($E(".1g",c))$E(".1g",c).R("1a","2f");9($E(".11",c))$E(".11",c).R("1a","1h")}',62,186,'||||||actual_slide|var|function|if|||||||||||||||||||||||||||||||||||||||||Fx|new|start|setStyle|duration|addEvent|this|class|length|getProperty|tick|getSize|size|gk_news_image_1_pause|Style|each|case|break|clear|click|Opacity|px|display|margin|delay|getElementsBySelector|border|solid|gk_news_image_1_play|none|left|thumbnail_border|true|innerHTML|periodical|gk_news_image_1_anim2|setProperty|replace|active|setStyles|else|timer_right|actual_animation_p|return|window|false|gk_news_image_1_text_bg|Event|preventDefault|right|actual_animation|index|top|element|thumbnail_border_color|thumbnail_border_color_inactive|gk_news_image_1_preloader|ES|50|gk_news_image_1_anim|gk_news_image_1_text|gk_news_image_1_text_anim|extend|initialize|parent|height|toggle|getStyle|toInt|scrollHeight|show|set|now|opacity|gk_news_image_1_slide|push|title|alt|style|setOpacity|location|gk_news_image_1_tb|getParent|width|mouseenter|scrollTo|mouseout|gk_news_image_1_prev|gk_news_image_1_next|block|outter_readmore|switch|Height|overflow|hidden|load|gk_news_image_1_wrapper|id|Gavick|anim_speed|anim_interval|autoanim|anim_type|anim_type_t|thumbnail_width|thumbnail_margin|bgcolor|Element|img|src|injectAfter|remove|complete|400|200|ie|toFloat|clickable_slides|cursor|pointer|gk_news_image_1_tick_buttons|gk_news_image_1_news_text|gk_news_image_1_tb_prev|gk_news_image_1_tb_next|gk_news_image_1_thumb|Math|floor|Scroll|transition|Transitions|linear|toLeft|gk_news_image_1_tbo|toRight|href|250'.split('|'),0,{}))

/*
# ------------------------------------------------------------------------
# JA Tabs Plugins for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - PHP files are GNU/GPL V2. CSS / JS are Copyrighted Commercial,
# bound by Proprietary License of JoomlArt. For details on licensing,
# Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# Redistribution, Modification or Re-licensing of this file in part of full,
# is bound by the License applied.
# ------------------------------------------------------------------------
*/
var wrap_W = 0;
var JATabs = new Class({
	initialize: function(element, options) {
		this.options = $extend({
			position:			'top',
			width:				'100%',
			height:				'auto',
			skipAnim:			false,
			animType:			'animMoveHor',
			mouseType:			'mouseover',
			changeTransition:	Fx.Transitions.Pow.easeIn,
			duration:			1000,
			mouseOverClass:		'hover',
			activateOnLoad:		'first',
			useAjax: 			false,
			ajaxUrl: 			'',
			ajaxOptions: 		'get',
			ajaxLoadingText: 	'Loading...',
			fixheight :			 1,
			fixwidth :			 1,
			colors: ''
		}, options || {});

		this.el = $(element);
		this.elid = element;

		this._W = this.el.offsetWidth.toInt();
		wrap_W = this._W;

		if(this.options.height=='auto'){
			this.options.fixheight = 0;
		}
		//tab colors
		if($type(this.options.colors)=='string'){
			regex = /(\d*):([^,]*)/gi;
			var colors = [];
			while((result = regex.exec (this.options.colors)))
				colors[result[1]]=result[2];

			this.options.colors = colors;
		}

		//this._H = this.el.getParent().getStyle('height').toInt();
		this._H = this.el.getParent().offsetHeight.toInt();
		this.panels = $$('#' + this.elid + ' .ja-tab-content');
		this.panelwrap = this.el.getElement('.ja-tab-panels-'+this.options.position);

		this.divtitles = $$('#' + this.elid + ' .ja-tabs-title-'+this.options.position);

		this.titles = $$('#' + this.elid + ' div.ja-tabs-title-'+this.options.position+' ul li');

		this.boxTab_H = this.el.getElement('ul.ja-tabs-title').offsetHeight + this.el.getElement('ul.ja-tabs-title').offsetTop;

		//add
		if (this.panels.length <= 1)
		{
			this.panels.setStyle ('position', 'relative');
			return;
		}

		this.titles.each(function(item,i) {
			var color = item.getElement('h3').className;
			if (!color) color=this.options.colors[i];
			item._color = '';
			if (color) {
				item.addClass (color);
				item._color = color;
			}

			item.addEvent(this.options.mouseType, function(){
					if (item.className.indexOf('active') != -1)	return;

					item.removeClass(this.options.mouseOverClass);
					this.activate(item,  this.options.skipAnim);
				}.bind(this)
			);

			item.addEvent('mouseover', function() {
				if(item != this.activeTitle)
				{
					item.addClass(this.options.mouseOverClass);
				}
			}.bind(this));

			item.addEvent('mouseout', function() {
				if(item != this.activeTitle)
				{
					item.removeClass(this.options.mouseOverClass);

				}
			}.bind(this));
		}.bind(this));


		this.titles[0].addClass('first');
		this.titles[this.titles.length-1].addClass('last');
		this.titles[0].addClass ('active');

		//height of title (for left, right, bottom)
		//this.tabHeight = $E('.ja-tabs-title-'+this.options.position, this.el);
		this.tabHeight = this.el.getElement('.ja-tabs-title-'+this.options.position);

		//Panel contents
		this.minHeight = 0;
		/*if((this.options.position=='left') || (this.options.position=='right')){

	      	this.minHeight = this.tabHeight.offsetHeight;
		    if (!this.options.fixheight ){
				this.divtitles.setStyle ('height', this.minHeight);
			}
	    }	*/

		/* Set height for DIV tabswrap and position Top*/
		if (!this.options.fixheight )
		{
			this.panelwrap.setStyle ('height', this.minHeight);
		}
		else if((this.options.position!='left') && (this.options.position!='right')){
			this.panelwrap.setStyle ('height', this._H - this.titles[0].offsetHeight.toInt());
		}

		/* Set set width for left/right tabs*/
		if((this.options.position=='left') || (this.options.position=='right')){
			var maxw = eval(this._W - this.divtitles[0].offsetWidth.toInt() -10);
			this.panelwrap.setStyle ('width', maxw);
		}

		this.titles.each(function(el,i){
			el.panel = this.panels[i];
			el.panel._idx = i;
		},this);

		if (this.options.skipAnim) this.options.animType = 'animNone';

		//Set default type for animation if needed
		if ((eval('typeof '+this.options.animType) == 'undefined') || (eval('$type ('+this.options.animType+')') != 'class')){
			this.options.animType = 'animFade';
		}

		//Create animation object
		this.anim = eval ('new '+this.options.animType + '(this)');

		if(this.options.activateOnLoad != 'none')
		{
			if(this.options.activateOnLoad == 'first')
			{
				this.activate(this.titles[0],  true);
			}
			else
			{
				this.activate(this.options.activateOnLoad, true);
			}
		}

		if (window.ie) this.firstload = true;
		window.addEvent('resize', this.resize.bind(this));

	},

	resize: function () {

		/* Set set width for left/right tabs*/
		this._W = this.el.offsetWidth;

		maxW = this._W;

    	if((this.options.position=='left') || (this.options.position=='right')){
	      	this.minHeight = this.tabHeight.offsetHeight + 10;
		    if (!this.options.fixheight ){
				//this.divtitles.setStyle ('height', Math.max(this.boxTab_H,this.activeTitle.panel.offsetHeight+10));
			}
			maxW = this._W - this.divtitles[0].offsetWidth.toInt() -10;
			this.panelwrap.setStyle('width', maxW);
	    }
    	else{
    		this.panelwrap.setStyle('height', Math.max(this.minHeight,this.activeTitle.panel.offsetHeight));
    	}
		if(wrap_W!=this._W){this.anim.reposition();};
	},

	activate: function(tab, skipAnim){
	    if (this.options.useAjax) this.cancelAjax();

		if (this.options.useAjax && !tab.loaded) {
			this._getContent(tab);
			this.activeTitle = tab;
	        return;
	    }

		if(! $defined(skipAnim))
		{
			skipAnim = false;
		}
		if($type(tab) == 'string')
		{
			myTab = $$('#' + this.elid + ' ul li').filterByAttribute('title', '=', tab)[0];
			tab = myTab;
		}

		if($type(tab) == 'element')
		{
			//add 5
			var newTab = tab.panel;
			var curTab = this.activePanel;
			this.activePanel = newTab;

			this.anim.move (curTab, newTab, skipAnim);

			this.titles.removeClass('active');
			tab.addClass('active');
			if (this.activeTitle && this.activeTitle._color) this.panelwrap.removeClass (this.activeTitle._color);
			if (tab._color) this.panelwrap.addClass (tab._color);

			this.activeTitle = tab;

			if (!this.options.fixheight) {
				if (skipAnim) {
					this.panelwrap.setStyle('height', Math.max(this.minHeight, this.activePanel.offsetHeight));
					if((this.options.position=='left') || (this.options.position=='right')){
						this.tabHeight.setStyle('height', Math.max(this.minHeight, this.panelwrap.offsetHeight, this.boxTab_H));
					}
				} else {
					if (!this.mainfx) this.mainfx = new Fx.Style(this.panelwrap, 'height',{duration:this.options.duration});
					//this.mainfx.start(this.panelwrap.offsetHeight, Math.max(this.minHeight,this.activeTitle.panel.offsetHeight+10));
					this.mainfx.stop();
					this.mainfx.start(Math.max(this.minHeight,this.activePanel.offsetHeight));

					if((this.options.position=='left') || (this.options.position=='right')){
						if(!this.changeEffectTitle) this.changeEffectTitle = new Fx.Style(this.tabHeight, 'height', {duration: this.options.duration});
						this.changeEffectTitle.start(Math.max(this.activePanel.offsetHeight, this.boxTab_H));
					}
				}
			}
			else{
				this.panelwrap.setStyle('height', this.options.height);
				this.tabHeight.setStyle('height', this.options.height);
			}
		}

	},
	cancelAjax: function() {
	  if (this.loadingTab) {
	    	this.tabRequest.cancel();
	      	this.loadingTab.imgLoading.remove();
	  		this.tabRequest = null;
	  		this.loadingTab = null;
	    }
  	},

	_getContent: function(tab){

		this.loadingTab = tab;
		var ids = this.options.ids.split(',');

		if(!ids.length || ids[tab.panel._idx]==undefined) return '';

		var h3 = $(this.loadingTab.getElementsByTagName('H3')[0]);
		var imgloading = new Element('img', {'src': 'plugins/content/ja_tabs/loading.gif','width': 13});
		if (this.options.position=='right') imgloading.inject(h3,'top');
		else imgloading.inject(h3);
		this.loadingTab.imgLoading = imgloading;
		this.tabRequest = new Ajax(this.options.ajaxUrl+ '&tab=' + ids[tab.panel._idx], {method:this.options.ajaxOptions,onComplete:this.update.bind(this)});
		this.tabRequest.request();

	},
	update: function (text) {
		if (!this.loadingTab) return;
		this.loadingTab.panel.subpanel = this.loadingTab.panel.getElement('.ja-tab-subcontent');
		this.loadingTab.panel.subpanel.innerHTML = text;
		this.loadingTab.loaded = true;
		this.tabRequest = null;
		var tab = this.loadingTab;
		this.loadingTab = null;

		var images = tab.panel.subpanel.getElements ('img');

		tab.switched = false;
		/**/
		if (images && images.length && !tab.imgLoaded) {
			var imgs = [];
			images.each (function (image) {imgs.push(image.src)});
			if (imgs.length) {
				new Asset.images(imgs, {
					onComplete: function(){
						this.switchTab(tab);
					}.bind(this)

				});

				tab.imgLoaded = true;

				//call this start if cannot load image after sometime
				//this.switchTab.delay (3000, this, tab);
				return ;
			}
		}
		this.switchTab (tab);
	},

	switchTab: function (tab) {
		if (tab.switched) return;
		tab.switched = true;
		tab.imgLoading.remove();

		this.anim.reposition();
		this.activate (tab);
	}
});
var animNone = new Class ({
	initialize: function(tabwrap) {
		this.options = tabwrap.options || {};
		this.tabwrap = tabwrap;

		this.tabwrap.panels.setStyle('position', 'absolute');
		this.tabwrap.panels.setStyle('left', 0);
	},

	move: function (curTab, newTab, skipAnim) {
		this.tabwrap.panels.setStyle('display', 'none');
		newTab.setStyle('display', 'block');
	},

	reposition: function() {

	}
});

var animFade = new Class ({
	initialize: function(tabwrap) {
		this.options = tabwrap.options || {};
		this.tabwrap = tabwrap;
		this.changeEffect = new Fx.Elements(this.tabwrap.panels, {duration: this.options.duration});
		this.tabwrap.panels.setStyles({'opacity':0,'width':'100%'});
	},

	move: function (curTab, newTab, skipAnim) {
		if(this.options.changeTransition != 'none' && skipAnim==false)
		{
			if (curTab)
			{
				curOpac = curTab.getStyle('opacity');
				var changeEffect = new Fx.Style(curTab, 'opacity', {duration: this.options.duration, transition: this.options.changeTransition});
				changeEffect.stop();
				changeEffect.start(curOpac,0);
			}
			curOpac = newTab.getStyle('opacity');
			var changeEffect = new Fx.Style(newTab, 'opacity', {duration: this.options.duration, transition: this.options.changeTransition});
			changeEffect.stop();
			changeEffect.start(curOpac,1);
		} else {
			if (curTab) curTab.setStyle('opacity', 0);
			newTab.setStyle('opacity', 1);
		}
	},
	reposition: function() {
	    if (this.tabwrap.activePanel) {
			this.changeEffect.stop();

			for (var i=this.tabwrap.activePanel._idx-1;i>=0;i--) {
			    this.tabwrap.panels[i].setStyle('opacity',0);
			}
		    for (i=this.tabwrap.activePanel._idx+1;i<this.tabwrap.panels.length;i++) {
		       this.tabwrap.panels[i].setStyle('opacity',0);
		     }
	    }
	}
});

var animMoveHor = new Class ({
	initialize: function(tabwrap) {
		this.options = tabwrap.options || {};
		this.tabwrap = tabwrap;
		this.changeEffect = new Fx.Elements(this.tabwrap.panels, {duration: this.options.duration});
	    var left = 0;
	    this.tabwrap.panels.each (function (panel) {
	      panel.setStyle('left', left);
	      left += panel.offsetWidth;
	    });
	    this.tabwrap.panels.setStyle('top', 0);
	},

	move: function (curTab, newTab, skipAnim) {
		if(this.options.changeTransition != 'none' && !skipAnim)
		{
			this.changeEffect.stop();
			var obj = {};
			var offset = newTab.offsetLeft.toInt();
			i=0;

			this.tabwrap.panels.each(function(panel) {
				obj[i++] = {'left':[panel.offsetLeft.toInt(), panel.offsetLeft.toInt() - offset] };
			});

			this.changeEffect.start(obj);
		}
	},
	reposition: function() {
	    if (this.tabwrap.activePanel) {
			this.changeEffect.stop();
	       	var left = this.tabwrap.activePanel.offsetLeft;
		    for (var i=this.tabwrap.activePanel._idx-1;i>=0;i--) {
		       left -= this.tabwrap.panels[i].offsetWidth;
		       this.tabwrap.panels[i].setStyle('left',left);
		     }
	       	var left = this.tabwrap.activePanel.offsetLeft;
		    for (i=this.tabwrap.activePanel._idx+1;i<this.tabwrap.panels.length;i++) {
		       left += this.tabwrap.panels[i-1].offsetWidth;
		       this.tabwrap.panels[i].setStyle('left',left);
		     }
	    }
	}
});

var animMoveVir = new Class ({
	initialize: function(tabwrap) {
		this.options = tabwrap.options || {};
		this.tabwrap = tabwrap;
		this.changeEffect = new Fx.Elements(this.tabwrap.panels, {duration: this.options.duration});

	    var top = 0;
	    this.tabwrap.panels.each (function (panel) {
	      panel.setStyle('top', top);
	      top += Math.max(panel.offsetHeight,  panel.getParent().getParent().offsetHeight);
	    });
	    this.tabwrap.panels.setStyle('left', 0);
	},
	move: function (curTab, newTab, skipAnim) {
		if(this.options.changeTransition != 'none' && skipAnim==false)
		{
      //reposition newTab

			this.changeEffect.stop();
			var obj = {};
			var offset = newTab.offsetTop.toInt();
			i=0;
			this.tabwrap.panels.each(function(panel) {
				obj[i++] = {'top':[panel.offsetTop.toInt(), panel.offsetTop.toInt() - offset]};
			});
			this.changeEffect.start(obj);
		}
	},
	reposition: function() {
	    if (this.tabwrap.activePanel) {
				 this.changeEffect.stop();
	       var top = this.tabwrap.activePanel.offsetTop;
		     for (var i=this.tabwrap.activePanel._idx-1;i>=0;i--) {
		       top -= this.tabwrap.panels[i].offsetHeight;
		       this.tabwrap.panels[i].setStyle('top',top);
		     }
	       var top = this.tabwrap.activePanel.offsetTop;
		     for (i=this.tabwrap.activePanel._idx+1;i<this.tabwrap.panels.length;i++) {
			top += this.tabwrap.panels[i-1].offsetHeight;
		     	this.tabwrap.panels[i].setStyle('top',top);
		     }
	    }
	}
});



/*
# ------------------------------------------------------------------------
# JA T3v2 Plugin - Template framework for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - GNU/GPL V2, http://www.gnu.org/licenses/gpl2.html. For details
# on licensing, Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

function switchFontSize (ckname,val){
	var bd = document.getElementsByTagName('body');
	if (!bd || !bd.length) return;
	bd = bd[0];
	var oldclass = 'fs'+CurrentFontSize;
	switch (val) {
		case 'inc':
			if (CurrentFontSize+1 < 7) {
				CurrentFontSize++;
			}
		break;
		case 'dec':
			if (CurrentFontSize-1 > 0) {
				CurrentFontSize--;
			}
		break;
		case 'reset':
		default:
			CurrentFontSize = DefaultFontSize;
	}
	var newclass = 'fs'+CurrentFontSize;
	bd.className = bd.className.replace(new RegExp('fs.?', 'g'), '');
	bd.className = trim(bd.className);
	bd.className += (bd.className?' ':'') + newclass;
	createCookie(ckname, CurrentFontSize, 365);
}

function switchTool (ckname, val) {
	createCookie(ckname, val, 365);
	window.location.reload();
}

function cpanel_reset () {
	var matches = document.cookie.match('(?:^|;)\\s*' + tmpl_name.escapeRegExp() + '_([^=]*)=([^;]*)', 'g');
	if (!matches) return;
	for (i=0;i<matches.length;i++) {
		var ck = matches[i].match('(?:^|;)\\s*' + tmpl_name.escapeRegExp() + '_([^=]*)=([^;]*)');
		if (ck) {
			createCookie (tmpl_name+'_'+ck[1], '', -1);
		}
	}

	if (window.location.href.indexOf ('?')>-1) window.location.href = window.location.href.substr(0,window.location.href.indexOf ('?'));
	else window.location.reload();
}

function cpanel_apply () {
	var elems = document.getElementById('ja-cpanel-main').getElementsByTagName ('*');

	var usersetting = {};
	for (i=0;i<elems.length;i++) {
		var el = elems[i];
	    if (el.name && (match=el.name.match(/^user_(.*)$/))) {
	        var name = match[1];
	        var value = '';
	        if (el.tagName.toLowerCase() == 'input' && (el.type.toLowerCase()=='radio' || el.type.toLowerCase()=='checkbox')) {
	        	if (el.checked) value = el.value;
	        } else {
	        	value = el.value;
	        }
	        if (usersetting[name]) {
	        	if (value) usersetting[name] = value + ',' + usersetting[name];
	        } else {
	        	usersetting[name] = value;
	        }
	    }
	}

	for (var k in usersetting) {
		name = tmpl_name + '_' + k;
		value = usersetting[k];
		createCookie(name, value, 365);
	}

	if (window.location.href.indexOf ('?')>-1) window.location.href = window.location.href.substr(0,window.location.href.indexOf ('?'));
	else window.location.reload();
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function getScreenWidth () {
    var x = 0;
    if (self.innerHeight) {
            x = self.innerWidth;
    } else if (document.documentElement && document.documentElement.clientHeight) {
            x = document.documentElement.clientWidth;
    } else if (document.body) {
            x = document.body.clientWidth;
    }
    return x;
}

function equalHeight (els) {
	els = $$_(els);
	if (!els || els.length < 2) return;
	var maxh = 0;
	var els_ = [];
	els.each(function(el, i){
		if (!el) return;
		//els_[i] = getDeepestWrapper (el);
		els_[i] = el;
		var ch = els_[i].getCoordinates().height;
		maxh = (maxh < ch) ? ch : maxh;
	},this);

	els_.each(function(el, i){
		if (!el) return;
		if (maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt() > 0) el.setStyle('min-height', maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());
	},this);
}

function getDeepestWrapper (el) {
	while (el.getChildren().length==1)
	{
		el = el.getChildren()[0];
	}
	return el;
}

function fixHeight (els, group1, group2) {
	els = $$_(els);
	group1 = $$_(group1);
	group2 = $$_(group2);
	if (!els || !group1) return;
	var height = 0;
	group1.each (function (el){
		if (!el) return;
		height += el.getCoordinates().height;
	});
	if (group2) {
		group2.each (function (el){
			if (!el) return;
			height -= el.getCoordinates().height;
		});
	}
	els.each(function(el, i){
		if (!el) return;
		if (height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt() > 0) el.setStyle('min-height', height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());
	});
}

function addFirstLastItem (el) {
	el = $(el);
	if (!el || !el.getChildren() || !el.getChildren().length) return;
	el.getChildren ()[0].addClass ('first-item');
	el.getChildren ()[el.getChildren ().length-1].addClass ('last-item');
}

function $$_ (els) {
	if ($type(els)=='string') return $$(els);
	var els_ = [];
	els.each (function (el){
		el = $(el);
		if (el) els_.push (el);
	});
	return els_;
}


/*
# ------------------------------------------------------------------------
# JA T3v2 Plugin - Template framework for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - GNU/GPL V2, http://www.gnu.org/licenses/gpl2.html. For details
# on licensing, Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

var jaMegaMenuMoo = new Class({

	initialize: function(menu, options){
		this.options = $extend({
			slide:	true, //enable slide
			duration: 300, //slide speed. lower for slower, bigger for faster
			fading: false, //Enable fading
			bgopacity: 0.9, //set the transparent background. 0 to disable, 0<bgopacity<1: the opacity of the background
			delayHide: 500,
			direction: 'down',
			action: 'mouseenter', //mouseenter or click
			hidestyle: 'normal'
		}, options || {});
		this.menu = menu;
		this.childopen = new Array();
		/*
		if (typeof(window.loaded) == 'undefined' || window.loaded) {
			this.imageloaded = false;
			this.start();
		} else {*/
			this.imageloaded = false;
			this.loaded = false;
			//window.addEvent('load', this.start.bind(this));
			this.start();
		//}
	},

	start: function () {
		//do nothing if loaded
		if (this.loaded) return;

		this.menu = $(this.menu);
		//preload images
		var images = this.menu.getElements ('img');
		if (images && images.length && !this.imageloaded) {
			var imgs = [];
			images.each (function (image) {imgs.push(image.src)});
			if (imgs.length) {
				new Asset.images(imgs, {
					onComplete: function(){
						this.start();
					}.bind(this)
				});
				this.imageloaded = true;

				//call this start if cannot load image after sometime
				this.start.delay (3000, this);
				return ;
			}
		}

		//mark as called
		this.loaded = true;

		//get wrapper
		p = this.menu;
		while (p=p.getParent()) {
			if (p.hasClass ('main') || p.hasClass ('wrap')) {this.wrapper = p; break;}
		}
		this.items = this.menu.getElements ('li.mega');
		//this.items.setStyle ('position', 'relative');
		this.items.each (function(li) {
			//link item
			if ((a = li.getElement('a.mega')) && this.isChild (a, li)) li.a = a;
			else li.a = null;
			//parent
			li._parent = this.getParent (li);
			//child content
			if ((childcontent = li.getElement('.childcontent')) && this.isChild (childcontent, li)) {
				li.childcontent = childcontent;
				li.childcontent_inner = li.childcontent.getElement ('.childcontent-inner-wrap');
				var coor = li.childcontent_inner.getCoordinates ();
				li._w = li.getElement('.childcontent-inner').offsetWidth;
				li._h = li.getElement('.childcontent-inner').offsetHeight;

				li.level0 = li.getParent().hasClass('level0');
				//
				li.childcontent.setStyles ({'width':li._w+10, 'height':li._h});
				li.childcontent_inner.setStyles ({'width':li._w});
				//fix for overflow
				li.childcontent_inner1 = li.childcontent.getElement ('.childcontent-inner');
				li.childcontent_inner1.ol = false;
				if (li.childcontent_inner1.getStyle ('overflow') == 'auto' || li.childcontent_inner1.getStyle ('overflow') == 'scroll') {
					li.childcontent_inner1.ol = true;
					//fix for ie6/7
					if (window.ie6 || window.ie7) {
						li.childcontent_inner1.setStyle ('position', 'relative');
					}

					if (window.ie6) {
						li.childcontent_inner1.setStyle ('height', li.childcontent_inner1.getStyle ('max-height') || 400);
					}
				}

				//show direction
				if (this.options.direction == 'up') {
					if (li.level0) {
						li.childcontent.setStyle ('top', -li.childcontent.offsetHeight); //ajust top position
					} else {
						li.childcontent.setStyle ('bottom', 0);
					}
				}

				if (li.level0) {
					//check position
					var lcor = li.getCoordinates();
					var ccor = li.childcontent.getCoordinates();
					var ml = 0;
					var l = lcor.left;
					var r = l + ccor.width;
					if (this.wrapper) {
						var wcor = this.wrapper.getCoordinates();
						l = l - wcor.left;
						r = wcor.right - r + 10;
					} else {
						r = window.getWidth() - r + 10;
					}
					if (l < 0 || l+r < 0) {
						ml = - l;
					} else if (r < 0) {
						ml = r;
					}
					li.childcontent.setStyle ('margin-left', ml);
/*
					var pos = li.getPosition();
					var win = {'x': window.getWidth(), 'y': window.getHeight()};
					var scroll = {'x': window.getScrollLeft(), 'y': window.getScrollTop()};
					if (pos['x'] + li.childcontent.offsetWidth > win['x'] + scroll ['x']) li.childcontent.setStyle ('right', 0);
*/
				}
			}
			else li.childcontent = null;

			if (li.childcontent && this.options.bgopacity) {
				//Make transparent background
				var bg = new Element ('div', {'class':'childcontent-bg'});
				bg.injectTop (li.childcontent_inner);
				bg.setStyles ({'width':'100%', 'height':li._h, 'opacity':this.options.bgopacity,
								'position': 'absolute', 'top': 0, 'left': 0, 'z-index': 1
								});
				if (li.childcontent.getStyle('background')) bg.setStyle ('background', li.childcontent.getStyle('background'));
				if (li.childcontent.getStyle('background-image')) bg.setStyle ('background-image', li.childcontent.getStyle('background-image'));
				if (li.childcontent.getStyle('background-repeat')) bg.setStyle ('background-repeat', li.childcontent.getStyle('background-repeat'));
				if (li.childcontent.getStyle('background-color')) bg.setStyle ('background-color', li.childcontent.getStyle('background-color'));
				li.childcontent.setStyle ('background', 'none');
				li.childcontent_inner.setStyles ({'position':'relative', 'z-index': 2});
			}

			if (li.childcontent && (this.options.slide || this.options.fading)) {
				//li.childcontent.setStyles ({'width': li._w});
				li.childcontent.setStyles ({'left':'auto'});
				if (li.childcontent.hasClass ('right')) li.childcontent.setStyle ('right', 0);
				if (this.options.slide) {
					li.childcontent.setStyles ({'left':'auto', 'overflow':'hidden'});
					if (li.level0) {
						if (this.options.direction == 'up') {
							li.childcontent_inner.setStyle ('bottom', -li._h-20);
						} else {
							li.childcontent_inner.setStyle ('margin-top', -li._h-20);
						}

					} else {
						li.childcontent_inner.setStyle ('margin-left', -li._w-20);
					}
				}
				if (this.options.fading) {
					li.childcontent_inner.setStyle ('opacity', 0);
				}
				//Init Fx.Styles for childcontent
				li.fx = new Fx.Styles(li.childcontent_inner, {duration: this.options.duration, transition: Fx.Transitions.linear, onComplete: this.itemAnimDone.bind(this, li)});
				//effect
				li.eff_on = {};
				li.eff_off = {};
				if (this.options.slide) {
					if (li.level0) {
						if (this.options.direction == 'up') {
							li.eff_on ['bottom'] = 0;
							li.eff_off ['bottom'] = -li._h;
						} else {
							li.eff_on ['margin-top'] = 0;
							li.eff_off ['margin-top'] = -li._h;
						}
					} else {
						li.eff_on['margin-left'] = 0;
						li.eff_off['margin-left'] = -li._w;
					}
				}
				if (this.options.fading) {
					li.eff_on['opacity'] = 1;
					li.eff_off['opacity'] = 0;
					//li.eff_off['margin-top'] = -li._h;
				}
			}

			if (this.options.action=='click' && li.childcontent) {
				li.addEvent('click', function(e) {
					var event = new Event (e);
					if (li.hasClass ('group')) return;
					if (li.childcontent) {
						if (li.status == 'open') {
							if (this.cursorIn (li, event)) {
								this.itemHide (li);
							} else {
								this.itemHideOthers(li);
							}
						} else {
							this.itemShow (li);
						}
					} else {
						if (li.a) location.href = li.a.href;
					}
					event.stop();
				}.bind (this));

				//If action is click, click on windows will close all submenus
				this.windowClickFn = function (e) {
					this.itemHideOthers(null);
				}.bind (this);
			}

			if (this.options.action == 'mouseover' || this.options.action == 'mouseenter') {
				li.addEvent('mouseenter', function(e) {
					if (li.hasClass ('group')) return;
					$clear (li.timer);
					this.itemShow (li);
					e.stop();
				}.bind (this));

				li.addEvent('mouseleave', function(e) {
					if (li.hasClass ('group')) return;
					$clear (li.timer);
					if (li.childcontent) li.timer = this.itemHide.delay(this.options.delayHide, this, [li, e]);
					else this.itemHide (li, e);
					e.stop();
				}.bind (this));

				//if has childcontent, don't goto link before open childcontent - fix for touch screen
				if (li.a && li.childcontent) {
					li.clickable = false;
					li.a.addEvent ('click',function (e){
						if (!li.clickable) {
							new Event(e).stop();
						}
					}.bind (this));
				}

			}

			//when click on a link - close all open childcontent
			if (li.a && !li.childcontent) {
				li.a.addEvent ('click',function (e){
					this.itemHideOthers (null);
					//Remove current class
					this.menu.getElements ('.active').removeClass ('active');
					//Add current class
					var p = li;
					while (p) {
						p.addClass ('active');
						p.a.addClass ('active');
						p = p._parent;
					}
					//new Event (e).stop();
				}.bind (this));
			}
		},this);

		if (this.options.slide || this.options.fading) {
			//hide all content child
			this.menu.getElements('.childcontent').setStyle ('display', 'none');
		}

	},

	getParent: function (li) {
		var p = li;
		while ((p=p.getParent())) {
			if (this.items.contains (p) && !p.hasClass ('group')) return p;
			if (!p || p == this.menu) return null;
		}
	},

	cursorIn: function (el, event) {
		if (!el || !event) return false;
		var pos = $merge (el.getPosition(), {'w':el.offsetWidth, 'h': el.offsetHeight});;
		var cursor = {'x': event.page.x, 'y': event.page.y};

		if (cursor.x>pos.x && cursor.x<pos.x+el.offsetWidth
				&& cursor.y>pos.y && cursor.y<pos.y+el.offsetHeight) return true;
		return false;
	},

	isChild: function (child, parent) {
		return !!parent.getChildren().contains (child);
	},

	itemOver: function (li) {
		if (li.hasClass ('haschild'))
			li.removeClass ('haschild').addClass ('haschild-over');
		li.addClass ('over');
		if (li.a) {
			li.a.addClass ('over');
		}
	},

	itemOut: function (li) {
		if (li.hasClass ('haschild-over'))
			li.removeClass ('haschild-over').addClass ('haschild');
		li.removeClass ('over');
		if (li.a) {
			li.a.removeClass ('over');
		}
	},

	itemShow: function (li) {
		clearTimeout(li.timer);
		if (li.status == 'open') return; //don't need do anything
		//Setup the class
		this.itemOver (li);
		//push to show queue
		li.status = 'open';
		this.enableclick.delay (100, this, li);
		this.childopen.push (li);
		//hide other
		this.itemHideOthers (li);
		if (li.childcontent) {
			if (this.options.action=='click' && this.childopen.length && !this.windowClickEventAdded) {
				//addEvent click for window
				$(document.body).addEvent ('click', this.windowClickFn);
				this.windowClickEventAdded = true;
			}
		}

		if (!$defined(li.fx) || !$defined(li.childcontent)) return;

		li.childcontent.setStyle ('display', 'block');

		if (!li.level0) {
			//check if it's out of view-port
			var lcor = li.getCoordinates();
			var ccor = li.childcontent.getCoordinates();
			var ml = 0;
			var l = ccor.left;
			var r = l + ccor.width;
			if (this.wrapper) {
				var wcor = this.wrapper.getCoordinates();
				l = l - wcor.left;
				r = wcor.right - r + 10;
			} else {
				r = window.getWidth() - r + 10;
			}
			if (r < 0) {
				//change the direction and position for submenu
				li.childcontent.setStyle ('margin-left', -ccor.width + 20);
				li.eff_on['margin-left'] = 0;
				li.eff_off['margin-left'] = li._w + 20;
				li.childcontent_inner.setStyle ('margin-left', li.eff_off['margin-left']);
			}
		}

		li.childcontent.setStyles ({'overflow': 'hidden'});
		if (li.childcontent_inner1.ol) li.childcontent_inner1.setStyles ({'overflow': 'hidden'});
		li.fx.stop();
		li.fx.start (li.eff_on);
		//if (li._parent) this.itemShow (li._parent);
	},

	itemHide: function (li, e) {
		if (e && e.page) { //if event
			if (this.cursorIn (li, e) || this.cursorIn (li.childcontent, e)) {
				return;
			} //cursor in li
			var p=li._parent;
			if (p && !this.cursorIn (p, e) && !this.cursorIn(p.childcontent, e)) {
				p.fireEvent ('mouseleave', e); //fire mouseleave event
			}
		}
		clearTimeout(li.timer);
		this.itemOut(li);
		li.status = 'close';
		this.childopen.remove (li);
		if (li.childcontent) {
			if (this.options.action=='click' && !this.childopen.length && this.windowClickEventAdded) {
				//removeEvent click for window
				$(document.body).removeEvent ('click', this.windowClickFn);
				this.windowClickEventAdded = false;
			}
		}

		if (!$defined(li.fx) || !$defined(li.childcontent)) return;

		if (li.childcontent.getStyle ('opacity') == 0) return;
		li.childcontent.setStyles ({'overflow': 'hidden'});
		if (li.childcontent_inner1.ol) li.childcontent_inner1.setStyles ({'overflow': 'hidden'});
		li.fx.stop();
		switch (this.options.hidestyle) {
		case 'fast':
			li.fx.options.duration = 100;
			li.fx.start ($merge(li.eff_off,{'opacity':0}));
			break;
		case 'fastwhenshow': //when other show
			if (!e) { //force hide, not because of event => hide fast
				//li.fx.options.duration = 300;
				li.fx.start ($merge(li.eff_off,{'opacity':0}));
			} else {	//hide as normal
				li.fx.start (li.eff_off);
			}
			break;
		case 'normal':
		default:
			li.fx.start (li.eff_off);
			break;
		}
		//li.fx.start (li.eff_off);
	},

	itemAnimDone: function (li) {
		//hide done
		if (li.status == 'close'){
			//reset duration and enable opacity if not fading
			if (this.options.hidestyle.test (/fast/)) {
				li.fx.options.duration = this.options.duration;
				if (!this.options.fading) li.childcontent_inner.setStyle ('opacity', 1);
			}
			//hide
			li.childcontent.setStyles ({'display': 'none'});
			this.disableclick.delay (100, this, li);
		}

		//show done
		if (li.status == 'open'){
			li.childcontent.setStyles ({'overflow': ''});
			if (li.childcontent_inner1.ol) li.childcontent_inner1.setStyles ({'overflow-y': 'auto'});
		}
	},

	itemHideOthers: function (el) {
		var fakeevent = null
		if (el && !el.childcontent) fakeevent = {};
		var curopen = this.childopen.copy();
		curopen.each (function(li) {
			if (li && typeof (li.status) != 'undefined' && (!el || (li != el && !li.hasChild (el)))) {
				this.itemHide(li, fakeevent);
			}
		},this);
	},

	enableclick: function (li) {
		if (li.a && li.childcontent) li.clickable = true;
	},
	disableclick: function (li) {
		if (li.a && li.childcontent) li.clickable = false;
	}
});


/**
* @version		$Id: caption.js 5263 2006-10-02 01:25:24Z webImagery $
* @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

/**
* JCaption javascript behavior
*
* Used for displaying image captions
*
* @package	Joomla
* @since	1.5
* @version	1.0
*/
var JCaption = new Class({
	initialize: function(selector)
	{
		this.selector = selector;

		var images = $$(selector);
		images.each(function(image){ this.createCaption(image); }, this);
	},

	createCaption: function(element)
	{
		var caption   = document.createTextNode(element.title);
		var container = document.createElement("div");
		var text      = document.createElement("p");
		var width     = element.getAttribute("width");
		var align     = element.getAttribute("align");

		if(!width) {
			width = element.width;
		}

		//Windows fix
		if (!align)
			align = element.getStyle("float");  // Rest of the world fix
		if (!align) // IE DOM Fix
			align = element.style.styleFloat;

		if (align=="") {
			align="none";
		}

		text.appendChild(caption);
		text.className = this.selector.replace('.', '_');

		element.parentNode.insertBefore(container, element);
		container.appendChild(element);
		if ( element.title != "" ) {
			container.appendChild(text);
		}
		container.className   = this.selector.replace('.', '_');
		container.className   = container.className + " " + align;
		container.setAttribute("style","float:"+align);

		container.style.width = width + "px";

	}
});

document.caption = null;
window.addEvent('load', function() {
	var caption = new JCaption('img.caption')
	document.caption = caption
});



/**
 * SqueezeBox - Expandable Lightbox
 *
 * Allows to open various content as modal,
 * centered and animated box.
 *
 * Inspired by
 *  ... Lokesh Dhakar	- The original Lightbox v2
 *  ... Cody Lindley	- ThickBox
 *
 * @version		1.0rc1
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */
var SqueezeBox = {

	presets: {
		size: {x: 600, y: 450},
		sizeLoading: {x: 200, y: 150},
		marginInner: {x: 20, y: 20},
		marginImage: {x: 150, y: 200},
		handler: false,
		adopt: null,
		closeWithOverlay: true,
		zIndex: 65555,
		overlayOpacity: 0.7,
		classWindow: '',
		classOverlay: '',
		disableFx: false,
		onOpen: Class.empty,
		onClose: Class.empty,
		onUpdate: Class.empty,
		onResize: Class.empty,
		onMove: Class.empty,
		onShow: Class.empty,
		onHide: Class.empty,
		fxOverlayDuration: 250,
		fxResizeDuration: 750,
		fxContentDuration: 250,
		ajaxOptions: {}
	},

	initialize: function(options) {
		if (this.options) return this;
		this.presets = $merge(this.presets, options)
		this.setOptions(this.presets);
		this.build();
		this.listeners = {
			window: this.reposition.bind(this, [null]),
			close: this.close.bind(this),
			key: this.onkeypress.bind(this)};
		this.isOpen = this.isLoading = false;
		this.window.close = this.listeners.close;
		return this;
	},

	build: function() {
		this.overlay = new Element('div', {
			id: 'sbox-overlay',
			styles: {
				display: 'none',
				zIndex: this.options.zIndex
			}
		});
		this.content = new Element('div', {
			id: 'sbox-content'
		});
		this.btnClose = new Element('a', {
			id: 'sbox-btn-close',
			href: '#'
		});
		this.window = new Element('div', {
			id: 'sbox-window',
			styles: {
				display: 'none',
				zIndex: this.options.zIndex + 2
			}
		}).adopt(this.btnClose, this.content);

		if (!window.ie6) {
			this.overlay.setStyles({
				position: 'fixed',
				top: 0,
				left: 0
			});
			this.window.setStyles({
				position: 'fixed',
				top: '50%',
				left: '50%'
			});
		} else {
			this.overlay.style.setExpression('marginTop', 'document.documentElement.scrollTop + "px"');
			this.window.style.setExpression('marginTop', '0 - parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + "px"');

			this.overlay.setStyles({
				position: 'absolute',
				top: '0%',
				left: '0%'
				//,marginTop: "expression(document.documentElement.scrollTop + 'px')"
			});

			this.window.setStyles({
				position: 'absolute',
				top: '0%',
				left: '0%'
				//,marginTop: "(expression(0 - parseInt(this.offsetHeight / 2) + document.documentElement.scrollTop + 'px')"
			});
		}

		$(document.body).adopt(this.overlay, this.window);

		this.fx = {
			overlay: this.overlay.effect('opacity', {
				duration: this.options.fxOverlayDuration,
				wait: false}).set(0),
			window: this.window.effects({
				duration: this.options.fxResizeDuration,
				wait: false}),
			content: this.content.effect('opacity', {
				duration: this.options.fxContentDuration,
				wait: false}).set(0)
		};
	},

	addClick: function(el) {
		return el.addEvent('click', function() {
			if (this.fromElement(el)) return false;
		}.bind(this));
	},

	fromElement: function(el, options) {
		this.initialize();
		this.element = $(el);
		if (this.element && this.element.rel) options = $merge(options || {}, Json.evaluate(this.element.rel));
		this.setOptions(this.presets, options);
		this.assignOptions();
		this.url = (this.element ? (this.options.url || this.element.href) : el) || '';

		if (this.options.handler) {
			var handler = this.options.handler;
			return this.setContent(handler, this.parsers[handler].call(this, true));
		}
		var res = false;
		for (var key in this.parsers) {
			if ((res = this.parsers[key].call(this))) return this.setContent(key, res);
		}
		return this;
	},

	assignOptions: function() {
		this.overlay.setProperty('class', this.options.classOverlay);
		this.window.setProperty('class', this.options.classWindow);
	},

	close: function(e) {
		if (e) new Event(e).stop();
		if (!this.isOpen) return this;
		this.fx.overlay.start(0).chain(this.toggleOverlay.bind(this));
		this.window.setStyle('display', 'none');
		this.trashImage();
		this.toggleListeners();
		this.isOpen = null;
		this.fireEvent('onClose', [this.content]).removeEvents();
		this.options = {};
		this.setOptions(this.presets).callChain();
		return this;
	},

	onError: function() {
		if (this.image) this.trashImage();
		this.setContent('Error during loading');
	},

	trashImage: function() {
		if (this.image) this.image = this.image.onload = this.image.onerror = this.image.onabort = null;
	},

	setContent: function(handler, content) {
		this.content.setProperty('class', 'sbox-content-' + handler);
		this.applyTimer = this.applyContent.delay(this.fx.overlay.options.duration, this, [this.handlers[handler].call(this, content)]);
		if (this.overlay.opacity) return this;
		this.toggleOverlay(true);
		this.fx.overlay.start(this.options.overlayOpacity);
		this.reposition();
		return this;
	},

	applyContent: function(content, size) {
		this.applyTimer = $clear(this.applyTimer);
		this.hideContent();
		if (!content) this.toggleLoading(true);
		else {
			if (this.isLoading) this.toggleLoading(false);
			this.fireEvent('onUpdate', [this.content], 20);
		}
		this.content.empty()[['string', 'array', false].contains($type(content)) ? 'setHTML' : 'adopt'](content || '');
		this.callChain();
		if (!this.isOpen) {
			this.toggleListeners(true);
			this.resize(size, true);
			this.isOpen = true;
			this.fireEvent('onOpen', [this.content]);
		} else this.resize(size);
	},

	resize: function(size, instantly) {
		var sizes = window.getSize();
		this.size = $merge(this.isLoading ? this.options.sizeLoading : this.options.size, size);
		var to = {
			width: this.size.x,
			height: this.size.y,
			marginLeft: - this.size.x / 2,
			marginTop: - this.size.y / 2
			//left: (sizes.scroll.x + (sizes.size.x - this.size.x - this.options.marginInner.x) / 2).toInt(),
			//top: (sizes.scroll.y + (sizes.size.y - this.size.y - this.options.marginInner.y) / 2).toInt()
		};
		$clear(this.showTimer || null);
		this.hideContent();
		if (!instantly) this.fx.window.start(to).chain(this.showContent.bind(this));
		else {
			this.window.setStyles(to).setStyle('display', '');
			this.showTimer = this.showContent.delay(50, this);
		}
		this.reposition(sizes);
	},

	toggleListeners: function(state) {
		var task = state ? 'addEvent' : 'removeEvent';
		this.btnClose[task]('click', this.listeners.close);
		if (this.options.closeWithOverlay) this.overlay[task]('click', this.listeners.close);
		document[task]('keydown', this.listeners.key);
		window[task]('resize', this.listeners.window);
		window[task]('scroll', this.listeners.window);
	},

	toggleLoading: function(state) {
		this.isLoading = state;
		this.window[state ? 'addClass' : 'removeClass']('sbox-loading');
		if (state) this.fireEvent('onLoading', [this.window]);
	},

	toggleOverlay: function(state) {
		this.overlay.setStyle('display', state ? '' : 'none');
		$(document.body)[state ? 'addClass' : 'removeClass']('body-overlayed');
	},

	showContent: function() {
		if (this.content.opacity) this.fireEvent('onShow', [this.window]);
		this.fx.content.start(1);
	},

	hideContent: function() {
		if (!this.content.opacity) this.fireEvent('onHide', [this.window]);
		this.fx.content.stop().set(0);
	},

	onkeypress: function(e) {
		switch (e.key) {
			case 'esc':
			case 'x':
				this.close();
				break;
		}
	},

	reposition: function(sizes) {
		sizes = sizes || window.getSize();
		this.overlay.setStyles({
			//'left': sizes.scroll.x, 'top': sizes.scroll.y,
			width: sizes.size.x,
			height: sizes.size.y
		});
		/*
		this.window.setStyles({
			left: (sizes.scroll.x + (sizes.size.x - this.window.offsetWidth) / 2).toInt(),
			top: (sizes.scroll.y + (sizes.size.y - this.window.offsetHeight) / 2).toInt()
		});
		*/
		this.fireEvent('onMove', [this.overlay, this.window, sizes]);
	},

	removeEvents: function(type){
		if (!this.$events) return this;
		if (!type) this.$events = null;
		else if (this.$events[type]) this.$events[type] = null;
		return this;
	},

	parsers: {
		'image': function(preset) {
			return (preset || this.url.test(/\.(jpg|jpeg|png|gif|bmp)$/i)) ? this.url : false;
		},
		'adopt': function(preset) {
			if ($(this.options.adopt)) return $(this.options.adopt);
			if (preset || ($(this.element) && !this.element.parentNode)) return $(this.element);
			var bits = this.url.match(/#([\w-]+)$/);
			return bits ? $(bits[1]) : false;
		},
		'url': function(preset) {
			return (preset || (this.url && !this.url.test(/^javascript:/i))) ? this.url: false;
		},
		'iframe': function(preset) {
			return (preset || this.url) ? this.url: false;
		},
		'string': function(preset) {
			return true;
		}
	},

	handlers: {
		'image': function(url) {
			this.image = new Image();
			var events = {
				loaded: function() {
					var win = {x: window.getWidth() - this.options.marginImage.x, y: window.getHeight() - this.options.marginImage.y};
					var size = {x: this.image.width, y: this.image.height};
					for (var i = 0; i < 2; i++)
						if (size.x > win.x) {
							size.y *= win.x / size.x;
							size.x = win.x;
						} else if (size.y > win.y) {
							size.x *= win.y / size.y;
							size.y = win.y;
						}
					size = {x: parseInt(size.x), y: parseInt(size.y)};
					if (window.webkit419) this.image = new Element('img', {'src': this.image.src});
					else $(this.image);
					this.image.setProperties({
						'width': size.x,
						'height': size.y});
					this.applyContent(this.image, size);
				}.bind(this),
				failed: this.onError.bind(this)
			};
			(function() {
				this.src = url;
			}).delay(10, this.image);
			this.image.onload = events.loaded;
			this.image.onerror = this.image.onabort = events.failed;
		},
		'adopt': function(el) {
			return el.clone();
		},
		'url': function(url) {
			this.ajax = new Ajax(url, this.options.ajaxOptions);
			this.ajax.addEvent('onSuccess', function(resp) {
				this.applyContent(resp);
				this.ajax = null;
			}.bind(this));
			this.ajax.addEvent('onFailure', this.onError.bind(this));
			this.ajax.request.delay(10, this.ajax);
		},
		'iframe': function(url) {
			return new Element('iframe', {
				'src': url,
				'frameBorder': 0,
				'width': this.options.size.x,
				'height': this.options.size.y
			});
		},
		'string': function(str) {
			return str;
		}
	},

	extend: $extend
};

SqueezeBox.extend(SqueezeBox, Events.prototype);
SqueezeBox.extend(SqueezeBox, Options.prototype);
SqueezeBox.extend(SqueezeBox, Chain.prototype);
