var banner_tabs=[];
var current_tab=-1;
function get_id(id){    var obj = null;if(document.getElementById)obj = document.getElementById(id);
    else if(document.all)obj = document.all[id];
    return obj; }

function initialize_tabs(tabs_holder_id){
	if(!document.getElementById(tabs_holder_id)){
		setTimeout(	"initialize_tabs('"+tabs_holder_id+"')",1000);
		return;
	}
	var tab_elm=get_id(tabs_holder_id).getElementsByTagName("*");
	var preloaded=[];
	
	for(i=0;i<tab_elm.length;i++){
		if(tab_elm[i].id && tab_elm[i].id=="prev_button"){
			tab_elm[i].style.cursor='pointer';
			tab_elm[i].onclick=function(){
				display_tabs(-1);
			}
		}
		else if(tab_elm[i].id && tab_elm[i].id=="next_button"){
			tab_elm[i].style.cursor='pointer';
			tab_elm[i].onclick=function(){
				display_tabs(1);
			}
		}
		else if(tab_elm[i].id && tab_elm[i].id.indexOf("_tab")>-1){
			banner_tabs.push(tab_elm[i].id);
			tab_elm[i].style.cursor='pointer';
			tab_elm[i].onclick=function(){
				display_tabs(this.id);				
			}
		}
		if(get_id(tab_elm[i].id+"_background")){
			var tab_options=get_id(tab_elm[i].id+"_background").value.split(":");
			preloaded.push(new Image(5,5));
			preloaded[(preloaded.length-1)].src=tab_options[1];
		}		
	}
get_id("banner_actual_text").style.height="248px";
get_id("banner_tabs").style.height="50px";
get_id("banner_tabs").style.cssFloat='left';
get_id("banner_content").style.height="298px";
display_tabs(1);
}
var tabs_timer;
function display_tabs(tab_id){
	clearInterval(tabs_timer);
	tabs_timer=setInterval("display_tabs(1)",7000);
	if(!tab_id)tab_id=0;
	for(tb=0;tb<banner_tabs.length;tb++){
		if(banner_tabs[tb]==tab_id && document.getElementById(banner_tabs[tb]) ){
			get_id(banner_tabs[tb]).style.borderBottom="#444444 1px solid";
			get_id(banner_tabs[tb]).style.borderRight="#444444 1px solid";
		}
		else if( document.getElementById(banner_tabs[tb]) ){
			get_id(banner_tabs[tb]).style.borderBottom="none";
			get_id(banner_tabs[tb]).style.borderRight="none";			

		}
	}
	if(parseInt(tab_id)!=tab_id){		
		if(get_id(tab_id+"_content")){
			get_id("banner_actual_text").innerHTML=get_id(tab_id+"_content").innerHTML;			
		}
		for(i=0;i<banner_tabs.length;i++)if(banner_tabs[i]==tab_id)current_tab=i;
	}
	else{
		current_tab=current_tab+tab_id;
		if(current_tab<0)current_tab=(banner_tabs.length-1);
		else if(current_tab>=banner_tabs.length)current_tab=0;
		else{	
		}
		display_tabs(banner_tabs[current_tab]);
	}
	if(get_id(tab_id+"_background")){
		var tab_options=get_id(tab_id+"_background").value.split(":");
		get_id("banner_outer").style.margin="0";
		get_id("banner_inner").style.margin="0";
		get_id("banner_content").style.margin="0";
		get_id("banner_outer").style.padding="0";
		get_id("banner_inner").style.padding="0";
		get_id("banner_content").style.padding="0";		
		get_id("banner_outer").style.background="url("+tab_options[2]+") right repeat-x";
		get_id("banner_inner").style.background="url("+tab_options[0]+") left no-repeat";			
		get_id("banner_content").style.background="url("+tab_options[1]+") right no-repeat";
		get_id("banner_actual_text").style.marginLeft=tab_options[3]+"px";
		get_id("banner_actual_text").style.marginRight=parseInt(tab_options[4])+"px";
		get_id("banner_actual_text").style.color="#"+tab_options[5];
	}
	return ;
}
document.onload=function(){	initialize_tabs("tabbed_icons"); }
window.onload=function(){ initialize_tabs("tabbed_icons"); }
initialize_tabs("tabbed_icons");
