//<![CDATA[


function FWRandom()
{
	fwRnd.seed = (fwRnd.seed*fwRnd.a+fwRnd.c)%fwRnd.m;
	return fwRnd.seed/fwRnd.m;
}
var fwRnd=new Object;
fwRnd.m=714025;fwRnd.a=4096;fwRnd.c=150889;
fwRnd.seed = (new Date()).getTime()%fwRnd.m;

function FWRandomInt(max,last)
{
	if (max < 2) return max; 
	var result = Math.floor(FWRandom()*max-1)+1;
	while(last && result == last)
		result = Math.floor(FWRandom()*max-1)+1;
	return result;
}
var fwRandomImage=new Object;
var rnd=FWRandomInt(16);
if (rnd==0)
	fwRandomImage.i0="images/EFM_hdr1.jpg";
if (rnd==1)
	fwRandomImage.i0="images/EFM_hdr2.jpg";
if (rnd==2)
	fwRandomImage.i0="images/EFM_hdr3.jpg";
if (rnd==3)
	fwRandomImage.i0="images/EFM_hdr4.jpg";
if (rnd==4)
	fwRandomImage.i0="images/EFM_hdr5.jpg";
if (rnd==5)
	fwRandomImage.i0="images/EFM_hdr6.jpg";
if (rnd==6)
	fwRandomImage.i0="images/EFM_hdr7.jpg";
if (rnd==7)
	fwRandomImage.i0="images/EFM_hdr8.jpg";
if (rnd==8)
	fwRandomImage.i0="images/EFM_hdr9.jpg";
if (rnd==9)
	fwRandomImage.i0="images/EFM_hdr10.jpg";
if (rnd==10)
	fwRandomImage.i0="images/EFM_hdr11.jpg";
if (rnd==11)
	fwRandomImage.i0="images/EFM_hdr12.jpg";
if (rnd==12)
	fwRandomImage.i0="images/EFM_hdr13.jpg";
if (rnd==13)
	fwRandomImage.i0="images/EFM_hdr14.jpg";
if (rnd==14)
	fwRandomImage.i0="images/EFM_hdr15.jpg";
if (rnd==15)
	fwRandomImage.i0="images/EFM_hdr16.jpg";

document.observe('dom:loaded', function(evt){
	// first load a random image in the header
	html = '<img src="http://elitefleet.com.au/wp-content/themes/elitefleet_sb/' + fwRandomImage.i0 + '" alt="EFM Header Images" >'; 
	$('EFMheaderimages').update(html);

	start_slideshow(1, 2, 10);	
	
	ShowAccordian();

});

function ShowAccordian () {
	var box = $('hentry').up();
	if('h2' == 'img'){
		var heads = box.select('#hentry > p > img');
	}else{
		var heads = box.select('#hentry > h2');
	}
	if('h2' == 'img'){
		heads = heads.collect(function(elm){ return elm.up('p'); });
	}
	if(heads.size() < 1) heads = box.select('#hentry > h2');
	var bods = box.select('#hentry > div');
	bods = bods.findAll(function(elm){return heads.include(elm) == false;});
	var tog = function(){
		var params = {duration:0.2,queue:'end'};
		var me = this;
		bods.findAll(function(elm){return elm.visible() && elm.previous('h2') !== me}).each(function(elm){Effect.BlindUp(elm,params)});
		if (this.next('div') && !this.next('div').visible()) {
			Effect.BlindDown(this.next('div'),params);
		}else{
			if(this.up().next('div') && ! this.up().next('div').visible()){
				Effect.BlindDown(this.up().next('div'),params);
			}
		}
	};
	bods.invoke('hide');
	bods.first().show();
	heads.invoke('observe','click',tog);
	heads.invoke('setStyle',{cursor:'pointer'});
}


function FWFindLayer(lay)
{
	if (lay)
	{
		if (document.layers) 
			return document[lay];
		else if (document.getElementById)
			return document.getElementById(lay).style;
		else if (document.all) 
			return document.all[lay].style;
	}
	return null;
}


function FWShowHideLayerFade(lay, vis, ch)
{
	if (ch && lay != "") 
	{
		vis = (vis) ? "visible" : "hidden";
		var obj = FWFindLayer(lay);
		if (obj && obj.visibility != vis) 
		{
			if(vis == "visible")
			{
				obj.visibility = vis;
				new Effect.Appear(lay, {duration:2, delay:null});
			}
			else
			{
				new Effect.Fade(lay, {duration:2, delay:null, afterFinish:function(){obj.visibility = vis}});
			}
		} 
	}
}


var frame = 1;
function start_slideshow(start_frame, end_frame, delay) {
    
    html = '<img src="http://elitefleet.com.au/wp-content/themes/elitefleet_sb/images/quotes/quote3.png" border=0 width=526 height=91 alt="Customer Quotes" />'; 
    $('quote_rotator2').update(html);


	
	new PeriodicalExecuter(function(pe) {
		var qr = 'quote_rotator' + frame;
	    var quote_div = $(qr);
	    new Effect.Fade(quote_div,
	    		{ queue: {scope: 'fadeovers', position: 'end'}});

	   if (frame == end_frame) { frame = start_frame; } else { frame++; }
	   qr = 'quote_rotator' + frame; 
	   quote_div = $(qr);
	    new Effect.Appear(quote_div,
	    		{ queue: {scope: 'fadeovers', position: 'end', delay: 3}});
	    
    }, delay);
}

//]]>

