//$(window).load(function() {
$(document).ready(function(){
	$("#section").css({opacity:0});
	$("#section-wrap").css({opacity:0});
	$("#subsection").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)>=130)
		$('#content').css({top:'50%'});	
	if (($('#content').offset().top)<130)
		$('#content').css({top:'320px'});
		
	/*var tam=TamVentana();
	if (($('#content').offset().top)>=130)
		$('#content').css({top:(tam[1]-170-$("#image img").height())/2});
	if (($('#content').offset().top)<130)
		$('#content').css({top:0});
		
	$("#content-wrap").css({height:$("#image img").height()});
	$("#section").css({height:$("#image img").height()-40});*/
	
	$('#content-wrap .mostrar').css({opacity:0.9,width:'200px'});
	$('#section .mostrar').css({opacity:1,width:'210px'});
	
	$('#section').animate({width:'200px',opacity:0.9},1000,function() {
		$('#section-wrap').animate({opacity:1},200);
		$('#location a').css({display:'block'});
		$('.jScrollPaneContainer').css({display:'block'});
	});
			
	$('#section-wrap').jScrollPane({showArrows:true, scrollbarWidth:5, scrollbarMargin:15, arrowSize:9});
	
	
	$(window).bind('resize', function() {
		/*var tam=TamVentana();
		if (($('#content').offset().top)>=130)
			$('#content').css({top:(tam[1]-170-$("#image img").height())/2});
		if (($('#content').offset().top)<130)
			$('#content').css({top:0});*/
		
		if (($('#content').offset().top)>=130)
			$('#content').css({top:'50%'});	
		if (($('#content').offset().top)<130)
			$('#content').css({top:'320px'});
	});
	
	
	$('#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'});
					$('#section').animate({width:0,opacity:0},1000);
					//$('#image img').fadeOut(900);
					$('#supersize').fadeOut(500);
					$('.subsection-wrap').fadeOut(200);
					$('#subsection').animate({width:0,opacity:0},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() {
	$("#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
		});
	});
});


/*function TamVentana() 
{ 
	var tam=[0, 0]; 
	if (typeof window.innerWidth != 'undefined')
		tam=[window.innerWidth,window.innerHeight];
	else 
		if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined'
				&& 	document.documentElement.clientWidth != 0)
			tam=[document.documentElement.clientWidth, document.documentElement.clientHeight];
		else
			tam=[document.getElementsByTagName('body')[0].clientWidth, document.getElementsByTagName('body')[0].clientHeight];
	return tam;
}*/
