function checkAll(type){

var tab=document.getElementsByTagName('input');

for (var i = 0; i < tab.length; i++) { 

		var Expression = new RegExp("^"+type,"")
		var resultat = tab[i].name.match( Expression );
		
		if(resultat){
		//alert(tab[i].id);
			var ok=(tab[i].checked==true)?false:true;
			tab[i].checked=ok;
			if(tab[i].id==type+"_all")
			tab[i].checked=!ok;
		}
	}

}

function checkForm(){

var tab=document.getElementsByTagName('input');

var total=0;

for (var i = 0; i < tab.length; i++) { 

	if(tab[i].checked==true)
	total+=1;
	
	}
if(total==0)
	{
		alert('Vous devez choisir au moins un document');
		return false;
	}
else
document.fichePro.submit();
}

function checkFormNews(type){
	
	var email=document.getElementById('mail').value;
	var nom=document.getElementById('nom').value;
	
	if(type=='unsuscribe')
		document.getElementById('unsuscribe').value=1;
	else
		document.getElementById('unsuscribe').value=0;
	
	if (nom=='' || email=='')
		alert('Vous devez remplir tous les champs')
	else if ((email!='') && (email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1))	 
		{
			alert('Merci d\'entrer une adresse mail valide');
			return false;
		}
	else
		{
			document.newsletter.submit();
			return true;
		}
}

function PopupImage(img, titre) { 
w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
w.document.write("<html><head><title>"+titre+"</title></head>"); 
w.document.write("<script language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+20,document.images[0].height+80); window.focus();} else { setTimeout('checksize()',250) } }</script>"); 
w.document.write("<body style=\"background-color:#050505;\" onload='checksize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
w.document.write("<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><tr>");
w.document.write("<td valign='middle' align='center'><img src='"+img+"' border=0 alt='Mon image'>"); 
w.document.write("</td></tr></table>");
w.document.write("</body></html>"); 
w.document.close(); 	
} 

function ShowNoShow(id, type, show){
var prefix=(show==true)?'show':'noShow';
var url='updateFiche.php?action='+prefix+type;
var myAjax = new Ajax(url,{
			method: 'post',
			data:'id='+id
			}).request();
}

/**********************************************
// Fonctions servant à l'editeur wysiwyg
/**********************************************/

 nav = "";

 nav = navigator.appName;

 function initialisation(){
	 var type=new Array()
	 type=['sousTitre', 'descriptif', 'distribution'];
	 
	 for(i=0; i<type.length; i++)
		{
		//alert (type[i])
		 if(nav == "Microsoft Internet Explorer")
		 {
			 win = window.frames["editeur"+type[i]];
			 doc = win.document;
		 }
		 else {
				 doc = document.getElementById("editeur"+type[i]).contentDocument;
				 win = document.getElementById("editeur"+type[i]).contentWindow;
		 }
		
		 if(doc.designMode != "On")
			 {
				doc.designMode = "On";
			 }
		}
	//win.focus();
 }
 

 function setContent(action, type){

 if(nav == "Microsoft Internet Explorer"){

		 win = window.frames['editeur'+type];
		 doc = win.document;
	 }
	 else{
		 win = document.getElementById('editeur'+type).contentWindow;
		 doc = document.getElementById('editeur'+type).contentDocument;
		}
	
	
	 doc.execCommand(action,false,null);
	 win.focus();
 }
  
 function changer(type){
	
 document.getElementById('code'+type).value = document.getElementById("editeur"+type).contentWindow.document.body.innerHTML;

 }
 function changerCouleur(couleur, type){

 if(nav == "Microsoft Internet Explorer"){

	 win = window.frames['editeur'+type];
	 doc = win.document;

 }else{

	 win = document.getElementById('editeur'+type).contentWindow;
	 doc = document.getElementById('editeur'+type).contentDocument;

 }

 doc.execCommand("ForeColor",false,couleur);
 win.focus();

 }
 
 function saveChange(){
	var type=new Array()
	 type=['sousTitre', 'descriptif', 'distribution'];
	 
	 for(i=0; i<type.length; i++)
		{
		 changer(type[i])
		}
 }
/**********************************************
//fin editeur wysiwyg
/**********************************************/
