
var position=new Array();

var projects = new Array();


function initRotating() {
	projects[0] = {
		content: 'project0'
	};
	projects[1] = {
		content: 'project1'
	};
	projects[2] = {
		content: 'project2'
	};
	projects[3] = {
		content: 'project3'
	};
	projects[4] = {
		content: 'project4'
	};
	
	var rot = Element.extend($('rotating'));
	position[0] = rot.style;

	rotateDiv(0);
}
var time=0;
var timer;

var cycle = 100;
function rotateDiv(n) {
	//var rot = Element.extend($('rotating'));
	
	timer = window.setInterval('showProject('+n+')',20);
}


function showProject(i) {
	if(i==projects.length) {
		i=0;
	}
	
	if(cycle>0) {
		position[0].backgroundPosition = ease(time,0,1024,1000);
		time++;		
		cycle--;
	} else {
		timer = clearInterval(timer);
		showInfo(i);
		//showBuilding(i);
		cycle = 100;
	}
	
}

function showInfo(i) {
	//document.body.appendChild(projects[i].content);
//	i++;
	timer = setTimeout('showShadow('+i+')',0);
}

function showShadow(i) {
//	i++;
	//$('project'+i).appear({duration:1});
	$('project'+i).appear({duration:1});
	timer = setTimeout('showLight('+i+')',5000);
	
}

function showLight(i) {
	//$('project1'+i).show();
	$('project'+i).appear({from:1, to:0});
	setTimeout('fade('+i+')',1000);
	
}

function fade(i) {
	//$('project1'+i).hide();
	//Effect.SwitchOff($('project'+i)); //
	//$('project'+i).appear({from:1, to:0});
	i++;
//	cycle=100;
	setTimeout('rotateDiv('+i+')',30);
	//timer = window.setInterval('showProject('+i+')',30);
}

function timeRotate() {

		position[0].backgroundPosition = ease(time,0,1024,1000);
		time++;
		timer = window.setInterval('timeRotate()',5000)
}
function ease (t, b, c, d) {
		return c*t/d + b;
}
function stopRotate(ev) {
	clearTimeout(timer);
}
