$(document).ready(function(){	
	
	/* HEADER MOODBAR STARTS */
	var total_img_count = $('.headerimg').attr("rel-total-count");
	var current_count = 1;
	var old_count = 0;
	var firstTime = true;
	
	switchMoodbar();
	
	function switchMoodbar() {
		if(current_count != total_img_count){
			if(!firstTime) {
				current_count = current_count + 1;
			} else {
				firstTime = false;
			}
		} 
		else {
			current_count = 1;
		}
		
		if(current_count == 1) {
			old_count = total_img_count;
		} 
		else {
			old_count = current_count - 1;
		}
		
		$('#headerimg_'+old_count).fadeOut(1000);
		$('#headerimg_'+current_count).fadeIn(1000, function(){
			window.setTimeout(function(){switchMoodbar();}, 5000);
		});
		
		
		/*$('#headerimg_'+old_count).fadeOut(500, function(){
			$('#headerimg_'+current_count).fadeIn(500, function(){
				window.setTimeout(function(){switchMoodbar();}, 5000);
			});
		});*/
	}
	/* HEADER MOODBAR ENDS */
	
});

