(function($) {      
	$.fn.showhide = function(options) {
		
		var opts = $.extend({}, $.fn.showhide.defaults, options);
		// trackers
		var active_id = null;
		var hideDelay = 100;
		var hideDelayTimer = null;
		
		return this.each(function() {
			
			//if the first occurance of the # in attr('href') is greater than zero then it is due to IE bug
			if($(this).attr('href').indexOf("#") > 0){
				//bug fix for IE miss hadnling of attr('href')
				// indexOf returns position of first #
				//substing returns the attr('href') string from the position of first #
				this.target_id = $($(this).attr('href').substring($(this).attr('href').indexOf("#"))).hide();
			}else{
				this.target_id = $($(this).attr('href')).hide();
			}
			
			//alert(this.target_id.html());
			
			//only show the target div if it has some content
			
					
					switch(opts.event){				
						case "mouseover":
							$(this).mouseover(onEvent);
							$(this).click(function(){return false;});//make sure then any click events return false
						break;
						case "click":
							$(this).click(onEvent);
						break;
					}
		});
	
		function onEvent() {
			
			if(opts.animate==true){				
				//hide all sibling active divs, fade them out and take away the active class using chaining
				this.target_id.siblings(".tgl-active").fadeOut('fast').removeClass('tgl-active');
				
				if(this.target_id.html()){
					if(this.target_id.html().length > 0){ 
						this.target_id.fadeIn('fast');
					}
				}
			}else{
				//hide all sibling active divs, hide them and take away the active class using chaining
				this.target_id.siblings(".tgl-active").hide().removeClass('tgl-active');
				if(this.target_id.html()){
					if(this.target_id.html().length > 0){ 
						this.target_id.show();
					}
				}
			}			
			this.target_id.addClass('tgl-active');
			// /****** AUGENTIUS ONLY ******/ //
			//quick hack to increase the padding on div#main to make space for the mouseover effects
			$('#main').css('padding-bottom','130px');
			// /****** AUGENTIUS ONLY ******/ //
			this.target_id.css("z-index","1000");
		return false;
		}
	}
  
	$.fn.showhide.defaults = {
		animate: false,
		event: 'click',		
		selected: false
	}
})(jQuery);
