$(document).ready(function(){
	$("#section-wrap").css({opacity:0});
	$(".subsection-wrap").css({display:"none"});
	$(".cerrado").css({display:"none"});
	if (jQuery.support.opacity)
		$("#list").css({opacity:0});
		
	/*if ($("#image img").attr('class')!="ocultar")
		$("#image img").fadeIn(900);*/

	if (($('#content').offset().top)>=0)
		$('#content').css({top:'50%'});	
	if (($('#content').offset().top)<0)
		$('#content').css({top:'300px'});
		
	if (($('#content').offset().left)>=0)
		$('#content').css({left:'50%'});	
	if (($('#content').offset().left)<0)
		$('#content').css({left:'490px'});
		
	
	$('#content-wrap #section.mostrar').css({padding:'60px 10px',width:'200px',height:'362px'});
	$('#content-wrap #section.mostrar .item').css({width:'190px'});
	$('#content-wrap #image.mostrar img').css({display:'block'});
	
	if (jQuery.browser.msie && jQuery.browser.version == 6)
		$('#section .mostrar').css({opacity:1,width:'190px'});
	else
		$('#section .mostrar').css({opacity:1,width:'230px'});
	
	$('#image img').fadeIn(500);
	
	if ($('#section').attr('class')!="mostrar")
	{
		if ($('#section').attr('class')!="contacto")
			$('#section').animate({width:'500px'},1000,function() {
				$('#section-wrap').animate({opacity:1},200);
				$('#location a').css({display:'block'});
				$('.jScrollPaneContainer').css({display:'block'});
			});
		else
			$('#section').animate({width:'280px'},1000,function() {
				$('#section-wrap').animate({opacity:1},200);
				$('#location a').css({display:'block'});
				$('.jScrollPaneContainer').css({display:'block'});
			});
	}
	else
		$('.jScrollPaneContainer').css({display:'block'});
			
	$('#section-wrap').jScrollPane({showArrows:true, scrollbarWidth:5, scrollbarMargin:15, arrowSize:9});
	
	
	$(window).bind('resize', function() {
		if (($('#content').offset().top)>=0)
			$('#content').css({top:'50%'});	
		if (($('#content').offset().top)<0)
			$('#content').css({top:'300px'});
			
		if (($('#content').offset().left)>=0)
			$('#content').css({left:'50%'});	
		if (($('#content').offset().left)<0)
			$('#content').css({left:'490px'});
	});
	
	
	$('#menu li a, #logo a').each(function(i) {
		if ($(this).attr('rel').length == 0) {
			$(this).attr('rel', $(this).attr('href'));
			$(this).attr('href', 'javascript: void(0);');
			$(this).click(function() {
				$('#section-wrap').animate({opacity:0},200,function() {
					$('#location a').css({display:'none'});
					$('.jScrollPaneContainer').css({display:'none'});
					if ($('#section').width()>200)
						$('#section').animate({width:'100px',paddingLeft:'60px',paddingRight:'60px'},1000);
					//$('#image img').fadeOut(500);
					$('.subsection-wrap').fadeOut(200);
					$('#subsection').animate({width:'-20px'},1000);
					$('#list').fadeOut(500);
				});
				setTimeout('window.location.href = \''+ $(this).attr('rel') +'\';',1000);
			});
		}
	});
	
	
	$('a.idioma').click(function() {
		$('#form_lang').append('<input type="hidden" value="'+$(this).attr('name')+'" name="l" />');
			
		$('#form_lang').submit();
	});
});


$(window).load(function() {
	$('#logo a img').css({marginTop:-($('#logo a img').height()/2)});
	
	$("#cuenta").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		onComplete			: function() {
			$('#log').focus();
		}
	});
	
	$("#editar,#registrarse,#newsletter").fancybox({
		'width'				: 570,
		'height'			: 380,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	
	$("#recordar").fancybox({
		'width'				: 310,
		'height'			: 80,
		'autoScale'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'				: 'iframe'
	});
	
	var datos=document.URL.split('?');

	if (datos[1]=="login=ko")
		alert("Datos incorrectos!");
		
	
	$('img').each(function() {
		$(this).bind('contextmenu', function() {
			return false
		});

		$(this).bind('copy', function() {
			return false
		});

		$(this).bind('dragstart', function() {
			return false
		});
	});
});
