/*-----------------------------------------------------------------------
Fichier : scripts.js
		  Groupe de javascript utilisés dans le site
-------------------------------------------------------------------------
Auteur : ROTH Damien
Société : VOLTIGEUR Informatique <http://www.voltigeur-informatique.com/>
-------------------------------------------------------------------------
Version : 1.0
Changements :
 - [2006-06-30] Initialisation
-----------------------------------------------------------------------*/

function openCalendar()
{
	fencal = window.open('minical.php','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=260, height=150, left=50, top=50');
}
function closeCalendar()
{
	if(typeof(fencal) == "object" && fencal.closed == false)
		fencal.close();
}
function complete(jour,mois,annee)
{
	elem = document.getElementById('dd');
	
	texte = jour + '-' + mois + '-' + annee;
	elem.value = texte;
	
	closeCalendar();
}

function testInt(champ)
{
	var chiffres = new RegExp("[0-9]");
	var verif;
	
	for(x = 0; x < champ.value.length; x++)
	{
		verif = chiffres.test(champ.value.charAt(x));
		if(verif == false)
		{
			champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1);
			x--;
		}
	}
}

function testTelephone(champ)
{
	var chiffres = new RegExp("[0-9+]");
	var verif;
	var plus = 0;

	for(x = 0; x < champ.value.length; x++)
	{
		verif = chiffres.test(champ.value.charAt(x));
		if(champ.value.charAt(x) == "+" && x==0) { plus++; }
		if(champ.value.charAt(x) == "+" && x!=0) { verif = false; }
		if(plus > 1) { verif = false; plus = 1; }
		if(verif == false)
		{
			champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1);
			x--;
		}
	}
}

/***** Calendrier *****/
function calDispPrec()
{
	var formulaire = document.calendar;
	var mois = formulaire.mois.value;
	var annee = parseInt(formulaire.annee.value);
	
	date = new Date();
	var actu_a = date.getFullYear();
	var	actu_m = date.getMonth()+1;
	
	if((actu_a == annee) && (mois == actu_m))
	{
		alert('erreur');
		return false;
	}
	
	mois--;
	
	if(mois < 1)
	{
		mois = 12;
		annee--;
	}
	
	formulaire.mois.value = mois;
	formulaire.annee.value = annee;
	
	formulaire.submit();
}

function calDispSuiv()
{
	var formulaire = document.calendar;
	var mois = formulaire.mois.value;
	var annee = parseInt(formulaire.annee.value);
	
	date = new Date();
	var actu_a = date.getFullYear();
	var	actu_m = date.getMonth()+1;
	
	if((annee == actu_a+1 ) && (mois == actu_m))
	{
		alert('erreur');
		return false;
	}
	
	mois++;
	
	if(mois > 12)
	{
		mois = 1;
		annee++;
	}
	
	formulaire.mois.value = mois;
	formulaire.annee.value = annee;
	
	formulaire.submit();
}

/*-----------------------------------------------------------------------
					    Fonction de l'administration
-----------------------------------------------------------------------*/
function shide(id)
{
	var elem = document.getElementById(id);
	(elem.style.display && elem.style.display == "block") ? elem.style.display = "none" : elem.style.display = "block";
}

function annule()
{
	return confirm("Voulez-vous réellement annuler cette réservation ?");
}
