var dialogBookmark = null;
var _selected_bookmark_id = "";

// Functions
function routeBookmarkDialog(object_id, content_type_id) {

    if (_MMF_GLOBAL.user.user_id == "") {
        
        var redirect_url = _MMF_GLOBAL.page_urls.login_register;
        redirect_url += "?login_required=1&next=" + this.window.location.href;
        this.window.location.replace(redirect_url);
    
    } else {
        
    	if (!object_id) { alert("Missing ID"); }
    	div_id = "user_bookmark_"+object_id;
    	
    	// In order to Internationalize Button
    	var dialog_buttons = {}; 
    	dialog_buttons[_MMF_GLOBAL.text.close_button] = function() {
        	$(this).dialog("close");
        	$(this).dialog('destroy');
        	$(this).remove();
    	};
    	
    	// Render Dialog
        var dialogBookmark = $('<div id="'+div_id+'"></div>')
            .dialog({
                autoOpen: false,
                title: _MMF_GLOBAL.text.user_bookmark_title + ' Route',
                buttons: dialog_buttons,
    			width: 400,
    			zIndex: 9999,
                close: function(event, ui) { 
               		$(this).dialog('destroy');
               		$(this).remove(); 
               	}    
            });
    	
    	render_data = {
    		"object_id": object_id,
    		"content_type": content_type_id,
    		"render": 1 	
    	};
    	
        $('#'+div_id).load(_MMF_GLOBAL.page_urls.user_bookmark_form, render_data, function() {
        	dialogBookmark.dialog('open');
        	});
    }
}



function iveDoneThisRouteDialog(route_id) {

    if (!route_id) { alert("Missing Route ID"); }
    div_id = "ive_done_this_route_"+route_id;
    
    // In order to internationalize button
    
    // Render Dialog
    var dialogIveDoneThisRoute = $('<div id="'+div_id+'"></div>')
        .dialog({
            autoOpen: false,
            title: _MMF_GLOBAL.text.ive_done_this_route_title,
            width: 400,
			modal: true,
            close: function(event, ui) { 
                $(this).dialog('destroy');
                $(this).remove();
                $(".bookmark_ive_done").attr("checked", false);
            }    
        });
    
    render_data = {
        "route_id": route_id,
        "render": 1     
    };
    
    $('#'+div_id).load(_MMF_GLOBAL.page_urls.ive_done_this_route_form, render_data, function() {
        dialogIveDoneThisRoute.dialog('open');
        });
    
}

