
function envoieDonneeTrie(cat, debut){
    trie = document.getElementById('trie').value;



    url = 'wallpaper-'+cat+'-'+trie+'-'+debut+'.html'
    document.location = url;
}

function askConfirmDel(arg1,arg2){
    ask = confirm(arg1);
    if(ask){
        document.location = arg2;
    }

}


function definition(type, cible) {
	var update = '';
	if(type == "lien"){
		lienPath = prompt('Entrer le lien vers lequel vous souhaitez pointer :', 'http://');
		if(lienPath == null){
			update = '';
		}
		else{
			repdeb = '<a href="'+ lienPath + '">';
			repfin = '</a>';
			update = 'ok';
		}
	}
	if(type == "gras"){
		
		repdeb = '<span STYLE="font-weight: bold;">';
		repfin = '</span>';
		update = 'ok';
	}
	if(type == "italic"){
		repdeb = '<i>';
		repfin = '</i>';
		update = 'ok';
	}
	if(type == "finSpan"){
		repdeb = '';
		repfin = '</span>';
		update = 'ok';
	}
	if(update == 'ok')
	insertion(repdeb, repfin, cible);
}

//function insertion(repdeb, repfin, cible){
//	
//  var input = document.forms['formulaire'].elements[cible];
//  input.focus();
//  /* pour l'Explorer Internet  */
//  if(typeof document.selection != 'undefined') {
//    /* Insertion du code de formatage */
//    var range = document.selection.createRange();
//    var insText = range.text;
//    range.text = repdeb + insText + repfin;
//    /* Ajustement de la position du curseur  */
//    range = document.selection.createRange();
//
//
//	alert(range.text);
//
//
//    if (insText.length == 0) {
//      range.move('character', -repfin.length);
//    } else {
//      range.moveStart('character', repdeb.length + insText.length + repfin.length);
//    }
//    range.select();
//  }
//  /* pour navigateurs plus récents basés sur Gecko */
//  else if(typeof input.selectionStart != 'undefined')
//  {
//    /* Insertion du code de formatage  */
//    var start = input.selectionStart;
//    var end = input.selectionEnd;
//    var insText = input.value.substring(start, end);
//    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
//    /* Ajustement de la position du curseur  */
//    var pos;
//    if (insText.length == 0) {
//      pos = start + repdeb.length;
//    } else {
//      pos = start + repdeb.length + insText.length + repfin.length;
//    }
//    input.selectionStart = pos;
//    input.selectionEnd = pos;
//  }
//  /* pour les autres navigateurs  */
//  else
//  {
//    /* requête de la position d'insertion  */
//    var pos;
//    var re = new RegExp('^[0-9]{0,3}$');
//    while(!re.test(pos)) {
//      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
//    }
//    if(pos > input.value.length) {
//      pos = input.value.length;
//    }
//    /* Insertion du code de formatage  */
//    var insText = prompt("Veuillez entrer le texte à formater:");
//    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
//  }
//}
//
//
//function Select(selectname, cible)
//{
//	
//  var cursel = document.getElementById(selectname).selectedIndex;
//  /* First one is always a label */
//  if (cursel != 0) {
//  	
//    var selected = document.getElementById(selectname).options[cursel].value;
//	var repdeb = selected;
//	var repfin = '</span>';
//	insertion(repdeb, repfin, cible);
//	document.getElementById(selectname).selectedIndex = 0;
//  }
  

function insertImg(){
  window.open('upload.php','winimg','resizable=yes,top=50%,left=50%,width=500,height=500');
}
function retour(){
	window.history.go(-1)
}

function OuvrirPopup(page,nom,option) {
	window.open(page,nom,option);
}



function popup() {
	// ouvre une fenetre sans barre d'etat, ni d'ascenceur
	w=open("",'popup','width=400,height=200,toolbar=no,scrollbars=no,resizable=yes');
	w.document.write("<TITLE>"+document.forms["f_popup"].elements["titre"].value+"</TITLE>");
	w.document.write("<BODY> Bonjour "+document.forms["f_popup"].elements["nom"].value+"<BR><BR>");
	w.document.write("Ce popup n'est pas un fichier HTML, il est écrit directement par la fenêtre appelante");
	w.document.write("</BODY>");
	w.document.close();
}
function showEl(id){
	var el = document.getElementById(id);
	
	if(el.style.display == "block"){
		el.style.display = "none";
	}else{
		el.style.display = "block";
	}
}
function showElByEl(el){
	
	if(el.style.display == "block"){
		el.style.display = "none";
	}else{
		el.style.display = "block";
	}
}
function changeClassEl(id, nClass){
	var el = document.getElementById(id);
	el.className = nClass;
}
function changeClass(el, nClass){
	el.className = nClass;
}
/* Fonction qui cache ou non la description et change la classe de l'élément cliqué */
function descOst(id, thisID){
	var el = document.getElementById(id);
	var thisEl = document.getElementById(thisID);
	showEl(id);

	if(thisEl.className == "puceJauneDown"){
		changeClass(thisEl, "puceJauneRight");
	}else{
		changeClass(thisEl, "puceJauneDown");
	}
}
function swicthClass(id, class1, class2){
	var el = document.getElementById(id);
	var currentClassName = el.className;

	if( currentClassName == class1){
		el.className = class2;
	}else{
		el.className = class1;
	}
}





