	var nTotalPeriods=36, arrLength=new Array(0,13,4,3,8,3,5);  //const
	var nCurrPeriod=0;

	function getFlashMovieObject(movieName){
		if(window.document[movieName]) return window.document[movieName];
		if(navigator.appName.indexOf("Microsoft Internet")==-1){
			if(document.embeds && document.embeds[movieName]) return document.embeds[movieName]; 
		}
		else{
			return document.getElementById(movieName);
		}
	}

	function fChangeImage(nPeriod){
		// the function that the flash calls. the flash sends values 1-6. this function finds the first id of this era 
		var nShowPeriod=0;
		for(i=1; i<nPeriod; i++) nShowPeriod+=arrLength[i];
		fChangePeriod(nShowPeriod+1);
	}

	function fChangePeriod(nPeriod){
		var bFound=false;
		// updating the flash pointer
		var nIntCount=0
		for(var i=0; (i<arrLength.length && nIntCount<nPeriod); i++) nIntCount+=arrLength[i]
		getFlashMovieObject("oTimelineFlash").SetVariable('newNum', i-1);

		// updating nav buttons
		document.getElementById("oNavPrevious").style.display=(nPeriod>1 ? "block" : "none");
		document.getElementById("oNavNext").style.display=(nPeriod<nTotalPeriods ? "block" : "none");

		// hiding previous and displaying new one
		if(nCurrPeriod) document.getElementById("oPeriod"+ nCurrPeriod).style.display="none";
		var oNewPeriod=document.getElementById("oPeriod"+ nPeriod);
		if(!oNewPeriod.style.backgroundImage) oNewPeriod.style.backgroundImage="url(/english/images/timeline/"+ nPeriod +".jpg)";
		oNewPeriod.style.display="block";

		nCurrPeriod=nPeriod;
	}

	window.onload=function(){fChangePeriod(1);}
