var photogalleryTimer=null;
var photogalleryTable=null;
var photogalleryOffset=5;
var photogalleryImgNum=0;
var photogalleryImgWidth=200;
var photogalleryCount=0;
var photogalleryDirection="";
function photogalleryInit() {
	photogalleryTable=document.getElementById('photogallery').getElementsByTagName('UL')[0];
	photogalleryImgNum=photogalleryTable.getElementsByTagName('LI').length;
	if(photogalleryImgNum<=5) photogalleryOffset=(1000-(photogalleryImgNum*photogalleryImgWidth))/2;
	if(photogalleryImgNum<=5) {
		document.getElementById('arrowLeft').style.display="none";
		document.getElementById('arrowRight').style.display="none";
		}
	/*for(i=0;photogalleryTable.getElementsByTagName('A')[i];i++) {
		var tr=photogalleryTable.getElementsByTagName('A')[i];
		tr.style.color="#ddd";
		}*/
	for(var i=0;photogalleryTable.getElementsByTagName('DIV')[i];i++) {
		photogalleryTable.getElementsByTagName('DIV')[i].style.display='none';
		}
	photogalleryTable.style.left="800px";
	photogalleryTimer=setInterval(photogalleryStartPos,10);
	}
function photogalleryStartPos() {
	var x=parseInt(photogalleryTable.style.left);
	if(x>photogalleryOffset) photogalleryTable.style.left=x-((x-photogalleryOffset)/30)+'px';
	else clearInterval(photogalleryTimer);
	}
function photogalleryRight() {
	if(photogalleryDirection=="") {
		photogalleryDirection="right";
		var target=photogalleryTable.getElementsByTagName('li')[photogalleryImgNum-1];
		var movethis=photogalleryTable.getElementsByTagName('li')[0];
		target.parentNode.appendChild(movethis.cloneNode(true));
		photogalleryCount=-1;
		photogalleryClearTimer();
		photogalleryTimer=setInterval(photogalleryMove,10);
		}
	}
function photogalleryLeft() {
	if(photogalleryDirection=="") {
		photogalleryDirection="left";
		var target=photogalleryTable.getElementsByTagName('li')[0];
		var movethis=photogalleryTable.getElementsByTagName('li')[photogalleryImgNum-1];
		target.parentNode.insertBefore(movethis.cloneNode(true),target);
		photogalleryTable.style.left=(parseInt(photogalleryTable.style.left)-photogalleryImgWidth)+'px';
		photogalleryCount=0;
		photogalleryClearTimer();
		photogalleryTimer=setInterval(photogalleryMove,10);
		}
	}
function photogalleryClearTimer() {
	if(photogalleryTimer!=false) {
		clearInterval(photogalleryTimer);
		photogalleryTimer=false;
		}
	}
function photogalleryMove() {
	var x=parseInt(photogalleryTable.style.left);
	var d=(photogalleryCount*photogalleryImgWidth)+photogalleryOffset;
	if(x>d) {
		var m=x-d<30?1:(x-d)/30;
		photogalleryTable.style.left=Math.round(x-m)+'px';
		}
	else if(x<d) {
		var m=d-x<30?1:(d-x)/30;
		photogalleryTable.style.left=Math.round(x+m)+'px';
		}
	else {
		if(photogalleryDirection=="right") {
			photogalleryTable.removeChild(photogalleryTable.getElementsByTagName('li')[0]);
			d+=photogalleryImgWidth;
			}
		else if(photogalleryDirection=="left") {
			photogalleryTable.removeChild(photogalleryTable.getElementsByTagName('li')[photogalleryImgNum]);
			}
		photogalleryDirection="";
		photogalleryTable.style.left=d+'px';
		photogalleryClearTimer();
		}
	}
function photogalleryOver(t) {
	t.getElementsByTagName('DIV')[0].style.display='block';
	/*for(i=0;t.getElementsByTagName('A')[i];i++) {
		var tr=t.getElementsByTagName('A')[i];
		tr.style.color="#000";
		}*/
	}
function photogalleryOut(t) {
	t.getElementsByTagName('DIV')[0].style.display='none';
	/*for(i=0;t.getElementsByTagName('A')[i];i++) {
		var tr=t.getElementsByTagName('A')[i];
		tr.style.color="#ddd";
		}*/
	}