// JavaScript Document

$(document).ready( function(){
							

$('a[name=modal]').click(function(e) {
	
	
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
		
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(document).width();	
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
			
		$('#mask').fadeTo(100,0.3, makeVisible());	
	
		$(id).center();
		
		//transition effect
		$(id).fadeIn(200); 
	
	
	});

$('#mask').click(close);	
$('.close').click(close);
$('.buy_button').submit(function() {
  close();

});
	
	

})

function makeVisible()
{
	$('#mask').css({'display':'block'});
}



	//close all open windows
	function close()
	{
		
		$('.window').hide();
		$('#mask').hide();
		 return false;
	};

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}

