//GESTIONE DELL'OGGETTO INPUT
function clear_input(Obj, valore){
	if(Obj.value == valore){
		Obj.value = '';
	}
	Obj.style.color = '#000';
}

function original_input(Obj, valore){
	if(Obj.value == ''){
		Obj.value = valore;
		Obj.style.color = '#BCBDC0';
	}
}

function hide_input(){
	var Obj = document.getElementById('input-embed');
	if(Obj.style.display == 'none'){
		Obj.style.display = 'block';
		
	}else{
		Obj.style.display = 'none';
	}
}


//GESTIONE DEGLI ALERT
function Obj_close(Obj){
	Obj.style.display = 'none';
}


//SCROLLING DELLA PAGINA
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 70);
    }
}



//GESTIONE DEL CAMPO "CAMBIO PAGINA"
var star_value = 0;
function change_page(Obj_value, Obj){
	star_value = Obj_value;
	Obj.value = '';
	var El = document.getElementById('alert-number');
	El.id="alert-number-active";
	El.style.display = 'block';
}

function original_page(Obj_value, Obj){
	if(Obj_value == ''){
		Obj.value = star_value;
	}
	var El = document.getElementById('alert-number-active');
	El.id="alert-number";
	El.style.display = 'none';
}


//GESTIONE DEL CAMPO "EMOTICONS"
var attivo = false;
function open_emoticon(){
	attivo = true;
	var El = document.getElementById('content-emoticon');
	if(El.style.display == 'none'){
		El.style.display = 'block';
	}else{
		attivo = false;
		setTimeout("remove()", 200);
	}
}

function insert_emoticon(val){
	var Area_testo = document.getElementById('testo-commento');
	if(Area_testo.value == 'Inserisci qui il tuo messaggio'){
		Area_testo.value = val;
		Area_testo.style.color = '#000000';
	}else{
		Area_testo.value = Area_testo.value + val;
	}
	Area_testo.focus();
	attivo = true;
}

function remove(){
	if(attivo == false){
		document.getElementById('content-emoticon').style.display = 'none';
	}else{
		attivo = true;	
	}
}

function preview(){
	var textarea = document.getElementById('testo-commento');
	var volgarita = document.getElementById('volgarita');
/*
	//CONTROLLO PAROLACCE
	textarea.value = textarea.value.replace(/cazzo/gi,"xxxxx")
	textarea.value = textarea.value.replace(/troia/gi,"xxxxx")
	textarea.value = textarea.value.replace(/puttana/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/lesbica/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/fottiti/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/porco/gi,"xxxxx")
	textarea.value = textarea.value.replace(/figa/gi,"xxxx")
	textarea.value = textarea.value.replace(/pompino/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/sborra/gi,"xxxxxx")
	textarea.value = textarea.value.replace(/porca/gi, 'xxxxx')
	textarea.value = textarea.value.replace(/stronzo/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/stronza/gi,"xxxxxxx")
	textarea.value = textarea.value.replace(/coglioni/gi,"xxxxxxxx")
	textarea.value = textarea.value.replace(/minchia/gi,"xxxxxx")
	textarea.value = textarea.value.replace(/fottuta/gi,"xxxxxxxx")
	textarea.value = textarea.value.replace(/fottere/gi,"xxxxxxxx")
	textarea.value = textarea.value.replace(/idiota/gi,"xxxxx")
	textarea.value = textarea.value.replace(/coglioni/gi,"xxxxxxxx")
	textarea.value = textarea.value.replace(/coglione/gi,"xxxxxxxx")
	textarea.value = textarea.value.replace(/fuck/gi,"xxxx")	
	textarea.value = textarea.value.replace(/pirla/gi,"xxxxx")	
	textarea.value = textarea.value.replace(/deficente/gi,"xxxxxxxxx")
	textarea.value = textarea.value.replace(/scemo/gi,"xxxxx")	
	textarea.value = textarea.value.replace(/scema/gi,"xxxxx")
	textarea.value = textarea.value.replace(/vaffanculo/gi,"xxxxxxxxxx")	
	
	//CONTROLLO ORTOGRAFICO
	textarea.value = textarea.value.replace(/gesu/gi,"Gesù")
	textarea.value = textarea.value.replace(/gesù/gi,"Gesù")
	textarea.value = textarea.value.replace(/senzo/gi,"senso")
	textarea.value = textarea.value.replace(/senzi/gi,"sensi")
	textarea.value = textarea.value.replace(/penzi/gi,"pensi")
	textarea.value = textarea.value.replace(/penza/gi,"pensa")
	textarea.value = textarea.value.replace(/penzo/gi,"penso")
	textarea.value = textarea.value.replace(/aqua/gi,"acqua")
	textarea.value = textarea.value.replace(/un'amico/gi,"un amico")
	textarea.value = textarea.value.replace(/un'altro/gi,"un altro")
	textarea.value = textarea.value.replace(/un amica/gi,"un'amica")
	textarea.value = textarea.value.replace(/un altra/gi,"un'altra")
	textarea.value = textarea.value.replace(/provincie/gi,"province")
	textarea.value = textarea.value.replace(/superfice/gi,"superficie")
	textarea.value = textarea.value.replace(/scenza/gi,"scienza")
	textarea.value = textarea.value.replace(/conoscienza/gi,"conoscenza")
	textarea.value = textarea.value.replace(/coscenza/gi,"coscienza")
	textarea.value = textarea.value.replace(/sufficente/gi,"sufficiente")
	textarea.value = textarea.value.replace(/blù/gi,"blu")
	textarea.value = textarea.value.replace(/propio/gi,"proprio")
	textarea.value = textarea.value.replace(/accellerare/gi,"accelerare")
	textarea.value = textarea.value.replace(/collutazione/gi,"colluttazione")
	textarea.value = textarea.value.replace(/eccezzionale/gi,"eccezionale ")
	textarea.value = textarea.value.replace(/esterefatto/gi,"esterrefatto")
	textarea.value = textarea.value.replace(/pressocché/gi,"pressoché")
	textarea.value = textarea.value.replace(/esterefatto/gi,"esterrefatto")
	textarea.value = textarea.value.replace(/appropiato/gi,"appropriato")
	textarea.value = textarea.value.replace(/areoporto/gi,"aeroporto")
	textarea.value = textarea.value.replace(/esterefatto/gi,"esterrefatto")
*/
	//punteggiatura
	//textarea.value = textarea.value.replace(/,[\s]*/g,", ");
	//textarea.value = textarea.value.replace(/\.[\s]*/g,". ");
	//textarea.value = textarea.value.replace(/\?[\s]*/g,"? ");
	//textarea.value = textarea.value.replace(/\![\s]*/g,"! ");

	
	if(textarea.value.search('xxxx') == '-1'){
		volgarita.style.display='none'
		textarea.style.border = '1px solid #999'
	}else{
		volgarita.style.display ='block'
		textarea.style.border = '1px solid red'
	}
}



function alt(){
	var avviso = document.getElementById('volgarita');
	avviso.style.display = 'block';
}


//-----------------OPZIONI CHAT
 var stile = "top=10, left=10, width=430, height=500, status=no, menubar=no, toolbar=no scrollbar=no";
     function Popup(apri) {
        window.open(apri, "", stile);
}



/*-------------------------------------------------FUNZIONI DI ANTEPRIMA PER IL DIZIONARIO------------------------------------------------------------*/
function anteprima(){
	var A = document.getElementById('diz_anteprima');
	var p = document.getElementById('diz_anteprima_p');
	var h2 = document.getElementById('diz_anteprima_h2');
	var text = document.getElementById('diz_testo_ins').value;
	var voce = document.getElementById('diz_voce_ins').value;
	
	text = text.replace(/\n/g,"<br />");
	h2.innerHTML = voce;
    p.innerHTML = text;
	
	A.style.display = 'block';
	document.getElementById('diz_form').style.display = 'none';
	document.getElementById('diz_but_anteprima').style.display = 'none';
	document.getElementById('diz_but_ins').style.display = 'inline';
	document.getElementById('diz_but_mod').style.display = 'inline';
}

function modifica(){
	var A = document.getElementById('diz_anteprima');
	var p = document.getElementById('diz_anteprima_p');
	var h2 = document.getElementById('diz_anteprima_h2');
	var text = document.getElementById('diz_testo_ins').value;
	var voce = document.getElementById('diz_voce_ins').value;
	text = text.replace(/\n/g,"<br />");
	//text = text.replace("<br />","\n");
	
	A.style.display = 'none';
	document.getElementById('diz_form').style.display = 'block';
	document.getElementById('diz_but_anteprima').style.display = 'inline';
	document.getElementById('diz_but_ins').style.display = 'none';
	document.getElementById('diz_but_mod').style.display = 'none';
}

function elimina(){
	var A = document.getElementById('diz_anteprima');
	var p = document.getElementById('diz_anteprima_p');
	var h2 = document.getElementById('diz_anteprima_h2');
	var text = document.getElementById('diz_testo_ins').value;
	var voce = document.getElementById('diz_voce_ins').value;
	
	voce = "";
	text = "";
	
	A.style.display = 'none';
	document.getElementById('diz_form').style.display = 'block';
	document.getElementById('diz_but_anteprima').style.display = 'inline';
	document.getElementById('diz_but_ins').style.display = 'none';
	document.getElementById('diz_but_mod').style.display = 'none';
}











