jQuery(document).ready(function(){

	// This code makes the description field in the Appearance / Menus / [ Menu ] area visible.
	var $target = jQuery('#description-hide')
	var $target2 = jQuery('.field-description').removeClass('hidden_field').css('display','block');
	if(($target).filter(':checked').length == 0)
	{
		$target.trigger('click');
	}
	
	// Main-Menu Toggle.
	$('ul.main-menu li').unbind().hover(
		function () { $(this).children('ul.main-menu li ul').stop(true, true).fadeIn('fast', function() {}); }, 
		function () { $(this).children('ul.main-menu li ul').stop(true, true).fadeOut('fast', function() {}); }
	);
	
	// This code has the Portfolio Item Info division appear when you hover over a Portfolio Item.
	$('.pi').unbind().hover(
		function () { $(this).children('.pi-info').stop(true, true).fadeIn('fast', function() {}); },
		function () { $(this).children('.pi-info').stop(true, true).fadeOut('fast', function() {}); }
	);
	
	// This code has the Portfolio Item Info division appear when you hover over a Portfolio Item.
	$('.pi-image').unbind().hover(
		function () { $('.pi-magnify').stop(true, true).fadeIn('fast', function() {}); },
		function () { $('.pi-magnify').stop(true, true).fadeOut('fast', function() {}); }
	);

	// Menu hover effect for the portfolio taxonomy.
	$('ul.portfolio-nav li').unbind().hover(
		function () { $(this).children('ul.portfolio-nav li ul').stop(true, true).fadeIn('fast', function() {
			$("ul.portfolio-nav li a:first").addClass("portfolio-menu-hover");
		}); },
		function () { $(this).children('ul.portfolio-nav li ul').stop(true, true).fadeOut('fast', function() {
			$("ul.portfolio-nav li a:first").removeClass("portfolio-menu-hover");
		}); }
	);
	
	// Changes the first item in the porfolio taxonomy to link to the portfolio page.
	$('ul.portfolio-nav li ul li a:first').attr("href", "portfolio");
	
	// This code is for page layout formatting.
	$('.post-entry a>img').parent().addClass('imgLink'); // Adds a class to images that are linked.
	$('.post-entry a>img').parent().prev('.post-entry *').addClass('imgLinkAfter');
	
	// Clears values from input text types and replaces them if the user doesn't type anything.
	$(function(){
		$('input:text').each(function(){
			var txtval = $(this).val();
			$(this).focus(function(){
				$(this).val('')
			});
			$(this).blur(function(){
				if($(this).val() == ""){
					$(this).val(txtval);
				}
			});
		});
	});
 	
	// Removes the image width and height tags in the post area to preserve position.
	$('.post-entry img').each(function(){
		$(this).removeAttr('width')
		$(this).removeAttr('height');
	});
	$('.pi-image img').each(function(){
		$(this).removeAttr('width')
		$(this).removeAttr('height');
	});
	$('.post-preview-thumb a>img').each(function(){
		$(this).removeAttr('width')
		$(this).removeAttr('height');
	});
	
});

