// JavaScript Document
var ctr = 0;
var timeShow = 4000;
var timeHide = 300;
var process;

function slideshow(){
	if(ctr != 4){
		ctr++;	
		process = setTimeout('fadeALL()', timeShow);
	}else{
		ctr=0;
		process = setTimeout('fadeALL()', timeShow);
	}
}

function jumpto(page){
	ctr = page;	
	clearTimeout(process);
	fadeALL();
}

function fadeALL(){	
	headDesc(0)		
	headImage(0)
	headText(0)	
	process = setTimeout('showALL()', timeHide)
}

function showALL(){
	switchCSS(ctr + 1)
	headText(1)
	headImage(1)
	headDesc(1)		
	slideshow()
}

function headText(flag){
	if(!flag){
		$("#head_text").fadeOut("fast", function(){
			$("#head_text").html(oTitle[ctr]);
			$("#head_link").attr("href", oLink[ctr]);
		});
	}else{
		$("#head_text").fadeIn("fast");
	}
}
function headImage(flag){
	if(!flag)
		$("#head_image").fadeOut("fast", function(){
			$("#head_image").attr({ src: oImage[ctr].src });										  
		});
	else
		$("#head_image").fadeIn("fast");
}
function headDesc(flag){
	if(!flag)
		$("#head_desc").fadeOut("fast", function(){
			$("#head_desc").html(oDesc[ctr])
		});
	else
		$("#head_desc").fadeIn("fast");
}	
function switchCSS(selectIndex){
	for(i=1; i <6; i++){//reset all class no nothing
		$("#img_"+i).removeClass("active");
	}
	$("#img_"+selectIndex).addClass("active");
}