


sErrColor = '#f4d7e2';
sValidColor = '#ffffff';
sTextErrColor = '#000000';
sTextValidColor = '#000000';
iTextMaxLength = 2500;

// Objet "Element de formulaire à vérifier"
// oItem : .item_id / .confirm_id / .mandatory / .type / .empty_msg / .invalid_msg / .differ_msg
// type : string | boolean | email | birth_year | login | password
/*
// Bruno : on d�porte la d�finition de cette fonction dans form_validation_top.js
function icFormItem (sItemId, sConfirmId, bMandatory, sType, sEmptyMsg, sInvalidMsg, sDifferMsg) {
	this.item_id     = sItemId;
	this.confirm_id  = sConfirmId;
	this.mandatory   = bMandatory;
	this.type        = sType;
	this.empty_msg   = sEmptyMsg;
	this.invalid_msg = sInvalidMsg;
	this.differ_msg  = sDifferMsg;	
}
*/
// Fonction de validation
// La liste des objets �l�ments est pass�e en param�tre
/*
function FormValidation(oFormItem) {
	if(!cancelAction) {
		for (var item in oFormItem) {
			var oItem = oFormItem[item];
			var oElement = document.getElementById(oItem.item_id);	

			// TYPE STRING
			if (oItem.type =='string'&&oElement) {
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				validate(oElement, null);
			}			
			// TYPE SELECT			
			if (oItem.type =='select'&&oElement) {
				if ((oItem.mandatory == 1)&&(oElement.selectedIndex == 0)) {
								
					return riseError(oElement, null, oItem.empty_msg);
				}
				validate(oElement, null);
			}
			// TYPE RADIO			
			if (oItem.type =='radio') {
				var rootNode = document.getElementById(oItem.item_id);
				inputs = rootNode.getElementsByTagName("input");
				is_empty = true;
				for(i=0;i<inputs.length;i++) {
					if(inputs[i].checked)
						is_empty = false;
				}
				
				if(is_empty) {
					alert(oItem.empty_msg);
					return false;
				}
			}	

			// TYPE BIRTH_YEAR
			if (oItem.type =='birth_year'&&oElement) {
				var today = new Date();
				if (oItem.mandatory == 1){
					if (oElement.value.length == 0) {
						return riseError(oElement, null, oItem.empty_msg);
					}
					else if ((isNaN(parseInt(oElement.value)))&&(oElement.value.length != 0)) {
						return riseError(oElement, null, oItem.invalid_msg);
					}
					else if (((parseInt(oElement.value)<1880)||(parseInt(oElement.value)>today.getFullYear())&&(oElement.value.length != 0))) {
						return riseError(oElement, null, oItem.invalid_msg);
					}
				}
				validate(oElement, null);
			}

			// TYPE INTEGER			
			if (oItem.type =='integer'&&oElement) {						
				var regInteger = /^[0-9]+$/;
					if (oItem.mandatory == 1 && oElement.value.length == 0) {					
						return riseError(oElement, null, oItem.empty_msg);					
					}
					else if ((isNaN(parseInt(oElement.value)) || !oElement.value.match(regInteger))&&(oElement.value.length != 0)) {
						return riseError(oElement, null, oItem.invalid_msg);					
					}
					else if (((parseInt(oElement.value)<oItem.mandatory) &&(oElement.value.length != 0))) {
						return riseError(oElement, null, oItem.differ_msg);
					}
				validate(oElement, null);
			}
			
			// TYPE LOGIN
			if (oItem.type =='login'&&oElement) {
				var regLogin = /^[a-zA-Z0-9_-]{3,20}$/i;
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0) ) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				else {
					if (!oElement.value.match(regLogin)) return riseError(oElement, null, oItem.invalid_msg);
				}
				validate(oElement, null);
			}

			// TYPE PASSWORD
			if (oItem.type =='password'&&oElement) {
				
				var oElementConfirm = document.getElementById(oItem.confirm_id);				
				var regPassword = /^[a-zA-Z0-9_-]{4,20}$/i;

				if ((oItem.mandatory == 1)&&((oElement.value.length == 0)||(oElementConfirm.value.length == 0))) {
					return riseError(oElement, oElementConfirm, oItem.empty_msg);
				}
				else if (oElement.value.length > 0){
					if (!oElement.value.match(regPassword)) 
						return riseError(oElement, oElementConfirm, oItem.invalid_msg);
					else if (oElement.value != oElementConfirm.value) {
						return riseError(oElement, oElementConfirm, oItem.differ_msg);
					}else 
					validate(oElement, oElementConfirm);
				}
				validate(oElement, oElementConfirm);
			}
			// TYPE EMAIL
			if (oItem.type =='email'&&oElement) {		
				var regEmail = /([0-9a-zA-Z]([-+.\w]*[0-9a-zA-Z_])*@(((([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})|(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))/;
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				else if (oElement.value.length > 0){					
					if (!oElement.value.match(regEmail))
						return riseError(oElement, null, oItem.invalid_msg);
					else
					validate(oElement, null);
				}
				
				validate(oElement, null);
			}

			// TYPE BOOLEAN
			if (oItem.type =='boolean'&&oElement) {
				if ((oItem.mandatory == 1)&&(!oElement.checked)) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				validate(oElement, null);
			}

			// TYPE TEXT
			if (oItem.type =='text'&&oElement) {
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				else if (oElement.value.length > iTextMaxLength){
					return riseError(oElement, null, oItem.invalid_msg);
				}
				validate(oElement, null);
			}

			// TYPE PHONE
			if (oItem.type =='phone'&&oElement) {
				var regPhone = /^[0-9\.\+\-\(\) ]{10,30}$/g;
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)) {
					return riseError(oElement, null, oItem.empty_msg);
				}
				else if (oElement.value.length > 0){
					if (!oElement.value.match(regPhone)) return riseError(oElement, null, oItem.invalid_msg);
				}
				validate(oElement, null);
			}
			

			// TYPE DUAL PHONE
			if (oItem.type =='dual_phone'&&oElement) {
				var oElementDual = document.getElementById(oItem.confirm_id);
				var regPhone = /^[0-9\.\+\-\(\) ]{10,30}$/g;
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)&&(oElementDual.value.length == 0)) {
					return riseError(oElement, oElementDual, oItem.empty_msg);
				}
				else if (oElement.value.length > 0){
					if (!oElement.value.match(regPhone)) return riseError(oElement, null, oItem.invalid_msg);
				}
				else if (oElementDual.value.length > 0){
					if (!oElementDual.value.match(regPhone)) return riseError(oElementDual, null, oItem.invalid_msg);
				}
				validate(oElement, oElementDual);
			}
			// TYPE DUAL DEP CITY
			if (oItem.type =='dual_ville_dep'&&oElement) {
				
				var oElementDual = document.getElementById(oItem.confirm_id);				
				if ((oItem.mandatory == 1)&&(oElement.value.length == 0)&&(oElementDual.value.length == 0)) {
					return riseError(oElement, oElementDual, oItem.empty_msg);
				}
				//else if (oElement.value.length > 0){
				//	if (!oElement.value.match(regPhone)) return riseError(oElement, null, oItem.invalid_msg);
				//}
				//else if (oElementDual.value.length > 0){
				//	if (!oElementDual.value.match(regPhone)) return riseError(oElementDual, null, oItem.invalid_msg);
				//}
				validate(oElement, oElementDual);
			}

		}
		return true;
	}
	else {
		return true;
	}
}

 function riseError (oItem,oConfirmItem,sMsg) {
	alert(sMsg);
	oItem.style.backgroundColor = sErrColor;
	oItem.style.color = sTextErrColor;
	if(oConfirmItem) {
		oConfirmItem.style.backgroundColor = sErrColor;
	}
	oItem.focus();

	return false;
}

 function validate (oItem, oConfirmItem) { 	
	oItem.style.backgroundColor = sValidColor;
	oItem.style.color = sTextValidColor;
	if(oConfirmItem) {
		oConfirmItem.style.backgroundColor = sValidColor;		
	}
	return true;
}

function oKiosk(sUrl,sName,iWid,iHei,iLeft,iTop){var kWid=750;if(iWid>=100) kWid=iWid;else if(screen&&screen.availWidth) kWid=screen.availWidth-50;else if(self.outerWidth) kWid=self.outerWidth;var kHei=550;if (iHei>=100) kHei=iHei;else if(screen&&screen.availHeight) kHei=screen.availHeight-100;else if(self.outerHeight) kHei=self.outerHeight;var kLeft=25;if(iLeft>=0) kLeft=iLeft;else if(screen&&screen.availWidth) kLeft=Math.floor((screen.availWidth-kWid)/2);else if(self.screenX) kLeft=self.screenX;var kTop=25;if(iTop>=0) kTop=iTop;else if(screen&&screen.availHeight) kTop=Math.floor((screen.availHeight-kHei)/2);else if(self.screenY) kTop=self.screenY;var options='toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + kWid + ',height=' + kHei + ',top=' + kTop + ',left=' + kLeft;newWindow = window.open(sUrl,sName,options);if (newWindow.focus){newWindow.focus();}}
*/
