(function($) {
$(document).ready(function($){

if (typeof template_shadow != 'undefined' && template_shadow) {
	$(".project").each(function() {
		$(this).addClass('project-shadow');
	});
	$(".post").each(function() {
		$(this).addClass('post-shadow');
	});
}

$(".section").each(function() {
    var left = -994 + 23 + 5 + $(this).children().width();
    $(this).css('left', left);
});

$("#navigation input.search").each(function() {
	var old = $(this).val();
	$(this).focus(function() {
		if ($(this).val() == old) {
			$(this).val('');
		}
	});
	$(this).blur(function() {
		if ($(this).val() == '') {
			$(this).val(old);
		}
	});
});

var max = 0;
$(".project .project-inner").each(function() {
	var height = $(this).height();
	max = height > max ? height : max;
}).each(function() {
	$(this).height(max);
});

// IE doesn't animate when mask_type = 1
var mask_type = 1; 

$(".project img").each(function(i) {
	if ($.browser && $.browser.msie && $.browser.version && $.browser.version == '6.0') {
		return;
	}
	var position = $(this).position(), width = $(this).width(), height = $(this).height();
	var mask = $('<img class="image-mask" src="' + template_directory + '/img/mask-280.png" alt=""/>');
	mask.css({
		'position':'absolute',
		// 'background': 'lime',
		'display':'block',
		'width': width + 'px',
		'height': height + 'px',
		'top': 0
	});
	if (mask_type == 0) {
		mask.attr('id', 'project-mask-' + i);
		mask.css({
			'top': position.top + 'px',
			'left': position.left + 'px'
		});
		$("#container").append(mask);
	}
	if (mask_type == 1) {
		mask.css({
			'top': position.top + 'px',
			'left': position.left + 'px'
		});
		if ($.browser && $.browser.safari) {
			mask.css({'left': position.left + 10 + 'px'});
		}
		$(this).parent().append(mask);
	}
});

if ($.browser) {
	if ($.browser.opera) { $(document.body).addClass('opera'); }
	if ($.browser.safari) { $(document.body).addClass('webkit'); }
	if ($.browser.mozilla) { $(document.body).addClass('mozilla'); }
	if ($.browser.msie) {
		$(document.body).addClass('ie');
		if ($.browser.version == '6.0') $(document.body).addClass('ie6');
		if ($.browser.version == '7.0') $(document.body).addClass('ie7');
		if ($.browser.version == '8.0') $(document.body).addClass('ie8');
	}
}

})
})(jQuery);