Common={
	
	// lingua
	lang: function(){
		var href = location.pathname;
		var cut = href.split('/');
		switch(location.host){
			default: var lingua = cut[1]; break; // online
			case 'xxx': var lingua = cut[3]; break; // locale
			case 'lavorazioni.addviser.net': var lingua = cut[2]; break; // lavorazioni
		}
		return lingua;
	},

	
	// nome dominio
	myhost: function(){
		var href = location.pathname;
		var cut = href.split('/');
		switch(location.host){
			default: var path = location.host; break; // online
			case 'xxx': var path = location.protocol+'//'+location.host+'/'+cut[1]+'/sito/'; break; // locale
			case 'lavorazioni.addviser.net': var path = location.protocol+'//'+location.host+cut[1]+'/'; break; // lavorazioni
		}
		return path;
	},

	

	// popup errore - apertura
	errore:function(messaggio,elemento){
		
		/* nascondo i select */
		var selects = document.getElementsByTagName("select"); 
		for (var i = 0; i < selects.length; i++) { 
			selects[i].style.visibility='hidden';
		}

		/* scrivo i div contenitori */
		var objBody = $$('body')[0];
		objBody.appendChild(Builder.node('div',{id:'error'}));
        objBody.appendChild(Builder.node('div',{id:'err_msg'}));
		err = $('error');
		msg = $('err_msg');
		err.style.display='none';
		msg.style.display='none';

		/* calcolo altezza complessiva della finestra */
		bodyWidth = $$('body')[0].getWidth();
		viewWidth = self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
		bodyHeight = $$('body')[0].getHeight();
		viewHeight = self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
		
		/* assegno altezza e larghezza */
		err.style.width =  bodyWidth > viewWidth  ?  bodyWidth+'px' : viewWidth+'px';
		err.style.height = bodyHeight > viewHeight  ?  bodyHeight+'px' : viewHeight+'px';
		msg.style.marginTop = ((bodyHeight > viewHeight  ?  bodyHeight : viewHeight)/2)-75+'px';

		/* scrivo l'errore */
		msg.innerHTML = '<div id="close_btn" onclick="Common.close(\''+elemento+'\');"></div><div class="cleaner"></div>'+messaggio+'<br/><br/><br/>';
		new Effect.Appear(err, {to:0.8, from:0.0, duration:0.3, afterFinish:function(){
				new Effect.Appear(msg, {to:1.0, from:0.0, duration:0.3});
			}
		});
	},

	

	// popup errore - chiusura
	close:function(elemento){
		err = $('error');
		msg = $('err_msg');
		new Effect.Opacity(msg, {to:0.0, from:1.0, duration:0.3, afterFinish:function(){
				new Effect.Appear(err, {to:0.0, from:1.0, duration:0.3, afterFinish:function(){
					err.remove();
					msg.remove();
					/* riappaiono i select */
					var selects = document.getElementsByTagName("select"); 
					for (var i = 0; i < selects.length; i++) { 
						selects[i].style.visibility='visible';
					}
					$(elemento).focus();
				}});	
			}
		});
	}


}
