ohcx=Array();
ohspd=Array(1,2,3,4,7,11,22,22,11,7,4,3,2,1);
ohspdtot=14;
ohspdid=0;
ohtot=0;
ohaction='';
ohcid=0;
dblemve=0;
ohdate=Array();

function ini_ourhistory(x){
	
	ohtot=x;
	
	for(i=0;i<ohtot;i++){
		ohcx[i]=(i+3)*100;	
	}
	
	document.getElementById('oh'+ohcid).style.opacity = 10/10;
	document.getElementById('oh'+ohcid).style.filter = 'alpha(opacity=' + 10*10 + ')';
	
	//document.getElementById('ourhistorycontent').innerHTML="<h2>"+ohdate[ohcid]+"</h2>";
	
	xmlHttp=GetXmlHttpObject();
	var url="/ourhistory/"+ohdate[ohcid]+".php";
	//var url="/ourhistory/2010.php";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", url.length);
	xmlHttp.send(null);
	
}

function ourhistory_gotodate(x){
	
	if(x>ohcid){
		if((x-1)==ohcid) dblemve=0; else dblemve=1;
		ourhistory_move(1);
	}else if(x<ohcid){
		if((x+1)==ohcid) dblemve=0; else dblemve=1;
		ourhistory_move(2);
	}
	
}

function ourhistory_move(x){
	
	if(ohaction==''){
		if(x==1){
			if(ohcid<(ohtot-1)){
				ohaction='move';
				ohcid++;
				ourhistory_asc();
			}
		}else{
			if(ohcid>0){
				ohaction='move';
				ohcid--;
				ourhistory_desc();
			}
		}
	}
}

function ourhistory_asc(){
	
	for(i=0;i<ohtot;i++){
		ohcx[i]=ohcx[i]-ohspd[ohspdid];
		document.getElementById('oh'+i).style.left=ohcx[i]+"px";
	}
	
	ohspdid++;
	
	if(ohspdid<ohspdtot){
		ohtmr=setTimeout(ourhistory_asc,20);
	}else{
		if(dblemve==1){
			dblemve=0;
			ohaction='';
			ohspdid=0;
			ourhistory_move(1);
		}else{
			ourhistory_show();		
		}
	}

}

function ourhistory_desc(){
	
	for(i=0;i<ohtot;i++){
		ohcx[i]=ohcx[i]+ohspd[ohspdid];
		document.getElementById('oh'+i).style.left=ohcx[i]+"px";
	}
	
	ohspdid++;
	
	if(ohspdid<ohspdtot){
		ohtmr=setTimeout(ourhistory_desc,20);
	}else{
		if(dblemve==1){
			dblemve=0;
			ohaction='';
			ohspdid=0;
			ourhistory_move(2);
		}else{
			ourhistory_show();		
		}
	}

}

function ourhistory_show(){
	
	ohspdid=0;
	ohaction='';
	
	for(i=0;i<ohtot;i++){
		document.getElementById('oh'+i).style.opacity = 7/10;
		document.getElementById('oh'+i).style.filter = 'alpha(opacity=' + 7*10 + ')';
	}
	
	document.getElementById('oh'+ohcid).style.opacity = 10/10;
	document.getElementById('oh'+ohcid).style.filter = 'alpha(opacity=' + 10*10 + ')';
	
	/*for(i=0;i<ohtot;i++){
		document.getElementById('ohi'+i).width="50";
	}
	
	document.getElementById('ohi'+ohcid).width="70";
	
	ohcid2=ohcid+1;
	if(ohcid2<ohtot) document.getElementById('ohi'+ohcid2).width="65";
	
	ohcid2=ohcid+2;
	if(ohcid2<ohtot) document.getElementById('ohi'+ohcid2).width="60";
	
	ohcid2=ohcid+3;
	if(ohcid2<ohtot) document.getElementById('ohi'+ohcid2).width="55";
	
	ohcid2=ohcid-1;
	if(ohcid2>=0) document.getElementById('ohi'+ohcid2).width="65";
	
	ohcid2=ohcid-2;
	if(ohcid2>=0) document.getElementById('ohi'+ohcid2).width="60";
	
	ohcid2=ohcid-3;
	if(ohcid2>=0) document.getElementById('ohi'+ohcid2).width="55";
	
	//alert(ohcid2);*/
	
	//document.getElementById('ourhistorycontent').innerHTML="<h2>"+ohdate[ohcid]+"</h2>";
	
	xmlHttp=GetXmlHttpObject();
	var url="/ourhistory/"+ohdate[ohcid]+".php";
	//var url="/ourhistory/2010.php";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", url.length);
	xmlHttp.send(null);
	
}


function stateChanged() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById('ourhistorycontent').innerHTML=xmlHttp.responseText;
	}
}


function GetXmlHttpObject(){

	var xmlHttp=null;
	
	try {
	  xmlHttp=new XMLHttpRequest();
	}catch (e){
	  	try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	   	}catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	   }
	}
	return xmlHttp;
	
}
