// JavaScript (jQuery) 'Selected' Document

var selectedItem = function() {
	// get url string
	var location = new String(window.location);
	// get page/file name
	var pageName = new String(location.substring(location.lastIndexOf('/')+1));

	// check if pagename is blank, this assumes that it's the home page
	if(pageName == '' || pageName == '/') {
		pageName = 'index.php';		
	}

	$('.nav a[@href$="' + pageName + '"]').addClass('selected');

	// jquery : find nav item and apply selected class
	// iterate through each UL first child LI elements
	$('ul > li').each(function() {
		// if a link item href matches current page/file name
		if($(this).find('a[@href='+pageName+']').length > 0) {
			// apply selected class to first anchor link child of list item.
			$(this).find('a:eq(0)').addClass("selected");
			$(this).addClass("selected");
		}
		if($(this).find('a[@href=/'+pageName+']').length > 0) {
			// apply selected class to first anchor link child of list item.
			$(this).find('a:eq(0)').addClass("selected");
			$(this).addClass("selected");
		}
	});
}
// ana
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-10453512-3']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


$(document).ready(function() {
	selectedItem();
});
