var clock = new Clock();
var index = 0;
var maxSeconds = 5;
var banners = new Array();
var indexes = new Array();
var descs = new Array();

/*function initBanner(){
	banners = document.getElementById("bannerHtml").getElementsByTagName("a");
	renderIndex();
	indexes = document.getElementById("bannerIndex").getElementsByTagName("a");
	descs = document.getElementById("bannerDescription").getElementsByTagName("div");
	changeBanner(0);
	timer();
}

function changeBanner(i){
	index = i==banners.length ? 0 : i;
	for (var j=0;j<banners.length;j++){
		banners[j].style.display = j==index ? "block" : "none";
		indexes[j].style.borderBottomColor = j==index ? "#fff" : "#000";
		descs[j].style.display = j==index ? "block" : "none";
	}
	
	clock.reset();
}

function Clock(){
	this.clock = 0;
	this.add = function(){
		this.clock++;
		if (this.clock == maxSeconds){
			changeBanner(index+1);
		}
	};
	this.reset = function(){
		this.clock = 0;
	};
}

function timer(){
	clock.add();
	setTimeout("timer()",1000);
} 

function renderIndex(){
	var html = "";
	for (var i=0;i<banners.length;i++)
		html += "<a href='javascript:changeBanner("+i+")'>"+(i+1)+"</a>";
	document.getElementById("bannerIndex").innerHTML = html;
}*/

var clock = new Clock();
var index = 0;
var maxSeconds = 5;
var banners = new Array();
var indexes = new Array();
var descs = new Array();

function initBanner(){
	banners = $('#bannerSlide div.lof-main-outer ul.lof-main-wapper li');
	descs = $('#bannerSlide div.lof-navigator-outer ul.lof-navigator li');
	$.each(descs,function(i, it){
		$(it).click(function(){
			changeBanner(i);
		});
	});
	
	changeBanner(0);
	timer();
}

function changeBanner(i){
	index = i==banners.length ? 0 : i;

	$(descs).removeClass('active');
	$(descs).eq(index).addClass('active');
	$(banners).stop().animate({opacity: 0},1000,function(){$(this).css('z-index','1');});
	$(banners).eq(index).stop().animate({opacity: 1},1000,function(){$(this).css('z-index','5');});
	
	clock.reset();
}

function Clock(){
	this.clock = 0;
	this.add = function(){
		this.clock++;
		if (this.clock == maxSeconds){
			changeBanner(index+1);
		}
	};
	this.reset = function(){
		this.clock = 0;
	};
}

function timer(){
	clock.add();
	setTimeout("timer()",1000);
} 
