// Peekanews.com JavaScript Document
$(document).ready(function() {
    if($(".thumb-wrapper").length > 0) {
        // Masonry.js - reorder thumbs
        $(".thumb-wrapper").masonry({
            itemSelector: '.thumb',
            isAnimated: true
        });
        // Fade to black for rest of thumbs on mouseover
       // $(".thumb-wrapper .thumb").mouseover(function() {
       //     $("#page-body .thumb").not(this).stop().animate({
       //         opacity: 0.5
       //     }, 200) ;

       // }) ;
       // $(".thumb-wrapper .thumb").mouseout(function() {
        //    $("#page-body .thumb").not(this).stop().animate({
         //       opacity: 1
          //  }, 200) ;
      //  });
    }
    if($(".links").length > 0) {
        $(".links a").click(function() {
            lightboxIn() ;
        });
    }
});
function lightboxIn() {
    $("#lightbox-wrapper").show() ;
    $("#lightbox-background").fadeTo('slow', 0.8) ;
    $("#lightbox").fadeIn() ;
    $("#lightbox-inner").vAlign() ;
    $("#lightbox .row-buttons input").click(function() {
        lightboxOut() ;
    });
}
function lightboxOut() {
    $("#lightbox-background").fadeOut('fast') ;
    $("#lightbox").fadeOut('slow', function() {

        $("#lightbox-wrapper").hide() ;
    }) ;
}
(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = Math.ceil((ph-ah) / 2);
	$(this).css('margin-top', mh);
	});
};
})(jQuery);

