var is_ie = false;
var htmlname,pathname;
$(document).ready(function(){
	if ( $.browser.msie ) {
		if ($.browser.version<8) {
			is_ie = true;	
		}
	}
	
	htmlname = returnDocument();
	pathname = window.location.pathname;
	var my_page_arr = pathname.split("/");
	var my_page = my_page_arr[my_page_arr.length-1];
	my_page_arr = my_page.split(".");
	my_page = my_page_arr[0];
	my_fullpage = my_page;
	my_page_arr = my_page.split("_");
	my_page = my_page_arr[0];
	
	/*
	if (!is_ie) {
		$('#menubar ul ul').css('display','block');
		$('#menubar li li').each(function(){
										  //alert ($(this).width());
										  if ($(this).width()<$(this).parent().parent().width()){
											  $(this).width($(this).parent().parent().width());
										  }
										  });
		$('#menubar ul ul').css('display','none');
		$('#menubar ul li').bind('mouseenter',function(){$('ul',this).slideDown('fast');});
		$('#menubar ul li').bind('mouseleave',function(){$('ul',this).slideUp('fast');});
	}
	
	
	$('#menubar li a').each(function() {
										var this_page_arr = $(this).attr('href').split("/");
										var this_page = this_page_arr[this_page_arr.length-1];
										this_page_arr = this_page.split(".");
										this_page = this_page_arr[0];
										//$(this).hide();
										if (this_page == my_page || this_page ==my_fullpage) {
											$(this).removeClass().addClass('menu_selected');
										}
										 });
	*/
	
	$('.banner').hide();
	$('.banner').eq(0).show();
	if ($('.banner_slideshow').length>0) {
		$('.banner_slideshow .banner_caption p').eq(1).hide();
		$('.banner_slideshow .banner_caption p').eq(2).hide();
		$('.banner_slideshow .banner_caption p').eq(0).show();
		$('.banner_slideshow .banner_caption p').eq(0).animate({left:0}, {duration:4000,queue: false,complete:function() {
																															  $(this).fadeOut(1000);
																															$('.banner_slideshow .banner_caption p').eq(1).fadeIn(1000);
			$('.banner_slideshow .banner_caption p').eq(1).animate({left:0}, {duration:6000,queue: false,complete:function() {
																																  $(this).fadeOut(1000,function(){
																																	  $('.banner_slideshow .banner_caption p').eq(2).fadeIn(1000);
																																		$('.banner_row, .banner_slideshow').cycle({fx:'fade',timeout:8000,timeoutFn:null});
																																	});
																																  }});
																															  }});
	}
	
	
	//$('#footer_bar').css('position','absolute');
	setup_menu();
	resize_window();
	
});
$(window).resize(function() {
	resize_window();
});
function setup_menu() {
	$('#mbar li a').removeClass();
	$('#mbar li a').each(function(){
									 if ($(this).attr('href')==htmlname) {
										 $(this).parent().addClass('selected');
										 var my_parent =  $(this).parent().parent().parent();
										 
										 while (my_parent[0].nodeName=="LI") {
											 my_parent.addClass('selected');
											 my_parent =  my_parent.parent().parent();
										 }
										 
									 }
									 });
	$('.people_box a').each(function(){
									 if ($(this).attr('href')==htmlname) {
										 $(this).addClass('selected');										 
									 }
									 });
	$('#mbar li').bind('mouseenter',function() {
											 $('> ul',this).hide().fadeIn(200);
											 });
	$('#mbar li').bind('mouseleave',function() {
											 $('ul',this).hide().fadeOut(0);
											 });
	////// Hide News, add "//" at the beginning of the line below to unhide
	$('ul li a').each(function(){if ($(this).attr('href')=='news.html') {$(this).parent().hide();}});
}
function returnDocument() {
	var file_name = document.location.href;
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	return file_name.substring(file_name.lastIndexOf("/")+1, end);
}
	
function resize_window() {
	//$('#footer').html($(window).height()+'|'+$(document).height());
	if ($(window).height()>=$(document).height()) {
		$('#footer_bar').css('position','fixed');
	} else {
		$('#footer_bar').css('position','relative');
	}
	
}
