$(document).ready(function(){

	 
 	 var currentbanner=-1;
	 /* var banners="#9b8fd7~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background2/top02.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background2/middle02.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background2/bottom02.jpg"+
	              "@#142a04~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background1/top01.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background1/middle01.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background1/bottom01.jpg" +
	              "@#83bcff~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background11/top11.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background11/middle11.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background11/bottom11.jpg"+
	              "@#cba368~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background10/top10.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background10/middle10.jpg~/adta2010/_resources/en-US/_images/defaultbackground/newbackgrounds/background10/bottom10.jpg"; 
	  */
	 var banners=document.getElementById('ctl00_hidBanners').value;
	 var bannerslen=banners.split('@').length
	 
	 var bgcolorbody,topimage,imgbanner,bottomimg,slogan;
	 
	 
	 ChangeBackGround=function(){
	  //$('#content').slideToggle("slow")
	  
	  if(currentbanner == -1)
	  {
	   currentbanner=1;
	   
	      if(bannerslen >1 )
	      {
	          if(currentbanner==bannerslen) currentbanner=0
    	  
	          if(currentbanner >4)
	          {
	  	          timer1=window.setTimeout(ChangeBackGround,5000)
	          }
	          else
	          {
	            timer1=window.setTimeout(ChangeBackGround,10000)
	          }
	      }
	      
	  }
	  else
	  {
	      if(bannerslen >1 )
	      {
	          SetCurrentBanner(currentbanner)
	      
	          currentbanner++
	          if(currentbanner==bannerslen) currentbanner=0
        	  
	          if(currentbanner >4)
	          {
	  	          timer1=window.setTimeout(ChangeBackGround,5000)
	          }
	          else
	          {
	            timer1=window.setTimeout(ChangeBackGround,10000)
	          }
	      }
	      
	  }
	  
	  
	 };
	SetCurrentBanner=function(){
	var data = banners.split('@')
	var newbannerSettings=data[currentbanner].split('~')
	
	bgcolorbody=newbannerSettings[0]
	topimage=newbannerSettings[1]
	imgbanner=newbannerSettings[2]
	bottomimg=newbannerSettings[3]
	//slogan=newbannerSettings[4]
	
	$("body").css("background-color",bgcolorbody)
	$(".bg-top").fadeIn("slow")
	$(".bg-top").css("background", "url("+ topimage+")");
	$(".bg-top").css("background-position", "top");
	$(".imgHomeBanner").attr("src",imgbanner);
	$(".bg-bottom").fadeIn("slow")
	$(".bg-bottom").css("background", "url("+bottomimg+")");
	$(".bg-bottom").css("background-position", "top");
//	if(slogan.length>0)
//	{
//	  document.getElementById('sloganContent').innerHTML=slogan;
//	  if(currentbanner <=1)
//	  {
//	  $("#slogan").addClass("black");
//	  }
//	  else {$("#slogan").removeClass("black");}
//	  
//	  $("#slogan").show();
//	}
//	else{$("#slogan").hide();}
	
	
	};
	
	function updateBackgrounds(bgcolorbody1,topimage1,imgbanner1,bottomimg1) 
	{
	//alert(topimage1);
	  //Update the CSS of the target divs
	  $("body").css("background-color",bgcolorbody1);
	  $("#bg-top").css("background", "url("+ topimage1 +")");
	  $("#bg-top").css("background-position", "top");
	  $("#imgHomeBanner").attr("src",imgbanner1);
	  $("#bg-bottom").css("background", "url("+bottomimg1+")");
	  $("#bg-bottom").css("background-position", "top");
	  $("#bg-bottom").css("bottom","0");

    }
	
	$(window).resize(
		function() {
				//updateBackgrounds(bgcolorbody,topimage,imgbanner,bottomimg);
			
		}
		)
	
	 ChangeBackGround();
	 
});

    
