/**
* LG Blog default JS
* 
*/
;(function($) {
	$(function(){
		
		
		/**
		 * Inject Icons
		 */
		$('#rss-links .hd').before('<div id="rss-icon" />');
		$('.neteye-recent-posts .hd').before('<div id="forum-icon" />');
		$('.widget_twitter .hd').before('<div id="twitter-icon" />');
		
    	/**
    	 * Key visuals cookie
    	 */
		var c = $.cookie("hideVisual");
		if (c === null) {
	       c = true;
	       //console.log("Using default value TRUE");
		} else {
	       c = parseInt(c, 10) === 1;
	       //console.log("Using cookie value ", c);
		}
		//console.log("Value = ", c);
		
		/**
		 * Expand Author Biography
		 */
		var context = $('.multiwidget_author_avatars');
		//$(".author-list", c).tabs(".body", {tabs: '.heading'});
		
		/**
		* Toggles author info boxes
		*/
		$('div.user', context).each(function(i, el) {
			var $this = $(this);
			var userBody = $this.find('div.body');
			var animating = false;
			$this.hover(function() {
				if (!animating) {
					animating = true;
					userBody.slideDown();
				}
			}, function() {
				userBody.slideUp('fast', function() {
					animating = false;
				});
			});
		});
		
		
		/**
		 * Toggle category Image
		 */	
		$('#topPost').after('<div id="headerToggle"><a href="#"  class="slideDown">Top Thema ausblenden</a></div>');
		var headerToggleLink = $("#headerToggle a").click(function () {
			
			var $this = $(this);
			$this.fadeOut("fast", function() {
				var topPost = $("#topPost");
				
				var methodName = topPost.is(":visible") ? 'slideUp' : 'slideDown';
				
				topPost[methodName]("slow", function() {
					if (methodName == 'slideUp') {
						$this.removeClass().addClass("slideDown").fadeIn("fast");
					} else {
						$this.removeClass().addClass("slideUp").fadeIn("fast");
					}	
					
					$.cookie("hideVisual", methodName === 'slideDown'  ? 1 : 0);
				})
			});
		});
		if (c === true) {
			//console.log('trigger...');
			headerToggleLink.trigger('click');
		} else {
			$('#headerToggle a').fadeIn('fast');
		}
		
		/**
		 * Toggle Feature-List Items
		 */
		$('#glossary dt').click(function() {
			
			var next = $(this).next(),
				action = next.is(':visible') ? 'hide' : 'show';
			
			$(this).toggleClass('active');
			
			next[action]('fast', function() {
				next.toggleClass('show');
				
			});
			
		});
		
		/**
		 * Form hint
		 */
		$('#comment').bind('mouseenter', function() {
			$('#form-allowed-tags').slideDown('slow');
		}).bind('mouseleave', function() {
			$('#form-allowed-tags').hide();
		});
		
		
	}); // #document.ready    

})(jQuery);




/**
 * Firebugx - firebuglight
 *
 * @note this prevents accidentially errors in non-ff browsers
 * @revisit remove when project is final
 */
//if ($.browser.msie) {
	if (!('console' in window) || !('firebug' in console)) {
		var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];

		window.console = {};
		for (var i = 0; i < names.length; ++i) {
			window.console[names[i]] = function(){ };
		}
		/*
		try {
			window.console.log = consoleLog;
		} catch (e) {
		}
		*/
	}
//}



