var DeleteSearchOverlay = function (id) {
	this.overlay = new Overlay(id, {	width: '350px',
										draggable: true,
										visible: false,
										zindex: 1000,
										fixedcenter: true,
										constraintoviewport: true
	});

	// Identifica un overlay a pił passi
	this.overlay.stepOverlay = true;
	
	this.show = function (anchorShow, text, anchorHide) {
		this.overlay.show(null, this.overlay.generateOverlay(text), null);
	};
	
	this.stepOne = function (overlay, searchId) {
		this.overlay.scriptUrl = "http://" +  conf.baseUrl + "/overlay_manager/cancella_ricerca";
		var actionString = 'overlay=' + overlay + '&searchId=' + searchId;
		
		this.overlay.setContentByAjax(actionString, null, null, this);		
	};
	
	this.stepTwo = function (overlay, searchId) {
		this.overlay.scriptUrl = "http://" +  conf.baseUrl + "/gui_manager/delete_search";
		var actionString = 'overlay=' + overlay + '&searchId=' + searchId;
		this.overlay.getResultByAjax(actionString, this, this.setBodyByResult);
	};
	
	this.setBodyByResult = function (obj, parsed_result) {
		var responseText = parsed_result.header + parsed_result.body;
		
		obj.show(null, responseText, null);
		if(obj.overlay.isSuccessResponse(parsed_result.result)) obj.deleteItem('l' + parsed_result.params.searchId)
	};
	
	this.deleteItem = function (itemId) {
		var item = YAHOO.util.Dom.get(itemId);
		var parent = item.parentNode;
		var anim = new YAHOO.util.Anim(item, { opacity: { from: 1, to: 0 } }, .5);
		anim.onComplete.subscribe(function() {
			parent.removeChild(item);
		});
		anim.animate();
	};
};