var timeout    = 100;
var closetimer = 0;
var nav_item = 0;

function nav_open() {
	nav_canceltimer();
	nav_close();
	nav_item = $(this);
	nav_item.find('ul').css('visibility', 'visible');
	nav_item.addClass('on');
}

function nav_close() {
	if(nav_item) {
		nav_item.find('ul').css('visibility', 'hidden');
	nav_item.removeClass('on');
	}
}

function nav_timer() {
	closetimer = window.setTimeout(nav_close, timeout);
}

function nav_canceltimer() {
	if(closetimer) {
		window.clearTimeout(closetimer);
      closetimer = null;
	}
}

$(document).ready(function() {
	$("#menu > li").bind('mouseover', nav_open);
	$("#menu > li").bind('mouseout',  nav_timer);
});

document.onclick = nav_close;


function insert_flash(name,url,width,height,param) {
	document.write('<object name="'+name+'" id="'+name+'" type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+url+'" />'+param+'</object>');
}

function checkNum(event) {
	var kc2;
	kc2=event?event.which:window.event.keyCode; 
    if (kc2<48 || kc2>57)  { return false; }
	return true;
}

function confirmRedir(text, url) {
	if (confirm(text)) {
		document.location.href = url;
	}
}
function change_crea(id) {
    document.getElementById("diaporama").changeRef(id); 
}

function showMel() {
	coded = "7ldNkR8rdy@qNN2N8BH.7lH"
	key = "KzxlBrWp20LmZ8fhY6qAONG3gJRFjwSu5cHDPInvM9oeiU4yCbTXtEkQ7aV1sd";
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++) {
		if (key.indexOf(coded.charAt(i))==-1) {
		ltr = coded.charAt(i)
		link += (ltr)
		}
		else {     
		ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
		link += (key.charAt(ltr))
		}
	}
	document.write("<a href='mailto:"+link+"'>"+link+"</a>");
}
