function mask(champs,type){
var long = champs.value;

long.toString();

switch (type){
   case 'hour':
   if(long.length==1){
      if(champs.value>2){
         champs.value = "0"+long;
         champs.value = champs.value + ":";
      }
      
   }
   if(long.length==2){
      if(champs.value<=23){
      champs.value = long + ":";
      }else{
      alert("Veuillez entrer une heure valide");
      champs.value ="";
      }
      }
   if(long.length==5){
         long2 = long.slice(3,5);
         
         //alert(long2);
         if(long2 > 60){
         alert("Le nombre de minute n'est pas valide");
         champs.value = long.slice(0,3);
         }
   }
   break;
   
   case 'date':
      if(long.length==1){
         if(champs.value>3){
            champs.value = "0"+long;
            champs.value = champs.value + "/";
      }
      }
      if(long.length==2){
         if(champs.value<=31){
         
            champs.value = champs.value + "/";
         }else{
            alert("Veuillez entrer une heure valide");
            champs.value ="";}
      }
      
      if(long.length==4){
      car = long.slice(3,6);
      
         if(car>1){
            car2 = long.slice(0,3);   
               
            champs.value = car2+"0"+car;
            champs.value = champs.value + "/";
      }
      }
      if(long.length==5){
      car = long.slice(4,6)
         if(car<=31){
            champs.value = champs.value + "/";
         }else{
            alert("Veuillez entrer une heure valide");
            champs.value ="";}
      }
      
      


}
}
function submitform(form){
	document.getElementById(form).submit() ;
}
function form_submit(cha,fid,sfor){
//	alert (fid);
//	return ;
	var field = document.getElementById(cha);
	var formulaire = document.getElementById(sfor);
	field.value = fid ;
	formulaire.submit();
}
function departement_mod(id){
	document.getElementById('tr_'+id).style.display = 'none';
	document.getElementById('tr_'+id+'_2').style.display = 'block';
}
function mailing_text(){
	alert(document.getElementById('info_text').value);
}

function check_all(){
	{
		count = document.frm.elements.length;
		    for (i=0; i < count; i++) 
			{
		    if(document.frm.elements[i].checked == 1)
		    	{document.frm.elements[i].checked = 0; }
		    else {document.frm.elements[i].checked = 1;}
			}
		}

}

function openConfirmDel(form,id,field,phrase){
	Dialog.confirm(phrase, 
			   {width:300,
			   okLabel: "Oui",
			   cancelLabel: "Non",
			   className: "alphacube",
			   id: "myDialogId",
			   cancel:function(win) {return false;},
			   ok:function(win) {form_submit(field,id,form);; return true;}
			  });				   
	}
	
function openConfirmYes(form,id,field,phrase){
	Dialog.confirm(phrase, 
			   {width:300,
			   okLabel: "Oui",
			   cancelLabel: "Non",
			   className: "alphacube2",
			   id: "myDialogId",
			   cancel:function(win) {return false;},
			   ok:function(win) {form_submit(field,id,form);; return true;}
			  });				   
	}

function alerte(phrase)
	{
		Dialog.alert(phrase, 
				{
				width:300,
				okLabel: "ok", 
				className:  "alphacube",
				ok:function(win) {debug("validate alert panel"); return true;}});
}
function messagerie_public_page(){
	var page = $('pages').value 
	var page = page -1 ;
	window.location="index.php?p=mur&action=list&page=" + page ;	
}
function temoignage_public_page(type){
	var page = $('pages').value 
	var page = page -1 ;
	window.location="index.php?p=temoignage&action="+type+"&page=" + page ;	
}


