// JavaScript Document

function popupcentree(page,largeur,hauteur,options) {	
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 
}


function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function changerEtat(champ) {
	switch(champ.type) {
		case 'text':
		case 'textarea':
		case 'password':
			champ.style.borderColor = 'red';
			champ.setAttribute('onkeyup', champ.id + ".style.borderColor = 'silver'; " + champ.id + ".setAttribute('onKeyUp', '');");
			break;
		default:
			break;
	}
}

function valid(form) {
	var nb = 0;
	for(var i = 0; i < (form.length); i++) {
		var champ = form.elements[i];
		switch(champ.type) {
			case 'text':
			case 'textarea':
			case 'password':
				var label = $('label_' + champ.id);
				if(label.innerHTML.charAt(0) == '*') {
					if(champ.value == '') {
						changerEtat(champ);
						nb++;
					}
				}
				break;
			default:
				break;
		}
	}
	if(nb!=0) {
		alert('Veuillez remplir les champs indiqués');
		scrollTo(0,0);
	}
	return (nb==0);
}

//-----------Gestion du chronomètre--------------------------------


