window.onload=focusForm;
function focusForm (){ 
   if (document.getElementById('LastName')){
     document.getElementById('LastName').focus(); 
   } 
   if (document.getElementById('term')){
      document.getElementById('term').focus();
   }
}


function godept(myform)
{
        var box = myform.deptid;
        var destination = box.options[box.selectedIndex].value;
        if (destination && destination != 0) {
           location.href="directory.php?deptid=" + destination;
        }
} 

$(function() {

	var interval = 10000;  // interval for rotation
	var num      = 0;     // the current banner
	var timer    = null;  // timer for rotation
	var setup;
	var num_of_banners = $('#banners img').size();
	
	// show the container
	$('#banner_nav_container').removeClass('hidden');
	
	// hide everything first
	$('#banners img').hide();
	$('#banner_text1').hide();
	$('#banner_text2').hide();
	$('#banner_text3').hide();
	$('#banner_nav').hide();
	
	// show the banner container
	$('#banners').css('visibility', 'visible');
	$('#banners').css('display', 'block');
	$('#banner_text_container').css('visibility', 'visible');
	$('#banner_text_container').css('display', 'block');
	
	// just show the first banner
	$('#banners').show();
	$('#banner0').show();
	$('#banner_text_container').show();
	$('div#banner_text0').show();
	$('#banner_nav_box0').css('background', 'url(/images/box.gif) 0 -10px');
	
	// the cursor of the nav
	$('#banner_nav div').hover(function() {
		$(this).css('cursor', 'pointer');
	});
	
	// only start the rotation when the last photo is loaded
	//$('#banner' + (num_of_banners - 1)).load(function() {
		$('#banner_nav').show();
		loadBanner(num);
	//});
	

	// handler for clicking the nav
	$('#banner_nav div').click(function() {
	
		var id_string = ($(this).attr('id'));
		var id = id_string.substr(-1);
	
		$('#banner' + num).fadeOut('slow');
		$('#banner_text' + num).fadeOut('slow');
		$('#banner_nav_box' + num).css('background', 'url(/images/box.gif) 0 0');
		
		num = parseInt(id);
		
		
		$('#banner' + num).fadeIn('slow');
		$('#banner_text' + num).fadeIn('slow');
		$('#banner_nav_box' + num).css('background', 'url(/images/box.gif) 0 -10px');
		
		clearInterval(timer);
		timer = null;
		
		loadBanner(num);
	});
	
	// the rotating function
	function loadBanner(current) {
		timer = setInterval(function() {
			next = (current + 1) % num_of_banners;
		
			$('#banner' + current).fadeOut('slow');
			$('#banner_text' + current).fadeOut('slow');
			$('#banner_nav_box' + current).css('background', 'url(/images/box.gif) 0 0');
			
			$('#banner' + next).fadeIn('slow');
			$('#banner_text' + next).fadeIn('slow');
			$('#banner_nav_box' + next).css('background', 'url(/images/box.gif) 0 -10px');
			
			num = next;
			current = next;
		}, interval);
	}
    
});



