var left_tab_enews = true;
var left_tab_press = false;
var right_tab_calendar = true;
var right_tab_athletics = false;

var tallest_column;
var tallest_size;

// window.onload = function() {
//  //---------------------------------------------------
//  // MATCH COLUMN 1 & 3 HEIGHTS 
//  //---------------------------------------------------
//  if( current_page == "index" ) {
//    InitializeColumns();
//  }
// };

$(document).ready(function() { 	
	//---------------------------------------------------
	// SETUP NAVIGATION ROLLOVERS
	//---------------------------------------------------
	$("img[@name^=nav_]").mouseover(function() {
		this.src = "/images/"+this.name+"-on.gif";
	});
	$("img[@name^=nav_]").mouseout(function () {
		this.src = "/images/"+this.name+"-off.gif";
	});
	
	
	//---------------------------------------------------
	// SETUP ENEWS/CALENDAR BOX TOGGLE FUNCTIONALITY
	//---------------------------------------------------
	
  var $enews = $("#enews-content");
  $enews.find(".enews-nav a").click(function(){
    _this = $(this);
    dest = _this.attr('href');
    $enews.find('.enews-nav a').removeClass('selected');
    _this.addClass('selected');
    $enews.find('.sidebar-list').hide();
    $(dest).show();
    return false;
  });
	
	var $cal = $("#right-tab-container");
  $cal.find(".enews-nav a").click(function(){
    _this = $(this);
    dest = _this.attr('href');
    $cal.find('.enews-nav a').removeClass('selected');
    _this.addClass('selected');
    $cal.find('.sidebar-list').hide();
    $(dest).show();
    return false;
  });

});



function InitializeColumns() {
	//$("#container-col1").css("height", "685px");
	//$("#container-col2").css("height", "685px");
	//$("#container-col3").css("height", "685px");
	
	var h_enews = $("#tab-content-enews").css("height");
	var h_press = $("#tab-content-press").css("height");
	var h_calendar = $("#tab-content-calendar").css("height");
	var h_athletics = $("#tab-content-athletics").css("height");
	
	var heights = new Array(h_enews, h_press, h_calendar, h_athletics);
	
	/*
	var max = 0;
	var max_col = 0;
	
	for( var i=0; i<heights.length; i++ ) {
		if( heights[i] > max ) { 
			max = heights[i];
			if( i == 0 || i == 1 ) {
				max_col = 1;
			}
			else {
				max_col = 3;
			}
		}
	}
	
	var col1_default = $("#container-col1").css("height") - h_enews;
	var col3_default = $("#container-col3").css("height") - h_calendar;
		
	if( max_col == 1 ) {
		$("#container-col1").css("height", (col1_default + max));
		var matcher = $("#container-col1").css("height");
		$("#container-col3").css("height", matcher);
		$("#container-col2").css("height", matcher);
	}
	else if( max_col == 3 ) {
		$("#container-col3").css("height",(col3_default + max));
		var matcher = $("#container-col3").css("height");
		$("#container-col1").css("height",matcher);
		$("#container-col2").css("height",matcher);
	}
	else {
		var col2 = $("#container-col2").css("height") + 175;
		if( col2 > col1_default && col2 > col3_default ) {
			$("#container-col1").css("height", col2);
			$("#container-col3").css("height", col2);
		}
		console.log('\nReset all to column #2 @ '+col2)
	}
	
	console.log('\nMax is: '+max+' in column #'+max_col+'\n');
	console.log('Resetting all to match column #'+max_col+' height of '+matcher+'\n');
	
	*/
}

function ResizeColumns() {
	// rematch all columns to the tallest current 
	
	/*
	var c1_height = $("#container-col1").height();
	var c2_height = $("#container-col2").height();
	var c3_height = $("#container-col3").height();
	
	if( c1_height > c3_height ) { 
		if( tallest_column != 1 ) {
			tallest_column = 1;
			tallest_size = c1_height;
		}
		else if( tallest_column == 1 ) { 
			tallest_size = c1_height; 
		}
		$("#container-col3").height(c1_height); 
		$("#container-col2").height(c1_height);
		$("#container-col1").height(c1_height);
	}
	else if( c3_height > c1_height ) {
		if( tallest_column != 3 ) {
			tallest_column = 3;
			tallest_size = c3_height;
		}
		else if( tallest_column == 3 ) {
			tallest_size = c3_height;
		}
		$("#container-col1").height(c3_height); 
		$("#container-col2").height(c3_height);
		$("#container-col3").height(c1_height);
	}
	
	console.log('ResizeColumns: Column #'+tallest_column+' @ '+tallest_size+', but Column #1 is '+c1_height+'\n');
	*/
}

function ResetColumns( clicked ) {
	// rematch all columns to the original tallest
	
	/*
	if( tallest_column == 1 ) {
		if( clicked == 1 ) tallest_size = $("#container-col1").height();

		$("#container-col2").height(tallest_size);
		$("#container-col3").height(tallest_size);
	}
	else if( tallest_column == 2 ) {
		$("#container-col1").height(tallest_size);
		$("#container-col3").height(tallest_size);
	}
	else if( tallest_column == 3 ) {
		if( clicked == 3 ) tallest_size = $("#container-col3").height();
		
		$("#container-col1").height(tallest_size);
		$("#container-col2").height(tallest_size);
	}
	
	console.log('ResetColumns: Column #'+tallest_column+' @ '+tallest_size+'\n');
	*/
}