/** 
 * Contains all jQuery and other JavaScript functions for the skin.
 *
 * @link				http://thesisplayground.com/thesis-skins/looks-good-naked/
 * @package			Looks Good Naked Thesis Skin
 * @version			0.1
 * @author			Ryan McKillen
 * @copyright		Copyright 2009 Ryan McKillen and Screaming Ventures, LLC
 * @license			GNU GPL v3 http://www.gnu.org/licenses/gpl-3.0-standalone.html  
 */

$(document).ready(function(){	

	// Shadow wrapper
	$('.shadow').wrap('<div class="slider_menu_container outerpair1"><div class="outerpair2"><div class="shadowbox"><div class="innerbox"></div></div></div></div>');

	// CSS sets div#slider_links_menu to display:none in order to prevent flicker
	$('.custom #slider_links_menu').css({'display':'block'});

	// Slider padding adjustment
	$('.slider_menu .sub:last').css({'padding-right':'10px'});

	// Slider down
  $('.slider').hover(
  	function(){
    	slidersUp($(this).attr('id'));
			var pos = $(this).offset();
    	var menu_id = '#' + $(this).attr('id') + '_menu';
			$(menu_id).parent().parent().parent().parent().css({'left':(pos.left - 1) + 'px', 'top':(pos.top + 23) + 'px'}).slideDown('normal');
    	$('a', this).addClass('menu_on');
   	}
   ); 
  
  // Ensures only one slider is down at a time
  function slidersUp(exception) {
  	$('.slider').each(function(){
  		var menu_id = '#' + $(this).attr('id') + '_menu';
  		if($(this).attr('id') != exception) {
  			$(menu_id).parent().parent().parent().parent().slideUp('normal');
  			$('a', this).removeClass('menu_on');
  		}
  	});
  }
  
  // Slider up
  $('.slider_menu_container').hover(
  	null,
  	function(){
  		$('.slider_menu_container').slideUp('normal');
  		$('ul#tabs a').removeClass('menu_on');
  	}
  );
  
  // Add styling for parent links in sliders
  $('li.page_item').each(function(){
  	tag = $(this).children('a:first').next();
  	if(tag.attr('tagName') == 'UL') {
  		$(this).children().filter('a:first').css({'font-weight':'bold'});
  		$(this).children().filter('ul:first').css({'margin':'4px 0 0 10px'});
  	}
  });
		
	// Make a link un-clickable
	$('.no_link').click(function(){
		return false;
	});		
	
	// Search box helper text
	$('#s').attr('value', 'search');
	$('#s').click(function(){
		if($(this).attr('value') == 'search' || $(this).attr('value') == 'SEARCH') {
			$(this).attr('value', '');
		}
	});
	$('#s').blur(function(){
		if($(this).attr('value') == '') {
			$(this).attr('value', 'search');
		}
	});	
		
});