$(document).ready(function() {    
	$('.no-autocomplete input[type=password]').attr('autocomplete', 'off');
});


function clearValue(object) {
    if (object.value == object.defaultValue) {
        object.value = '';
    }
}

function restoreValue(object) {
    if (object.value == '') {
        object.value = object.defaultValue; 
    }
}

function favoris(){
	var thePage = location.href;
	if(thePage.lastIndexOf('#')!=-1){
		thePage = thePage.substring(0,thePage.lastIndexOf('#'));
	}

	if (typeof window.sidebar != "undefined") {
		window.sidebar.addPanel('www.echelle-europeenne.com',thePage,"");
	} else if (typeof window.external.AddFavorite != "undefined") { 
		window.external.AddFavorite(thePage,'www.echelle-europeenne.com');
	} else {
		alert('Your browser does not support this functionality, please use the one embedded instead.');
	}
}

lock = 0;
timeAuto = 10000;
timeAnim = 700;
size = 726;
timer = null;

// slideshow
next = function(to)
{
    if (lock==1) return false;
    lock = 1;
    clearTimeout(timer);

    // index du li affiché courament
    var index = $('#slide li').index($('#slide li:visible'));
    // si la suivante est la courante alors on arrête
    if (to==index) {
        lock = 0;
        return false;
    }

    // si le suivant est spécifié et qu'il existe, on le prend, sinon c'est le courant + 1
    if (typeof to!='undefined' && $('#slide li:eq(' + to + ')')) {
    	var next = to;
    } else {
        var next = index + 1;
        next = next > ($('#slide li').size()-1) ? 0 : next;
    }

    // direction
    var dir = next > index ? -1 : 1;
    
	// on cache le premier
    $('#slide li:eq(' + index + ')').animate({left: size*dir + "px"}, timeAnim, 'swing', function() {
        $('#slide li:eq(' + index + ')').hide(); 
    });

	
    $('#actu-nav .current' + index).fadeOut(timeAnim/2, function() {
    	$('#actu-nav .current' + next).fadeIn(timeAnim/2);
    });
    
    $('#slide li:eq(' + next + ')').css('left', size*dir*-1 + "px");
    $('#slide li:eq(' + next + ')').show();

    // on affiche le 2nd
    $('#slide li:eq(' + next + ')').animate({ left: "0" }, timeAnim, 'swing', function() { 
        lock = 0;
        timer = setTimeout('next()', timeAuto);
    });

    return false;
}
