$(function()
{
	if($('#banners').length==1){
		playBanner();
	}
});

var banner_count = 5;
var banner_index = 0;
var banner_timer = null;
var banner_timeout = 5000;

function prevBanner(){
	banner_index = banner_index - 1;
	if(banner_index<=0){
		banner_index = banner_count;
	}
	showBanner(banner_index,-1);
}

function nextBanner(){
	banner_index = banner_index + 1;
	if(banner_index>banner_count){
		banner_index = 1;
	}
	showBanner(banner_index,1);
}

function playBanner(){
	banner_index = banner_index + 1;
	if(banner_index>banner_count){
		banner_index = 1;
	}
	showBanner();
}

function showBanner(index,dir){
	var old_index = banner_index;
	if(index){
		banner_index = index;
		banner_timer = clearTimeout(banner_timer);
	}
	if(!index){
		banner_timer = setTimeout(playBanner,banner_timeout);
	}
	if(!dir){
		var dir = (old_index>banner_index) ? -1 : 1;
	}
	$('.banner:visible').css({'z-index':1});
	$('.banner:visible').animate({left:(-967*dir)},500);
	$('#banner'+banner_index).css({'left':(967*dir),'z-index':2,'width':(967*dir)}).show().animate({left:0},500,function(){
		$('.banner:not(#banner'+banner_index+'):visible').hide().css({'z-index':1});
	});
	$('#tabs .tab:not(:eq('+(banner_index-1)+'))').removeClass('current');
	$('#tabs .tab:eq('+(banner_index-1)+')').hide().addClass('current').fadeIn(500);
}

function toggle_step(step) {
	for(i=1; i<=3; i++) {
		if(i==step) {
			document.getElementById("quote_step" + i).style.display = "block";
			document.getElementById("img_quote_step").src = "media/quote_step" + i + ".gif";
		}
		else {
			document.getElementById("quote_step" + i).style.display = "none";
		}
	}
}

var tempImg = new Array();
for(var x=1; x<=5; x++) {
	tempImg[x] = new Image();
	tempImg[x].src = "media/banner" + x + ".jpg";
}

