$(document).ready(function(){
	//Navigation  					   
	$("ul.sf-menu").supersubs({ 
		minWidth:    9,   // minimum width of sub-menus in em units 
		maxWidth:    13,   // maximum width of sub-menus in em units 
		extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();  // call supersubs first, then superfish, so that subs are 
					 // not display:none when measuring. Call before initialising 
					 // containing tabs for same reason. 

  		
	/*other global elements*/
	$('.skip a').focus(function() {
		$(this).parents('.skip').addClass("skipselected");
	});
	$('.skip a').blur(function() {
		$(this).parents('.skip').removeClass("skipselected");
	});
	
	/*Search*/
	var searchBoxValue = 'Search';
	$('#txtQuery').val(searchBoxValue);
	$('#txtQuery').focus(function(){
		if ($(this).val() == searchBoxValue){
			$(this).val('');
		}
	});
	
	/*table zebra*/
	$("tr:nth-child(odd)").addClass("odd");
	
	
	/*subnav*/
	
	
	
	var folderpath = location.pathname.substring(0).toLowerCase();
	var pagefilename = folderpath.substring(folderpath.lastIndexOf('/')+1).toLowerCase();
	var defaultfilename = "default.asp";
	
	//remove default.asp if it exists in folderpath
	if (pagefilename == defaultfilename) {
		folderpath = location.pathname;
		folderpath = folderpath.substring(0,folderpath.lastIndexOf('/')+1).toLowerCase();
	}

	$('#subnav ul ul').hide();
	//mark item as selected and show submenu if necessary
	$('#subnav ul a[href="' + folderpath + '"]').addClass('selected');
	$('#subnav > ul > li > a.selected').siblings('ul').slideDown();
	$('#subnav ul a.selected').parents('ul').show();
	$('#subnav ul ul ul').hide();
	
	/*Generate differnt bg image on top-right depending on root directory or filename if there is no directory*/
	var rootname = location.pathname.match(/\w+/)[0].toLowerCase(); 
	
	switch(rootname) {
		case "about":
		$('#top').addClass('about');
		break;
		
		case "classes":
		$('#top').addClass('classes');
		break;
		
		case "programs":
		$('#top').addClass('programs');
		break;
		
		case "enrollment":
		var enrollpattern = /\/\w+\/\w+\//;
		$('#subnav ul a[href="' + location.pathname.match(enrollpattern) + '"]').siblings('ul').show();
		$('#top').addClass('enrollment');
		break;
		
		case "resources":
		$('#top').addClass('resources');
		break;
			
		case "news":
		$('#top').addClass('news');
		var newspattern = /\/\w+\/\w+\//;
		$('#subnav ul a[href="' + location.pathname.match(newspattern) + '"]').siblings('ul').show();
		break;
		
		case "directories":
		$('#top').addClass('directories');
		break;
		
		default:
		$('#top').addClass('directories');
		break;
	}
	
	/*IE 6 Hacks*/
if (jQuery.browser.msie) {
	if(parseInt(jQuery.browser.version) == 6) {
      	$("#content h1 + h2, #content h2 + h3, #content h3 + h4, #content h4 + h5, #content h5 + h6, #content h1 + p, #content h2 + p, #content h3 + p, #content h4 + p, #content  h5 + p, #content h6 + p").addClass("AfterH"); 
	  	$("#content p + ul, #content h1 + ul, #content h2 + ul, #content h3 + ul, #content h4 + ul, #content h5 + ul,#content h6 + ul, #content p + ol, #content h1 + ol, #content h2 + ol, #content h3 + ol, #content h4 + ol, #content h5 + ol, #content h6 + ol").addClass("afterPH");
	  	$("#nav ul li:first-child > a").addClass("first");  
	}
} 
	$("#logo img").attr("src", "/images/bellevuecollege.gif");
});


attachRollOverEvent = function(imageId){
		$(imageId).mouseover( function(){ $(this).attr("src", $(this).attr("src").split('_off').join('_on')) } );
		$(imageId).mouseout( function(){ $(this).attr("src", $(this).attr("src").split('_on').join('_off')) } );
		$(imageId).parents("a").focus(function(){ $(this).children("img").attr("src", $(this).children("img").attr("src").split('_off').join('_on')) } );
		$(imageId).parents("a").blur( function(){ $(this).children("img").attr("src", $(this).children("img").attr("src").split('_on').join('_off')) } );
}