var mouseOn = new Array(0,0,0,0), boxOpen = new Array(0,0,0,0), working = new Array(0,0,0,0), set_array = new Array ('','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg'), iSet=2;

function moveBox(num,inOut) {
	if (inOut==1) {
		mouseOn[num]=1;
		if (working[num]<1 && boxOpen[num]<1) { 
			working[num] =1; boxOpen[num]=1;
			new Effect.Tween('text'+num, 0.0, 1.0, { duration: 0.5} , function(p) { this.setStyle({opacity : p })} );
			new Effect.Tween('cover'+num, 95, 70, { duration: 0.2,afterFinish: function (){
				working[num] =0; 
				if (mouseOn[num]==0) {
					moveBox(num,0);
				}
			}} , function(p) { this.setStyle({height : p + "px" })} );
		}
	}
	else {
		mouseOn[num]=0;
		if (working[num]<1 && boxOpen[num]>0) {
			working[num] =1; boxOpen[num]=0;
			new Effect.Tween('text'+num, 1.0, 0.0, { duration: 0.5} , function(p) { this.setStyle({opacity : p })} );
			new Effect.Tween('cover'+num, 70, 95, { duration: 0.2,afterFinish: function (){
				working[num] =0; 
				if (mouseOn[num]==1) {
					moveBox(num,1);
				}
			}} , function(p) { this.setStyle({height : p + "px" })} );
		}
	}
}

function setUpHomePage() {
	$('ov1').observe('mouseover', function () { moveBox(1,1); });
	$('ov1').observe('mouseout', function () { moveBox(1,0); });
	$('ov2').observe('mouseover', function () { moveBox(2,1); });
	$('ov2').observe('mouseout', function () { moveBox(2,0); });
	$('ov3').observe('mouseover', function () { moveBox(3,1); });
	$('ov3').observe('mouseout', function () { moveBox(3,0); });
	$('text1').setStyle({ opacity: 0.0 });
	$('text2').setStyle({ opacity: 0.0 });
	$('text3').setStyle({ opacity: 0.0 });
	setUpSwaps();
}

function setUpSwaps() {
	var int3 = setTimeout ( function () { var int2 = setInterval ( swapImages, 8000 ) },8000);
}

function swapImages () {
	cross2 = new crossfade($('football_image'), 'images/front_page_football/'+set_array[iSet], '1', 'set fashion');
	if (iSet<6) iSet=iSet+1; else iSet=1;
}


Event.observe(window, 'load', setUpHomePage);