//Javascript Document

//INPUT OPTIONS
	//Announcement Options (Array(Text,Link,Target))
	messageRotateDelay=4; //sec
	messages=new Array(Array('Rebound Rumble Update:  Scored on the top goal! (see video above)','#','_parent'),Array('Rebound Rumble Update: Checklist - Going over the divider.  Check','#','_parent'));
	messageId='newsFeed';
	
	//Image Rotate Options (Array(Image,Link))
	mainImageId="mainImage";
	nextImageId="subImage";
	imageRotateDelay=4; //sec
	images=new Array(Array('http://www.kyeot.com/home/slides/FIRST.jpg','#','_parent'),Array('http://www.kyeot.com/home/slides/FIRST2.jpg','#first','_parent'));

	//Countdown Settings
	var countdown=new Array();
	countdown['month']='3';
	countdown['day']='1';
	countdown['year']='2012';
	countdown['hour']='8';
	countdown['min']='30';
	countdown['ap']='am';
//Do not Edit Below This	

//Initial Var Setup
var opacity=0;
var currentImage=0;
var rotateNow=0;
var timer=0;
var currentMessage=0;
messageRotateDelay=(messageRotateDelay*1000)/75;
imageRotateDelay=(imageRotateDelay*1000)/75;
function startJavascript(){
	setInterval('timing()',75);
}

function timing(){
//This function is repeated every 100 milli sec
	if(timer==0){
		//Initial Setup
		document.getElementById(nextImageId).style.backgroundImage='url('+images[currentImage][0]+')';
	}

	/*if(timer==0 || timer/imageRotateDelay==Math.round(timer/imageRotateDelay) || rotateNow==1){
		imageFade();
	}*/
	
	countdownUpdate();
	
	if(timer==0 || timer/messageRotateDelay==Math.round(timer/messageRotateDelay)){
		announcementRotate();
	}
	
	timer=timer+1;
	
}

function announcementRotate(){
	document.getElementById(messageId).innerHTML=messages[currentMessage][0];
	document.getElementById(messageId).href=messages[currentMessage][1];
	document.getElementById(messageId).target=messages[currentMessage][2];
	if(currentMessage>=(messages.length-1)){
		currentMessage=0;
	}else{
		currentMessage=currentMessage+1;
	}
}

function countdownUpdate(){
	//Get Current Data
	var currentDate;
	currentDate=new Date();
	
	//Setup Countdown Date
	var countdownDate=new Date();
	countdownDate.setMonth(countdown['month']-1);
	countdownDate.setDate(countdown['day']);
	countdownDate.setFullYear(countdown['year']);
	countdown['adjustHour']=countdown['hour'];
	if(countdown['adjustHour']=='12'){
		countdown['adjustHour']=0;
	}
	if(countdown['ap']=='pm'){
	countdown['adjustHour']=parseInt(countdown['adjustHour'])+12;
	}
	countdownDate.setHours(countdown['adjustHour'],countdown['min'],0,0);
	countdownTime=countdownDate.getTime()-currentDate.getTime();
	if(countdownDate.getTimezoneOffset()/60!=5){
		countdownTime=countdownTime+((300-countdownDate.getTimezoneOffset())*60*1000);
	}
	if(countdownTime<0){
	countdownTime=0;
	}
	countdownDisplay=new Array();
	countdownDisplay['millisec']=countdownTime;
	countdownDisplay['days']=Math.floor(countdownDisplay['millisec']/(24*60*60*1000));
	countdownDisplay['millisec']=countdownDisplay['millisec']-(countdownDisplay['days']*(24*60*60*1000));
	countdownDisplay['hours']=Math.floor(countdownDisplay['millisec']/(60*60*1000));
	countdownDisplay['millisec']=countdownDisplay['millisec']-(countdownDisplay['hours']*(60*60*1000));
	countdownDisplay['mins']=Math.floor(countdownDisplay['millisec']/(60*1000));
	countdownDisplay['millisec']=countdownDisplay['millisec']-(countdownDisplay['mins']*(60*1000));
	countdownDisplay['secs']=Math.floor(countdownDisplay['millisec']/(1000));
//Update Countdown Fields
	if(countdownDisplay['days']<10){
		zero='0';
	}else{
		zero='';
	}
	document.getElementById('countdownDay').innerHTML=zero+countdownDisplay['days'];
	if(countdownDisplay['hours']<10){
		zero='0';
	}else{
		zero='';
	}
	document.getElementById('countdownHour').innerHTML=zero+countdownDisplay['hours'];
	if(countdownDisplay['mins']<10){
		zero='0';
	}else{
		zero='';
	}
	document.getElementById('countdownMin').innerHTML=zero+countdownDisplay['mins'];
	if(countdownDisplay['secs']<10){
		zero='0';
	}else{
		zero='';
	}
	document.getElementById('countdownSec').innerHTML=zero+countdownDisplay['secs'];
}
//Functions that make stuff work
function imageFade(){
	opacity=opacity+10;
	if(opacity==100){
		opacity=99.99999;
		document.getElementById(mainImageId).style.backgroundImage='url('+images[currentImage][0]+')';
		document.getElementById(mainImageId).href=images[currentImage][1];
		document.getElementById(mainImageId).target=images[currentImage][2];
		document.getElementById(nextImageId).style.visibility="hidden";	
		if(currentImage>=(images.length-1)){
			currentImage=0;
		}else{
			currentImage=currentImage+1;
		}
		document.getElementById(nextImageId).style.backgroundImage='url('+images[currentImage][0]+')';
		opacity=0;
		rotateNow=0;
	}else{
		document.getElementById(nextImageId).style.visibility="visible";
		rotateNow=1;
	}
		document.getElementById(nextImageId).style.filter = "alpha(opacity:"+opacity+")";
		
		document.getElementById(nextImageId).style.KHTMLOpacity=opacity/100;
		
		document.getElementById(nextImageId).style.MozOpacity= opacity/100;
		
		document.getElementById(nextImageId).style.opacity=opacity/100;
}
