/*Rolling = {};

Rolling.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".rolling").hover(
         function () { $(this).attr( 'src', Rolling.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', Rolling.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.rolling').each( function( key, elm ) { $('<img>').attr( 'src', Rolling.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }

});
*/
$(document).ready(function(){
	//select all the a tag with name equal to modal  
	$('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 = $(window).width();  
	  
		 //Set height and width to mask to fill up the whole screen  
		 $('#backgroundPopup').css({'width':maskWidth,'height':maskHeight});  
			
		 //transition effect
		$('#backgroundPopup').css("opacity",0.8);
		$('#backgroundPopup').fadeIn(500);
	  
		 //Get the window height and width  
		 var winH = $(window).height();  
		 var winW = $(window).width();  
					
		 //Set the popup window to center  
		 $(id).css('top', winH/2-$(id).height()/2);  
		 $(id).css('left', winW/2-$(id).width()/2);  
	  
		 //transition effect  
		 $(id).fadeIn(500);
	  
	});  
     
   //if close button is clicked  
   $('.popbtnclose').click(function (e) {  
       //Cancel the link behavior  
       e.preventDefault();  
       $('#backgroundPopup, .popup').fadeOut(200);
   });       
     
   //if mask is clicked  
   $('#backgroundPopup').click(function () {  
       $(this).fadeOut(200);
       $('.popup').fadeOut(200);
   });
	
/*
	$(document).keyup(function(e) {
		if(e.keyCode == 13) {
			$('#backgroundPopup').hide();
			$('.popup').hide();
		}
	});
*/
	//Rolling.rollover.init();
});