/***************************************************
* Active-state-nav.js
****************************************************
* This script adds a 'selected' class to the top level navigation for the PUJ airport website.
* This should be easier, but I can't get jQuery to work with the noConflict() call.
******************************************************/
function active_site_nav_handler(){
	var path_parts = (location.pathname.indexOf('/') != -1)? location.pathname.split('/') : location.pathname.split('\\');
	var site_section = '';
	for(var i=0; i<path_parts.length; i++){
		if( path_parts[i].length ){
			site_section = path_parts[i];
			break;
		}
	}
	if( site_section != '' ){
		var header_nav = document.getElementsByTagName('ul')[0];
		if( header_nav ){
			var lis = header_nav.getElementsByTagName('li');
			for(var i=0; i<lis.length; i++){
				if( lis[i].className.indexOf( "cms_" + site_section.replace( /-/g, '_') ) != -1){
					lis[i].className += ' selected';
					return true;
				}
			}
		}
	}
	return false;
}

if( document.addEventListener ){
	document.addEventListener('load', active_site_nav_handler, true);
} else if (document.attachEvent){
	document.attachEvent( 'onload', active_site_nav_handler )
}
