﻿// JScript File

    var FotoDal = new Class({
	    'Implements': Events,
	    'initialize': function()
	    {
	        this.json = null;
	        this.request_success = function(json){this.onGetFotos(json);}.bind(this);
	    },
	    'onGetFotos': function(fotos)
	    {
	        data = {};
	        
	        for(var i = 0; i < fotos.length; i++)
	        {
	            var foto = fotos[i];
	            var path = '.image?id='+ foto.Id +'&thumbnail=false';
	            var pathThumbnail = '.image?id='+ foto.Id +'&thumbnail=true';
	            data[path] = {'caption': '', 'thumbnail': pathThumbnail };
	        }
	        
	        this.fireEvent('GetFotos', [this, data]);
	    },
	    'getFotos': function()
	    {
	        var request = new Request.JSON({
	            'url': 'App_Services/FotoService.asmx/GetFotos',
	            'onSuccess': this.request_success
	        }).get();
	    },
	    'getFotosDestaque': function()
	    {
	        var request = new Request.JSON({
	            'url': 'App_Services/FotoService.asmx/GetFotosDestaque',
	            'onSuccess': this.request_success
	        }).get();
	    }
	});


