/*
 * t is a prototype transport
 * so this can be used as the onsuccess for a Ajax.Request(...)
 */
function _showImageViewerInLitebox( t )
{
	/*
	 * Inject the content into the litebox, with additional form tags
	 * which pipe the submit through ajax
	 */
	$( '#modal_form' ).html( t );

    _showLitebox();
	return false;
}

function _updateImageViewerInLitebox( t )
{
	/*
	 * Inject the content into the litebox, with additional form tags
	 * which pipe the submit through ajax
	 */
	$( '#modal_form' ).html( t );

	return false;
}

function modalOpen( dialog )
{
	dialog.overlay.show(); //fadeIn( 300, function () {
	    dialog.overlay.bind( 'click', function() { modalClose( dialog ); } );
		dialog.container.show();
		dialog.data.show();
	//});
}

function modalClose( dialog )
{
    dialog.container.hide();
	dialog.data.hide();
	dialog.overlay.hide(); //fadeOut( 300, function () {
		$.modal.close();
	//});
}

function _showLitebox() {
	
    $( '#modal_form' ).modal( {
        onOpen: modalOpen,
        onClose: modalClose
    } );
    
	return false;
}

function open_news_gallery( news_id, id, image_width, image_height, image_path, count ) {
    
    // reset position
    index_id = id;
    // end reset
    
	var url = HTML_ROOT + '/includes/plugin_image_viewer.inc.php'
    	$.ajax( {
           type: "GET",
           url: url,
           data: 'news_id=' + news_id + '&width=' + image_width + '&height=' + image_height + '&image=' + image_path + '&count=' + count + '&index=' + index_id,
           success: _showImageViewerInLitebox
        } );

	return false;
}