// JavaScript Document

var $j = jQuery.noConflict();

$j(function($){
	
	/*CLEAR SEARCH FORM*/
	$('#searchform #s').click(function(){
		$(this).attr('value', '');								   
	});
	
	//MENU DROP DOWN
	$(".menu li").hover(function(){
		$(this).find('ul:first').slideDown('fast');
	},function(){
		$(this).find('ul:first').fadeOut('fast');
	});  
	$('.menu ul li .page_item').hover(function(){
		$(this).animate({left:10}, 200);										
	},function(){
		$(this).animate({left:0}, 200);
	});
	$('.menu ul li ul').append('<li class="menu-bottom"></li>');
	
	//TOP HEADER LINKS
	//MENU DROP DOWN
	$(".header-top-links li").hover(function(){
		$(this).find('ul:first').slideDown('fast');
	},function(){
		$(this).find('ul:first').fadeOut('fast');
	});  
	$('.header-top-links ul li .page_item').hover(function(){
		$(this).animate({left:10}, 200);										
	},function(){
		$(this).animate({left:0}, 200);
	});
	$('.header-top-links ul li ul').append('<li class="menu-bottom"></li>');
	
	//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' : '-10px'});												   
	},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;
	});
	
});