function Hovertest()
{
    this.obj;
    this.imageType;
    this.todoItemId;
    this.imageToDisplay;
    this.todoItemState;
    
    this.init = function(obj, imageType, todoItemId)
    {
        this.obj            = obj;
        this.imageType      = imageType;
        this.todoItemId     = todoItemId;
        this.imageSwap();
    };

    
    this.imageSwap = function()
    {
        if (this.imageType == 1)
        {
            this.imageToDisplay = "list-remove.png";
            this.todoItemState = 0;
        }
        else
        {
            this.imageToDisplay = "dialog-ok-apply.png";
            this.todoItemState = 1;
        }
        
        $(this.obj).stop();
        var subObj = this.obj;
        var idis = this.imageToDisplay;
        var currentBg = $(this.obj).css("backgroundImage");
        $(this.obj).fadeTo(200, 0.0, function()
        {
            $(subObj).css({"background-image" : "url(./skins/slik/images/"+idis+")"});
            $(subObj).fadeTo(200, 1.0);
        });
        
        $(this.obj).mouseout(function () {
            $(subObj).stop();
            $(subObj).fadeTo(200, 0.0, function(){
                   $(subObj).fadeTo(200, 1.0);
                   $(subObj).css("backgroundImage", currentBg);
            });
        });
        
        //alert("OLD :: " + this.imageType);
        var tdis = this.todoItemState;
        var tdid = this.todoItemId;
        $(this.obj).click(function(){
            $(subObj).css("backgroundImage", "url(./skins/slik/images/"+idis+")");
            currentBg = idis;
            $.get("./ajax.php", { todoid: tdid, todostate: tdis, act: "updateTodoItem" } );
            
        jQuery.blockUI({ css: { 
            border: '4px solid grey', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: '.5', 
            color: '#000' 
        },
            message : 'Settings saved!'});
        setTimeout(jQuery.unblockUI, 500);
        });
    };
    

}
var HoverClass = new Hovertest();

function removeItem(id, name, obj)
{
    var answer = confirm("Are you sure you want to delete: " + name + "?")
    if (answer){
        
        $.get("./ajax.php", { todoid: id, act: "deleteTodoItem" } );
        jQuery.blockUI({ css: { 
            border: '4px solid grey', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: '.5', 
            color: '#000' 
        },
            message : 'Settings saved!'});
        setTimeout(jQuery.unblockUI, 500);
        
        $(obj.parentNode).fadeOut("slow");
    }
    
}


function hoverbg(obj, imgType, todoItemId)
{
    var obj;
    var imgType;
    var currentBg = $(obj).css("backgroundImage");
    var imageChanged = false;
    var imageToDisplay;
    var todoItemId;
    var todoItemState;
    var timeoutRunning = false;
    
    if (imgType == 1)
    {
        imageToDisplay = "list-remove.png";
        todoItemState = 0;
    }
    else
    {
        imageToDisplay = "dialog-ok-apply.png";
        todoItemState = 1;
    }
    
    HoverClass.hover();
    
    $(obj).stop();
    $(obj).fadeTo(200, 0.0, function(){
        $(this).css("backgroundImage", "url(./skins/slik/images/"+imageToDisplay+")");
        $(this).fadeTo(200, 1.0);
    });
    
    $(obj).click(function(){
        $(this).css("backgroundImage", "url(./skins/slik/images/"+imageToDisplay+")");
        currentBg = imageToDisplay;
        imgType = todoItemState;
        $.get("./ajax.php", { todoid: todoItemId, todostate: todoItemState, act: "updateTodoItem" } );
        jQuery.blockUI({ css: { 
            border: '4px solid grey', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: '.5', 
            color: '#000' 
        },
            message : 'Settings saved!'});
        setTimeout(jQuery.unblockUI, 500);
    });
    
        $(obj).mouseout(function () {
            $(obj).stop();
            $(this).fadeTo(200, 0.0, function(){
                   $(this).fadeTo(200, 1.0);
                   $(this).css("backgroundImage", currentBg);
            });
        });
    
}
