var Natural = {
	
	start: function(){
		$(document).bind("contextmenu",function(e){
       		return false;
    	});
		Natural.menu_izq();
		Natural.menu_sup();
		$('h1').css('cursor', 'pointer').click(function(){
			document.location = $('h1 a').attr('href');
		});
		Natural.galeria_fotos();
		Natural.mapas();
		$('#principal').pngFix();
		$('#menu_sup li:eq(2) a').click(function(){
			$('#horario').fadeIn('slow');
			$('#cerrar_horario').unbind('click').click(function(){
				$('#horario').fadeOut('slow');
				return false;
			});
			return false;
		});
	},
	
	menu_izq: function(){
		$('#izq dd').not('.actual').hide();
		$('#izq dt.actual a').addClass('actual').parent().removeClass('actual').addClass('actual2');
		$('#izq dt').not('.solo').children('a').not('.actual').click(function(){
			$('#izq dt a.actual').removeClass('actual');
			$(this).addClass('actual');
			$(this).stop().animate({
				paddingLeft: 0
			});
			var relacion = $(this).parent().attr('title');
			$('#izq dd').each(function(){
				if($(this).attr('title') == relacion){
					$(this).slideDown();
				}else{
					$(this).slideUp();
				}
			});
			return false;
		}).mouseover(function(){
			if($(this).hasClass('actual') == false){
				$(this).stop().animate({
					paddingLeft: 10
				});	
			}
		}).mouseout(function(){
			if ($(this).hasClass('actual') == false) {
				$(this).stop().animate({
					paddingLeft: 0
				});
			}
		});
		$('#izq dd a').mouseover(function(){
			$(this).stop().animate({
				paddingLeft: 10
			});
		}).mouseout(function(){
			$(this).stop().animate({
				paddingLeft: 0
			});
		})
	},
	
	menu_sup: function(){
		$('ul#menu_sup li a').not('actual').each(function(){
			var ruta_img = $(this).children().attr('src').replace(/off1/gi,'on1');;
			var img = $('<img>').attr('src', ruta_img);
			$(this).mouseover(function(){
				$(this).children().attr('src', ruta_img);
			}).mouseout(function(){
				$(this).children().attr('src', ruta_img.replace(/on1/gi,'off1'));
			});
		});
	},
	
	galeria_fotos: function(){
		var isMSIE = /*@cc_on!@*/false; 
		var version = 8;
		if(isMSIE){
			var userAgent = navigator.userAgent.toLowerCase();
			var version = parseInt((userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1]);
		}
		if(version < 8){
			$('.galeria .fotos li a').each(function(){
				var tamano_antiguo = $(this).height();
				$(this).css({
					display: 'block'
				}).height(100);
				$(this).children('img').css({
					marginTop: (100 - tamano_antiguo) / 2
				});
			});	
		}
		$.superbox.settings = {
			loadTxt: "Cargando...", // Loading text
			closeTxt: "[x] Cerrar", // "Close" button text
			prevTxt: "&lArr; Anterior", // "Previous" button text
			nextTxt: "Siguiente &rArr;" // "Next" button text
		};
		$.superbox();
		$('#superbox-innerbox').attr('title', 'cerrar').click(function(){
			$('#superbox p.close a').click();
		});
	},
	
	mapas: function(){
		$('#mapa').jmap('init', {
			'mapType':'map',
			'mapCenter':[37.9773419,-1.1284046], 
			'language': 'es',
			'mapZoom': 14
		});
		$('#mapa').jmap('AddMarker',{
			'pointLatLng':[37.9773419,-1.1284046],
			'pointHTML': '<p><strong>NaturalMobiliario</strong> Especialistas en muebles</p>'
		});
	}
	
}

$(document).ready(Natural.start);
