// JavaScript Document
function ferme_view(){
	document.getElementById("view_prod").innerHTML = "";
	document.getElementById("view").style.display ='none';
	document.getElementById("masque").style.display ='none';
}
function setFunction (func,scr,id){
	var form = document.getElementById('listeForm');
	switch(func){
		case 1:
			if(confirm("Confirmer la suppression de tous les éléments")){
				form.action = 'index.php?mode=mdelete'+((scr)?scr:'');
			}
		break;
		case 2:
			form.action = 'index.php?mode=metat1'+((scr)?scr:'');
		break;
		case 3:
			form.action = 'index.php?mode=metat0'+((scr)?scr:'');
		break;
		case 4:
			form.action = 'index.php?mode=envoi&cat_dir='+((id)?id:'')+((scr)?scr:'');
		break;
	}
	form.submit();
}
function checkSelect (ch,nb){
	var st = (ch.checked)?1:0;
	document.getElementById('lselall').innerHTML = (ch.checked)?'Tout désélectionner':'Tout sélectionner';
	for(i=0;i<nb;i++){
		document.getElementById('check'+i).checked= st;
	}
}
// boite de dialogue de suppression
function confirm_delete(url){
	if(confirm("Confirmer la suppression")){
			document.location.href= url;   
	}
}
// affiche ou masque du contenu dans l'element id
function view_or_mask(id,cont){
	document.getElementById(id).innerHTML = (document.getElementById(id).innerHTML=="")?cont:'';
}
// bascule entre deux contenu plus et moins
function plus_ou_moins(id){
	var m=new RegExp('plus.png');
	document.getElementById(id).innerHTML = (m.test(document.getElementById(id).src))?document.getElementById(id).src="../../medias/moins.png":document.getElementById(id).src="../../medias/plus.png";
}
/////////////////////////////////////// nl2br
function nl2br(str){
	return str.split('\n').join('<br />');	
}

function vire_chariot(str) {
	str=str.split('\n').join('');	
	str=str.split('\r').join('');
	str=str.split('\t').join('');
	return str;
}

//////////////////////////////////////////
function setMSG (msg){
 var al  = new Alert_window();
 al.setCloseButton ("X","FERMER")
 al.create(msg);	
}
///////////////////////////////////insertion des images dans un champ
function insertIMG(champ,id,alt){
	var p = opener.document.getElementById(champ);
	p.value += ' <img src="'+id+'" alt="'+alt+'" align="right"/> ';
	window.close();
}
///////////////////////// copie dans presse papiers
function copyclipboard(intext) {
if(!window.clipboardData) {
    window.clipboardData = {
        setData : function(mode,content) {
            var clipboard = document.body;
            var flashclipboard = clipboard.flashclipboard;
            if(flashclipboard == null) {
                flashclipboard = document.createElement('div');
                clipboard.flashclipboard = flashclipboard;
                clipboard.appendChild(flashclipboard);
            }
            flashclipboard.innerHTML = '<embed src="'+url_swf_copy+'" FlashVars="clipboard='+encodeURIComponent(content)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
        }
    }
}
	
window.clipboardData.setData('Text', intext);
}