$(document).ready(function(){
	
	
	
	//$("#testscreen").css("opacity",.15);
	//$("#testscreen").css("opacity",0);
	
	//$(".adfloats").css("opacity",0);
	$(".adfloats div").css("opacity",0);
	
	$(".adfloats").css("top","0px");
	//$(".adfloats").animate({opacity:1},{queue:false, duration:2000});  //ie 7 hates this.. don't think i needed anyway
	
	$("#featflip").append("<div class='dotholder'/>");
	$(".adfloats div").each(function(){
		
		//$(".dotholder").append("<img src='images_11/features/dotblank.png'/>");
		
	});
	
	//alert($("#featflip .dotholder").parent().height());
	
	$("#featflip .dotholder").css("top",($("#featflip .dotholder").parent().height()-20)+"px");
	
	
	
myslides=$(".adfloats div").length-1;
//alert (myslides);
if (myslides>=0){
	 for (x=0;x<=myslides;x++){
		 
		
			 $("#featflip .dotholder").prepend("<img src='images_11/features/dotblank.png'/>");
		
		 
		//$(".adfloats div").eq(x).css("opacity",0);
		 
	 } //make all but the last in line opacity 0
	
	setTimeout(startbanners,1000);
}

function rotatebanners(donum){
	$("#featflip .dotholder img").attr("src","images_11/features/dotblank.png");
	$("#featflip .dotholder img").eq(donum).attr("src","images_11/features/dotsolid.png");
	
	
	if(donum==myslides){
		//alert("i got in zero");
		nextslide=0;
	} else {
		nextslide=donum+1;
	}
	if(donum==0){
		lastslide=myslides;
	} else {
		lastslide=donum-1;
	}
	if(nextslide==0){
		//alert("next should be zero");
	}
	oldslide=donum;
	//alert("animating slide"+donum+ " and fading out"+lastslide);
	
	$(".adfloats div").each(function(){
	
	if ($(this).index(".adfloats div")!=donum&&$(this).css("z-index")>2){
		$(this).css("z-index",$(this).css("z-index")-1);
	}
	});
	
	
	$(".adfloats div").eq(donum).css("z-index",20);
	//alert ("sending "+donum+" to 20");
$(".adfloats div").eq(donum).animate({opacity:1},{queue:false, duration:3000,complete:function(){
																								 rotatebannerspause(nextslide,oldslide)
																								 }});
$(".adfloats div").eq(lastslide).animate({opacity:0},{queue:false, duration:2000});
}


function rotatebannerspause(thisnumber,oldnumber){
	//alert("this number made it to function"+thisnumber);
	$(".adfloats div").eq(thisnumber).css("z-index",10);
	//alert ("sending "+thisnumber+" to 10");
	thischecker=thisnumber;
	oldchecker=oldnumber;
	$(".adfloats div").each(function(){
		if($(this).index(".adfloats div")!=thischecker&&$(this).index(".adfloats div")!=oldchecker){
			$(this).css("z-index",0);
			//alert ("sending "+$(this).index(".adfloats div")+" to 10");
		}
	});
	
	
	
	$(".adfloats div").eq(thisnumber).animate({opacity:0},{queue:false, duration:3000,complete:function(){
																								 rotatebanners(thisnumber)
																								 }});
}

function startbanners(){
	rotatebanners(0);
}

						
						
				
				
						   });





