/**
 * Javascript Modal Window Component
 *
 * This requires jqModal to be included
 */

// setup the dialog box
$(document).ready(function() {
    $('#dialog').jqm();
});

var modalComponent = function(){
    
    var debug        = false;
        
    var log = function(data){
        if(debug){
            console.log(data);
        }
    }
        
    return{
        
        setDebug: function(enable){
            debug = enable;
        },
        
        log : function(message){
            log(message);
        },
        
        showUserProfile : function(userid){
            
            $('#dialog .content').html('Loading...');
            
            $('#dialog .content').load(
                baseUrl + '/users/index/info',
                { id : userid}
            );
            
            $('#dialog').jqmShow();
            
        },
        
        showFriendSelector : function(){
            $('#dialog .content').html('Loading...');
            
            $('#dialog .content').load(
                baseUrl + '/users/friends/selector'
            );
            
            $('#dialog').jqmShow();
        },
        
        showUserRankInfo : function(){
            $('#dialog .content').html('Loading...');
            
            $('#dialog .content').load(
                baseUrl + '/users/rank/info'
            );
            
            $('#dialog').jqmShow();
        },
        
        showLoggedOutError : function(){
            $('#dialog .content').html('Loading...');
            
            $('#dialog .content').load(
                baseUrl + '/users/index/loggedouterror'
            );
            
            $('#dialog').jqmShow();
        },
        
        showHtml : function(html){
            
            $('#dialog .content').html(html);
            $('#dialog').jqmShow();
            
        }
        
    }
}();
