/* Call back function for XeroxJS object */
/* Functions name must by like PHP script class XeroxAjax */
var callBackXeroxJS = {
		test: function(result) {
			alert(result);
		},
		deleteProductImage: function(result) {
			if (result == 1)
			{
				var message = '<font color="red" size="4">Zdjęcie produktu zostało usunięte z bazy danych.</font>';
				document.getElementById('delete_product_image').innerHTML = message;
			}
		}
    };

var XeroxJS = {
    
	optionsProduct: {
        serial: '',
        id: ''
    },
    // synchronize Ajax object
	provider: new XeroxAjax(),
	// asynchronize Ajax object. Object has a callback function.
    providerCallBack: new XeroxAjax(callBackXeroxJS),
	init: function() {
    },
    
    testAjax: function (options) {
	    alert(this.provider.test(options));
		
	},
	
	testAjaxCallBack: function(options) {	
		this.providerCallBack.test(options);
    },
    
    checkSerialProduct: function(serial, id) {
	    
	    var options = this.optionsProduct;
	    if (serial != '')
	    {
		    options.serial = serial;
		    if (id == '')
		    {
			    id = 0;
		    }
		    options.id = id;
	        var ret = this.provider.checkSerialProduct(options);
	        if (ret==1)
            {
	            alert('Uwaga!!. Produkt o takim numerze seryjnym już istnieje.');
            }
        }
    },
    deleteProductImage: function(id) {
	   this.providerCallBack.deleteProductImage(id); 
    },
    
    /* can't by callabck function*/
    getStepInfo: function(id, divElem) {
	   
	   return this.provider.getStepInfo(id, 1); 
    },
    
    getStepInfoModuleElement: function(id) {
	    return this.provider.getStepInfoModuleElement(id);
    },
    
    getStepDependencies: function(productId, id, nextId, addIds) {
        return this.provider.getStepDependencies(productId, id, nextId, addIds);
    }
	
};
