$(document).ready(function () {

	var folderpath = location.pathname.substring(0).toLowerCase();
	var pagefilename = folderpath.substring(folderpath.lastIndexOf('/')+1).toLowerCase();
	var defaultfilename = "default.asp";
	
	var sectionname = /\/\w+\/\w+\//;
	var section = folderpath.match(sectionname);
	
	// figure out which section you are in
	if (section == null | section == '/webpublishing/serveraccess/' | section == '/webpublishing/help/') {
		var section = '/webpublishing/';
	}
	
	//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').siblings('ul').slideDown();
	$('#subnav ul a.selected').parents('ul').show();
	
	// do the same thing for the main nav, but we don't need anything fancy
	$('#nav ul a[href="' + section + '"]').parent('li').addClass('highlight');
	
	//make the header clickable w/o changing the html code
	$('.titleContent h2').wrapInner('<a href="/webpublishing/"></a>');	
	
	//clear search box... not the preferred method, but whatever for now
	$('#txtQuery').one("focus", function() {
  		$(this).val("");
		}); 
	
	
	/*clear search boxes on focus
	var selector = $('#txtQuery');
	var defvalue = 'Search!'
	
	function populateElement(selector, defvalue) {
    $(selector).each(function() {
        if($.trim(this.value) == "") {
            this.value = defvalue;
        }
    });
  
    $(selector).focus(function() {
        if(this.value == defvalue) {
            this.value = "";
        }
    });
    
    $(selector).blur(function() {
        if($.trim(this.value) == "") {
            this.value = defvalue;
        }
    });
 }*/

});