var billCount = 3;
var hotBill = 1;
$(document).ready(function(){
	$("#billboardButtons").append('<span class="billboardButton" id="sL">&lt;</span>');
	for(i=1;i<billCount+1;i++)
	{
		if(i > 1){
			$("#billboardL"+i).css('top','189px');
			$("#billboardR"+i).css('top','-189px');
		}
		$("#billboardButtons").append('<span class="billboardButton" id="'+i+'">'+i+'</span>');
	}
	$("#billboardButtons").append('<span class="billboardButton" id="sR">&gt;</span>');
	$("#billboardButtons > #1").css('color','#f58426');
	
	$("body").append('<div id="enphaseScreen"></div><div id="enphaseWindow"><div id="closeLink">[close]</div><iframe id="enphaseFrame" src="http://enlighten.enphaseenergy.com/public/systems/nXAQ16789" frameborder="0"></iframe></div>');
	
	$("#enphaseLink").click(function(){
		$("#enphaseScreen").animate(
		{width:'100%',height:'100%'},
		function(){
			var lM = ($("#enphaseScreen").width() - 960) / 2;
			$("#enphaseWindow").css('left',lM+'px').show();}
		);
	});
	$("#enphaseWindow > #closeLink").click(function(){
		$("#enphaseWindow").hide();
		$("#enphaseScreen").animate({width:'1%',height:'1%'});
	});
																									
	$(".billboardButton").hover(function(){
		$(this).css('color','#f58426');},
		function(){
		$(this).not("#"+hotBill).css('color','#5e9732');
	});
	
	$(".billboardButton").click(function(event){
		var whatBut = $(this).attr('id');
		var nextSlide = 0;
		if(isNaN(whatBut)){
			var dir = (whatBut == 'sL') ? -1 : 1;
			nextSlide = hotBill + dir;
			if(nextSlide < 1){nextSlide = billCount;}
			if(nextSlide > billCount){nextSlide = 1;}
		}else{
			if(whatBut != hotBill){nextSlide = whatBut;}
		}
		if(nextSlide > 0)
		{
			var slideIn = "#billboardL"+nextSlide;
			var slideOut = "#billboardL"+hotBill;
			$(slideIn).animate({top:0});
			$(slideOut).animate({top:189});
			slideIn = "#billboardR"+nextSlide;
			slideOut = "#billboardR"+hotBill;
			$(slideIn).animate({top:0});
			$(slideOut).animate({top:-189});
			hotBill = nextSlide;
			$(".billboardButton").not("#"+hotBill).css('color','#5e9732');
			$("#billboardButtons > #"+hotBill).css('color','#f58426');
		}
	});
	
	var flashCheck = DetectFlashVer(10, 0, 0);
	if(flashCheck)
	{
		var vidSrc = prepFlash('/videos/plug-into-the-sun.swf','','plugIntoSolar',246,176,'fff','transparent','center','showall',10,'','');
		$("#featureBox2 > .featureContent").html(vidSrc);
	}
});
