var linkArray = new Array(3);
linkArray[0] = new Array(4);
linkArray[1] = new Array(4);
linkArray[2] = new Array(4);

PeriodicalExecuter.prototype.registerCallback = function() {
    this.intervalID = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
}

PeriodicalExecuter.prototype.stop = function() {
    clearInterval(this.intervalID);
}

var modCount = new Array();
modCount[0] = 0;
modCount[1] = 0;
modCount[2] = 0;

function timerFunction(){

	var period1 = (modCount[0]++%4)+1;
	var period2 = (modCount[1]++%4)+5;
	var period3 = (modCount[2]++%4)+9;

	//fade('hs_image1', 'hs_text1', period1, 1, 4, 0, $('hs_text1').style.height, '');
	//setTimeout('fade(\'hs_image2\', \'hs_text2\', ' + period2 + ', 5, 8, 1, \'' + $('hs_text2').style.height + '\', \'\')',800);
	//setTimeout('fade(\'hs_image3\', \'hs_text3\', ' + period3 + ', 9, 12, 2, \'' + $('hs_text3').style.height + '\', \'' + internationalDir + '\')',1600);
}

var timer = new PeriodicalExecuter(timerFunction, 5);


function fade(elementForImage, elementForBR, period, min, max, id, height, intDir){

	var current = period;
	var next = ++period;
	var nextBack = ++period;

	if(next > max && nextBack > max){
		next = min;
		nextBack = min+1;
	} else if(nextBack > max){
		nextBack = min;
	}

	new Effect.Opacity(elementForImage, {duration:1.5, from:1.0, to:0.0, afterFinish: function() {
												$(elementForImage).src = 'imx/portal/' + intDir + next + '_lg.jpg';
												$(elementForImage).setOpacity('1');
												$(elementForBR).style.backgroundImage = 'url(imx/portal/' + intDir + nextBack + '_lg.jpg)';
											}
								}
						);
	if(id == 0){
		$('hs_link' + (id+1)).href = linkArray[id][parseInt(next-1)];
	} else {
		$('hs_link' + (id+1)).href = linkArray[id][parseInt(next%min)];
	}
}



function LoadVscroll(){
	new Effect.Opacity('hs_image1', {duration:0.0, from:1.0, to:1.0});
	new Effect.Opacity('hs_image2', {duration:0.0, from:1.0, to:1.0});
	new Effect.Opacity('hs_image3', {duration:0.0, from:1.0, to:1.0});
}



