//ON DOM READY CALLS
jQuery(document).ready(function () {

	
	jQuery("#loginUsername").focus(function () {
		document.getElementById('loginUsername').style.background = '#ffffff';
		//console.log('loginUsername:focus');
	});
	
	jQuery("#loginUsername").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_email.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('loginUsername').style.background = bgimage;
		//console.log('loginUsername:blur');
	});
	
	jQuery("#loginPass").focus(function () {
		document.getElementById('loginPass').style.background = '#ffffff';
		//console.log('loginPass:focus');
	});
	
	jQuery("#loginPass").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_password.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('loginPass').style.background = bgimage;
		//console.log('loginPass:blur');
	});
	
	jQuery("#Login_ID").focus(function () {
		document.getElementById('Login_ID').style.background = '#ffffff';
		//console.log('Login_ID:focus');
	});
	
	jQuery("#Login_ID").blur(function () {
		bgimage = "url(/fls/10600/site_graphics/bg_enews.jpg) #ffffff no-repeat";
		if(this.value=='')
			document.getElementById('Login_ID').style.background = bgimage;
		//console.log('Login_ID:blur');
	});
		
});

function TopTab(num) {
	jQuery("#TabBox1 .tab-buttons").removeClass("active");
	jQuery("#TabBox1 .tab-buttons:eq("+num+")").addClass("active");
	jQuery("#TabBox1 .tab-content").fadeOut(500);
	setTimeout('jQuery("#TabBox1 .tab-content:eq('+num+')").fadeIn(500)',510);
}

function BottomTab(num) {
	jQuery("#TabBox2 .tab-buttons").removeClass("active");
	jQuery("#TabBox2 .tab-buttons:eq("+num+")").addClass("active");
	jQuery("#TabBox2 .tab-content").fadeOut(500);
	setTimeout('jQuery("#TabBox2 .tab-content:eq('+num+')").fadeIn(500)',510);
}

/**************************************************************************
START ROTATOR
**************************************************************************/
if (location.href.indexOf('HomePage') >= 0) 
	var rotate = true;	
else
	var rotate = false;
var rotate_current = 0;
var rotate_end = 6;
var rotate_past = rotate_end;
var r = null;

jQuery(document).ready(function () {
	jQuery("img.sub-image").click(function () { 
		if(rotate)
			toggle();
		for(i=0;i<jQuery("img.sub-image").length;i++) {
			if(jQuery("img.sub-image")[i]==this) {
				rotate_current = i;
				//console.log('subimage click:'+rotate_current);
				changeArticle();
			}
		}
	});
});

function tickerSlide (tickerWidth, tickerTime, tickerStart) {
	jQuery("#rotatorTickerCont .rotatorTicker").css("left", tickerStart+"px");
	jQuery("#rotatorTickerCont .rotatorTicker").animate({
	  left: -tickerWidth
	}, tickerTime);
}

function changeArticle() {
	//rotate_past = rotate_current - 1;
	//console.log("old: "+rotate_past+" new: "+rotate_current);
	jQuery("#rotatorRightCover").css("display", "block");
	jQuery("#rotatorLeftCover").css("display", "block");
	setTimeout('jQuery("#rotatorLeftCover").css("display", "none")',1000);
	setTimeout('jQuery("#rotatorRightCover").css("display", "none")',1000);
	if (document.getElementById("imgPlay"+(rotate_past+1))) {
		jQuery("#imgPlay"+(rotate_past+1)).fadeOut(500);
	}
	
	jQuery("#main-image-"+rotate_past).fadeOut(500);
	//jQuery("#Rotator .main-content").hide();
	//jQuery("#Rotator .main-content").css("display","none");
	setTimeout('jQuery("#main-image-'+rotate_current+'").fadeIn(500)',500);
	if (document.getElementById("imgPlay"+(rotate_current+1))) {
		setTimeout('jQuery("#imgPlay'+(rotate_current+1)+'").fadeIn(500)',500);
	}
	
	jQuery("#main-text-box-"+rotate_past).fadeOut(500);
	setTimeout('jQuery("#main-text-box-'+rotate_current+'").fadeIn(500)',500);
	
	jQuery("#rotate-title-"+rotate_past).fadeOut(500);
	setTimeout('jQuery("#rotate-title-'+rotate_current+'").fadeIn(500)',500);
	
	jQuery("#rotate-teaser-"+rotate_past).fadeOut(500);
	setTimeout('jQuery("#rotate-teaser-'+rotate_current+'").fadeIn(500)',500);
	
	jQuery("#rotate-links-"+rotate_past).fadeOut(500);
	setTimeout('jQuery("#rotate-links-'+rotate_current+'").fadeIn(500)',500);
	
	jQuery("#sub-rotator-"+rotate_past).css("border", "1px solid #ccc");
	jQuery("#sub-rotator-"+rotate_current).css("border", "2px solid #DF5312");
	
	jQuery("#sub-rotator-"+rotate_past).css("margin-top", "0px");
	jQuery("#sub-rotator-"+rotate_current).css("margin-top", "-1px");
	/*jQuery("#sub-rotator-"+rotate_current).animate({
	  width: 0
	}, 500);

	jQuery("#sub-rotator-"+rotate_current).css("border", "0px");
	jQuery("#sub-rotator-"+rotate_current).css("margin", "0px");

	jQuery("#sub-rotator-"+rotate_past).animate({
	  width: 80
	}, 500);
	
	jQuery("#sub-rotator-"+rotate_past).css("border", "1px solid #ccc");
	jQuery("#sub-rotator-"+rotate_past).css("margin", "0px 3px");*/
	
	// fixes IE's problem displaying a space for the div that's hidden
	//setTimeout('jQuery("#sub-rotator-'+rotate_current+'").css("display", "none")',500);
	
	jQuery('#sub-rotator-count').html((rotate_current+1)+"/7&nbsp;&nbsp;");
}

function article(num) {
	rotate_past = rotate_current;
	rotate_current = num;
	//jQuery("#Rotator .main-content").fadeOut(500);
	//setTimeout('jQuery("#Rotator .main-content:eq('+rotate_current+')").fadeIn(500)',510);
	//console.log(rotate_current+' - '+rotate_past);
	//jQuery("#Rotator .main-content:eq('+rotate_current+')").css("display","block");
	
	changeArticle();
	
	rotate = false;
}

/*function subStoryOn(num) {
	//console.log('subStoryOn:'+num);

function subStoryOn(num) {
	//console.log('subStoryOn:'+num);

	jQuery("img.sub-image").css("borderStyle","solid")

	//console.log(jQuery("img.sub-image").css("borderColor"));
	
	jQuery("img.sub-image:eq("+num+")").css("border", "2px solid #fff");
	jQuery("img.sub-image:eq("+num+")").css("marginBottom", "2px");

	//console.log(jQuery("img.sub-image").css("borderColor"));

	jQuery("img.sub-image:eq("+num+")").animate({
		borderWidth:"2px",
		marginBottom:"2px"
	},500);
	//jQuery("img.arrow:eq("+num+")").slideDown(500);
	
	jQuery("img.arrow:eq("+num+")").css("display", "block");
}*/


function rotateForward() {
	//console.log('Forward');
	rotate_past = rotate_current;
	
	if(rotate_current!=6)
		rotate_current ++;
	else
		rotate_current = 0;	
	clearTimeout(r);
	if(rotate)
		r = setTimeout('Rotate()',7000);	
	changeArticle();
}

function rotateBack() {
	rotate_past = rotate_current;

	if(rotate_current!=0)
		rotate_current --;
	else
		rotate_current = rotate_end;	
	changeArticle();
}

function Rotate() {
	rotate_past = rotate_current;
	
	if(rotate_current!=6)
		rotate_current ++;
	else
		rotate_current = 0;	
	changeArticle();
	
	if(rotate)
		r = setTimeout('Rotate()',7000);	
}

function toggle() {
	if(rotate) 
		rotate = false;
	else 
		rotate = true;
}

jQuery(document).ready(function () {
	if(document.getElementById("Rotator")) {
		if(rotate) 
			r = setTimeout('Rotate()',7000);	
	}
});

/**************************************************************************
END ROTATOR
**************************************************************************/