var banner={data:{},fadeSpeed:'slow',delay:5000,count:1,totalImg:0,timeout:'',animate:function()
{$('#rotateImage').animate({opacity:0},banner.fadeSpeed,function()
{$('#rotateImage').attr('src',banner.data.img[banner.count].src).animate({opacity:1},banner.fadeSpeed);$('#rotateLink').attr('href',banner.data.img[banner.count].url);banner.activeControl('skip'+banner.count);banner.count=(banner.count<banner.totalImg)?(banner.count+1):0;banner.timeout=setTimeout("banner.loadImage("+banner.count+",'animate')",banner.delay);});},activeControl:function(id)
{$('#bannerControl > li').attr('class','adPage');$('#'+id).attr('class','activePage');},pause:function()
{clearTimeout(banner.timeout);$('#rotateImage').stop().animate({opacity:1},10);$('#pausePlay').unbind('click').bind('click',function(){banner.play();}).html('play');},play:function()
{clearTimeout(banner.timeout);$('#pausePlay').unbind('click').bind('click',function(){banner.pause();}).html('pause');banner.timeout=setTimeout("banner.loadImage("+banner.count+",'animate')",250);},skip:function(imgNum)
{clearTimeout(banner.timeout);banner.count=parseInt(imgNum);$('#loading').show();$('#rotateImage').stop().animate({opacity:0},10);$('#bannerControl > li').unbind('click');banner.loadImage(banner.count,'skipComplete');},skipComplete:function()
{$('#rotateImage').attr('src',banner.data.img[banner.count].src).animate({opacity:1},10);$('#rotateLink').attr('href',banner.data.img[banner.count].url);banner.activeControl('skip'+banner.count);banner.count=(banner.count<banner.totalImg)?(banner.count+1):0;$('#pausePlay').bind('click',function(){banner.play();}).html('play');$('#bannerControl > li').bind('click',function(){banner.skip($(this).attr('id').replace('skip',''));});$('#loading').hide();},loadControls:function()
{var li='';$.each(banner.data.img,function(i,val)
{var publicNumber=i+1;var className=(i==0)?'activePage':'adPage';li+='<li id="skip'+i+'" class="'+className+'">'+publicNumber+'</li> ';});html='<ul id="bannerControl">'+'<li id="pausePlay" class="adPage">Pause</li> '+
li+'</ul>';$('#hlNavigation').hide().html(html);$('#pausePlay').bind('click',function(){banner.pause();});$('#bannerControl > li').bind('click',function(){banner.skip($(this).attr('id').replace('skip',''));});$('#hlNavigation').show();},loadImage:function(i,callback)
{var nextImage=new Image();nextImage.src=banner.data.img[i].src;if(nextImage.complete)
{if(callback=='animate')
{banner.animate();}
else
{banner.skipComplete();}}
else
{nextImage.onload=function()
{if(callback=='animate')
{banner.animate();}
else
{banner.skipComplete();}}}},init:function()
{banner.data={'img':[{'src':'headerAds/coopConBanner2.jpg','url':'trackRedirect.php?site=http://www.spec.coop/coopConnections.php&banner=1&date=20110524'},{'src':'headerAds/energyCost2.jpg','url':'trackRedirect.php?site=http://www.togetherwesave.com&banner=2&date=20110524'},{'src':'headerAds/ourEnergyOurFuture.jpg','url':'trackRedirect.php?site=http://www.ourenergy.coop&banner=3&date=20110524'},{'src':'headerAds/goodHabbits.jpg','url':'trackRedirect.php?site=http://www.togetherwesave.com&banner=4&date=20110524'},{'src':'headerAds/billPay4.jpg','url':'trackRedirect.php?site=https://billing.southplainselectric.com/bpp/login.aspx&banner=5&date=20110524'}]}
banner.totalImg=banner.data.img.length-1;if(banner.totalImg!=0)
{banner.loadControls();banner.timeout=setTimeout("banner.loadImage("+banner.count+",'animate')",banner.delay);}
$('#loading').hide();}}
$(document).ready(function(){banner.init();});
