var TimeOut_camping;
var TimeOut_mh;
var TimeOut_animations1;
var TimeOut_animations2;
var TimeOut_sport;
var TimeOut_plages;

var n_inc_img_camping = 0;
var n_inc_img_mh = 0;
var n_inc_img_animations1 = 0;
var n_inc_img_animations2 = 0;
var n_inc_img_sport = 0;
var n_inc_img_plages = 0;

var s_mh1_selection = '';
var s_mh2_selection = '';
var s_car1_selection = '';
var s_you1_selection = '';

var n_inc_mh1 = 0;
var n_inc_mh2 = 0;
var n_inc_car1 = 0;
var n_time = 2000;


function init(ps_name)
{	
	if(document.getElementById('img_' + ps_name))
	{
		img_animation(ps_name);
	}
}

function img_animation(ps_img)
{
	var n_nb_img = eval("t_img_" + ps_img + ".length;");
	eval("n_inc_img_" + ps_img + " = (n_inc_img_" + ps_img + " < n_nb_img) ? n_inc_img_" + ps_img + " : 0;");
	eval("document.getElementById('img_" + ps_img + "').src = t_img_" + ps_img + "[n_inc_img_" + ps_img + "];");
	eval("n_inc_img_" + ps_img + "++;");
	eval("TimeOut_" + ps_img + " = setTimeout(\"img_animation('" + ps_img + "')\", " + n_time + ");");
	n_time = (n_time == 2000) ? 3000 : 2000;
}



function afficher_fiche(ps_name, ps_bloc)
{
	switch(ps_bloc)
	{
		case 'mh1':
			s_mh1_selection = ps_name;
			n_inc_mh1 = 0;
			break;
		
		case 'mh2':
			s_mh2_selection = ps_name;
			n_inc_mh2 = 0;
			break;
			
		case 'car1':
			s_car1_selection = ps_name;
			n_inc_car1 = 0;
			break;
			
		case 'you1':
			s_you1_selection = ps_name;
			n_inc_you1 = 0;
			break;
	}
	
	if(eval("s_txt_" + ps_name))
	{
		document.getElementById('txt_desc_fiche_' + ps_bloc).innerHTML = eval("s_txt_" + ps_name);
	}
	
	if(eval("t_img_" + ps_name))
	{
		document.getElementById('img_' + ps_bloc).src = eval("t_img_" + ps_name + "[0]");
	}
	if(eval("s_titre_" + ps_name))
	{
		document.getElementById('titre_fiche_' + ps_bloc).innerHTML = eval("s_titre_" + ps_name);
	}
}

function img_prec(ps_bloc)
{	
	var s_selection = '';
	
	switch(ps_bloc)
	{
		case 'mh1':
			s_selection = s_mh1_selection;
			break;
		
		case 'mh2':
			s_selection = s_mh2_selection;
			break;
			
		case 'car1':
			s_selection = s_car1_selection;
			break;
			
		case 'you1':
			s_selection = s_you1_selection;
			break;
	}
	
	if(s_selection != '')
	{
		eval("n_inc_" + ps_bloc + "--;");
		var n_tab_length = eval("t_img_" + s_selection + ".length;");
		
		if(parseInt(eval("n_inc_" + ps_bloc)) < 0)
			eval("n_inc_" + ps_bloc + " = (parseInt(n_tab_length) - 1);");
		
		document.getElementById('img_' + ps_bloc).src = eval("t_img_" + s_selection + "[" + eval("n_inc_" + ps_bloc) + "]");		
	}
}

function img_suiv(ps_bloc)
{
	var s_selection = '';
	
	switch(ps_bloc)
	{
		case 'mh1':
			s_selection = s_mh1_selection;
			break;
		
		case 'mh2':
			s_selection = s_mh2_selection;
			break;
			
		case 'car1':
			s_selection = s_car1_selection;
			break;
			
		case 'you1':
			s_selection = s_you1_selection;
			break;
	}
	
	if(s_selection != '')
	{
		eval("n_inc_" + ps_bloc + "++;");
		var n_tab_length = eval("t_img_" + s_selection + ".length;");
		
		if(parseInt(eval("n_inc_" + ps_bloc)) > (parseInt(n_tab_length) - 1))
			eval("n_inc_" + ps_bloc + " = 0;");
		
		document.getElementById('img_' + ps_bloc).src = eval("t_img_" + s_selection + "[" + eval("n_inc_" + ps_bloc) + "]");		
	}
}

function afficher_popup(ps_popup)
{
	var s_url = "";
	var n_left = 0;
	var n_top = 0; 
	var n_width = 0;
	var n_height = 0;
	var s_config = '';
	
	if(ps_popup == '')
		return;	
	n_width = 920;
	n_height = 550;
	s_url = ps_popup;
	n_left = (window.screen.width/2) - (n_width/2);
	n_top = (window.screen.height/2)-(n_height/2);
	s_config += "scrollbars=yes, dependent=yes, toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, width=" + n_width + ", height="+ n_height + ", left=" + n_left + ", top=" + n_top;
	window.open(s_url,"Pop", s_config);
}

function check_contact() 
{
	if (document.frm_contact.nom.value == "") {
		document.frm_contact.nom.style.background="yellow";
		document.frm_contact.nom.focus();
		return;
	}
	document.frm_contact.nom.style.background="white";
	if (document.frm_contact.email.value == "") {
		document.frm_contact.email.style.background="yellow";
		document.frm_contact.email.focus();
		return;
	}
	document.frm_contact.email.style.background="white";
	if (isNotEmailAdress (document.frm_contact.email.value)) {
		document.frm_contact.email.style.background="yellow";
		document.frm_contact.email.focus ();
		return;
	}
	document.frm_contact.email.style.background="white";
	if (document.frm_contact.sujet.value == -1) {
		document.frm_contact.sujet.style.background="yellow";
		document.frm_contact.sujet.focus();
		return;
	}
	document.frm_contact.sujet.style.background="white";
	if (document.frm_contact.message.value == "") {
		document.frm_contact.message.style.background="yellow";
		document.frm_contact.message.focus();
		return;
	}
	document.frm_contact.submit();
	
}

function isNotEmailAdress(valeur) 
{
	regExpEmailAdress = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/g;
	resultat = valeur.match(regExpEmailAdress);
	if (resultat != null && resultat.length == 1) {
		return false;
	} else {
		return true;
	}
}