$(function () {
	$('.showExtra').click(function () {
		if (isiPhone())
		{
			$("#content").animate({"top": "+=1000px", opacity: 0.1}, "slow");
		}
		else
		{
			$("#content").animate({"left": "+=1080px", opacity: 0.1}, "slow");
		}
		
		img = document.createElement("IMG");
		img.id="imgOverlay";
		img.src="/wp-content/themes/linc 2011/assets/images/semitrans.png";
		img.height = $("#content").height();
		img.width = $("#content").width();
		$("#content").append(img);
		
		$("#content #imgOverlay").maxZIndex({ inc: 5 });

		$("#extra_content.post").empty();
		$("#extra_content").fadeIn("slow");
	});
	
	$('.hideExtra').click(function () {
		if (isiPhone())
		{
			$("#content").animate({"top": "-=1000px", opacity: 1.0}, "fast");
		}
		else
		{
			$("#content").animate({"left": "-=1080px", opacity: 1.0}, "fast");
		}
		$("#content #imgOverlay").remove();
		$("#extra_content").fadeOut(0);
	});
	
	if (!isiPhone())
	{
		$('#content .post')
		.mouseenter(function () {
			$(this).find('.link_overlay').stop(true, true);
			$(this).find('.link_overlay').fadeIn(200);
		})
		.mouseleave(function () {
			$(this).find('.link_overlay').stop(true, true).css('opacity', '1');
			$(this).find('.link_overlay').fadeOut(200);
		});
	}
	
});

function isiPhone(){
    return (
		(navigator.platform.indexOf("iPad") != -1) ||
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}

$.maxZIndex = $.fn.maxZIndex = function(opt) {
    var def = { inc: 10, group: "*" };
    $.extend(def, opt);    
    var zmax = 0;
    $(def.group).each(function() {
        var cur = parseInt($(this).css('z-index'));
        zmax = cur > zmax ? cur : zmax;
    });
    if (!this.jquery)
        return zmax;

    return this.each(function() {
        zmax += def.inc;
        $(this).css("z-index", zmax);
    });
}
