
function init_popups() {
    $('a[class=popup-link]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();
        
        //Get the A tag
        var box = $(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
        $('#mask').css({'width':maskWidth,'height':maskHeight});
         
        //transition effect     
        $('#mask').fadeTo("fast",0.8);  
     
        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
        
		//Set the popup window to center
		 $(box).css({'top':(winH - $(box).height())/2,'left':(winW - $(box).width())/2});
		 $(box).fadeTo("fast",1.0);
     
    });
    
  //if close button is clicked
    $('.popup .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
        $('.popup').hide();
        $('#mask').hide();
    });     
     
    //if mask is clicked
    $('#mask').click(function () {
        $(this).hide();
        $('.popup').hide();
    }); 
}

function init_slideshows() {
    $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 10000,
		pager: '#slideshow-nav',
		pause: 1
	});
    $('.slideshow-right').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 5000
	});
}

function init_lightbox() {
	$('ul.gallery a').lightBox(); 
}

$(document).ready(function() {
      init_popups();
      init_slideshows();
      init_lightbox();
      
      $("#get-deal").click(function(e) {
      	e.preventDefault();
      	$.ajax({
      		'url':'deal.php',
      		'success':function(data) {
      			$("#coupon").html(data);
      			}
      		});
      });
});

