var SendsmsOverlay = function (id) {
	this.overlay = new Overlay(id, {	width: '420px',
										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) {
		/*if(!text[0].body) this.overlay.show(null, this.overlay.generateOverlay(text), null);
		else {
			this.overlay.show(null, this.overlay.generateOverlay(text[0].body), null);
			this.reloadPage(text[0].params.t_profile_id);
		}*/
		this.overlay.show(null, this.overlay.generateOverlay(text), null);
	};
	
	this.stepOne = function (overlay, mtype, aaa_fn, t_nick, t_pid, euro) {
		this.overlay.color = 'blu';
		
		// this.show è il text che viene richiamato nell'html
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/overlay_manager/send_" + mtype;
		
		var actionString = 'overlay=' + overlay + '&t_profile_id=' + t_pid + '&t_nick=' + t_nick + (euro ? '&euro=' + euro : '') + '&aaa_fn=' + aaa_fn;
		
		// definisce cosa fare nello step 2, in realtà chiama step 2
		this.overlay.setContentByAjax(actionString, null, null, this);
	};
	
	this.stepTwo_old = function (overlay, params, mtype) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/gui_manager/send_" + mtype; 
		var actionString = Utilities.createActionString(params) + '&type=' + mtype;
		
		this.overlay.stepTwo(actionString, null, null, this);
	};
	
	this.stepTwo = function (overlay, formName, mtype) {
		this.overlay.scriptUrl = "http://" + conf.baseUrl + "/gui_manager/send_" + mtype;
		this.overlay.setContentByAjax('', null, null, this, formName, true);
	};
	
	this.reloadPage = function (t_pid) {
		var url = location.href.split('/');
		if(url[3] == 'message' && url[4] == 'outbox') {
			reload_ajax('http://' + conf.baseUrl + '/message/outbox?method=outbox', 'outbox', 'container message');
		} else if(url[3] == 'message' && url[4] == 'chronology') {
			reload_ajax('http://' + conf.baseUrl + '/message/chronology/' + t_pid + '/1?method=chronology', 'cronologia', 'container');
		}
	};
};