



/*
====================================================================
	FONCTION DE CONTROLE DE VALIDITE DES DONNEES DES FORMULAIRES
====================================================================
*/

function testAllFld( frm ){
	
	var elt = eval("document."+frm+".elements")
	var lng = eval("document."+frm+".elements.length")
	
	for( i=0;i< lng ;i++){
		 if( elt[i].type.toUpperCase() != "HIDDEN" && ! _IC_CCI_hasValue2( elt[i] , elt[i].type ) ){
		 	alert("Tous les champs sont obligatoires")
			eval("document."+frm+"."+elt[i].name+".focus()")
			
		 	return false
		 }
	}
	return true
}

/*
	------------------------------------------------
	LA fonction qui effectue le controle des données 
	d'un formulaire
	------------------------------------------------
*/

function _CCI_Ctl_ObjForm_Data( formname ){
	
	//Pointeur sur le formulaire
	var frm = eval ( " document." + formname );
	
	//Etat controle
	var bCtlObjVal = true ;
	
	var sFctName = "" ; //nom de la fonction à exécuter
	var sMsg = ""     ; //Message à afficher
	var sWrongValue = "" ; //Valeur fausse à refuser
	var sFldName = ""     ; //Nom du champ du formualire
	var sLibChamp = "" ; //libellé du champ
	var objName = ""  ; //nom du champ en cours
	var sType = ""    ; //Type de l'element
	
	
	var objCurForm = eval( "tFrmCtl." + formname ) ; //[ tCtlForm ] 

	for( tCtlFld in objCurForm ){ // Parcours des elements du tableau des controles

//alert( tCtlFld )

		sFctName = eval("objCurForm."+tCtlFld+".fct") ; // fonction a appeller

		sMsg     = eval("objCurForm."+tCtlFld+".msg") ; // message
		
		sWrongValue = eval("objCurForm."+tCtlFld+".wrongVal") ; // valeur à refuser
		
		sFldName     = eval("objCurForm."+tCtlFld+".fld") ; // nom champ
		
		sLibChamp    = eval("objCurForm."+tCtlFld+".sLibChamp") ; // libell& champ


		
		sType    = eval( "frm." + sFldName + ".type" ) ; //Type de HTML du champ
		
	//alert( sType + "  " + sFldName + "  " + sLibChamp )
	
		objHtml  = eval( "frm." + sFldName ) ; // champ
		
		eval( "sValue = frm." + sFldName + ".value" ) ; // valeur sasie dans le champ

		if (  !_IC_CCI_CallFonction( frm , objHtml , sFctName , sType , sMsg , sWrongValue , sLibChamp , sValue ) ){
			objHtml.focus()
			return false
		}

	}
	
	return true;
}

function _CCI_Ctl_ObjForm_Data_sav( formname ){
	
	//Pointeur sur le formulaire
	var frm = eval ( " document." + formname );
	
	//Etat controle
	var bCtlObjVal = true ;
	
	var sFctName = "" ; //nom de la fonction à exécuter
	var sMsg = ""     ; //Message à afficher
	var sWrongValue = "" ; //Valeur fausse à refuser
	var sFldName = ""     ; //Nom du champ du formualire
	var sLibChamp = "" ; //libellé du champ
	var objName = ""  ; //nom du champ en cours
	var sType = ""    ; //Type de l'element
	
	//Tableau des paramettres a controler
	//var tParamTOCtl = eval( tFrmCtl + "." + pageid + "." + formname + "." + objname )
	//var tCtlPage = tFrmCtl[ pageid ]
	
	//for( tCtlForm in tCtlPage ) {
		
		var objCurForm = eval( "tFrmCtl." + formname ) ; //[ tCtlForm ] 
//alert(objCurForm)
		for( tCtlFld in objCurForm ){ // Parcours des elements du tableau des controles
//alert(tCtlFld)
			sFctName = objCurForm [ tCtlFld ].fct ; // fonction a appeller
			//alert(sFctName )
			
			sMsg     = objCurForm [ tCtlFld ].msg ; // message
			//alert(sMsg )
			
			sWrongValue = objCurForm [ tCtlFld ].wrongVal ; // valeur à refuser
			//alert(sWrongValue )
			
			sFldName     = objCurForm [ tCtlFld ].fld ; // nom champ
			//alert(sFldName )
			
			sLibChamp    = objCurForm [ tCtlFld ].sLibChamp ; // libell& champ
			//alert(sLibChamp )
			
			sType    = eval( "frm." + sFldName + ".type" ) ; //Type de HTML du champ
			//alert(sType )
			
			objHtml  = eval( "frm." + sFldName ) ; // champ
			//alert(objHtml )
			
			
			eval( "sValue = frm." + sFldName + ".value" ) ; // valeur sasie dans le champ
			//alert( "Valeur saisie ==> " + sValue )
			

			if (  !_IC_CCI_CallFonction( frm , objHtml , sFctName , sType , sMsg , sWrongValue , sLibChamp , sValue ) ){
				objHtml.focus()
				return false
			}
	
		}
	//}
	
	return true;
}


	
/*
	fonction d'invocation des fonctions de controles
*/

function  _IC_CCI_CallFonction( ObjForm , objFld , sFuncName , sFldType , sMsg , sWrongValue , sLibChamp ){



	if( ! ObjForm ){
		alert( "Objet formulaire obligatoire" )
		return false
	}

	if( ! objFld ){
		alert( "Objet champ de formulaire obligatoire" )
		return false
	}

	if( ! sFuncName ){
		alert( "Nom de fonction obligatoire" )
		return false
	}

	switch( sFuncName ) {

	case "_IC_CCI_checkeurodate" :
	    if  (!_IC_CCI_checkeurodate(objFld.value))
	    {
			
			if ( sMsg == "" || sMsg == null ){
				sMsg = "Format de date du champ " + sLibChamp + " invalide. Veuillez saisir les dates au format DD/MM/YYYY"
			}
	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
	
	            {
	
	            return false; 
	
	            }
	
	        }
		break;
	
	case "_IC_CCI_checkphone" :
	
	    if  (!_IC_CCI_checkphone( objFld , objFld.value))
	
	        {
	
			if ( sMsg == "" || sMsg == null ){
				sMsg = "Le format du numéro de téléphone n'est pas valide"
			}
	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg))
	
	            {
	
	            return false; 
	
	            }
	
	        }
		break;
	
	case "_IC_CCI_checktime" :
	    if  (!_IC_CCI_checktime(objFld.value))
	
	        {
	
			if ( sMsg == "" || sMsg == null ){
				sMsg = "LE format de l'heure est invalide. Les haures doivent être au format HH:MM"
			}
	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
	
	            {
	
	            return false; 
	
	            }
	
	        }
		break;
		
	case "_IC_CCI_checkinteger" :
	
	    if  (!_IC_CCI_checkinteger(objFld.value))
	
	        {
	
			if ( sMsg == "" || sMsg == null ){
				sMsg = "Le valeur du champ " + sLibChamp + " que vous saisie n'est pas un entier."
			}
	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg))
	
	            {
	
	            return false; 
	
	            }
	
	        }
		break;
	
	case "_IC_CCI_checknumber" :
	
	    if  (!_IC_CCI_checknumber(objFld.value))
	
	        {
	
			if ( sMsg == "" || sMsg == null ){
				sMsg = "Le valeur du champ " +sLibChamp + " que vous saisie n'est pas un nombre réel."
			}
	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
	
	            {
	
	            return false; 
	
	            }
	
	        }
	
			break ;

	case "_IC_CCI_hasValue" :
	    if  (!_IC_CCI_hasValue(objFld, sFldType ,sWrongValue )) 
	
	        {
	
			if ( sMsg == "" || sMsg == null ){
				sMsg = "Le champ " +sLibChamp + " doit obligatoirement être renseigné."
			}

	        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
	
	            {
	
	            return false; 
	
	            }
	
	        }
	
		break ;
		
	case "_IC_CCI_StrLen" :

		if  (! _IC_CCI_StrLen( objFld.value , sWrongValue ) )
	        {
	
				if ( sMsg == "" || sMsg == null ){
					sMsg = "La longeur du champ " + sLibChamp + " doit être inférieure à " + sWrongValue + " caractères "
				}
		        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
		
		            {
		
		            return false; 
		
		            }
	
	        }
	
		break ;		
	
	case "_IC_CCI_StrLenBetween" :
		
		var t = sWrongValue.split("|") ;
		var deb = sWrongValue.split("|")[0];
		var fin = sWrongValue.split("|")[1];
		var mkctl = true ;
		
				

		if( t.length > 2){
			
			
			
			var toCtl = parseInt( sWrongValue.split("|")[2] );
			
//			alert( "== > toCtl : " + toCtl + "Val == [" + objFld.value.length +"]" )
			
			if( toCtl == 1 && objFld.value.length > 0 ){
//				alert( "== >" + objFld.value.length)
				mkctl = true;
			}else{
				if( objFld.value.length > 0 )
					mkctl = true;
				else
					mkctl = false;
			}
//			alert(mkctl)
		}
		if( mkctl ){
			if  ( ! _IC_CCI_StrLenBetween( objFld.value , parseInt(deb),parseInt(fin) ) )
		        {
		
					if ( sMsg == "" || sMsg == null ){
						if( parseInt(deb) != parseInt(fin) )
							sMsg = "La longeur du champ " + sLibChamp + " doit être comprise entre " + parseInt(deb) + " et " + parseInt(fin) +" caractères "
						else
							sMsg = "La longeur du champ " + sLibChamp + " doit être de " + parseInt(deb) +" caractères "
					}
			        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
			
			            {
			
			            return false; 
			
			            }
		
		        }
		}
		
		break ;		
			
	case "_IC_CCI_ConfirmPwd" :
		if  (! _IC_CCI_ConfirmPwd( objFld.value , eval( "ObjForm." + sWrongValue + ".value" ) ))
	        {
	
				if ( sMsg == "" || sMsg == null ){
					sMsg = "Les mots de passe ne sont pas identiques"
				}
		        if  (!_IC_CCI_onError(ObjForm, objFld, objFld.value, sMsg ))
		
		            {
		
		            return false; 
		
		            }
	
	        }
	
		break ;		
		
	case "_IC_CCI_emailCheck" :

		if  (! _IC_CCI_emailCheck( objFld.value ) )
	        {
	            return false; 
	        }
	}	
		
    return true;

}

/*
	===========================================================================
*/

/*
	Fonction controlant les champs vides
*/


function _IC_CCI_hasValue2(obj, obj_type)
    {
	
	obj_type = obj_type.toUpperCase()

    if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA")
	{
    	if (obj.value.length == 0)  
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SELECT-ONE")
	{
	//alert("val = " + obj.options[ obj.options.selectedIndex ].value)
        //for (i=0; i < obj.length; i++){
			//if (obj.options[i].selected)
			//if ( obj.options[i].selected && obj.options[i].value == wrg_val ){
			
			if ( obj.options[ obj.options.selectedIndex ].value == "0" ){
				return false;
			}
		//}

       	return true;	
	}
    else if (obj_type == "SELECT-MULTIPLE")
	{
	//alert(wrg_val)
        for (i=0; i < obj.length; i++){
			//if (obj.options[i].selected)
			if ( obj.options[i].selected && obj.options[i].value == "0" )
				return false;
		}

       	return true;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}


function _IC_CCI_hasValue(obj, obj_type , wrg_val )
    {
	
	obj_type = obj_type.toUpperCase()

	//alert(obj_type)

    if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA" )
	{
    	//if (obj.value.length == 0) 
		if( obj.value == wrg_val)
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT-ONE")
	{
	//alert("val = " + obj.options[ obj.options.selectedIndex ].value)
        //for (i=0; i < obj.length; i++){
			//if (obj.options[i].selected)
			//if ( obj.options[i].selected && obj.options[i].value == wrg_val ){
			
			if ( obj.options[ obj.options.selectedIndex ].value == wrg_val ){
				return false;
			}
		//}

       	return true;	
	}
    else if (obj_type == "SELECT-MULTIPLE")
	{
	//alert(wrg_val)
        for (i=0; i < obj.length; i++){
			//if (obj.options[i].selected)
			if ( obj.options[i].selected && obj.options[i].value == wrg_val )
				return false;
		}

       	return true;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}



/*
	controle si les mots de passes saisis sont identiques
*/
function _IC_CCI_ConfirmPwd( sVal1 , sVal2 ){
	if( sVal2 != sVal1 ){
		return false
	}
	return true
}


/*
	controle la longueur des chaines
*/
function _IC_CCI_StrLen( sVal , iLen ){
	
	var sLocalVal = sVal.toString()
	
	if ( sLocalVal.length > parseInt( iLen ) ){
		return false
	}
	return true
}



/*
	controle la longueur des chaines : si une chaine a un longueur précise
*/
function _IC_CCI_StrLenBetween( sVal , iDeb , iFin ){
	
	var sLocalVal = sVal.toString()
	if ( sLocalVal ){
	if ( 
		! ( 
			sLocalVal.length <= parseInt( iFin ) && 
			sLocalVal.length >= parseInt( iDeb ) 
		) 
	){
		
		return false
	}
	}
	return true
}
/*
function _IC_CCI_ComboBox ( form_name , object_name ) {
	var cboObj = eval( "document." + form_name + "." + object_name  )
	var sValue = cboObj.options[ cboObj.selectedIndex ].value
	
	if( parseInt( sValue ) == 0 ){
		return false
	}
	
	return true
}
*/

/*
	controle la validité des emails
*/

function _IC_CCI_emailCheck (emailStr) {

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	if( emailStr == "" || emailStr == null )
		return true
		
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		alert("Email incorrecte: @ et/ou . manquant")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
	    alert("Le nom utilisateur ne semble pas valide.")
	    return false
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("L'adresse IP n'est pas valide.")
			return false
		    }
	    }
	    return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Le nom de domaine semble invalide")
	    return false
	}
	

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   alert("L'adresse email doit se terminer par 3 lettres correspondant au domaine ou 2 lettres correspondant au pays")
	   return false
	}

	if (len<2) {
	   var errStr="Cette adresse ne contient pas le nom d'hôte!"
	   alert(errStr)
	   return false
	}

	return true;
}	

/*
	gestionnaire d'erreurs
*/

function _IC_CCI_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }


/*
	controle le format des dates
*/

function _IC_CCI_checkeurodate(object_value)
    {
    //Returns true if value is a eurodate format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the dd/mm/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.');
	}

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sDay = object_value.substring(0, isplit);

	monthSplit = isplit + 1;

	isplit = object_value.indexOf('/', monthSplit);

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.', monthSplit);
	}

	if (isplit == -1 ||  (isplit + 1 )  == object_value.length)
		return false;

    sMonth = object_value.substring((sDay.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_IC_CCI_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_IC_CCI_checkrange(sMonth, 1, 12)) // check month
		return false;
	else
	if (!_IC_CCI_checkinteger(sYear)) //check year
		return false;
	else
	if (!_IC_CCI_checkrange(sYear, 0, null)) //check year
		return false;
	else
	if (!_IC_CCI_checkinteger(sDay)) //check day
		return false;
	else
	if (!_IC_CCI_checkday(sYear, sMonth, sDay)) //check day
		return false;
	else
		return true;
    }

function _IC_CCI_checkeurodate2(object_value)
    {
    //Returns true if value is a eurodate format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the dd-mm-yyyy format
	isplit = object_value.indexOf('-');

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.');
	}

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sDay = object_value.substring(0, isplit);

	monthSplit = isplit + 1;

	isplit = object_value.indexOf('-', monthSplit);

	if (isplit == -1)
	{
		isplit = object_value.indexOf('.', monthSplit);
	}

	if (isplit == -1 ||  (isplit + 1 )  == object_value.length)
		return false;

    sMonth = object_value.substring((sDay.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_IC_CCI_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_IC_CCI_checkrange(sMonth, 1, 12)) // check month
		return false;
	else
	if (!_IC_CCI_checkinteger(sYear)) //check year
		return false;
	else
	if (!_IC_CCI_checkrange(sYear, 0, null)) //check year
		return false;
	else
	if (!_IC_CCI_checkinteger(sDay)) //check day
		return false;
	else
	if (!_IC_CCI_checkday(sYear, sMonth, sDay)) //check day
		return false;
	else
		return true;
    }
/*
	controle les jours
*/

function _IC_CCI_checkday(checkYear, checkMonth, checkDay)
    {

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 ||
			checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else
		if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return _IC_CCI_checkrange(checkDay, 1, maxDay); //check day
    }


/*
	controle des entiers
*/

function _IC_CCI_checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _IC_CCI_checknumber(object_value);
    else
	return false;
    }


/*
	controle si un entier est bien dans les ilmites fixées
*/

function _IC_CCI_numberrange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
    }


/*
	controle des nombres en général (reel, entier...)
*/

function _IC_CCI_checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }


/*
	controle si un nombre est bien dasn son ensemble de definition
*/

function _IC_CCI_checkrange(object_value, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (object_value.length == 0)
        return true;


    if (!_IC_CCI_checknumber(object_value))
	{
	return false;
	}
    else
	{
	return (_IC_CCI_numberrange((eval(object_value)), min_value, max_value));
	}
	
    //All tests passed, so...
    return true;
    }


/*
	controle des heures
*/

function _IC_CCI_checktime(object_value)
    {
    //Returns true if value is in time format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf(':');

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sHour = object_value.substring(0, isplit);
	iminute = object_value.indexOf(':', isplit + 1);

	if (iminute == -1 || iminute == object_value.length)
		sMin = object_value.substring((sHour.length + 1));
	else
		sMin = object_value.substring((sHour.length + 1), iminute);

    if (!_IC_CCI_checkinteger(sHour)) //check hour
		return false;
    else
    if (!_IC_CCI_checkrange(sHour, 0, 23)) //check hour
		return false;

	if (!_IC_CCI_checkinteger(sMin)) //check minutes
		return false;
	else
	if (!_IC_CCI_checkrange(sMin, 0, 59)) // check minutes
		return false;

	// did they specify seconds
    if (iminute != -1)
	{
		sSec = object_value.substring(iminute + 1);

		if (!_IC_CCI_checkinteger(sSec)) //check seconds
			return false;
		else
		if (!_IC_CCI_checkrange(sSec, 0, 59)) //check seconds
			return false;	
	}
    
    return true;
    }
    

/*
	controle des numeros de telephone
*/
//function _IC_CCI_formatTelFax( objFld , val ){
function _IC_CCI_formatTelFax( val ){	
	
	var tmp = "" 
	
	if( val.length )
	
	tmp = val.substring(0,2) 
	
	for( i=2;i<10;i+=2 ){
		tmp = tmp + " " + val.substring(i,i+2) 
			
	}
	//objFld.value = tmp
	return tmp
	
}
function _IC_CCI_checkphone( obj , object_value )
    {
    	
    if (object_value.length == 0)
        return true;
		
    if ( object_value.length == 10){
        object_value = _IC_CCI_formatTelFax( object_value )
        obj.value = object_value
	}

    if (object_value.length != 10 && object_value.length != 14 )
        return false;




	// check if first 3 characters represent a valid area code
    if (!_IC_CCI_checknumber(object_value.substring(0,2)))
    		
		return false;
    else
	if (!_IC_CCI_numberrange((eval(object_value.substring(0,2))), 1, 10))
		return false;
	// check if area code/exchange separator is either a'-' or ' '
	if (object_value.charAt(2) != "-" && object_value.charAt(2) != " " && object_value.charAt(2) != ".")
        return false



	// check if  characters 4 - 6 represent a valid exchange
    if (!_IC_CCI_checknumber(object_value.substring(3,5)))
		return false;
    else
	if (!_IC_CCI_numberrange((eval(object_value.substring(3,5))), 0, 100))
		return false;
	

	// check if exchange/number separator is either a'-' or ' '
	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " "&& object_value.charAt(5) != ".")
        return false;


    if (!_IC_CCI_checknumber(object_value.substring(6,8)))
		return false;
    else
	if (!_IC_CCI_numberrange((eval(object_value.substring(6,8))), 0, 100))
		return false;
	
	// check if exchange/number separator is either a'-' or ' '
	if (object_value.charAt(8) != "-" && object_value.charAt(8) != " "&& object_value.charAt(8) != ".")
        return false;


    if (!_IC_CCI_checknumber(object_value.substring(9,11)))
		return false;
    else
	if (!_IC_CCI_numberrange((eval(object_value.substring(9,11))), 0, 100))
		return false;

	
	// check if exchange/number separator is either a'-' or ' '
	if (object_value.charAt(11) != "-" && object_value.charAt(11) != " "&& object_value.charAt(11) != ".")
        return false;

	// make sure last for digits are a valid integer
	return (_IC_CCI_checkinteger(object_value.substring(12,14)));

    }

