function show_content() {
	jQuery('#show').hide("fast");
	jQuery('#hide').show("normal");
	jQuery('#all').show("normal");
}
function hide_content() {
	jQuery('#hide').hide("fast");
	jQuery('#all').hide("normal");
	jQuery('#show').show("fast");
}
function show_facturation() {
	jQuery('#facturation').show("fast");
	}
	
function show_overlay(id) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	var objPlan = document.getElementById(id);
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objPlan.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 600) / 2) + 'px');
	objPlan.style.left = (((arrayPageSize[0] - 600) / 2) + 'px');
	jQuery('#overlay').fadeIn("slow");
	jQuery('#'+id).fadeIn("slow");
	}
function close_overlay(id) {
	jQuery('#'+id).fadeOut("slow");
	jQuery('#overlay').fadeOut("slow");
}
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){pageHeight = windowHeight;} else { pageHeight = yScroll;}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) {pageWidth = windowWidth;} else {pageWidth = xScroll;}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function	check_mail(email)
{
	var verif 	= /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/
	if (verif.exec(email) == null)
	{
		alert("Votre adresse e-mail est incorrecte");
		return false;
	}
	else
		return true;
}

function	change_div_lightbox(link, id)
{
	var	content;
	
	content = '<div class="bg_popup_top">&nbsp;</div>';
	content += '<div class="wrapper_proposer">';
		content += '<div class="top"><a href="javascript:close_overlay(\'proposer-lieu\')" id="lieuClose">[x] Fermer</a></div>';
		content += '<h2>Proposer un autre lieu</h2>';
		content += '<h3>Merci pour votre contribution !</h3>';
		content += '<p>Votre proposition a bien &eacute;́t&eacute;́ enregistr&eacute;e. Nous nous engageons &agrave;̀ modifier votre inscription dans une autre ville si la formation est ouverte pr&egrave;s de chez vous.<br/><br/>';
	content += 'En attendant vous pouvez d&egrave;s &agrave;̀ pr&eacute;́sent r&eacute;server cette formation dans les villes disponibles.<br/><br/></p>';
	content += '<form action="' + link + '/reservation/inscription-12/" method="post">';
	content += '<input type="hidden" value="' + id + '" name="id_formation" />';
	content += '<div id="inscription2" class="center"><input  type="submit" value="Je r&eacute;serve ma place" class="inscription_submit" /></div>';
	content += '</form>';
	content += '</div>';
	content += '<div class="bg_popup_bottom">&nbsp;</div>';
	jQuery('#proposer-lieu').html(content);
}

function add_lieu(path, link, id)
{
	if (!check_mail(jQuery('#lieu_email').val()))
		return false;
	var	msg = jQuery('#lieu').formSerialize();
	jQuery.post(path, msg, function success(data) { if (data != 'OK') alert(data); else change_div_lightbox(link, id) });
	return false;
}

function dl_file(path, link, id)
{
	if (!check_mail(jQuery('#tele_email').val()))
		return false;
	var	msg = jQuery('#dl_file').formSerialize();
	jQuery.post(path, msg, function success(data) { if (data == 'Vous devez renseigner votre secteur' || data == 'Vous devez renseigner votre fonction') alert(data); else jQuery('#' + id).html(data); });
	return false;
}