(function($){
$.fn.activeMenu = function(options){
	var defaults = {  
		idSwitch: 'active',
		defaultSite: 'www.legacydesigns.biz',
		defaultIndex: 0
	},  
	intialize = function(id){
		var op = $.extend({},defaults,options);
		var loc = location.href;
		
		var activeCount = 0;
	
		$(id).find('a').each(function(){
			var href = $(this).attr('href');
			
			var leng = op.defaultSite.length + 7;
			var linkURL = loc.substr(leng, href.length);
			
			var listNum = $("#mainMenu li").length; // Gets number of list items
			
			if(linkURL == "/"){
				// Do nothing
				activeCount++;
			}
			
			else if(linkURL == href){
				
				$(this).attr('id', op.idSwitch);
				
			}
			else{
				$(this).attr('id', '');
				activeCount++;
				
			}
			
			if(activeCount == listNum){
			
				if(loc.search(op.defaultSite) != -1){
					$(id).find('a').eq(0).attr('id', op.idSwitch);
				}
			}
		});	
	}
	
	return this.each(function(){
		intialize(this);					  
	});
}
})(jQuery);
