$(document).ready(function () {

	$('.gallery .grid').css('opacity','0.7');
	$('.gallery .label').css('height','30px');
	
	$('.gallery').mouseenter(function(){
		$('img', this).css('opacity','0');
		$('img', this).animate({"opacity": "1"},350);
		$('.grid', this).animate({"opacity": "0.35"},400);
		$('.label', this).animate({"height": "40px"},200);
	}).mouseleave(function(){
		$('.grid', this).css('opacity','0.7');
		$('.top', this).css('opacity','0');
		$('.top', this).animate({"opacity": "1.0"},400);	
		$('.label', this).animate({"height": "30px"},150);	
	});

	$('.post .grid').css('opacity','0.7');
	//$('.post .label').css('height','30px');
	
	$('.post').mouseenter(function(){
		$('img', this).css('opacity','0');
		$('img', this).animate({"opacity": "1"},350);
		$('.grid', this).animate({"opacity": "0.35"},400);
		$('.meta', this).animate({"left": "80px"},150);
	}).mouseleave(function(){
		$('.grid', this).css('opacity','0.7');
		$('.top', this).css('opacity','0');
		$('.top', this).animate({"opacity": "1.0"},400);	
		$('.meta', this).animate({"left": "85px"},85);
	});
	
	
	$('#Logo .logo').remove();
	$('#Logo').prepend('<a href="http://www.kamilkonrad.com"></a><div id="Logo_left_a"></div><div id="Logo_left_b"></div><div id="Logo_right"></div>');
	
	
	$('#Logo').mouseenter(function(){
		$('#Logo_left_a', this).animate({"background-position": "20px 0px"},500);
		$('#Logo_left_b', this).animate({"background-position": "0px 0px"},500);
	}).mouseleave(function(){
		$('#Logo_left_a', this).animate({"background-position": "0px 0px"},500);
		$('#Logo_left_b', this).animate({"background-position": "92px 0px"},500);
	});
	
	
	
	$('#comment_form input, #comment_form textarea').each(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('defaultvalue'));
		}
	}).focus(function () {
		$(this).removeClass('inputerror');
		if ($(this).val() == $(this).attr('defaultvalue')) {
			$(this).val('');
		}
	}).blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('defaultvalue'));
		}
	});
	$('#comment_form').submit(function () {
		$('#submiterror').remove();
		var errors = 0;
		$(this).find('textarea, input').each(function () {
			if ($(this).val() == $(this).attr('defaultvalue')) {
				if ($(this).attr('name') != 'comment_post_ID') {
					$(this).val('');
				}
			}
			if ($(this).hasClass('required') && $(this).val() == '') {
				$(this).addClass('inputerror');
				errors++;
			}
		});

		if (errors > 0) {
			$(this).find('textarea, input').each(function () {
				if ($(this).val() == '') {
					$(this).val($(this).attr('defaultvalue'));
				}
			});
			$(this).prepend('<div id="submiterror">**Please complete ALL required fields.</div>');
			return false;
		}
		return true;
	});
});
