$(document).ready(function(){
	
	var section = $('#section').attr('value');
	
	if (section == 'home'){
		$('.menu2,.information').hide();
						
	}else{
		if (section == 'designer'){
			$('#gallery-images').css('clip','rect(0px,270px,180px,0px)');
		} else if (section == 'productinfo'){
			$('#gallery-images').css('clip','rect(0px,564px,137px,0px)');
		}
	//	$('.menu,.menu-footer').hide();
		$('.menu').hide();
		$('.background').fadeIn('slow');
		$('.menu2 .text').show();
	}
	
	$('a.home').click(function(){
		section = $('#section').attr('value');
		if (section != "home"){	
			$('.background').fadeOut('slow');
			$('.menu2 .text').fadeOut('slow',wait_hide_text($(this).attr('href'),800))
			return false;
		}else{
			return true;
		}
	});
	
	$('a.no-home').click(function(){
		section = $('#section').attr('value');
		if (section == "home"){
			$('.menu2,.information').slideDown('slow',wait_show_text($(this).attr('href'),1000));	
		//	$('.menu,.menu-footer').slideUp('slow');
			$('.menu').slideUp('slow');
		}else{
			$('.background').fadeOut('slow',go_page($(this).attr('href'),1000));
		}
		return false;
	});
	
	$('.menu2 a,.submenu a').not('#m2-selec').find('div').hover(
		function(){
			$(this).css('color','#e7e7e8');
			Cufon.refresh();
		},
		function(){
			$(this).css('color','#ffffff');
			Cufon.refresh();
		}
	);
	
	$('a.show-avis-legal').click(function(){
		$('#fullscreen').fadeIn('slow');
		$('#avis-legal').fadeIn('slow');
	});
	
	$('a.hide-avis-legal').click(function(){
		$('#fullscreen').fadeOut('slow');
		$('#avis-legal').fadeOut('slow');
	});
	
	$('a.show-credits').click(function(){
		$('#fullscreen').fadeIn('slow');
		$('#credits').fadeIn('slow');
	});
	
	$('a.hide-credits').click(function(){
		$('#fullscreen').fadeOut('slow');
		$('#credits').fadeOut('slow');
	});		
});

function wait_show_text (page,ms){
	setTimeout("show_text('"+page+"')",ms);
}

function show_text(page){
	$('.menu2 .text').fadeIn('slow',go_page(page,800))	
}

function wait_hide_text (page,ms){
	setTimeout("hide_text('"+page+"')",ms);
}

function hide_text(page){
	$('.menu2,.information').slideUp('slow');
	$('.menu,.menu-footer').slideDown('slow',go_page(page,1000));
}

function go_page (page,ms){
	setTimeout("open_page('"+page+"')",ms);
}

function open_page(page){
	document.location.href = page;	
}


