/*--------------------------------------------------------------
# Corporate - April 2009 (for Joomla 1.5)
# Copyright (C) 2007-2009 Gavick.com. All Rights Reserved.
# License: Copyrighted Commercial Software
# Website: http://www.gavick.com
# Support: support@gavick.com  
---------------------------------------------------------------*/

var $zz=jQuery.noConflict();
function dis1(){
	
	var $b = $zz(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($zz('slider')){
		var slider = new Fx.Slide('wrapper_banner');
		$zz('wrapper_banner').getParent().addClass("wrapper_banner_helper");
		if(!$zz('slider').hasClass('slider_up')){
			$zz('wrapper_banner').setStyle('display','block');
			slider.hide();	
		}
		$zz('slider').addEvent("click", function(){
			slider.toggle();
			$zz('slider').toggleClass('slider_up');
			if($zz('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($zz('popup_login')) var popup_login = new Fx.Opacity('popup_login', {duration: 250}).set(0);
	if($zz('popup_login')){
		$zz('popup_login').setStyle("display", "block");
		$zz('close_button_login').addEvent("click", function(){popup_login.start(0);});
	}
	if($zz('popup_register')) var popup_register = new Fx.Opacity('popup_register', {duration: 250}).set(0);
	if($zz('popup_register')){
		$zz('popup_register').setStyle("display", "block");
		$zz('close_button_register').addEvent("click", function(){popup_register.start(0);});		
	}
	// login
	if($zz('login_btn')) $zz('login_btn').addEvent("click", function(e){new Event(e).stop();popup_login.start(1);});
	if($zz('login_btn_noborder')) $zz('login_btn_noborder').addEvent("click", function(e){new Event(e).stop();popup_login.start(1);});
	// register
	if($zz('register_btn')) $zz('register_btn').addEvent("click", function(e){new Event(e).stop();popup_register.start(1);});
	if($zz('register_btn_noborder')) $zz('register_btn_noborder').addEvent("click", function(e){new Event(e).stop();popup_register.start(1);});
	// users_wrap I
	if($zzES('.users_wrap')[0]){
		if($zzES('.moduletable_content', $zzES('.users_wrap')[0]).length > 0){
			var max = 0;
			$zzES('.moduletable_content', $zzES('.users_wrap')[0]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	
			$zzES('.moduletable_content', $zzES('.users_wrap')[0]).each(function(el){ el.setStyle("height", max+"px"); });	
		}		
	}
	// users_wrap II
	if($zzES('.users_wrap')[1]){
		if($zzES('.moduletable_content', $zzES('.users_wrap')[1]).length > 0){
			var max = 0;
			$zzES('.moduletable_content', $zzES('.users_wrap')[1]).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	
			$zzES('.moduletable_content', $zzES('.users_wrap')[1]).each(function(el){ el.setStyle("height", max+"px"); });	
		}			
	}
	//
	if($zz('stylearea')){
		$zzA($zz$zz('.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 = $zztemplate_path+'/css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk25_style',style,{duration: 200,path: "/"});
}
