/* -----------------------------------------------
   JavaScript Framework v2.0
   Copyright to James Kirby - www.jameskirby.me.uk
   Creative Commons Attribution-Noncommercial-No Derivative Works 2.0 UK: England & Wales License (http://creativecommons.org/licenses/by-nc-nd/2.0/uk/)
----------------------------------------------- */

$(document).ready(function() {
	/* Highslide */
	hs.registerOverlay({ overlayId:'closebutton', position:'top right', fade:2 });
	
	if ($.browser.safari) {
		if ( $(document).width() < 1205 ) {
			$("#side-advert").css("display","none");
		} else {
			$("#side-advert").css("display","block");
		}
	}
	
	$(window).resize(function(){
		if ($.browser.safari) {
			if ( $(document).width() < 1205 ) {
				$("#side-advert").css("display","none");
			} else {
				$("#side-advert").css("display","block");
			}
		}
	});
	
});

/* ----------------------
   Scripts
---------------------- */

/* Menu Highlighter - Will add active to the <li> node. */
/*
$(document).ready(function() {
	var path = location.pathname;
	
	alert(location);
	var home = "/index.htm";
	if (path == home || path == "/") {
		var $nav = $('#nav ul li a[@href="' + home + '"]');
	} else {
		var $nav = $('#nav ul li a[@href$="' + path + '"]');
	}
	$nav.parent().addClass('active');
});
*/



/* Auto Highlight Main Menu */
function extractPageName(hrefString) {
	var arr = hrefString.split('/');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();	
}

function setActiveMenu(arr, crtPage) {
	for( var i=0; i<arr.length; i++ ) {
		if(extractPageName(arr[i].href) == crtPage) {
			arr[i].parentNode.className = "active";
		}
	}
}

$(document).ready(function() {
	if( document.location.href ) {
		hrefString = document.location.href;
	} else {
		hrefString = document.location;
	}
	if ( document.getElementById("nav") != null )  {
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
	}
});
