﻿// POUR LE MENU DU BACK-OFFICE ----------------------------------------------------------------------------- >>
function montre(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {
			document.getElementById('smenu'+i).style.display='none'; 
			if (navigator.appName=="Microsoft Internet Explorer") swapmenuUp("select");
		}
	}
	if (d) {
		d.style.display='block'; 
		if (navigator.appName=="Microsoft Internet Explorer") swapmenuDown("select");
	}
}
function scrollfooter(action){
	if(action == "open"){
		new Effect.SlideDown("plan_du_site", { afterUpdate : function() { $("plandusite").scrollTo()}}); 
		var new_action = 'close';
		var label = 'Masquer le plan du site';
	} else {
		new Effect.BlindUp("plan_du_site", { afterUpdate : function() { $("plandusite").scrollTo()}}); 
		var new_action = 'open';
		var label = 'Afficher le plan du site'
	}
	

	var content = '<a href="#plandusite" style="cursor:pointer;" title="Plan du site" '
		+'onClick=\'scrollfooter("'+new_action+'");return false;\'>'+label+'</a></li>';
	document.getElementById("plan_li").innerHTML = content;
}
function selectall(theField) {
	//var tempval=eval("document.getElementById('"+theField+"'))
	var tempval=theField;
	tempval.focus()
	tempval.select()
	if (document.all&&copytoclip==1){
		therange=tempval.createTextRange()
		therange.execCommand("Copy")
		window.status="Le code a bien été copié !"
		setTimeout("window.status=''",1800)
	}
}
function envoyerAmi(id){
	if(id){
		window.open("/_includes/pages/envoi_ami.php?id_video="+id, "envoyer", "width=550, height=500");
	}
}





function swapmenuDown(tag) {
	tab = document.getElementsByTagName(tag);
	for(var i=0;i<tab.length;i++) {
			tab[i].style.visibility = "hidden";
	}
}

function swapmenuUp(tag) {
	tab = document.getElementsByTagName(tag);
	for(var i=0;i<tab.length;i++) {
			tab[i].style.visibility = "visible";
	}
}

/* POUR LES ONGLETS */
function aff_onglet(id){
	for (var i = 0; i<=10; i++) {
		if (document.getElementById('onglet_'+i)) {
			document.getElementById('onglet_'+i).style.display = 'none';
			document.getElementById('btn_'+i).className = 'btn_off';
		}
	}
	document.getElementById('onglet_'+id).style.display = 'block';
	document.getElementById('btn_'+id).className = 'btn_selected';
}


// FERMER UN GREYBOX --------------------------------------------------------------------------------------- >>
function fermer_greybox(){
	parent.parent.GB_hide();	
}

// SUPPRIMER LES IMAGES DANS LE GESTIONNAIRE D'IMAGES ET DE FICHIERS --------------------------------------- >>
function sup_asso(id) {
	document.getElementById("document_"+id).style.display = "none";
	document.forms.form1.ids_fich.value =  document.forms.form1.ids_fich.value.replace(id+",", "");
}

function sup_asso_img(id) {
	document.getElementById("image_"+id).style.display = "none";
	document.forms.form1.ids_img.value =  document.forms.form1.ids_img.value.replace(id+",", "");
}

// AFFICHER / MASQUER UNE DIV ------------------------------------------------------------------------------ >>
function swap(madiv){
	var etat = document.getElementById(madiv).style.display;
	if(etat == "none"){
		document.getElementById(madiv).style.display = "block";
	} else {
		document.getElementById(madiv).style.display = "none";
	}
}

// AFFICHER / MASQUER UNE DIV SELON ETAT ------------------------------------------------------------------- >>
function swapChoose(madiv,etat){
	if(etat == "none"){
		document.getElementById(madiv).style.display = "none";
	} else if (etat == "block") {
		document.getElementById(madiv).style.display = "block";
	} else if (etat == "inline") {
		document.getElementById(madiv).style.display = "inline";
	}
}

// TOUT DEPLIER / TOUT MASQUER ----------------------------------------------------------------------------- >>
function swapAllDown(){
	var tab = document.getElementsByTagName("div");
	for(i=0;i<tab.length; i++){
		if (tab[i].getAttribute("label") == "swapy") {
		tab[i].style.display = "none";
		}
	}
}
function swapAllUp(){
	var tab = document.getElementsByTagName("div");
	for(i=0;i<tab.length; i++){
		if (tab[i].getAttribute("label") == "swapy") {
		tab[i].style.display = "block";
		}
	}
}

// POP UN D'AIDE ------------------------------------------------------------------------------------------ >>
function helpop(hcheminh) {
	window.open(hcheminh+"aide.php","Aide","height=625, width=625 ,toolbar=no, scrollbars=yes");
}

function supprimer(quoi, urltraitement){
	if(confirm("Es-tu sûr de vouloir supprimer "+quoi+"?")){
		document.location.href = urltraitement;
	}	
}


function reinitialiserInput(obj, defaut){
	if(obj.value=='')	obj.value = defaut;
}
function viderInput(obj, defaut){
	if(obj.value==defaut)	obj.value = '';
}



///////////////////////// ROBIN

////////////// GOTO ETAPE SUIVANTE ------------------------------------------------------>
function gotoEtape(nom, id){	
	for (var i=0; i<=20; i++) {
		if (document.getElementById(nom+i)) {
				document.getElementById(nom+i).style.display = 'none';
				document.getElementById("btn_suivant_"+i).className = '';
		}
	}	
	
	document.getElementById("form_etape_"+id).style.display = 'block';
	document.getElementById("btn_suivant_"+id).className = 'selected';
	
	return true;
}
	
function verif_email(email){
    var verif = /^[^@]+@(([\w\-]+\.){1,4}[a-zA-Z]{2,4}|(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5]))$/  
    return ( verif.test(email) );
}

function ChercheValeurRadio(nb_radio, nom_form, nom_champ)
	{
	for(i=0;i<nb_radio;i++)
		eval("if(document.forms."+nom_form+"."+nom_champ+"[i].checked)	valeur = document.forms."+nom_form+"."+nom_champ+"[i].value");
	return valeur;
	}

//Fonction permettant de récupérer n'importe quel valeur d'un élément de formulaire
function getFormElementValue(e) {
	if (e.type == 'radio') {
		return getFormRadioValue(e);
	} else if (e.type == 'checkbox') {
		return getFormCheckValue(e);
	} else {
		return e.value;
	}
}

//renvoi la valeur d'un checkbox
function getFormCheckValue(e) {
	if (e.checked) {
		return e.value;
	}
	return null;
}
//renvoi la valeur dun bouton radio
function getFormRadioValue(e) {
	for (var i=0; i <e.length; i++) {
		if (e[i].checked) {
			return e[i].value;
		} else {
			return null;
		}
	}
}
/////


//vérifie le traitement d'une action définie
function verifierTraitement(nom_form, nom_champs, nb_champs, debut, id_champs_verif, lien){	
	//nom du traitement à vérifier
	formulaire =  "document."+nom_form;
	nom_traitement = formulaire+"."+nom_champs;

	//
	if(compterNbCasesChochees(nom_form, id_champs_verif, nb_champs, debut)){
		//pour suppression
		if(eval(nom_traitement+".value") == 'supprimer'){
			if(confirm('Etes-vous sûr de vouloir supprimer tous les éléments sélectionnés ?')){
				eval(formulaire+".action = '"+lien+"'");
				eval(formulaire+".submit()");
			}
			else return false;
		}
	}
	else alert("Vous devez sélectionner au moins un élément dans la liste !");
}
	

function compterNbCasesChochees(nom_form, id_champs, nb_champs, debut)
	{
	//initialisation du compteur
	compteur = 0;
	
	//on recupère l'id du formulaire et de la case à cocher
	id_checkbox = "document."+nom_form+"."+id_champs;
	
	for(i=debut; i<nb_champs; i++)
		if (eval(id_checkbox+i+".checked == true")) compteur++;
		
	//
	if(compteur > 0) return true;
	else return false;
	}
	
function CocherCase(nom_form, id_champs, nb_champs, debut, action)
	{
	//on recupère l'id du formulaire et de la case à cocher
	id_checkbox = "document."+nom_form+"."+id_champs;

	if(action == 'cocher')
		{
		for(i=debut; i<nb_champs; i++)
			{
			if(eval(id_checkbox+i+".disabled == false")) eval(id_checkbox+i+".checked = true");
			}
		}
	else if(action == 'decocher')
		{
		for(i=debut; i<nb_champs; i++) eval(id_checkbox+i+".checked = false");
		}
	}
//-->


function popupcentree(page,largeur,hauteur,options){
	var top = (screen.height-hauteur)/2;
	var left = (screen.width-largeur)/2;
	window.open(page,"pop","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}	
	
function confirmerSortirPage(){
	if(confirm("Etes-vous sûr de vouloir quitter la page en cours ?")) return true;
	else{ 
		return false;
		//document.location.href = '/mon_compte/messages/messages_composer.php?recup=1';
	}
}

/*
function ajouter_img(){
	var num = document.forms.form1.nb_diapo.value;
	var suivant = parseInt(num)+1; 	
	var champs_sup = "<label class='lib'>&nbsp;</label><input type='file' name='img_"+suivant+"' /><div id='diapo_"+suivant+"'></div>";

	document.getElementById("diapo_"+num).innerHTML = champs_sup;
	document.forms.form1.nb_diapo.value++;
	
}
*/
/*
function swapauto(nom) {
	tab = document.getElementsByTagName("div");
	for(var i=0;i<tab.length;i++) {
		if (tab[i].getAttribute("label") == nom) {
			tab[i].style.display = "none";
		}
	}
}
*/
/*
function exec_url(urltraitement){
	document.location.href = urltraitement;
}*/

function aller_vers(url){
	//alert(url);
	document.location.href = url;
}

// AJOUTER UN MSG DANS UNE DIV EN INNER HTML  -------------------------------------------------- >> # 07/05/2007
function affiche_inner(msg, div){
	document.getElementById(div).innerHTML = msg;
}

// SUPPRIMER UNE IMAGE EN AJAX ----------------------------------------------------------------- >> # 04/05/2007
function ajax_supprimer_photo(id,mode,fichier_traitement,id_inner){
	var xhr_object = null;
	var data=null;
	if(window.XMLHttpRequest) // Firefox
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}		
	data = id;
	xhr_object.open("POST", fichier_traitement+"?mode="+mode+"&id="+id, true);		
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
	xhr_object.send(data);  	
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4){
			infos = xhr_object.responseText;
			document.getElementById(id_inner).innerHTML = infos;
		}
	}
}

// STYLE DIV VISIBLE -------------------------------------------------------------------------- >> # 07/05/2007
function visible(div){
	var etat = document.getElementById(div).style.display;
	if(etat == "block"){
		var retour = "none";
	} else {
		var retour = "block";
	}
	document.getElementById(div).style.display = retour;

}

// GENERER UNE CHAINE TYPE URL8REWRITING ------------------------------------------------------ >> # 15/05/2007
function generer_url(chaine, champs){
		var nurl = chaine.toLowerCase();
		var remplacer = Array("#¤-", "?¤-", "ù¤u", "ô¤o", "û¤u", "î¤i", ".¤-", "|¤-", "_¤-", ",¤-", "°¤-", 
			"ü¤u", "ë¤e", "ö¤o", "ë¤e", "ê¤e", "%¤-", "(¤-", ")¤-", "ç¤c", "*¤-", "²¤2", '"¤-', "\\¤-",
			"¨¤-", "^¤-", "é¤e", "è¤e", "à¤a", "'¤-", "&¤et", "@¤a", "/¤-", " ¤-", 
			"&¤et", "&amp;¤et", "â¤a", '"¤', "+¤-", "!¤-", "$¤", ":¤-", ";¤-", "§¤", "=¤", "}¤", "]¤", 
			"`¤", "[¤", "{¤", "<¤-", ">¤-", "--¤-");
		for( var j=0; j < remplacer.length; j++){
			var chaine2 = remplacer[j].split("¤");
			while(nurl.indexOf(chaine2[0]) != -1){
				nurl = nurl.replace(chaine2[0], chaine2[1]);
			}
		}
		
		if(nurl.indexOf("-") == 0){ nurl = nurl.replace("-", ""); }
		if(nurl.lastIndexOf("-") == nurl.length-1){ nurl = nurl.substring(0, nurl.length-1);}
		var newurl = (nurl+".html").toLowerCase();
		document.getElementById(champs).value = newurl;
	}
	
// GENERER UNE CHAINE TYPE URL8REWRITING ------------------------------------------------------ >> # 22/08/2007
function alea(longeur) {
	var aleatoire;
	var chaine = '';
	var cars = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9");
	for(i=0; i<=longeur; i++){
		aleatoire = Math.round((Math.random()*35));
		chaine += cars[aleatoire];
	}
	return chaine;
}


// FONCTIONS AJAX ///////////////////////////////////////////////////////////////////////////////////////////////////////

////////////// SUPPRESSION GENERIQUE AJAX ------------------------------------------------------>
function ajax_supprimer(id, mode, fichier_traitement, id_inner){
	if(confirm("Etes-vous sûr de bien vouloir supprimer ?")){
		var xhr_object = null;
		var data=null;
		if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest(); // Firefox
		else if(window.ActiveXObject) xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer
		else { // XMLHttpRequest non supporté par le navigateur
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); return;
		}
		
		data = id;
		xhr_object.open("POST", fichier_traitement+"?mode="+mode+"&id="+id, true);  
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
		xhr_object.send(data);   
		xhr_object.onreadystatechange = function(){
			if(xhr_object.readyState == 4){
				infos = xhr_object.responseText;
				document.getElementById(id_inner).innerHTML = infos;				
				if(infos=="") alert("Suppression effectuée !");
				else alert("Erreur lors de la suppression !");
			}
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// TOUT COCHER / DECOCHER ------------------------------------------------------------------------ >> 16/06/2007
function tout_cocher(nom,action){
	if(action == "cocher") var coche = true;
	if(action == "decocher") var coche = false;
	
	var field = document.getElementsByName(nom+"[]");
	
	for(i=0; i<field.length; i++){
		field[i].checked = coche;
	}
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Fonctions Cookies ----------------------------------------------------------------------------------------- >> 29/04/2008

   function cre_cook0(nom,contenu) {
      document.cookie = nom + "=" + escape(contenu)
      }
     
   function cre_cook(nom,contenu,jours) {
      var expireDate = new Date();
      expireDate.setTime(expireDate.getTime() + jours*24*3600*1000);
      document.cookie = nom + "=" + escape(contenu)
         + ";expires=" + expireDate.toGMTString()
		 +";path=/";
      }
     
   function lit_cook(nom) {
      var deb,fin
      deb = document.cookie.indexOf(nom + "=")
      if (deb >= 0) {
         deb += nom.length + 1
         fin = document.cookie.indexOf(";",deb)
         if (fin < 0) fin = document.cookie.length
         return unescape(document.cookie.substring(deb,fin))
         }
      return ""
      }
     
   function tue_cook(nom) { cre_cook(nom,"",-1) }

   function askCook(nom) {
      c=prompt("Mettre dans le cookie :","")
      cre_cook0(nom,c)
      }

   function litCook(nom) {
      c=lit_cook(nom)
      if(c=="") alert("Le cookie est vide !")
      else alert("Le cookie vaut : "+c)
      }




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Fonction pour Favoris et pour mettre en Homepage

/*var IE6 = false @cc_on || @_jscript_version < 5.7 @;
if ( navigator.appName != "Microsoft Internet Explorer" )
	var isIe=false;
else
	var isIe=true;*/
    
function addFav(){ if ( navigator.appName != "Microsoft Internet Explorer" ){
	window.sidebar.addPanel(document.title,location.href,"");
	}else window.external.AddFavorite(location.href, document.title);}
    
    
function home()
	{
		if ( navigator.appName != 'Microsoft Internet Explorer' ) 
		{ 
			alert('Fonctionne uniquement avec Internet Explorer 5.5 ou les versions supérieures.'); 
		} 
		else 
		{
			document.getElementById('conteneur').style.behavior='url(#default#homepage)';
			document.getElementById('conteneur').setHomePage('http://www.sitedefilles.com');
		}
	}