function vide(chaine) 
{
	if (chaine.length=="0") 
		{
		return true;
		}
		else
		{
   		i=0;
	   while (i<chaine.length)
       {
        y=i++;
	    car=chaine.substring(i,y);
       if ((car==" ") || (car=='\r') || (car=='\n'))
		 {
		   i++;
		 }
		 else
		 {
		 return false;
		 }
		}
		 return true;	
	 	}
}

		function IndicatifPays (Indicatif,Pays){
			this.Indicatif 	 	= Indicatif;
			this.Pays 	 	= Pays;
		}
		function ListeIndicatifPays (){
			this.IndicatifPaysArray 	= new Array();
			
			this.addIndicatifPays = function(IndicatifPays){
				this.IndicatifPaysArray.push(IndicatifPays);
			};
			this.getIndicatifPays = function(Indicatif){
			  	for(this.cpt=0 ; this.cpt<this.IndicatifPaysArray.length ; this.cpt++) {
			   		IndicatifPays = this.IndicatifPaysArray[this.cpt];
					if (IndicatifPays.Indicatif==Indicatif){
						return IndicatifPays;
					}
				}
				return false;
			};
			this.setIndicatifPays = function(Indicatif){
				corrigeNumeroTelephone(document.getElementById("InputIndicatif"));
				if (Indicatif.length<3){
				 
					hideElementById("TablePays1");
					hideElementById("TablePays2");
					hideResult();

				} else {
					showElementById("TablePays1");
					showElementById("TablePays2");
					
					IndicatifPays=this.getIndicatifPays(Indicatif);
					
					if (IndicatifPays){
						
						_InputPays = document.getElementById('InputPays');
						_InputPays.innerHTML = "";
						_InputPays.innerHTML = IndicatifPays.Pays;
						setNumeroTelephone(document.getElementById("InputNumero"));
						InputNumero = document.getElementById("InputNumero");
						InputNumero.focus();
						
						if (Indicatif=="221"){
							_InputExemple = document.getElementById('TexteAideContext');
							_InputExemple.innerHTML = "";
							_InputExemple.innerHTML = "Vérifiez bien le numéro <br/>"+
										"que vous avez saisi (ex : 762840025)<br/>"+
										"<font color='red'>Nouvelle numérotation, n'oubliez pas le 76.</font>";
						} else if (Indicatif=="243"){
							_InputExemple = document.getElementById('TexteAideContext');
							_InputExemple.innerHTML = "";
							_InputExemple.innerHTML = "Vérifiez bien le numéro <br/>"+
										"que vous avez saisi (ex : 812589654) ";
						} else if (Indicatif=="242"){
							_InputExemple = document.getElementById('TexteAideContext');
							_InputExemple.innerHTML = "";
							_InputExemple.innerHTML = "Vérifiez bien le numéro <br/>"+
										"que vous avez saisi (ex : 6210866) ";
						} else if (Indicatif=="237"){
							_InputExemple = document.getElementById('TexteAideContext');
							_InputExemple.innerHTML = "";
							_InputExemple.innerHTML = "Vérifiez bien le numéro <br/>"+
										"que vous avez saisi (ex : 79754999) ";
						}
					}else{
		   				
		   				_InputPays = document.getElementById('InputPays');
						_InputPays.innerHTML = "";
						_InputPays.innerHTML = "<font color='red'>Indicatif inconnu</font>";
						InputIndicatif = document.getElementById("InputIndicatif");
						InputIndicatif.focus();
						hideResult();
						
					}
				}
				
			}
			
		}
		var ListeIndicatifPays = new ListeIndicatifPays();

 		function corrigeNumeroTelephone(InputTelephone){
 			//InputTelephone.value=InputTelephone.value.replace(/^0/gi, '');
	 		InputTelephone.value=InputTelephone.value.replace(/[^0-9]/gi, '');
 			return;
 		}
 		function corrigeNumeroTelephoneSimple(InputTelephone){
	 		InputTelephone.value=InputTelephone.value.replace(/[^0-9]/gi, '');
 			return;
 		}

	//reg = new RegExp('[^0-9]+', 'g'); 


 		function setNumeroTelephone(InputTelephone){
 			corrigeNumeroTelephone(InputTelephone);
			
			if (InputTelephone.value.length<10){
				 
				hideElementById("TableOperator1");
				hideElementById("TableOperator2");
				hideResult();
					
			} 
			
			_InputIndicatif = document.getElementById("InputIndicatif");

			if (_InputIndicatif.value==237 && InputTelephone.value.length>7){
				showElementById("TableOperator1");
				showElementById("TableOperator2");
				if ( InputTelephone.value.substring(0,1)==7 && InputTelephone.value.length==8 ) {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "MTN Cameroun";
					if (	document.getElementById("IndicatifOK").value=1 
						&& (document.getElementById("ChargeOK").value==1 || document.getElementById("ChargeCarteOK").value==1) )showResult();
				} else {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
					hideResult();
				}
			} else if (_InputIndicatif.value==242 && InputTelephone.value.length>6){
				showElementById("TableOperator1");
				showElementById("TableOperator2");
				if ( ( InputTelephone.value.substring(0,1)==6 || InputTelephone.value.substring(0,2)==95 || InputTelephone.value.substring(0,2)==97 )
					 && InputTelephone.value.length==7 ){
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "MTN Congo";
					if ( document.getElementById("IndicatifOK").value=1 
						&& (document.getElementById("ChargeOK").value==1 || document.getElementById("ChargeCarteOK").value==1) )showResult();
					if ( document.getElementById("IndicatifOK").value=1 ) showResult();
				} else {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
					//alert("c'est la ...");
					//hideResult();
				}
			} else if (_InputIndicatif.value==243 && InputTelephone.value.length>8){
				showElementById("TableOperator1");
				showElementById("TableOperator2");
				if (InputTelephone.value.substring(0,2)==81 && InputTelephone.value.length==9){
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "Vodacom";
					if ( document.getElementById("IndicatifOK").value=1 
						&& (document.getElementById("ChargeOK").value==1 || document.getElementById("ChargeCarteOK").value==1) )showResult();
					if ( document.getElementById("IndicatifOK").value=1 ) showResult();
				} else {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
					//alert("c'est la ...");
					//hideResult();
				}
			} else if(_InputIndicatif.value==213 && InputTelephone.value.length>7) {
				showElementById("TableOperator1");
				showElementById("TableOperator2");
				if (InputTelephone.value.substring(0,2)==70 && InputTelephone.value.length==8){
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "Djezzy";
					if (	document.getElementById("IndicatifOK").value=1 
						&& (document.getElementById("ChargeOK").value==1 || document.getElementById("ChargeCarteOK").value==1) )
							showResult();
					if ( document.getElementById("IndicatifOK").value=1 ) showResult();
				} else {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
					hideResult();
				}
			} else if(_InputIndicatif.value==221 && InputTelephone.value.length==7) {
				if (InputTelephone.value.substring(0,2)!=76){
					InputTelephone.value = "76"+InputTelephone.value;
					showResult();
				}
			} else if(_InputIndicatif.value==221 && InputTelephone.value.length>8) {
				showElementById("TableOperator1");
				showElementById("TableOperator2");
				if (InputTelephone.value.substring(0,2)==76 && InputTelephone.value.length==9 ){
					
					if (   InputTelephone.value.substring(2,4)==28
						|| InputTelephone.value.substring(2,4)==29
						|| InputTelephone.value.substring(2,4)==33
						|| InputTelephone.value.substring(2,4)==34
						|| InputTelephone.value.substring(2,4)==38
						|| InputTelephone.value.substring(2,4)==39
						|| InputTelephone.value.substring(2,4)==46
						|| InputTelephone.value.substring(2,4)==47
						|| InputTelephone.value.substring(2,4)==48
						|| InputTelephone.value.substring(2,4)==49
						|| InputTelephone.value.substring(2,4)==58
						|| InputTelephone.value.substring(2,4)==59
						|| InputTelephone.value.substring(2,4)==66
						|| InputTelephone.value.substring(2,4)==67
						|| InputTelephone.value.substring(2,4)==68
						|| InputTelephone.value.substring(2,4)==69
						|| InputTelephone.value.substring(2,4)==74
						|| InputTelephone.value.substring(2,4)==75
						|| InputTelephone.value.substring(2,4)==12
						|| InputTelephone.value.substring(2,4)==13
						|| InputTelephone.value.substring(2,4)==86
						|| InputTelephone.value.substring(2,4)==84
						|| InputTelephone.value.substring(2,4)==85
						){

	
						_InputOperateur = document.getElementById("InputOperateur");
						_InputOperateur.innerHTML = "";
						_InputOperateur.innerHTML = "Tigo";
						if (	document.getElementById("IndicatifOK").value=1 )
								showResult();
					} else {
						_InputOperateur = document.getElementById("InputOperateur");
						_InputOperateur.innerHTML = "";
						_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
				
						alert("Désolé, ce numéro ne correspond pas ŕ un abonné Tigo. Merci de demander ŕ votre correspondant de vous communiquer un numéro Tigo.");
				
						hideResult();
					}
				} else {
					_InputOperateur = document.getElementById("InputOperateur");
					_InputOperateur.innerHTML = "";
					_InputOperateur.innerHTML = "<font color='red'>Opérateur inconnu</font>";
					hideResult();
				}

			} else {
				hideElementById("TableOperator1");
				hideElementById("TableOperator2");
				hideResult();
			}
		
 		}

		function hideResult(){
			_Etape3 = document.getElementById("Etape3");
			if (_Etape3)
				_Etape3.style.display="none";
		}

		function showResult(){
			document.CalculCharge.submit();
		}
 
 		function hideElementById(IdToHide){
			ElementToHide = document.getElementById(IdToHide);
			if (ElementToHide)
				ElementToHide.style.display="none";
		}
 		function showElementById(IdToShow){
			ElementToShow = document.getElementById(IdToShow);
			if (ElementToShow)
				ElementToShow.style.display="block";
		}
		function docheck(num){
			RadioPaiement = document.CalculCharge.ModePaiement;
			RadioPaiement[num].checked=true;
			document.CalculCharge.submit()
		}


