// JavaScript Document
var speed = 5000;
var pic = new Array();
var t, x;


img_prefix='/common/images/homepage/backgrounds/';
pic[0]=img_prefix+'feature05.jpg';
pic[1]=img_prefix+'feature03.jpg';
pic[2]=img_prefix+'feature04.jpg';
pic[3]=img_prefix+'feature02.jpg';
pic[4]=img_prefix+'feature06.jpg';
pic[5]=img_prefix+'feature07.jpg';
pic[6]=img_prefix+'feature08.jpg';
pic[7]=img_prefix+'feature09.jpg';
pic[8]=img_prefix+'feature11.jpg';
pic[9]=img_prefix+'feature10.jpg';
pic[10]=img_prefix+'feature01.jpg';

var p = pic.length;
var preLoad = new Array();
var j=0;
for (r = 0; r < p; r++) {
	preLoad[r] = new Image();
	preLoad[r].src = pic[r];
}

//var j = 0;
var s=0;
var randomnumber=0;

function initAnimationElements(){
var objFeatureContainer = document.getElementById('feature-container');

var objBG1Image = document.createElement("div");
	objBG1Image.setAttribute('id','background-pane-one');
	objBG1Image.style.width = '762px';
	objBG1Image.style.height = '244px';
	objBG1Image.style.position = 'absolute';
	objBG1Image.style.top = "0px";
	objBG1Image.style.left = "0px";
	objBG1Image.style.backgroundImage = 'url(/common/images/homepage/backgrounds/feature05.jpg)';
	objBG1Image.style.backgroundRepeat = 'no-repeat';
	objBG1Image.style.opacity = '1.0';
	objBG1Image.style.filter = 'alpha(opacity=100)';
	objBG1Image.style.mozOpacity = '1.0';
	objBG1Image.style.margin = '0 auto';
	objFeatureContainer.insertBefore(objBG1Image, objFeatureContainer.firstChild);
	
var objBG2Image = document.createElement("div");
	objBG2Image.setAttribute('id','background-pane-two');
	objBG2Image.style.width = '762px';
	objBG2Image.style.height = '244px';
	objBG2Image.style.position = 'absolute';
	objBG2Image.style.top = "0px";
	objBG2Image.style.left = "0px";
	objBG2Image.style.backgroundImage = 'url(/common/images/homepage/backgrounds/feature05.jpg)';
	objBG2Image.style.backgroundRepeat = 'no-repeat';
	objBG2Image.style.opacity = '0.0';
	objBG2Image.style.filter = 'alpha(opacity=0)';
	objBG2Image.style.mozOpacity = '0.0';
	objFeatureContainer.insertBefore(objBG2Image, objBG1Image.nextSibling);
/*
var objCompanyNewsButton = document.createElement("div");	
	objCompanyNewsButton.setAttribute('id', 'company-news');
	objCompanyNewsButton.style.width = '187px';
	objCompanyNewsButton.style.height = '51px';
	objCompanyNewsButton.style.backgroundImage = 'url(/common/images/homepage/buttons/button-company-news.gif)';
	objCompanyNewsButton.style.zIndex = '10';
	objCompanyNewsButton.style.position = 'absolute';
	objCompanyNewsButton.style.bottom = '0px';
	objCompanyNewsButton.style.right = '0px';
	objFeatureContainer.insertBefore(objCompanyNewsButton, objBG2Image.nextSibling)
*/	
	mainAnimation(objBG1Image, objBG2Image);

}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

addLoadEvent(initAnimationElements);	


function mainAnimation(objBG1Image,objBG2Image){

	animateTransition(objBG1Image, objBG2Image);
	
	
}

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

function animateTransition(objShown, objHidden){	

	showAnimation(objHidden, objShown);
	
	objShown2=objHidden;
	objHidden2=objShown;

	setTimeout('mainAnimation(objShown2, objHidden2)',speed);

}




function showAnimation(objShown,objHidden){
	
	objHidden = changeBackground(objHidden);
	
	new Effect.Appear(objHidden);
	new Effect.Fade(objShown);				  
	
}




function changeBackground(objectBG){
	

	if (j > (preLoad.length - 1)) j = 0;
	
	objectBG.style.backgroundImage = 'url('+preLoad[j].src+')';
	j = j + 1;
	return objectBG;
}



