window.addEvent("domready",function(){
	
	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($('showcart') && $('icart')){
		var regxp = new RegExp("Your Cart is currently empty");
		var icart_visible = false;
		
		$('showcart').setStyle("display","block");
		new Fx.Height($('showcart'),{duration: 350}).set(0);
		
		var icart_opacity = new Fx.Opacity($('showcart'),{duration: 350}).set(0);
		
		if(!regxp.test($('showcart').innerHTML)) $('icart').addClass("icart-active");
		
		$('icart').addEvent("click", function(e){
			var event = new Event(e);
			event.stop();
			icart_opacity.start((icart_visible) ? 0 : 1);
			new Fx.Height($('showcart'),{duration: 350}).start((icart_visible) ? 0 : $E('.page980',$('showcart')).getSize().size.y);
			icart_visible = !icart_visible;
		});
		
	}
	
	if($("gkvm_menu")){
		var actual_tabmenu = $E("#gkvm_menu li").getProperty("id").substr(11);
		
		$ES("#gkvm_menu li").each(function(el,i){
			el.addEvent("mouseenter",function(){
				var num = (el.getProperty("id")).substr(11);
				if($('gkvm_menu_s'+actual_tabmenu)) $('gkvm_menu_s'+actual_tabmenu).setStyle("display","none");
				$("gkvm_menu_f"+actual_tabmenu).removeClass("gkvm_active");
				actual_tabmenu = num;
				if($('gkvm_menu_s'+actual_tabmenu)) $('gkvm_menu_s'+actual_tabmenu).setStyle("display","block");
				el.addClass("gkvm_active");
			});
		});
	}
	
	if($('advanced_search_form')){
		$('advanced_search_form').setStyle("display", "block");
		var adv_searcho = new Fx.Opacity($('advanced_search_form')).hide();	
		$("bsearch_bottom").addEvent("click",function(e){new Event(e).stop();adv_searcho.start(1);});
		$("form_adv_close").addEvent("click",function(e){new Event(e).stop();adv_searcho.start(0);});
	}
	
	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 changeStyle(style){
	var file = template_path+'/css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk14_style',style,{duration: 200,path: "/"});
	actual_style = style;
}