boletin_email_t = '';

function posicion_menu(t) {
	if (t=='apropos') {
		p = document.getElementById("menu_a_propos_position");
		e_ = document.getElementById("menu_a_propos");
		e_.style.top = (findPosY(p)+25)+'px';
		e_.style.left = (findPosX(p)+1)+'px';
		return;
	} else if(t=='mregions') {
		p = document.getElementById("menu_regions_position");
		e_ = document.getElementById("menu_regions");
		e_.style.top = (findPosY(p)+25)+'px';
		e_.style.left = (findPosX(p)+1)+'px';
		return;
	}
}

function showMapa() {
	ll = document.getElementById("mapaFlash");
	oo = document.getElementById("overlayAll");
	with(ll.style){
		left = ((document.body.offsetWidth/2)-180)+'px';
		top = '100px';
		display = 'block';
	}
	with(oo.style){
//		height = document.body.height;
		top = document.body.scrollTop;
		display = 'block';
	}
	document.body.style.overflow='hidden';
}

function hideMapa() {
	document.getElementById("mapaFlash").style.display='none';
	document.getElementById("overlayAll").style.display='none';
	document.body.style.overflow='auto';
}

function posicion_geomapa() {
		p = document.getElementById("head");
		e_ = document.getElementById("geomapa");
		e_.style.top = (findPosY(p))+'px';
		e_.style.left = (findPosX(p)+880)+'px';
		return;
}

function swapImage(i) {
	document.getElementById("imgGeo").src=i;
}

function compartirShow(t) {
	document.getElementById('descIconCompartir').innerHTML=t;
}

function compartirHide(t) {
	document.getElementById('descIconCompartir').innerHTML='';
}

function wOpen(url)
{
	newwindow=window.open(url,'name','height=660,width=600,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

var isNN = document.layers ? true : false;
var isIE = document.all ? true : false;
function init() {
  if ( isNN )
    document.captureEvents(Event.MOUSEMOVE)
  document.onmousemove = handleMouseMove;
}
function handleMouseMove(evt) {
  mouseX = isNN ? evt.pageX : window.event.clientX;
  mouseY = isNN ? evt.pageY : window.event.clientY;
  e_ = document.getElementById("menu_a_propos");
  if( e_.style.display=='block' ) {
  	
  	if (mouseX < (findPosX(p)+1) || mouseX > (findPosX(p)+1+180) || mouseY < (findPosY(p)+25) || mouseY > (findPosY(p)+1+e_.style.height) ) {
  		e_.style.display='block';
  	}
  }
  return false;
}

document.onmousemove=function() {
	//if( mouseX< )
}
ocultar = null;
tmpTime = null;
function showMenu(t){
	if(t=='apropos'){
		document.getElementById("menu_a_propos").style.visibility='visible';
		if (tmpTime) clearTimeout(tmpTime);
	}else if(t=='mregions'){
		document.getElementById("menu_regions").style.visibility='visible';
		if (tmpTime) clearTimeout(tmpTime);
	}
	return false;
}
function hideMenu(t){
	ocultar = t;
	tmpTime = setTimeout( "hideMenu_()",500 );
}

function hideMenu_(){
	if(ocultar=='apropos')
		document.getElementById("menu_a_propos").style.visibility='hidden';
	else if(ocultar=='mregions')
		document.getElementById("menu_regions").style.visibility='hidden';
		
}


function findPosX(obj)
{
  var curleft = 0;
  if(obj.offsetParent)
      while(1) 
      {
        curleft += obj.offsetLeft;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if(obj.offsetParent)
      while(1)
      {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

function loadDiaporama() {
	//posicion_menu('mregions');
	//posicion_menu('apropos');
	
	if (window.XMLHttpRequest) {
		ajax = new XMLHttpRequest(); //Not IE
	} else if(window.ActiveXObject) {
		ajax = new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		//Display your error message here. 
		//and inform the user they might want to upgrade
		//their browser.
		alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
	}
	if (ajax.readyState == 4 || ajax.readyState == 0) {
		ajax.open("GET", '#DOSSIER_SQUELETTE/codes/diaporama.php', true);
		ajax.onreadystatechange = function(){
			if (ajax.readyState == 4) {
				//Set the contents of our span element to the result of the asyncronous call.
				document.getElementById('diaporama').innerHTML = ajax.responseText;
				$('#diaporamaFade').innerfade({
					animationtype: 'fade',
					speed: 1500,
					timeout: 4000,
					type: 'random',
					containerheight: '1em'
				});
			}
		}
		ajax.send(null);
	}
}

//mapa
function loadMapa() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
    //map.setCenter(new GLatLng(14.823090, -88.755337), 13);
  	loadMapAccion(map);
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function js_buscar(q){
	window.location.href='busqueda?recherche='+q+'&lang=#ENV{lang}'
}

window.onload = function() {
	$('#newsLetterField').focus(function(){
		el = document.getElementById('newsLetterField');
		if (el.value==boletin_email_t)
		{
			el.value='';
		}
		el.style.color='#000000';
	});
	$('#newsLetterField').blur(function(){
		el = document.getElementById('newsLetterField');
		if (el.value=='')
		{
			el.value=boletin_email_t;
			el.style.color='#aaaaaa';
		}
	});
	
	posicion_menu('apropos');
	posicion_menu('mregions');
	fixMenuWidth();
	posicion_geomapa();
	if(document.getElementById("map")){
		loadMapa();
	}
	//
	MM_preloadImages('http://volensafrica.org/squelettes/images/navGeoAFAU.gif','http://volensafrica.org/squelettes/images/navGeoAFCE.gif','http://volensafrica.org/squelettes/images/navGeoAFOU.gif');
	diaporama();
}

function fixMenuWidth() {
	if (typeof document.body.style.maxHeight != "undefined") {	
		document.getElementById('menu_a_propos_position').style.width=(document.getElementById('menu_a_propos_position').offsetWidth+20)+'px';
		document.getElementById('btn_clic_solidario').style.width=(document.getElementById('btn_clic_solidario').offsetWidth+20)+'px';
		document.getElementById('btn_contactenos').style.width=(document.getElementById('btn_contactenos').offsetWidth+20)+'px';
		document.getElementById('btn_actualidad').style.width=(document.getElementById('btn_actualidad').offsetWidth+20)+'px';
		document.getElementById('menu_regions_position').style.width=(document.getElementById('menu_regions_position').offsetWidth+20)+'px';
		document.getElementById('btn_acciones').style.width=(document.getElementById('btn_acciones').offsetWidth+20)+'px';
		document.getElementById('btn_actores').style.width=(document.getElementById('btn_actores').offsetWidth+20)+'px';
		document.getElementById('btn_galeria').style.width=(document.getElementById('btn_galeria').offsetWidth+20)+'px';
	} else {
		document.getElementById('menu_a_propos_position').style.width= '145px';
		document.getElementById('btn_clic_solidario').style.width= '120px';
		document.getElementById('btn_contactenos').style.width= '125px';
		document.getElementById('btn_actualidad').style.width= '90px';
		document.getElementById('menu_regions_position').style.width= '85px';
		document.getElementById('btn_acciones').style.width= '80px';
		document.getElementById('btn_actores').style.width= '100px';
		document.getElementById('btn_galeria').style.width= '120px';
	}
}

window.onunload = function() {
	GUnload();
}

var timeOut=5, currentElement = 0;
//var elementos = new Array();
var st;

function diaporama() {
	imgDD = document.getElementById('imgD');
	urlDD = document.getElementById('urlD');
	titDD = document.getElementById('titD');
	
	imgDD.src = elementos[currentElement].img;
	imgDD.style.width = elementos[currentElement].tW+'px';
	imgDD.style.height = elementos[currentElement].tH+'px';
	
	urlDD.href = elementos[currentElement].url;
	titDD.innerHTML = elementos[currentElement].tit;
	
	setCurrentNav(currentElement+1);
	
	currentElement = currentElement==3?0:currentElement+1;
	
	st = setTimeout( diaporama, timeOut * 1000 );
}

function diaporamaCambiar( i ) {
	
	clearTimeout(st);
	
	imgDD = document.getElementById('imgD');
	urlDD = document.getElementById('urlD');
	titDD = document.getElementById('titD');
	
	imgDD.src = elementos[i].img;
	imgDD.style.width = elementos[i].tW+'px';
	imgDD.style.height = elementos[i].tH+'px';
	
	urlDD.href = elementos[i].url;
	titDD.innerHTML = elementos[i].tit;
	
	setCurrentNav(i+1);
	
	currentElement = i==3?0:i+1;
	
	st = setTimeout( diaporama, timeOut * 1000 );
}

function setCurrentNav(i) {
	for(var j=1;j<=4;j++){
		if(j==i){
			document.getElementById('nav'+j).style.color='#666666';
			document.getElementById('nav'+j).style.fontWeight='bold';
		} else {
			document.getElementById('nav'+j).style.color='#999999';
			document.getElementById('nav'+j).style.fontWeight='normal';
		}
	}
}


function posFrmNewsLetter() {
	i = document.getElementById('frm_newletter');
	a = document.getElementById('newsLetterField');
	i.style.left = findPosX(a)+'px';
	i.style.top = (findPosY(a)+3)+'px';
}