// JavaScript Document
$(document).ready( function() {
	
	var numOverviews = 3; //Number of overview buttons
	var btnHeight = 110; //Button height for controling background position
	
	
	$('#event-highlights .highlights_buttons a').hover( function(){
		var index = getIndex($(this).attr('id'));
		var yposi = (index-1)*btnHeight*(-1);
		$(this).css('background-position', '-181px '+yposi+'px');
	}, function(){
		index = getIndex($(this).attr('id'));
		if($('#overview'+index+'_cnt').css('display') != 'block') {
			var yposi = (index-1)*btnHeight*(-1);
			$(this).css('background-position', '0 '+yposi+'px');
		}
	});
	
	$('#event-highlights .highlights_buttons a').click( function(){
		return false;
	});
	
	$('#event-highlights .highlights_buttons a').click( function(){
		var index = getIndex($(this).attr('id'));
		$('#event-highlights .each_content').hide();
		for(var i=0; i<numOverviews; i++) {
			$('#overview'+(i+1)+'_btn').css('background-position', '0 '+i*btnHeight*(-1)+'px');	
		}
		$('#overview'+index+'_cnt').show();
		var yposi = (index-1)*btnHeight*(-1);
		$('#overview'+index+'_btn').css('background-position', '-181px '+yposi+'px');
	});
	
	
		
});

function getIndex(id) {
	var index = id.substr(0, id.length-4);
	index = index.substr(index.length-(index.length-8));
	//console.log(index);
	return index;
}
