// JavaScript Document

function apri_annuncio(id,stampa) {
Richiesta('hit_annuncio.aspx?id=' + id,'hit_annuncio',stampa);

document.getElementById("hit_annuncio").style.display='inline';

//posx=e.clientX+document.documentElement.scrollLeft;
posy=document.documentElement.scrollTop + 240;

document.getElementById("hit_annuncio").style.top=posy + "px";

}


function galleria_foto_annuncio(foto) {
	
	document.getElementById("ante_foto_hit_annuncio").innerHTML="<img src='" + foto + "' width='100%'>";
	
}


function print_ann() {
top_or=document.getElementById('hit_annuncio').style.top;
document.getElementById('hit_annuncio').style.top='0px';
window.print();
document.getElementById('hit_annuncio').style.top=top_or;
setTimeout("chiudi_annuncio()",2000);
}

function chiudi_annuncio() {
document.getElementById('hit_annuncio').style.display="none";
document.getElementById('hit_annuncio').innerHTML="";
}

function invia_amico(tnome,tmail,smail,id,div_dest,div_form) {
	
	if(tnome != "" && tmail != "" && smail != "") {
	document.getElementById(div_form).style.display='none';
		Richiesta('funzioni.aspx?az=amico_send&tnome='+tnome+'&tmail='+tmail+'&smail='+smail+'&id='+id+'',div_dest,div_dest);
	
	}else{
	document.getElementById(div_dest).innerHTML="Annuncio non Inviato. Compilare tutti i Campi!";	
	}
}


function invia_ate(tmail,id,div_dest,div_form) {
	
	if(tmail != "") {
	document.getElementById(div_form).style.display='none';
		Richiesta('funzioni.aspx?az=ate_send&tmail='+tmail+'&id='+id+'',div_dest,div_dest);
	
	}else{
	document.getElementById(div_dest).innerHTML="Annuncio non Inviato. Compilare tutti i Campi!";	
	}
}


function avvia_ricerca() {

	testo=document.getElementById('testo_ricerca').value;
	cate_sotto=document.getElementById('categoria_ricerca').options[document.getElementById('categoria_ricerca').selectedIndex];

	testo=testo.replace(/ /g,"-");
	
	if (cate_sotto.value == "" || cate_sotto.value == null || cate_sotto.value == 'null' || cate_sotto.value == 0) {
		pre="tutto-0";
	}else{
		pre=cate_sotto.getAttribute('name') + "-" + cate_sotto.value;
	}
	
	percorso="annunci_ricerca_" + pre + "-" + testo + ".aspx";
	
	document.location=percorso;
		
	return false;
}

function ritorna_txt_ric(txt,az) {
	if(az==2){
	if (txt == "") {
		return pre_testo;
	}else{
	return txt;
	}
	}
	
	if(az==1){
		pre_testo=txt;
		return "";
	}
}

function check(val1,val2,id) {

	if(val2.length>=val1.length) {
	if(val1==val2) {
		document.getElementById(id).style.backgroundColor="#00CC33";
	}else{
		document.getElementById(id).style.backgroundColor="#FF0000";
	}
	}else{
		document.getElementById(id).style.backgroundColor="";
	}
}

function chiedi(nome) {
	var chied=confirm('Sicuro di eliminare questo Annuncio?');
	if (chied) {
		return true;
	}else{
	return false;
	}
	
}

function pop_info_foto(foto,id) {

	Richiesta('foto_azioni.aspx?id=' + id + '&ft=' + foto,'azioni_foto','azioni_foto');

document.getElementById("azioni_foto").style.display='inline';

//posx=e.clientX+document.documentElement.scrollLeft;
posy=document.documentElement.scrollTop + 200;

document.getElementById("azioni_foto").style.top=posy + "px";
}


function pop_info_foto_pdr(foto,id) {

	Richiesta('foto_azioni_pdr.aspx?id=' + id + '&ft=' + foto,'azioni_foto','azioni_foto');

document.getElementById("azioni_foto").style.display='inline';

//posx=e.clientX+document.documentElement.scrollLeft;
posy=document.documentElement.scrollTop + 200;

document.getElementById("azioni_foto").style.top=posy + "px";
}


var form_inviare="";
function sistema_dipendenze(formn,tipo) {
	form_inviare=formn;
	document.getElementById('dipendenza_cat_mex').innerHTML="Questa " + tipo + " ha degli Annunci che dipendono da essa!<br><br>Prima di ELIMINARE la " + tipo + ", selezionare una categoria/sottocategoria di destinazione.";
	
	document.getElementById('dipendenza_cat').style.display='inline';
	
	posy=document.documentElement.scrollTop + 150;

document.getElementById("dipendenza_cat").style.top=posy + "px";
	
}



function esegui_js_hitannuncio() {
var codici=document.getElementById('hit_annuncio').getElementsByTagName('script');
eval(codici[0].text);
add_all_foto();
}
