





window.addEvent("domready",function(){

	var $b = $(document.getElementsByTagName('body')[0]);

	// smoothscroll init

	new SmoothScroll();

	// aniation classes - Fx.Height and Fx.Opacity

	Fx.Height = Fx.Style.extend({initialize: function(el, options){this.parent(el, 'height', options);this.element.setStyle('overflow', 'hidden');},toggle: function(){return (this.element.offsetHeight > 0) ? this.custom(this.element.offsetHeight, 0) : this.custom(0, this.element.scrollHeight);},show: function(){return this.set(this.element.scrollHeight);}});

	Fx.Opacity = Fx.Style.extend({initialize: function(el, options){this.now = 1;this.parent(el, 'opacity', options);},toggle: function(){return (this.now > 0) ? this.start(1, 0) : this.start(0, 1);},show: function(){return this.set(1);}});

	

	if($('slider')){

		var slider = new Fx.Slide('wrapper_banner');

		$('wrapper_banner').getParent().addClass("wrapper_banner_helper");

		if(!$('slider').hasClass('slider_up')){

			$('wrapper_banner').setStyle('display','block');

			//slider.hide();	//da modificare per visibilita del banner promozionale

		}

		$('slider').addEvent("click", function(){

			slider.toggle();

			$('slider').toggleClass('slider_up');

			if($('slider').hasClass('slider_up')) new Cookie.set('gk25_slider', 1,{duration: 200,path: "/"});

			else new Cookie.set('gk25_slider', 0,{duration: 200,path: "/"});

		});

	}

	// help vars

	if($('popup_login')) var popup_login = new Fx.Opacity('popup_login', {duration: 250}).set(0);

	if($('popup_login')){

		$('popup_login').setStyle("display", "block");

		$('close_button_login').addEvent("click", function(){popup_login.start(0);});

	}

	if($('popup_register')) var popup_register = new Fx.Opacity('popup_register', {duration: 250}).set(0);

	if($('popup_register')){

		$('popup_register').setStyle("display", "block");

		$('close_button_register').addEvent("click", function(){popup_register.start(0);});		

	}

	// login

	if($('login_btn')) $('login_btn').addEvent("click", function(e){new Event(e).stop();popup_login.start(1);});

	if($('login_btn_noborder')) $('login_btn_noborder').addEvent("click", function(e){new Event(e).stop();popup_login.start(1);});

	// register

	if($('register_btn')) $('register_btn').addEvent("click", function(e){new Event(e).stop();popup_register.start(1);});

	if($('register_btn_noborder')) $('register_btn_noborder').addEvent("click", function(e){new Event(e).stop();popup_register.start(1);});

	// users_wrap I

	if($ES('.users_wrap')[0]){

		if($ES('.moduletable_content', $ES('.users_wrap')[0]).length > 0){

			var max = 0;

			$ES('.moduletable_content', $ES('.users_wrap')[0]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	

			$ES('.moduletable_content', $ES('.users_wrap')[0]).each(function(el){ el.setStyle("height", max+"px"); });	

		}		

	}

	// users_wrap II

	if($ES('.users_wrap')[1]){

		if($ES('.moduletable_content', $ES('.users_wrap')[1]).length > 0){

			var max = 0;

			$ES('.moduletable_content', $ES('.users_wrap')[1]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	

			$ES('.moduletable_content', $ES('.users_wrap')[1]).each(function(el){ el.setStyle("height", max+"px"); });	

		}			

	}

	//

	if($('stylearea')){

		$A($$('.style_switcher')).each(function(element,index){

			element.addEvent('click',function(event){

				var event = new Event(event);

				event.preventDefault();

				changeStyle(index+1);

			});

		});

		new SmoothScroll();

	}

});

// Function to change backgrouns

function changeStyle(style){

	var file = $template_path+'/css/style'+style+'.css';

	new Asset.css(file);

	new Cookie.set('gk25_style',style,{duration: 200,path: "/"});

}