// JavaScript Document

var $j = jQuery.noConflict();

$j(function($){
	
	/*CLEAR SEARCH FORM*/
	$('#searchform #s').click(function(){
		$(this).attr('value', '');								   
	});
	
	//MENU DROP DOWN
	$(".menu-item").hover(function(){
		$('.sub-menu', this).show();
	},function(){
		$('.sub-menu', this).hide();
	});
	
	//LOADING GIF
	if($('#loading').length > 0)
	{
		$("#loading").ajaxStart(function(){ 
		  $(this).show(); 
		});
		$("#loading").ajaxStop(function(){ 
		  $(this).hide(); 
		});
	}
	
	//SOCIAL ICONS DANCE 
	$('.social_widget ul > li').hover(function(){
		$(this).find('a')
		.css('position', 'relative')
		.animate({'top' : '-5px'});												   
	},function(){
		$(this).find('a')
		.animate({'top' : '0'});
	});
	$('.knil').prepend('<a href="http://empoweredblogs.com" title="Empowered Blogs for Wordpress by The Empowered Tribe">Empowered Blogs for Wordpress by the Empowered Tribe</a>');
	
	//HIDE SEARCH FORM IF IT EXISTS IN WIDGET
	/*var sidebar_search = $('.side-bar #searchform');
	if(sidebar_search.length > 0)
	{
		$('.header .search').hide();	
	}*/
	
	//FLOATING WIDGET
	$('.content-wrapper').css('position', 'relative');
	var widget = $('.floating-social-widget');
	$(window).scroll(function(){			
		$(widget).stop().animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "normal" );			
	});
	$('.floating-social-widget-top a').click(function(){
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;
	});
	$('.floating-social-widget-read a').live('click', function(){
		var list = $('.floating-social-widget-read-sub');
		if($(list).css('display') == 'none')
		{
			$(list).animate({ width: 'show' });
			$(this).text('Hide');
		}
		else
		{
			$(list).animate({ width: 'hide' });	
			$(this).text('Read');
		}
		return false;
	});
	$('.floating-social-widget-read-posts').live('change', function(){
		var href = $(this).val();
		window.location = href;
		return false;
	});
	
	//COMMENT BOX
	$('#commentform #comment').focus(function(){
		$(this).height(200);										  
	});
	
	//VIEW PINGS IN COMMENT AREA	
	$('.view-pings').click(function(){
		var pingbacklist = $('.pingbacklist');
		var comments = $('.commentlist');
		var button = $(this);
		var visual = $('.pingbacklist').css('display');
		if(visual == 'none')
		{
			$(comments).hide();
			$(pingbacklist).show();
			$(button).val('View Comments');
		}
		else
		{
			$(comments).show();
			$(pingbacklist).hide();
			$(button).val('View Pings');
		}
	});
	
});
