  /*
 * Copyright (c) 2008 Paulo Rodrigues (jp7.com.br)
 * Colaborattor: Joćo Pedro Barbosa  
 * Version: 1.0.3
 * Release: 2008-06-03 
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software.
 */ 

function autoLoadBox(numberF) {	    
	numCount = numberF;
	$(".display").hide();    	
	$("#display"+numberF).fadeIn("slow");
	$(".control").removeClass("pointer_selected");
	$("#control"+numberF).addClass("pointer_selected");
	numberF++;
	if(numberF==$(".control").length)numberF=1;
	setTimeout('autoLoadBox('+numberF+')',4000);	    		
}
	 	 
  $(document).ready(function(){
  
	/* 
	*  Start, hide all <div class="display"> and do fadeIn() on first 
	*  Add class to active/selected link  	  		
	*/
	$(".display").hide();
	$("#display1").fadeIn("slow");
	$("#control1").addClass("pointer_selected");	
	numCount = 1;
	
	/* Function to rotate automatic */			
	autoLoadBox(1)	
   
   	/* 
	*  Control the click links    
	*/         
    for(var i=1;i<=$(".control").length;i++){
		$("#control"+i).click(function () {
			numCount = 1;
	    	$(".display").hide();    	
			$("#display"+numCount).fadeIn("slow");
			$(".control").removeClass("pointer_selected");
			$(this).addClass("pointer_selected");
	    });
    }
    
    /* next and previous buttons. 
	*  They hide all divs and apply fadeIn() in de active (next or previous) div 
	*/
    $("#next").click(function () {
		$("#display"+numCount).hide();
		numCount++;
		$("#display"+numCount).fadeIn("slow");
		$("#control"+(numCount-1)).removeClass("pointer_start");
		$("#control"+(numCount-1)).removeClass("pointer_selected");	
		$("#control"+numCount).addClass("pointer_selected");			
	});
	
    $("#previous").click(function () {
		$("#display"+numCount).hide();
		numCount--;
		$("#display"+numCount).fadeIn("slow");
		$("#control"+(numCount+1)).removeClass("pointer_start");
		$("#control"+(numCount+1)).removeClass("pointer_selected");	
		$("#control"+numCount).addClass("pointer_selected");			
	});	

  });
