	/*--------------------------------------------------------------
	# The News II - October 2008 (for Joomla 1.5)
	# Copyright (C) 2007-2008 Gavick.com. All Rights Reserved.
	# License: Copyrighted Commercial Software
	# Website: http://www.gavick.com
	# Support: support@gavick.com
	---------------------------------------------------------------*/

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

	//Fx.Height = Fx.Tween.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.Tween.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($('login_wrap')){
		//var ef = new Fx.Height($('login_wrap'), {duration: 200});
		$('login_wrap').setStyle('display','block');
		$('login_wrap').style.display= 'none';
		var opened = false;
		$('btn_login').addEvent("click", function(e){
			new Event(e).stop();

			if($('login_wrap').style.display != 'block') {
				$('login_wrap').setStyle('display','block');
			} else {
				$('login_wrap').setStyle('display','none');
			}

			$('btn_login').innerHTML = (!opened) ? '<span>CLOSE LOGIN AREA</span>': '<span>LOGIN</span>';
			opened = !opened;
		});
	}

	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();
	}

	if($('bottom_wrap')){
		var max_height = 0;
		$ES('.users', $('bottom_wrap')).each(function(el, i){
			var chld = el.getChildren()[0];
			var h = chld.getSize().size.y - chld.getStyle("padding-top").toInt() - chld.getStyle("padding-bottom").toInt();
			if(h > max_height) max_height = h;
		});

		$ES('.users', $('bottom_wrap')).each(function(el, i){
			el.getChildren()[0].setStyle("height", max_height+"px");
		});
	}
});

function changeStyle(style){
	var file = template_path+'/css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk20_style',style,{duration: 200,path: "/"});
	actual_style = style;
}

function openPreview(file,thumbnail,type) {

	if(type == 'image') {
		Slimbox.open(file);
	} else {
		window.open('/components/com_assetcenter/preview.php?file=' + file + '&thumbnail=' + thumbnail + '&type=' + type,'Preview','width=432,height=324,scrollbars=0,resizable=0,menubar=0,location=0');	}

}
