window.addEvent("domready",function(){
	var $b = $(document.getElementsByTagName('body')[0]);
	
	new SmoothScroll();
	
	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($('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);});		
	}
	
	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);});
	
	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);});
	
	if($('wrapper_bottom')){
		if($ES('.moduletable_content', $('wrapper_bottom')).length > 0){
			var max = 0;
			$ES('.moduletable_content', $('wrapper_bottom')).each(function(el){ if(el.getSize().size.y > max) max = el.getSize().size.y; });	
			$ES('.moduletable_content', $('wrapper_bottom')).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 changeStyle(style){
	var file = $template_path+'/css/style'+style+'.css';
	new Asset.css(file);
	new Cookie.set('gk26_style',style,{duration: 200,path: "/"});
}// JavaScript Document
var message=href="www.surftotal.com";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")// GK MooMenu v.2.0 Copyright by GavickPro
window.addEvent("domready", function(){
	// necessary classes
		Fx.Height = Fx.Style.extend({initialize: function(el, options){$(el).setStyle('overflow', 'hidden');this.parent(el, 'height', options);},toggle: function(){var style = this.element.getStyle('height').toInt();return (style > 0) ? this.start(style, 0) : this.start(0, this.element.scrollHeight);},show: function(){return this.set(this.element.scrollHeight);}});
			Fx.Width = Fx.Style.extend({initialize: function(el, options){this.element = $(el);this.element.setStyle('overflow', 'hidden');this.iniWidth = this.element.getStyle('width').toInt();this.parent(this.element, 'width', options);},toggle: function(){var style = this.element.getStyle('width').toInt(); return (style > 0) ? this.start(style, 0) : this.start(0, this.iniWidth);},show: function(){return this.set(this.iniWidth);}});
			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);}});
	
	var main = $("horiz-menu");
	var levels = new Array();
	var opacityFX = new Array();	var heightFX = new Array();	var widthFX = new Array();	
	main.getChildren().each(function(el,i){
		levels.push(new Array());
		opacityFX.push(new Array());		heightFX.push(new Array());		widthFX.push(new Array());		
		el.getElementsBySelector("ul").each(function(elm,j){
			levels[i].push(elm.getParent());
			opacityFX[i].push(new Fx.Opacity(elm, {duration: 180, transition: Fx.Transitions.Quad.easeIn,wait:true}).set(0));			heightFX[i].push(new Fx.Height(elm, {duration: 180, transition: Fx.Transitions.Quad.easeIn,wait:true}).set(0));			widthFX[i].push(new Fx.Width(elm, {duration: 180, transition: Fx.Transitions.Quad.easeIn,wait:true}).set(0));		});
	});
	
	levels.each(function(e,k){
		e.each(function(a,l){
			a.addEvents({
				"mouseenter" : function(){
					a.getChildren()[1].setStyle("overflow","hidden");
					if(window.ie7 && (a.getChildren()[1].getParent() && a.getChildren()[1].getParent().getParent() && a.getChildren()[1].getParent().getParent().getParent() && a.getChildren()[1].getParent().getParent().getParent().hasClass("level1")) && a.getChildren()[1].getStyle("position") != 'absolute') a.getChildren()[1].setStyle("margin-top","35px");
					a.getChildren()[1].setStyle("position","absolute");
					opacityFX[k][l].toggle();					heightFX[k][l].toggle();					widthFX[k][l].toggle();					(function(){a.getChildren()[1].setStyle("overflow","")}).delay(180);
				},
				"mouseleave" : function(){
					a.getChildren()[1].setStyle("overflow","hidden");
					opacityFX[k][l].stop().set(0);					heightFX[k][l].stop().set(0);					widthFX[k][l].stop().set(0);				}
			});
		});
	});	
	// submenu activation
	$ES('li.level1','#horiz-menu').each(function(el){
		/*if(($E('.active',el) || el.hasClass('active')) && $E('ul', el)){
			$E('ul', el).setStyle("display", "block");
			$ES('li.level1','#horiz-menu').each(function(elm){
				elm.addEvent("mouseenter", function(){
					if(elm != el){
						if(!window.ie) $E('ul', el).setProperty("style","");
						else $E('ul', el).removeProperty("style");
					} 
				});
				
				elm.addEvent("mouseleave", function(){
					if(elm != el){
						$E('ul', el).setStyle("display","block");
					} 
				});
			});
		}*/
	});
});