﻿function lPager(url,psize,back_c,id)
{
    this.Url = url;
    this.Amount = psize;
    this.LastCall = 0;
    this.Callback = back_c;    
    this.TotalCount = null;
    this.Id = id;
    this.curdir = "";    
    this.page = function(dir,callback)
    {
        this.LastCall = dir;
        this.load(callback,this);                        
    }    
    this.load = function(callback,caller)
    {        
        $.ajax({
        type: "POST",
        url: this.Url,    
        data: { action: "pageImages", id : caller.Id, start : caller.LastCall, amount : caller.Amount},        
        dataType: "json",
        success: function(msg) { callback(msg); }
        });              
    }                
}

function Service(url)
{
    this.url = url;
    this.postJSON = function(method,_data,success)
    {        
        $.ajax({
        type: "POST",
        url: url + "/" + method,    
        data: $.toJSON(_data),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            success(msg);
        }
        });         
    }
    
    this.getJSON = function(method,data,callback)
    {
        $.getJSON(url + "/" + method,data,        
		function(jdata){
		    callback(jdata);		          
		});
    }
}
