// JavaScript Document
var opacity = 0.25, toOpacity = 1.0, hidden = 0.0, length = 1100;
// Intro div
var ableIntro;
// Information divs
var ableGroupInfo, ableESIinfo, ableLSIinfo, ableCTIinfo, ableGMDinfo;
// Button divs
var ableESIbtn, ableLSIbtn, ableCTIbtn, ableGMDbtn;
//Popover alerts
var popover;

window.addEvent('domready', domready);
function SetCookie( name, value, expires, path, domain, secure ){
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; }
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" );
}
function GetCookie( name ) { 
	var cookieValue = null;
	if ( document.cookie.length > 0 ) {
		var extractExp = new RegExp("(?:^|;)\\s*" + name + "=(.*?)(?:$|;)");
		var match = document.cookie.match(extractExp);
		if ( match != null ) { cookieValue = unescape(match[1]); }
	}
	return cookieValue;
}
function domready() {
	ableIntro = $('intro');
	var skip = GetCookie('able_skip');
	if( skip == null )
	{
		SetCookie('able_skip','skip');
		var flashVersion = Browser.Plugins.Flash.version || false;
		if(flashVersion){
			ableIntro.setStyle('visibility','visible');
			ableIntro.setStyle('display','block');
			ableIntro.set('opacity', toOpacity).set('tween', {duration: length});
		}
	}
	//set dom objects
	//info divs
	ableGroupInfo = $('ableGroup');
	ableESIinfo = $('ableESIinfo');
	ableLSIinfo = $('ableLSIinfo');
	ableCTIinfo = $('ableCTIinfo');
	ableGMDinfo = $('ableGMDinfo');
	//btn divs
	ableESIbtn = $('ableESIbtn');
	ableLSIbtn = $('ableLSIbtn');
	ableCTIbtn = $('ableCTIbtn');
	ableGMDbtn = $('ableGMDbtn');
	//set opacity ASAP
	$$('div.info').set('opacity', hidden);
	ableGroupInfo.set('opacity', toOpacity);
	//set opacity ASAP and add button anim
	$$('div.ableButton').set('opacity', opacity).set('tween', {duration: length});
	$$('div.info').set('tween', {duration: length});
	//add button events
	ableESIbtn.addEvents( { mouseenter: onESIenter, mouseleave: onESIleave } );
	ableLSIbtn.addEvents( { mouseenter: onLSIenter, mouseleave: onLSIleave } );
	ableCTIbtn.addEvents( { mouseenter: onCTIenter, mouseleave: onCTIleave } );
	ableGMDbtn.addEvents( { mouseenter: onGMDenter, mouseleave: onGMDleave } );
}
function onIntroEnd()
{
	ableIntro.tween('opacity',hidden);
	setTimeout(function(){ableIntro.setStyle('visibility','hidden');ableIntro.setStyle('display','none');}, length);
	//setTimeout(function(){ableIntro.setStyle('visibility','hidden');ableIntro.setStyle('display','none');Slimbox.open("_images/ABLE_Xmas.jpg");}, length);
}
function onESIenter()
{
	ableESIbtn.tween('opacity',toOpacity);
	ableESIinfo.tween('opacity', toOpacity);
	ableGroupInfo.tween('opacity', hidden);
}
function onESIleave()
{
	ableESIbtn.tween('opacity',opacity);
	ableESIinfo.tween('opacity', hidden);
	ableGroupInfo.tween('opacity', toOpacity);
}
function onLSIenter()
{
	ableLSIbtn.tween('opacity',toOpacity);
	ableLSIinfo.tween('opacity', toOpacity);
	ableGroupInfo.tween('opacity', hidden);
}
function onLSIleave()
{
	ableLSIbtn.tween('opacity',opacity);
	ableLSIinfo.tween('opacity', hidden);
	ableGroupInfo.tween('opacity', toOpacity);
}
function onCTIenter()
{
	ableCTIbtn.tween('opacity',toOpacity);
	ableCTIinfo.tween('opacity', toOpacity);
	ableGroupInfo.tween('opacity', hidden);
}
function onCTIleave()
{
	ableCTIbtn.tween('opacity',opacity);
	ableCTIinfo.tween('opacity', hidden);
	ableGroupInfo.tween('opacity', toOpacity);
}
function onGMDenter()
{
	ableGMDbtn.tween('opacity',toOpacity);
	ableGMDinfo.tween('opacity', toOpacity);
	ableGroupInfo.tween('opacity', hidden);
}
function onGMDleave()
{
	ableGMDbtn.tween('opacity',opacity);
	ableGMDinfo.tween('opacity', hidden);
	ableGroupInfo.tween('opacity', toOpacity);
}
