function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getHTTPObject() {
	var xhr_object = null; 
	if(window.XMLHttpRequest) // Firefox 
		xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	return xhr_object;
}

function largeur_fenetre()
{
 if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
 else if (window.innerWidth) return window.innerWidth  ;
 else return 0;
}

function hauteur_fenetre()
{
 if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
 else if (window.innerHeight) return window.innerHeight  ;
 else return 0;
}

function loadBarre()
{
	maBarre=MM_findObj("barreMenu");
	winH = hauteur_fenetre();
	winL = largeur_fenetre();
	maBarre.style.top=(winH-55)+"px";
	maBarre.style.width=winL;
	maBarre.style.display="";
	
	ajustFondPop();
	
	window.onresize = loadBarre;
}

function ajustFondPop()
{
	monVoileLightbox=MM_findObj("voileLightbox");
	monVoileLightbox.style.top="0px";
	monVoileLightbox.style.left="0px";
	monVoileLightbox.style.width=winL+"px";
	monVoileLightbox.style.height=winH+"px";
}

function chargeThema(mode)
{
	// Défini le fond
	var objFond=document.body;
	backgroundImage="img/";
	switch (mode)
	{
		case 'conseil':
			objFond.style.backgroundImage="url(img/powow_fond_conseil_2.jpg)";
			objFond.style.backgroundColor="#692004";
			break;
		case 'design':
			objFond.style.backgroundImage="url(img/powow_fond_design_2.jpg)";
			objFond.style.backgroundColor="#629a01";
			break;
		case 'ref':
			objFond.style.backgroundImage="url(img/powow_fond_ref_2.jpg)";
			objFond.style.backgroundColor="#236992";
			break;
		case 'dev':
			objFond.style.backgroundImage="url(img/powow_fond_dev_2.jpg)";
			objFond.style.backgroundColor="#1e94d6";
			break;
		case 'market':
			objFond.style.backgroundImage="url(img/powow_fond_market_2.jpg)";
			objFond.style.backgroundColor="#af1552";
			break;
		default:
			objFond.style.backgroundImage="url(img/powow_fond_home_2.jpg)";
			objFond.style.backgroundColor="#46a19a";
			break;
	}
	
	// Défini la barre du bas
	var objBarreMenu=MM_findObj("barreMenu");
	var objZnLiensMenu=MM_findObj("zoneMenu");
	switch (mode)
	{
		case 'conseil':
			objBarreMenu.style.backgroundImage="url(img/trame_bas_conseil.gif)";
			objZnLiensMenu.style.backgroundColor="#2b0d02";
			break;
		case 'design':
			objBarreMenu.style.backgroundImage="url(img/trame_bas_design.gif)";
			objZnLiensMenu.style.backgroundColor="#214901";
			break;
		case 'ref':
			objBarreMenu.style.backgroundImage="url(img/trame_bas_ref.gif)";
			objZnLiensMenu.style.backgroundColor="#07283c";
			break;
		case 'dev':
			objBarreMenu.style.backgroundImage="url(img/trame_bas_dev.gif)";
			objZnLiensMenu.style.backgroundColor="#073148";
			break;
		case 'market':
			objBarreMenu.style.backgroundImage="url(img/trame_bas_market.gif)";
			objZnLiensMenu.style.backgroundColor="#66082d";
			break;
		default:
			objBarreMenu.style.backgroundImage="url(img/trame_bas_home.gif)";
			objZnLiensMenu.style.backgroundColor="#033c47";
			break;
	}	
}

function lightboxes(contenu,x,y,color)
{
	monVoileLightbox=MM_findObj("voileLightbox");
	monContenuLightbox=MM_findObj("contenuLightbox");
	if (contenu!=null && contenu>"")
	{
		if (color!="") monVoileLightbox.style.backgroundColor=color;
		ajustFondPop();
		
		monContenuLightbox.style.top=y+"px";
		monContenuLightbox.style.left=x+"px";
		monContenuLightbox.innerHTML=contenu;
		
		monVoileLightbox.style.display="";
		monContenuLightbox.style.display="";
	}
	else
	{
		monVoileLightbox.style.display="none";
		monContenuLightbox.style.display="none";
	}
}

function chargeActu(ref)
{
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "powow_actus.php",true);

	xmlhttp.onreadystatechange = function() { 
		if(xmlhttp.readyState == 4) lightboxes(xmlhttp.responseText,100,50,"#000");
	}	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	var data="ref="+ref;
	xmlhttp.send(data);
}

function chargeAnnonce()
{
	lightboxes(MM_findObj("divAnnonce").innerHTML,100,50,"#000");
}

