// JQUERY CUSTOM COMMANDS
$(function() {
	
	// LAYOUT
	$('.entry img.alignleft').each(function() {
		var iWidth = $(this).outerWidth(true);
		$(this).parent().nextAll('.entry ul').css("margin-left",iWidth);
	});
	// Activate homepage
	$('body.home').find('#mainMenu li:first').addClass('current-menu-item'); 
	
	// FULLSIZE BACKGROUND
	var theWindow	= $(window),
	$bg				= $("#fullsize"),
	aspectRatio		= $bg.width() / $bg.height();
	
	function resizeBg() {
		if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
			$bg.removeClass().addClass('bgheight');
		} else {
			$bg.removeClass().addClass('bgwidth');
		}
	}
	theWindow.resize(function() {
		resizeBg();
	}).trigger("resize");

	
	
	// FORMS - focus and blur
	$('.input input').focus(function() {
		$(this).select().parent().addClass('focus');
	});
	$('.input input').blur(function() {
		$(this).parent().removeClass('focus');
	});
	// FORMS - clicking on hint
	$('.input .hint').click(function() {
		$(this).parent().addClass('focus').find('input').select();
	});
	// FORMS - Empty filled fields on blur
	$('.input input').each(function() {
		$(this).blur(function() {
			$(this).parent().removeClass('focus');
			if ($(this).val() != "") {
				$(this).parent().addClass('filled');
			} else {
				$(this).parent().removeClass('filled');
			};
		});
	});
	// FORMS - Empty filled fields on load
	$('.input input').each(function() {
		if ($(this).val() != "") {
			$(this).parent().addClass('filled');
		} else {
			$(this).parent().removeClass('filled');
		};
	});
	// mainMenu
	//$('#mainMenu > ul > li:first').addClass('first');
	//$('#mainMenu li.current_page_item, #mainMenu li.current_page_parent, #mainMenu li.current_page_ancestor').prev().addClass('beforeActive');
	
   
});

