// contrôle de validité d'une adresse email
function isEmail(string) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(string))
		return true;
	else
		return false;
}

function isValidDate(d) {
	var dateRegEx = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
	return d.match(dateRegEx);
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g, '') ;
}

function openPage(ref){
	document.location.href = ref;
}

function OpenWindowPopup(str){
	win=window.open(str,'OpenWindowPopup','scrollbars=yes,resizable=yes,width=850,height=600,status=no,location=no,toolbar=yes');
}

function Popup(url, width, height, left, top){
	if (left == 0){
		left = (screen.width - width) / 2;
	}
	if (top == 0){
		top = (screen.height - height) / 2;
	}
	window.open(url,'_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width='+width+', height='+height+', left='+left+', top='+top+'');
}


function GoogleMapPopup(lat, lng, adresse, titre){
	var width = 660;
	var height = 450;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var href = '/scripts/php/map.php?lat='+lat+'&lng='+lng+'&add='+adresse+'&title='+titre;
	window.open(href,'_blank','toolbar=0, location=0, directories=0, status=1, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width='+width+', height='+height+', left='+left+', top='+top+'');
}

// Lit le contenu de la page courante avec Dixerit
function Vocalise(langue){
	var page = document.location;
	page = escape(document.location);
	window.open('http://voice.dixerit.com/nyon_chdix?lang='+langue+'&url='+escape(document.location),'dixerit','width=300, height=120, top=80, left=800');
}



/* CHANGEMENT DE TAILLE DE POLICE DANS UN BLOC */
var taille_texte=11;
function diminue(z){
	var elem = document.getElementById(z);
	//if(taille_texte>8 && elem){
		taille_texte=taille_texte-1;
		pixel=taille_texte+"px";
		elem.style.fontSize = pixel;
		elem.style.lineHeight = (taille_texte+5)+'px';
	//}
}
function augmente(z){
	var elem = document.getElementById(z);
	//if(taille_texte<36 && elem){
		taille_texte++;
		pixel=taille_texte+"px";
		elem.style.fontSize = pixel;
		elem.style.lineHeight = (taille_texte+5)+'px';
	//}
}

$(document).ready(function() {

	$('a.fancy').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'titlePosition'	: 'over',
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});


	$('#stf').fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'height'			: 380,
		'width'				: 700,
		'autoDimensions'	: false
	});

});

