// JavaScript Document

$(document).ready(function() {
	extendLeft();
 });

/* Adjust left sidebar height to match center column height */
function extendLeft() {
	var bot_offset = 150;
	var min_height = 500;
	var sh = $('#squeeze').height();
	
	// Adjust sidebars
	if($('#sl_menu').length != 0) {
		eh = $('#sl_menu').height();
		$('#sl_menu').height(Math.max((sh + bot_offset),min_height));
	}
	
	if($('#sidebar-left-content').length != 0) {
		eh = $('#sidebar-left-content').height();
		$('#sidebar-left-content').height(Math.max((sh + bot_offset),min_height));
	}
	
	// Adjust menu wrap for correct height to show the white-blue gradient
	if($('#sidebar-left .menuwrap').length !=0) {
		if($('#sidebar-left .submenu#anchors').length != 0) {
			var mn = $('#sidebar-left .submenu#anchors').height();
			$('#sidebar-left .menuwrap').height(mn+75);
		} else if($('#sidebar-left .submenu#pagesl').length != 0) {
			var mn = $('#sidebar-left .submenu#pagesl').height();
			$('#sidebar-left .menuwrap').height(mn+75);
		}
	}
	
}

function startIdleTimeout() {
	
	if($('#dialog').length != 0) {
		$('#dialog').dialog({
			autoOpen: false,
			width: 600,
			buttons: {
				"Ok": function() { 
					$(this).dialog("close"); 
				}, 
				"Cancel": function() { 
					$(this).dialog("close"); 
				} 
			}
		});
	}

	$(document).idleTimeout({
		// 1 min = 60000
		inactivity: (60000*7), /* How long before showing notice? */
		noconfirm: (60000*1), /* How long to wait for user to respond before logging out*/
		sessionAlive: (60000*2), /* How often to hit the alive_url */
		alive_url: 'session_alive.php',
		redirect_url: 'logout.php?autologout=1'
	});
	
}

