function delSearch(old_val) {
	var champ = document.getElementById('search');
	if (champ.value == old_val)
	{
		champ.value = "";
	}
	else if(champ.value == "") {
		champ.value = old_val;	
	}
}

function langTxt(mot,old_mot) {
	var lang = document.getElementById('flagsTxt');
	if(mot == '') {
		lang.innerHTML = old_mot;
	}
	else {
		lang.innerHTML = mot;	
	}
}


function slideSwitch() {
    var $active = $('#diaporama IMG.active');

    if ( $active.length == 0 ) $active = $('#diaporama IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#diaporama IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
	
	$("#contenu img").each(function() { 
		imgDir = $(this).attr("src");
		imgH = $(this).attr("height");
		imgW = $(this).attr("width");
		imgAlt = $(this).attr("alt");
		$(this).replaceWith("<a href='"+imgDir+"' rel='zoombox'><img src='"+imgDir+"' width='"+imgW+"' height='"+imgH+"' alt='"+imgAlt+"' /></a>");
	});
	
    setInterval( "slideSwitch()", 5000 );
});






// MENU --------------------------------------------------------


var timeout    = 0;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open() {
	jsddm_canceltimer();
	jsddm_close();
	//ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	ddmenuitem = $(this).find('ul').css('display', 'block');
}

function jsddm_close() {
	//if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
	if(ddmenuitem) ddmenuitem.css('display', 'none');
}

function jsddm_timer() {
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

$(document).ready(function() {
	
	$("#pageMenu .directory a")
		.css("-moz-border-radius","10px")
		.css("-webkit-border-radius","10px")
		.css("border-radius","10px");
	
	$('#menuL > li, #menuR > li').bind('mouseover', jsddm_open);
	$('#menuL > li, #menuR > li').bind('mouseout',  jsddm_timer);
	
});

document.onclick = jsddm_close;