// JavaScript Document

var winfenetre = null;
var contentWin;
function inscription(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Inscription", 
                      top:70, left:100, width:500, height:400, 
                      url: "html/site/inscription.html", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}
	
function rechercher(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Rechercher", 
                      top:70, left:100, width:400, height:200, 
                      url: "html/site/recherche.html", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}	

function contact(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Contact", 
                      top:70, left:100, width:500, height:200, 
                      url: "html/site/site_contact.html", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}
	
function identification(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Identification", 
                      top:70, left:100, width:500, height:200, 
                      url: "html/site/identification.html", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}
	
function mdp_oublie(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Identification", 
                      top:70, left:100, width:500, height:200, 
                      url: "html/site/users_mdp_oublie.html", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}	
function add_site(){
if(winfenetre!=null)winfenetre.close();
winfenetre = new Window({className: "alphacube", title: "Nouveau Congres", 
                      top:70, left:100, width:500, height:350, 
                      url: "/v2/index.php?rq=congres_display_add_site", showEffectOptions: {duration:1.5}})
winfenetre.showCenter();
winfenetre.show();                                            
	}	
	
	
	
function compte(rq){
	if(rq==null)rq="users_comptexml";
	display_div("compteloading",true);
	 ajax = new Ajax.Request("/v2/index.php",{
     method: "GET",
     parameters: "rq="+rq,
     onSuccess: function(transport, json) {
			if (200 == transport.status){
			//	alert(transport.responseText);
				if(!json){
					alert("Erreur transmition de données");
					alert(transport.responseText);
					return;
				}
				if(json.error!=""){
					display_div("compteloading",false);
				}
				
				if(json.message=="session_detroy" && document.location.href.indexOf("rq=adminsite_")!=-1){
					document.location.href="index.php";
				}
			  	else loadcompte(json);
			}
			 else 
				alert("Une erreur s'est produite");
		    }
     } );
}

function loadcompte(json){
	html="";
	if(json.message=="session_close" || json.message=="session_detroy"){
		setTimeout('display_div("compteloading",false);',1000);
		display_div("comptevide",true);
		display_div("compteactif",false);
		set_html_to_id_element("comptecontent",html);
		set_html_to_id_element("compteutilisateur","");
		return;
	}
	set_html_to_id_element("compteutilisateur",json.data.user.prenom+" "+json.data.user.nom);
	display_div("comptevide",false);
	display_div("compteactif",true);
	if(json.data.annuaire != null){
	for(i=0;i<json.data.annuaire.length;i++){
			tableau = get_html_from_id_element("comptetype");
			tableau=tableau.replace("//login//",json.data.annuaire[i].login); 
			tableau=tableau.replace("//login//",json.data.annuaire[i].login); 
			tableau=tableau.replace("//siteid//",json.data.annuaire[i].id); 
			tableau=tableau.replace("//titre//",unescape(json.data.annuaire[i].titre_url)); 
			html+=tableau;
		}
	}
	//if(json.data.annuaire.length>0)
	//	html = "<font size='2'><b>Liste de vos congr&egrave;s</b></font>"+html;
	set_html_to_id_element("comptecontent",html);
	
	display_div("comptetype",false);
	setTimeout('display_div("compteloading",false);',1000);
	set_html_to_id_element("comptecontent",html);
	
}