var t; // timer
var itemObj; // the current div to fade
var counter; // counter - counts up to the maxLength, an int set by the php base on the length of the array of pictures used on that page
var str; 
var maxLength;
var rand_no;
var firefox;
var mac;
var bNum;
// called from php
function setUp(_someLength){
	
firefox = $.browser.firefox; 
mac = $.browser.mac;
bNum = $.browser.version.number()
	
maxLength = _someLength; // set the number of divs 

rand_no = Math.ceil(maxLength * Math.random());



}


$(document).ready(function() {
	
	
	for(var i=1;i< maxLength+1;i++){
		
		
		str = i.toString();
		// attaches classes from the syles.css file using jquerry
		$('#item'+str).addClass('hidden'); // hides divs at first
		$('#item'+str).addClass('absolute'); // possition divs absolutly
	
	}
	
	$('#item' + rand_no).show(); // jquerry effect 

	
	t=setTimeout("startFade()",10000); // begins the fading sequence by calling the startFade function

});

function startFade(){

	
	counter = rand_no; // sets the counter
	str = counter.toString(); // casts the conter as a string
	itemObj = String('#item'+str); // creates the string to id the div
	doFade(); // calls the fade function
};


function doFade(){
	
	//alert(firefox);
	//	alert(mac);
	
	if(firefox == true && bNum > 1.5 && bNum < 3 && mac == true){
			
			/*
			$(itemObj).fadeOut('slow');
	
			str = counter.toString();
			itemObj = '#item'+str;
			if(counter == maxLength){
				counter = 1
			} else {
			counter = counter + 1;
			
			}
			str = counter.toString();
			itemObj = '#item'+str;
			
			$(itemObj).fadeIn('slow');
			t=setTimeout("doFade()",1000);*/
			
		} else {
			
			$(itemObj).fadeOut('def');
		
			str = counter.toString();
			itemObj = '#item'+str;
			if(counter == maxLength){
				counter = 1;
			} else {
			counter = counter + 1;
			
			}
			str = counter.toString();
			itemObj = '#item'+str;
			
			$(itemObj).fadeIn('def');
			t=setTimeout("doFade()",10000);
			
			
	
	}
	
	
	
}