var isMSIE;

$(function (){ 

	resizeHeight();
	
	if($('body').hasClass('department')) {
		$('.forward, .back').css("cursor","pointer");
		$('.forward') // le lien pour avancer
			.click(function() {
				window.location=$(this).find("a").attr("href");
		});

		$('.back') // le lien pour reculer
			.click(function() {	
				window.location=$(this).find("a").attr("href");
		});
	}	
	
	$('.others a:last-child').addClass('last');
		
});

function displayCurrent() {
	
	$("#backstretch-wrap img").fadeOut(500, function() {
		$(this).attr("src", base_url+"img/bg/store"+(current)+".jpg");	//on affiche le bon arriere-plan
	});	
	
	$('#slide-title').html( $('#menu'+current).find('a').html() );	
	
	$('#subnav li').removeClass('active');
	$('#menu'+current).addClass('active'); // on met une classe sur l'element actif
	$('#quote li').hide();
	
	$('#quote'+current).show();
	
	/* on donne les valeurs aux elements precedent/suivant */
	
	if(current<l && current!=0) {
		prev = current-1;
		next = current+1;	
	}
	
	if(current==l) {
		prev = current-1;
		next = 0;	
	}
	
	else if(current == 0) {
		prev = l;
		next = current+1;	
	}
	
	else if(current == l) {
		prev = current-1;
		next = 1;	
	}
	
	$('.back').text($('#menu'+prev).text());
	$('.forward').text($('#menu'+next).text());
	
	if(isMSIE == true) {
		Cufon.replace('h2');	
	}
		
}

function resizeHeight() {
	
	$('#node').width($(window).width());
	fullW = $('#node').width();
	nodeS = $('#node li').length;
	nodeW = Math.floor(fullW/nodeS);
	rest = fullW - (nodeW * nodeS);
	$('#node li').width(nodeW);
	$('#node li').last().width(fullW-(nodeW*(nodeS-1)));
    $('#node li,#node li div').height($(window).height()-110);
	$('#node li').each(function() {
		var url = $(this).find('h2 a').attr('href');
		$(this).find("h2").css('padding-top', $('#node li').height()/2-180)
		$(this).click(function() {
			window.location.href = url;
		});

	})
	
	// if($(window).height()-140 > $('.center').height() ) {
	// 		$('.center').css('margin-top',($(window).height()-$('.center').height()-140)/2+'px');	
	// 	}	
	
};

var resizeTimer = null;
	$(window).bind('resize', function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(resizeHeight, 10);
});
