$(document).ready(function()
{
	$('table.item-info').each(function(){
	    $(this).find('tr:even').css('backgroundColor', '#f5f0fc');
	});
    
    $('#modalWindowsOverlay').click(function() { closePreview(); });
   
   $('#content').each(function(){
	   $(this).find('.previewPhotoLink').click(function () { 
           var href_addrr = $(this).attr("href").split('/');
           var photo_id  = href_addrr[href_addrr.length - 1];
           showPhotoPreview(photo_id);
           return false;
      });
      
      	   $(this).find('.previewVideoLink').click(function () { 
           var href_addrr = $(this).attr("href").split('/');
           var file_id  = href_addrr[href_addrr.length - 1];
           showVideoPreview(file_id);
           return false;
      });
      
      
	});
});

function showPhotoPreview(image_id)
{
    $.get("/photos/preview/" + image_id, function(data)
    { 
      $('.modalPhotoWindow').html(data);
      
    });
    
    $('#modalWindowsOverlay').show();
    $('.modalPhotoWindow').fadeIn("slow");
}

function showVideoPreview(file_id)
{
    $.get("/videos/preview/" + file_id, function(data)
    { 
      $('.modalVideoWindow').html(data);      
    });
    
    $('#modalWindowsOverlay').show();
    $('.modalVideoWindow').fadeIn("slow");
}


function closePreview()
{
    $('#modalWindowsOverlay').fadeOut("slow");;
    $('.modalPhotoWindow').fadeOut("slow").empty();
    $('.modalVideoWindow').fadeOut("slow").empty();
}