$(document).ready(function() {

$("html").removeClass("noscript");

	//select all the a tag with name equal to modal
	$('a[rel=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();

		//Get the A tag
		var id = $(this).attr('href');
                
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		//$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
	
		//transition effect
		$(id).fadeIn();
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//$('#fade').fadeOut();
		$('.window').fadeOut();
	});		
	
	//if mask is clicked
	$('#fade').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});

$(window).load(function(){
               $('#fademask').delay(500).fadeOut(2000); 
});

document.onkeydown = function(e) {
// Right = 39
// Left = 37
e = (typeof e == "undefined") ? event : e;
b = (typeof e.which == "number") ? e.which : e.keyCode;
if (b == 39) {location.href = document.getElementById("nextPost").href}
else if (b == 37) {location.href =
document.getElementById("prevPost").href}
}

