// parse the URL to get the 'lang=' query string
$.urlParam = function(name) {
    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    if (!results) {
        return 0;
    }
    return results[1] || 0;
};


var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);			


document.title = "McClaren Lawn, Landscaping, Irrigation, Fertilizing and more! | Bloomington, Indiana";


jQuery(document).ready(function($) {

		// list the important elements that should be included on each page
		$("#top_bar, #logo, #sidebar, #dark_footer_wrap, #light_footer_wrapper").addClass('jqinclude');

		// recursive function to perform the includes, then do other stuff to the included content
		function load_include() {
			var incthis = jQuery(this).attr("id");
			jQuery(this).load('template.html #'+incthis+' div.template', function() {
		
				// after loading stuff from the template, repeat the load of any includes within an include
			    jQuery(this).addClass("js").removeClass("jqinclude").addClass("jqincluded").find("div.jqinclude").each(load_include);
	
				// if filename is empty, then filename is index.html - add 'on' active state to menu links
				if (filename == "") {
					jQuery('li a[href=index.html]').addClass('on');
				};
				jQuery('li a[href='+filename+']').addClass('on');
				jQuery('#nav li a[href='+filename+']').parent().parent().prev('a.navparent').addClass('on');
		
				// flash font replacement on h tags
				Cufon.replace('h1, h2, h5, .footer, #logo strong', { hover: 'true' });
						
				jQuery('*').removeClass('js');
				jQuery('body').css('display', 'block');
				
				// per client's request, disable highlighting on the page
				//jQuery('body').attr('onDragStart','return false;');
				//jQuery('body').attr('onContextMenu','return false;');
				//jQuery('body').attr('onSelectStart','return false;');
				

		  });
		};	// end jqinclude fn

		// find every item with the include class and perform the includes function as defined above
		jQuery(".jqinclude").each(load_include);



		// for CSS
		var fileref=document.createElement("link");
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", "http://mcclarenlawn.net/javascript/shadowbox/shadowbox.css");
		document.getElementsByTagName("head")[0].appendChild(fileref);
		
		
		$.getScript('http://mcclarenlawn.net/javascript/shadowbox/shadowbox.js', function(){

			Shadowbox.init();
			
			// programtable's - open links in shadowbox & change background color on even rows
			$('table.programtable').each(function() {
				$(this).find('tr:even').not('.header').css('backgroundColor','#eee');
			});

			$('table.programtable.popuplinks').each(function() {
				$(this).find('a').attr('rel','shadowbox;width=645;height=468');
			});
			
			// per client's request, disable highlighting on the page
			//jQuery('body').attr('onDragStart','return false;');
			//jQuery('body').attr('onContextMenu','return false;');
			//jQuery('body').attr('onSelectStart','return false;');
			
			
		});
		
		

		// the featureList is the image rotator on the home page
		$.featureList(
			$("#tabs li a"),
			$("#output li"), {start_item: 0}
		);

		// weed control navigation on the weeding page 
		$('.weedNav a.weedDown').click(function() {
			$('.weedContent').toggle();
		});

		// per client's request, disable highlighting on the page
		//jQuery('body').attr('onDragStart','return false;');
		//jQuery('body').attr('onContextMenu','return false;');
		//jQuery('body').attr('onSelectStart','return false;');
		

	
});

// per client's request, disable highlighting on the page
//jQuery('body').attr('onDragStart','return false;');
//jQuery('body').attr('onContextMenu','return false;');
//jQuery('body').attr('onSelectStart','return false;');

