/*
 * t is a prototype transport
 * so this can be used as the onsuccess for a Ajax.Request(...)
 */
function _showPopupWindow( 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 ) {
	
	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,
       success: _showPopupWindow
    } );

	return false;
}

function open_property_gallery( property_id, id, image_width, image_height, image_path, count, title, desc ) {
    
	index_id = id;
	
	var url = HTML_ROOT + '/includes/plugin_image_property_viewer.inc.php';
	$.ajax( {
       type: "GET",
       url: url,
       data: 'property_id=' + property_id + '&width=' + image_width + '&height=' + image_height + '&image=' + image_path + '&count=' + count + '&index=' + index_id + '&title=' + title + '&desc=' + desc,
       success: _showPopupWindow
    } );

	return false;
}

function open_floorplan( space_id, width, height ) {
    
	var url = HTML_ROOT + '/includes/plugin_image_viewer_floorplan.inc.php';
	$.ajax( {
       type: "GET",
       url: url,
       data: 'space_id=' + space_id + '&width=' + width + '&height=' + height,
       success: _showPopupWindow
    } );

	return false;
}