/*$(function(){
	$('.tab').mouseover(function(){
		var tabNr = parseInt($(this).attr('nr'));
		clearInterval(swapAutoLoad);
		check(tabNr);
	});
		
	var swapAutoLoad = setInterval(check,3000);
	
	var active = 1;
	var nrtabs = $("div.tab").length;
	function check(start){
		if(start) {active=start;}
		if(active>nrtabs) active=1;
		var el='.tab'+active;
		var newBg = $(el).attr('newbg');
		var textBox = $(el).attr('textbox');
		
		$('.tab').removeClass('home_left_on');
		$('.tab').removeClass('home_left_off');
		$('.tab').addClass('home_left_off');
		$(el).removeClass('home_left_off');
		$(el).addClass('home_left_on');
		$('#top_home_panel_img').css({'background':"url('"+newBg+"')"});
		$('#top_home_panel_info').html(textBox);
		
		$('.dots .dot.active').removeClass('active');
		$('.dots .dot'+active).addClass('active');
		
		active = (active+1);
	};
});*/

$(function(){
	$('.tab').mouseover(function(){
		var tabNr = parseInt($(this).attr('nr'));
		var next = tabNr;
		clearInterval(swapAutoLoad);
		$('.tab').removeClass('home_left_on');
		$('.tab').removeClass('home_left_off');
		$('.tab').addClass('home_left_off');
		
		$('.tab'+next).addClass('home_left_on');
		$('.tab'+next).removeClass('home_left_off');
		
		var el = $('.tab'+next);
		
		var newBg = $(el).attr('newbg');
		var textBox = $(el).attr('textbox');
		var link = $(el).attr('link');
		$('#top_home_panel_img').css({'background':"url('"+newBg+"')"});
		$('#top_home_panel_info').html(textBox);
		$('#top_home_panel_info').attr('link',link);
		
		$('.dots .dot.active').removeClass('active');
		$('.dots .dot'+next).addClass('active');
		
		//setTimeout(swapAutoLoad=setInterval(check,3000),2000);
	});
		
	//var swapAutoLoad = setInterval(check(10),3000);
	var swapAutoLoad = setInterval(check,7000);
	
	function check(){
		var nrTabs = $("div.tab").length;
		var active = parseInt($("div.tab.home_left_on").attr('nr'));
		var next = (active+1);
		 
		$('.tab').removeClass('home_left_on');
		$('.tab').removeClass('home_left_off');
		$('.tab').addClass('home_left_off');
		
		//return to pos 1
		if(next>nrTabs){
			$('.tab1').addClass('home_left_on');
			$('.tab1').removeClass('home_left_off');
			var el = $('.tab1');
			next=1;
		}
		//continue
		else{
			$('.tab'+next).addClass('home_left_on');
			$('.tab'+next).removeClass('home_left_off');
			var el = $('.tab'+next);
		}
		
		var newBg = $(el).attr('newbg');
		var textBox = $(el).attr('textbox');
		var link = $(el).attr('link');
		$('#top_home_panel_img').css({'background':"url('"+newBg+"')"});
		$('#top_home_panel_info').html(textBox);
		$('#top_home_panel_info').attr('link',link);
		$('.dots .dot.active').removeClass('active');
		$('.dots .dot'+next).addClass('active');
	};
	
	$('#top_home_panel_info').click(function(){
		var link = $(this).attr('link');
		document.location.href=link;
	});
});
