if (typeof console == 'undefined') {
	var console = {
		info: function() {},
		dir: function() {},
		group: function() {},
		groupEnd: function() {}
	};
}

TT = {
	
	init : function() {
		$('table td:last').css({'border-right': 0});
		$('#navigation li:last').addClass('last');
		$('#navigation .sub li:last').addClass('last');
		
		this.addBindings();
		this.toggleMenu();
		
	},
	switchBg : function(el) {
	//	alert('here');
		var bgImage = el.attr('rel');
		$("#layout_image").hide().css("background", "url(/fotos/fotos/"+ bgImage + ") top center no-repeat").show();
	},
	addBindings : function() {
		$('a.switch').bind('click', function(){ TT.switchBg($(this)); });
		$('a.mo_switch').bind('mouseover', function(){ TT.switchBg($(this)); });
	},
	toggleMenu : function() {
		var aParent = $('#navigation .sub').parent();
		
		aParent.each(function(){
			$(this).hover(function(){
				if(!$('.sub', this).is(':visible')){
					$('.sub', $(this)).show(0, function(){ $(this).parent().addClass('active'); });
				}
				//$('.sub', $(this)).slideDown('fast', function(){ $(this).parent().addClass('active'); });
			}, function(){
				//$('.sub', $(this)).delay(1000).slideUp('normal', function(){ if(!$(this).is(':visible')) $(this).parent().removeClass('active'); });
				$('.sub', $(this)).hide(0, function(){ if(!$(this).is(':visible')) $(this).parent().removeClass('active'); });
			});
		});
	}
	
};

$(document).ready(function() {
	$('.thumbholder a').preload();
	TT.init();	
});
