function criarObjMSXMLHttp() {
	var versoes = ["MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
	for (var i=0; i<versoes.length; i++){ try{ var objetoXMLHttp=new ActiveXObject(versoes[i]); return objetoXMLHttp; } catch (ex) { } } return false; 
}
function url_encode(str) { 
var hex_chars = "0123456789ABCDEF"; 
var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
var n, strCode, hex1, hex2, strEncode = ""; 
for(n = 0; n < str.length; n++) { 
if (noEncode.test(str.charAt(n))) { 
strEncode += str.charAt(n); 
} else { 
strCode = str.charCodeAt(n); 
hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
hex2 = hex_chars.charAt(strCode % 16); 
strEncode += "%" + (hex1 + hex2); 
} 
} 
return strEncode; 
} 

function url_decode(str) { 
var n, strCode, strDecode = ""; 
for (n = 0; n < str.length; n++) { 
if (str.charAt(n) == "%") { 
strCode = str.charAt(n + 1) + str.charAt(n + 2); 
strDecode += String.fromCharCode(parseInt(strCode, 16)); 
n += 2; 
} else { 
strDecode += str.charAt(n); 
} 
} 
return strDecode; 
}

function clickbox(i,j,k) {
	var ajax=false;
	document.getElementById("clickbox").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","ajax.php?t="+i+"&id="+j+"&idcontent="+k,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("clickbox").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("clickbox").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function clickbox2(i,j,k) {
	var ajax=false;
	document.getElementById("clickbox").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/regional/ajax.php?t="+i+"&id="+j+"&idcontent="+k,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("clickbox").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("clickbox").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function newPageView(id,p,l) {
	var ajax=false;
	document.getElementById("resultBox").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","ajax.php?p="+p+"&id="+id+"&l="+l,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("resultBox").innerHTML=ajax.responseText;
	} else { document.getElementById("clickbox").innerHTML="Error. Try again!"; } } } } ajax.send(null);	
}
function newPageViewRegional(id,p,l) {
	var ajax=false;
	document.getElementById("resultBox").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/regional/ajax.php?p="+p+"&id="+id+"&l="+l,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("resultBox").innerHTML=ajax.responseText;
	} else { document.getElementById("clickbox").innerHTML="Error. Try again!"; } } } } ajax.send(null);	
}
function newPageView2(id,p,l) {
	var ajax=false;
	document.getElementById("resultBox").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/regional/ajax.php?p="+p+"&id="+id+"&l="+l,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("resultBox").innerHTML=ajax.responseText;
	} else { document.getElementById("clickbox").innerHTML="Error. Try again!"; } } } } ajax.send(null);	
}
function photo(i,j) {
	var ajax=false;
	photoPOP();
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","photoajax.php?ajax&id="+i+"&photo="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("photo").innerHTML=url_decode(ajax.responseText);
	jQuery('#first-carousel').jcarousel();
	} else { document.getElementById("photo").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function photolimit2(i,j) {
	var ajax=false;
	document.getElementById("photolimitPhoto").innerHTML='';
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","photolimit.php?ajax2&id="+i+"&limit="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("photolimitPhoto").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("photolimitPhoto").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function photoRegional(i,j) {
	var ajax=false;
	document.getElementById("photo").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/regional/photoajax.php?ajax&id="+i+"&photo="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("photo").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("photo").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function photolist(i,j) {
	var ajax=false;
	document.getElementById("photolist").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","photolist.php?ajax&id="+i+"&pag="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("photolist").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("photolist").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function photolistRegional(i,j) {
	var ajax=false;
	document.getElementById("photolist").innerHTML="Loading...";
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/regional/photolist.php?ajax&id="+i+"&pag="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("photolist").innerHTML=url_decode(ajax.responseText);
	} else { document.getElementById("photolist").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function phototable(i) {
	for (j=1;j<=15;j++) {
		document.getElementById("tablephoto"+j).className='photobox2';
	}
	document.getElementById(i).className='photobox1';
}
function openWindow(i,j) {
	diaporamaPOP();
	var ajax=false;
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/slideshow.php?id="+i+"&related="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("diaporamaslide").innerHTML=url_decode(ajax.responseText);
	carregarDiaporama(0,j);	
	} else { document.getElementById("diaporamaslide").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
function carregarSlideshow(i,j) {
	var ajax=false;
	if(window.XMLHttpRequest) { ajax= new XMLHttpRequest();	} else if (window.ActiveXObject) { ajax = criarObjMSXMLHttp(); }
	if (ajax) {
	ajax.open("GET","http://www.msf.fr/slideshow.php?ids="+i+"&related="+j,true);
	ajax.onreadystatechange = function () {
	if (ajax.readyState==4) { if (ajax.status==200) {
	document.getElementById("diaporamaslide").innerHTML=url_decode(ajax.responseText);
	carregarDiaporama(i,j);	
	} else { document.getElementById("diaporamaslide").innerHTML="Error. Try again!"; } } } } ajax.send(null);
}
var varDiaporama= 0;
var fileName = "";
var currentPhotoID;
var totalPhotos = 0;
var delay = 1; // seconds
var textDisplayed = false;
function carregarDiaporama(i,j) {
	fileName = "http://www.msf.fr/slideshow.php?related="+j;
	varDiaporama = j;
	currentPhotoID;
	totalPhotos = 0;
	onPageLoad(i,j);
}
function onPageLoad(i,j) {
	var photoSet = getXMLElements("http://www.msf.fr/slideshowxml.php?id="+j,"photo");
	totalPhotos = photoSet.length;
	var photoID = i;
	textDisplayed = false
	var photo = getPhoto(photoSet,photoID);
	setPhotoOnPage(photo,totalPhotos);
	currentPhotoID = photo.id;
	setPhotoControls(photoSet,currentPhotoID,j);
	toggleText(delay);
}
function onPageLoad2(i,j) {
	document.getElementById("currentPhoto").src='';
	var photoSet = getXMLElements("http://www.msf.fr/slideshowxml.php?id="+j,"photo");
	totalPhotos = photoSet.length;
	var photoID = i;
	textDisplayed = false
	var photo = getPhoto(photoSet,photoID);
	setPhotoOnPage(photo,totalPhotos);
	toggleText(delay);
}
function openWindowRegional(i,j) {
	window.open("http://www.msf.fr/regional/slideshow.php?id="+i+"&related="+j,null,"height=670,width=720,top=0,left=0,status=yes,toolbar=no,menubar=no,location=no");
}
function openWindowMap(i,j,k) {
	l="width="+j+",height="+k+",top=0,left=0,status=yes,toolbar=no,menubar=no,location=no";
	window.open("http://www.msf.fr/"+i,null,l);
}
function openWindowLink(i,j) {
	window.open(i,null,j);
}
function changeBackIn(i) {
	if (document.getElementById(i).className=="menuLevel1") {
		document.getElementById(i).style.backgroundImage='url(images/menuleft/list-menu3.gif)';
	}
}
function changeBackOut(i) {
	if (document.getElementById(i).className=="menuLevel1") {
		document.getElementById(i).style.backgroundImage='';
	}
}
function changeBackIn2(i) {
	if (document.getElementById(i).className=="menuLevel3") {
		document.getElementById(i).style.backgroundImage='url(images/menuleft/list-menu5.gif)';
	}
}
function changeBackOut2(i) {
	if (document.getElementById(i).className=="menuLevel3") {
		document.getElementById(i).style.backgroundImage='';
	}
}
function changeBackIn3(i) {
	if (document.getElementById(i).className=="menuLevel3S") {
		document.getElementById(i).style.backgroundImage='url(images/menuleft/list-menu5.gif)';
	}
}
function changeBackOut3(i) {
	if (document.getElementById(i).className=="menuLevel3S") {
		document.getElementById(i).style.backgroundImage='';
	}
}