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 posicion_geomapa() {
		p = document.getElementById("head");
		e_ = document.getElementById("geomapa");
		e_.style.top = (findPosY(p))+'px';
		e_.style.left = (findPosX(p)+820)+'px';
		return;
}

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=550');
	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);
  }
}

window.onload = function() {
//	posicion_menu('apropos');
//	posicion_menu('mregions');
//	posicion_geomapa();
//	if(document.getElementById("map")){
//		loadMapa();
//	}
/*
	if(navigator.userAgent.indexOf( 'Safari' ) != -1){
		if (document.getElementById('contenido')) document.getElementById('contenido').style.marginLeft='-260px';
		if (document.getElementById('contenidoRegions')) document.getElementById('contenidoRegions').style.marginLeft='-260px';
		if (document.getElementById('contenidoActualidad')) document.getElementById('contenidoActualidad').style.marginLeft='-260px';
		if (document.getElementById('contenidoAction')) document.getElementById('contenidoAction').style.marginLeft='-260px';
		if (document.getElementById('contenidoActions')) document.getElementById('contenidoActions').style.marginLeft='-260px';
		if (document.getElementById('col1Acteurs')) document.getElementById('col1Acteurs').style.marginLeft='-260px';
		if (document.getElementById('contenidoActeurs')) document.getElementById('contenidoActeurs').style.marginLeft='-80px';
		if (document.getElementById('contenidoArticle')) document.getElementById('contenidoArticle').style.marginLeft='-260px';
		if (document.getElementById('contenidoRessources')) document.getElementById('contenidoRessources').style.marginLeft='-260px';
		if (document.getElementById('contenidoActeursRegion')) document.getElementById('contenidoActeursRegion').style.marginLeft='-260px';
	}
	*/
	
	diaporama();
}
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==elementos.length?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==elementos.length?0:i+1;
	
	st = setTimeout( diaporama, timeOut * 1000 );
}

function setCurrentNav(i) {
	for(var j=1;j<=elementos.length;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';
		}
	}
	
	
}

