var template='annucity';



function com(id) {mag=open('commentaires.php?id='+id,'mag','width=550,height=600,status=no,scrollbars=YES,menubar=no,toolbar=no,location=no').focus();}

function recomand(id) {mag=open('gestion/recomand.php?id='+id,'mag','width=350,height=450,status=no,scrollbars=YES,menubar=no,toolbar=no,location=no').focus();}

function suppc(n) {mag=open('gestion/supp.php?cat='+n+'&t=c','mag','width=500,height=400,status=no,scrollbars=YES,menubar=no,toolbar=no,location=no').focus();}

function supps(id) {mag=open('gestion/supp.php?id='+id+'&t=s','mag','width=500,height=400,status=no,scrollbars=YES,menubar=no,toolbar=no,location=no').focus();}

function suppcom(id_com,id_site) {mag=open('../gestion/supp.php?id='+id_com+'&id_site='+id_site+'&t=com','mag','width=500,height=300,status=no,scrollbars=YES,menubar=no,toolbar=no,location=no').focus();}

function aller(formulaire) { location.href = formulaire.page.options[formulaire.page.selectedIndex].value; }

function clic(id){ if(document.images) (new Image()).src="gestion/out.php?go=no&url_id=" + id;  return true; }



/* GESTION de la  Modif rapide */

function fast_site_edit(id,numero){

	RSIrefresh_site(id,numero,'edition');

}

function fast_site_cancel(id,numero){

	RSIrefresh_site(id,numero,'display');

}

function fast_site_verif(id,numero){

	RSIrefresh_site(id,numero,'verif');

}

function fast_site_dead(id,numero){

	RSIrefresh_site(id,numero,'dead');

}

// vote rapide - si aff_site ==true , on affiche le site a la fin

function fast_site_vote(id,numero){

	RSIrefresh_site(id,numero,"vote");

}



// validation d'un element

function fast_site_valid(id,numero,to_confirm,message) {

	if (!to_confirm || confirm(message)==true) { RSIrefresh_site(id,numero,'activer'); }

}

// validation d'un categorie

function fast_cat_valid(id,to_confirm,message) {

	if (!to_confirm || confirm(message)==true) { RSIrefresh_cat(id,'activer'); }

}



// activation d'un user

function fast_user_activate(id,to_confirm,message,p) {

	if (!to_confirm || confirm(message)==true) { RSIrefresh_user(id,'activate',p); }

}

// validation d'un user

function fast_user_valid(id,to_confirm,message,p) {

	if (!to_confirm || confirm(message)==true) { RSIrefresh_user(id,'valid',p); }

}

// suppression d'un user

function fast_user_delete(id,to_confirm,message,p) {

	if (!to_confirm || confirm(message)==true) { RSIrefresh_user(id,'delete',p); }

}





// affichage des stats d'un site

function fast_view_stats(name,id,view){ 

	if (view) {

		window.document.getElementById('view_stats_'+id).innerHTML="<a href=\"javascript:fast_view_stats('stats',"+id+",false)\"><img src='template/"+template+"/im/no_preview.gif' border='0'></a>";

		RSIrefresh_item(name,'item_stats',id);

	}

	else {

		window.document.getElementById('view_stats_'+id).innerHTML="<a href=\"javascript:fast_view_stats('stats',"+id+",true)\"><img src='template/"+template+"/im/preview.gif' border='0'></a>";

		RSIloadSourceFinish(name,'');

	}

}



// Affiche un message d'information en Mode RSI

function aff_message_info(message,style_css,time) {

	parent.document.getElementById('RSI_info').style.visibility = "visible";

	parent.document.getElementById('RSI_info').innerHTML=message;

	parent.document.getElementById('RSI_info').className =style_css;

	if (time!=-1) setTimeout("parent.document.getElementById('RSI_info').style.visibility = 'hidden'",time);

}



/* FONCTIONS generique RSI */

//charge une site

function RSIrefresh_site(id,numero,action) {

	if (sem_get()) return alert("Wait, please");

	sem_ver();

	document.getElementById("site_" + id).innerHTML="opération en cour, merci de patienter ...";

	setTimeout("document.getElementById('RSIFrame').src='gestion/gest_site.php?id=" + id + "&p=" + numero + "&action=" + action + "'",50);

}



function RSIrefresh_cat(id,action) {

	if (sem_get()) return alert("Wait, please");

	sem_ver();

	document.getElementById("cat_" + id).innerHTML="opération en cour, merci de patienter ...";

	setTimeout("document.getElementById('RSIFrame').src='gestion/gest_cat.php?id=" + id + "&action=" + action + "'",50);

}

function RSIrefresh_user(id,action,p) {

	if (sem_get()) return alert("Wait, please");

	sem_ver();

	document.getElementById("user_" + id).innerHTML="opération en cour, merci de patienter ...";

	setTimeout("document.getElementById('RSIFrame').src='../gestion/gest_user.php?id=" + id + "&action=" + action + "&p="+p+"'",50);

}

// rafraichit un item

function RSIrefresh_item(name,action,id) {

	if (sem_get()) return alert("Wait, please");

	sem_ver();

	document.getElementById(name).innerHTML="opération en cour, merci de patienter ...";

	setTimeout("document.getElementById('RSIFrame').src='gestion/gest_display.php?id=" + id + "&action=" + action + "'",50);

}



// fonction appelé par les pages gest_xxx.php qui s'auto met à jour

function RSIloadSourceFinish(ID_DIV,value) {

	sem_dever();

	window.parent.document.getElementById(ID_DIV).innerHTML=value;

}

/*SEMAPHORE */

function sem_ver() {

	parent.document.getElementById('SEM').innerHTML="VERROU";

	parent.document.getElementById('RSI_info').className="message_info";	

	parent.document.getElementById('RSI_info').innerHTML="opération en cour, merci de patienter";

	parent.document.getElementById('RSI_info').style.visibility = "visible";

}



function sem_dever() {

	parent.document.getElementById('SEM').innerHTML="";

	parent.document.getElementById('RSI_info').innerHTML="";

	parent.document.getElementById('RSI_info').style.visibility = "hidden";

}

function sem_get() {

	if (parent.document.getElementById('SEM').innerHTML=="VERROU") 

		return true;

		else return false;

}

// **************

function elt_preview(id,url,view) {

	if (view) {

		window.document.getElementById('ifr_elt_'+id).src=url;

		window.document.getElementById('ifr_elt_'+id).className = "ifr_on";

		window.document.getElementById('ifr_elt_'+id).height = "300";

		window.document.getElementById('prev_elt_'+id).innerHTML="<a href=\"javascript:elt_preview("+id+",'"+url+"',false)\"> <img src=\"template/"+template+"/im/no_preview.gif\" border=\"0\" alt=\"fermer la prévisualisation\"/></a>";

		}

	else {

		window.document.getElementById('ifr_elt_'+id).src='';

		window.document.getElementById('ifr_elt_'+id).className = "ifr_off";

		window.document.getElementById('ifr_elt_'+id).height = "0";

		window.document.getElementById('prev_elt_'+id).innerHTML="<a href=\"javascript:elt_preview("+id+",'"+url+"',true)\"> <img src=\"template/"+template+"/im/preview.gif\" border=\"0\" alt=\"fermer la prévisualisation\"/></a>";

	}

}



function SelAll (){ 

for (var i=0;i<document.formu.elements.length;i++){ 

   var e = document.formu.elements[i]; 

    e.checked = 1; 

    } 

} 



function UnSelAll (){ 

	for (var i=0;i<document.formu.elements.length;i++){ 

		var e = document.formu.elements[i]; 

	   e.checked = 0; 

		} 

} 



function CheckSel(msg){

	for (var i=0;i<document.formu.elements.length;i++)

		if (document.formu.elements[i].checked==1) return true;			

	if (msg!="") alert (msg);

	return false;

}



function InvSelect() { 

	for (var i = 0; i < document.formu.elements.length; i++) { 

	   if(document.formu.elements[i].type == 'checkbox'){ 

		 document.formu.elements[i].checked =!(document.formu.elements[i].checked); 

	   } 

	 } 

} 



function form_del(err_mess){

	if (CheckSel("")){

		centrePop("poplist",400,450);

		document.formu.target="poplist";

		document.formu.action = "gestion/supp.php";

		}

}



function form_move(err_mess){

	if (CheckSel("")){

		centrePop("poplist",400,450);

		document.formu.target="poplist";

		document.formu.action = "gestion/move.php";

		}

}



function form_valid(err_mess){

	if (CheckSel("")){

		centrePop("poplist",400,450);

		document.formu.target="poplist";

		document.formu.action = "gestion/valid.php";

		}

}



function centrePop(name,largeur,hauteur) {

	var gauche = (screen.width - largeur)/2

	var haut =  (screen.height - hauteur)/2

	window.open("",name,"width="+largeur

	 +",height="+hauteur+",left="+gauche

	 +",top="+haut+",status=no,scrollbars=YES")

}



var url='';

function ChangeInputURL(checked) {

	document.formu.url.disabled=checked;

	document.getElementById('NR_url_label').style.visibility = !checked ? "visible" : "hidden";	

	document.getElementById('NR_url').style.visibility = !checked ? "visible" : "hidden";	

	if (checked) { 

		url=document.formu.url.value;

		document.formu.url.value=url; 

	}

	else if (url!='') document.formu.url.value=url;

}



// filtrage d'une page - user

function filtre_page(filtre,p,sort) {

	location.href = '?p='+p+'&filtre='+filtre+'&sort='+sort;

}



function ChangeIM(form,dossier){

	document.getElementById(1).innerHTML="<img src='"+dossier+form.im.options[form.im.selectedIndex].value+"'>";

}