var jv_centerWidth = $( 'html' ).width() / 2;
var jv_centerHeight = $( 'html' ).height() / 2;;

$( document ).ready( function() {
});


// Show a picture in a lightbox
function loadPictLightBox( id, popup ) {
	$.ajax({
		type: 'POST',
		url: 'index.php?ctr=ajaxCommander&class=photosGetPhoto',
		data: {
			id: id
		},
		success: function( data ) {
			$( popup ).html( data );
			closeLightBox( popup );
		}
	});
}


// Show lightbox window
function manageLightBox( id, popup ) {
	var boxPopup = popup ? popup : '.boxPopup';
	var x = jv_centerWidth - ( $( boxPopup ).width() / 2 );
	var y = jv_centerHeight - ( $( boxPopup ).height() / 2 );
	
	// Display lightbox window
	if( $.browser.msie ) $( '.backgroundWindow' ).show();
	else  $( '.backgroundWindow' ).fadeIn();
	
	$( boxPopup ).css( {'top' : y, 'left' : x } ).fadeIn();
	
	if( id ) loadPictLightBox( id, boxPopup );
	else closeLightBox( boxPopup );
}


// Close lightbox window
function closeLightBox( popup ) {
	$( '.closeLightBox' ).click( function() {
		$( '.backgroundWindow' ).fadeOut();
		if( popup ) $( popup ).fadeOut();
		else $( '.boxPopup' ).fadeOut();
	});
}

