
jQuery.tabs_init = function(){
	

	$.timertab();
}	
jQuery.timertab = function(){

	$("#tabs").everyTime(7000, function() {
			
			$.corusel();
			
	});
	
}

jQuery.tabs = function(page, first) {	
	
	var tab = $('#' + page);
	
 	$.cookie('tab', page);
	
	tab.parent().siblings().removeClass('selected').end().addClass('selected');
	
	if(first)
	{
	
		$('#' + page + '-tab').css({'display' : 'block'});
	
	} else {
	
		$('#' + page + '-tab').fadeIn();
	
	}
	
	$('.tab', $('#promo')).not($('#' + page + '-tab')).css('display','none');
	
	$("#promo").removeClass().addClass(page + '-promo');	  		
	
}

jQuery.corusel = function(){	
	
	var content_height = $('#home-content').height();
	
	var current_id = $("#tabs li[class = 'selected'] a").attr("id");
	var next_id = $('#' + current_id).parent().next().next().children().attr("id");
	
	$("#tabs li").siblings().removeClass('selected');
	

	if($('#' + current_id).parent().next().hasClass('space'))
	{		
		$.tabs(next_id);
		
	}else{
		
		$.tabs($("#tabs li a").attr("id"));
		
	}
	
	$('#home-content').height(content_height);
		
}
