var buildModal = function (modalClasses) {

    var $modal = $('#dialog-box-modal');

    if(!$modal.length)
    {
    	$modal = $('<div class="modal fade" id="dialog-box-modal" tabindex="-1" role="dialog"  aria-hidden="true">'
	        +'<div class="modal-dialog ' + modalClasses + '">'
	            +'<div class="modal-content">'
	            +'</div>'
	        +'</div>'
	    +'</div>');
	    $('body').append($modal);
    }
    $('body').append($modal);

    return $modal;
};

showModal = function(url){

    var $modal = buildModal();

    $.get(url, {}, function(data){
        $('.modal-content', $modal).html(data);
        $modal.modal('show');
    });
};

$(document).on('click', '.dialog-box', function(){
	var $button = $(this);
    var modalClasses = $(this).data('modal-classes') || '';
    var $modal = buildModal(modalClasses);

    if($button.attr('href') || $button.attr('data-href'))
    {
    	var url = $button.attr('href') ? $button.attr('href') : $button.attr('data-href');
    	$.get(url, {}, function(data){
    		$('.modal-content', $modal).html(data);
    		$modal.modal('show');
    	});
    }
    return false;
});
