

function coll(e) {
    if (document.getElementById(e).style.display == 'none') {
        document.getElementById(e).style.display = 'block';
    } else {
        document.getElementById(e).style.display = 'none';
    }
}
function genTemplate(e)
{
	if (window.document.go.categorie.value == 0)
	{
		window.alert("Note: vous n'avez selectionnez aucune catégorie.");
	}
	window.document.go.message.value = window.document.go.message.value + "#"+e+"#"
	window.document.go.message.focus();
	return false;
}

function hideall() {
	var Nodes = document.getElementsByTagName('dl')
	var max = Nodes.length
	for(var i = 0;i < max;i++) {
		var nodeObj = Nodes.item(i)
		nodeObj.style.display = 'none';
	}
}
function IsNumericC(oElem)
{
   var strString = oElem.value;
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
            window.alert("Ce champ n'accepte que les nombres.");
            highlight(oElem);
            //oElem.focus();
        }
   }
   return blnResult;

}


function toConfirm(go)
{
    /*if (window.document.go.categorie.value == "" && window.document.go.categorie.value == 0)
   {
       alert("Veuillez selectionner une catégorie !");
        window.document.go.categorie.focus();
      return false;
    }*/

   //window.document.go.message.value=replace(window.document.go.message.value,charCodeAt(13)," ")
    if (window.document.go.message.value == "")
   {
        alert ("Veuillez saisir un texte !");
        window.document.go.message.focus();
       return false;
   }
   
   	if (window.document.go.categorie.value == "")
   {
        alert ("Veuillez identifier vos destinataires !");
        window.document.go.categorie.focus();
		
       return false;
   }
   
   if(window.document.go.categorie.value.indexOf(";")!= -1 ){
	   	alert ("Veuillez séparer les N° GSM qu'avec la virgule !");
        window.document.go.categorie.focus();
        return false;   
   }
  

	if (window.document.go.remLen.value >= 161)
	{
		alert("Le message ne doit pas dépasser 160 caractéres");
	
		return false;
	}
}

function textCounter(field, countfield, maxlimit) 
{ 
			 
	var countStr = 0;
	for(i=0 ;i<field.value.length;i++){
		  
		  car=field.value.substring(i,i+1);
		  rc =String.fromCharCode(10)
		  
		  if (rc==car){
	
			  countStr = countStr + 1
		  }
		  
		  if(car=='é' || car=='è' || car=='à' || car=='@' || car=='£' || car=='ç' || car=='Ç' || car=='ù' || car=='ì' || car=='_' || car=='&'){
			
		  	countStr = countStr + 3;
		  }
		  else{
			countStr = countStr + 1;
		  }
	}
	//alert(countfield.value);
  if ( countStr > maxlimit )
  {
    
    alert( 'Le message ne doit pas dépasser 160 caractéres' );
	var NCar=0;
	var CountC=0;
	
	for(j=0;j<field.value.length;j++)
	{
		 car=field.value.substring(i,i+1);
		if(CountC<=maxlimit)
		{
		  if(car=='é' || car=='è' || car=='à' || car=='@' || car=='&')
		  {
			  CountC = CountC + 3;
			  NCar = NCar + 1;
		  }
		  else
		  {
			  CountC = CountC + 1;	  
			  NCar = NCar + 1;
		  }
		}
		else
		{
			break;
		}
	}
	field.value = field.value.substring( 0, NCar-1 );
	var c=0;
		for(i=0 ;i<field.value.length;i++){
		  car=field.value.substring(i,i+1);
		  //alert(car);
		  if(car=='é' || car=='è' || car=='à' || car=='@' || car=='&'){
			
		  	c = c + 3;
		  }
		  else{
			c = c + 1;
		  }
	}
	countfield.value = c;
    return false;
	
  }
  else
  {
	  countfield.value =countStr;
  }
  /*else{
	  var car;
	  var countStr = 0;
	  for(i=0 ;i<field.value.length;i++){
		  car=field.value.substring(i,i+1);
		  //alert(car);
		  if(car=='é' || car=='è' || car=='à' || car=='@'){
			
		  	countStr = countStr + 3;
		  }
		  else{
			countStr = countStr + 1;
		  }
		   countfield.value = countStr;
	  }*/
	 
	  /*car=field.value.substring(field.value.length-1,field.value.length);
	  //alert(car);
	  if(car=='é' || car=='è' || car=='à' || car=='@'){
		  var countStr = countfield.value * 1;
		  countfield.value = countStr + 3;
	  }
	  else{
     	  countfield.value = field.value.length;
	  }*/
  
}


function IsNumericTo(oElem)
{
   var strString = oElem.value;
   var strValidChars = "0123456789,";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      	if (strValidChars.indexOf(strChar) == -1)
        {
        	blnResult = false;
			window.alert("Ce champ accepte juste les nombres et ','.");
			highlight(oElem);
			//oElem.focus();
        }
   }
   return blnResult;

}



function changeAction( element ) {
		if (element.value == '3') {
			document.getElementById('targetGroup').style.visibility = 'hidden';
		} else {
			document.getElementById('targetGroup').style.visibility = 'visible';
		}
}
function popopen(file, nom, width, height) {
	window.open(file, nom, 'scrollbars=no,location=no,directories=no, status=no, menubar=no,left=80,top=100,toolbar=no,resize=no,width='+ 390 +',height='+ 160);
}
function popopen5(file, nom, width, height) {
	window.open(file, nom, 'scrollbars=yes,location=no,directories=no, status=no, menubar=no,left=80,top=100,toolbar=no,resize=no,width='+ 390 +',height='+ 160);
}
function popopen6(file, nom, width, height) {
	window.open(file, nom, 'scrollbars=NO,location=no,directories=no, status=no, menubar=no,left=80,top=100,toolbar=no,resize=no,width='+ 628 +',height='+ 242);
}
function popopen2(file, nom, width, height) {
	window.open(file, nom, 'scrollbars=yes,location=no,directories=no, status=no, menubar=no,left=10,top=10,toolbar=no,resize=no,width='+ 810 +',height='+ 600);
}
function popopen1(file, nom, width, height) {
	window.open(file, nom, 'scrollbars=no,location=no,directories=no, status=no, menubar=no,left=80,top=100,toolbar=no,resize=no,width='+ 500 +',height='+ 350);
}
function redirectPage( sPage ) {
		window.location.href = '/membres/' + sPage;
	}
	
function check_desti() 
{ 
   temp = (document.selection.elements.length); 
   if (document.selection.elements[0].checked) 
	
   { 
     for (i=1; i < temp; i++) 
     { 
	 document.selection.elements[i].checked=1; 
	 } 
   } 
   else 
   { 
      for (i=1; i < temp; i++) 
     { 
         document.selection.elements[i].checked=0; 
     	 
     } 
   } 
} 

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function validate() {
if (!(go.save.checked)) {
event.returnValue=false;
}
}
   
function MIT(Id_cat,categ){
	
if (go.elements.categorie.value.length == 0 || go.elements.categorie.value.indexOf(categ) == -1) 
{
if (go.elements.categorie.value.length != 0 && go.elements.categorie.value.charAt(go.elements.categorie.value.length - 1) != ",")
go.elements.categorie.value += ",";
go.elements.categorie.value += categ;
}
//if (go.elements.id_cat.value.length != 0 && go.elements.id_cat.value.charAt(go.elements.id_cat.value.length - 1) != ",")
//go.elements.id_cat.value += ",";
//go.elements.id_cat.value += Id_cat;
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

