




/*
     FILE ARCHIVED ON 14:25:26 Jun 29, 2007 AND RETRIEVED FROM THE
     INTERNET ARCHIVE ON 12:11:22 Jan 6, 2012.
     JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.

     ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
     SECTION 108(a)(3)).
*/
if(!document.getElementById){
	if(document.all)
		document.getElementById=function(){
			if(typeof document.all[arguments[0]]!="undefined")
				return document.all[arguments[0]]
			else
				return null
		}
	else if(document.layers)
		document.getElementById=function(){
			if(typeof document[arguments[0]]!="undefined")
				return document[arguments[0]]
			else
				return null
		}
}

if(!document.getElementByName){
	if(document.all)
		document.getElementByName=function(){
			if(typeof document.all[arguments[0]]!="undefined")
				return document.all[arguments[0]]
			else
				return null
		}
	else if(document.layers)
		document.getElementByName=function(){
			if(typeof document[arguments[0]]!="undefined")
				return document[arguments[0]]
			else
				return null
		}
}

var cat_animazione = new Image();
cat_animazione.src = "/images/cat_animazione.gif";

var trasparente = new Image();
trasparente.src = "/images/trasparente.gif";

function pulsante_categoria_over(oggetto, step){
	oggetto.className += "_over";
	oggetto.tBodies[0].rows[1].cells[0].getElementsByTagName("a")[0].className += "_over";
	oggetto.tBodies[0].rows[0].cells[0].getElementsByTagName("img")[0].src = cat_animazione.src;
}

function pulsante_categoria_out(oggetto){
	oggetto.className = oggetto.className.replace("_over", "");
	oggetto.tBodies[0].rows[1].cells[0].getElementsByTagName("a")[0].className = oggetto.tBodies[0].rows[1].cells[0].getElementsByTagName("a")[0].className.replace("_over", "");
	oggetto.tBodies[0].rows[0].cells[0].getElementsByTagName("img")[0].src = trasparente.src;
}

function pulsante_generale_over(oggetto){
	oggetto.className += "_over";
	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className += "_over";
}

function pulsante_generale_out(oggetto){
	oggetto.className = oggetto.className.replace("_over", "");
	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className = oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className.replace("_over", "");
}

function pulsante_utente_over(oggetto){
	oggetto.className += "_over";
// 	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className += "_over";
}

function pulsante_utente_out(oggetto){
	oggetto.className = oggetto.className.replace("_over", "");
// 	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className = oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className.replace("_over", "");
}

function obj_over(oggetto){
	oggetto.className += "_over";
}

function cambia_classe_over(oggetto){
	oggetto.className += "_over";
// 	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className += "_over";
}

function cambia_classe_out(oggetto){
	oggetto.className = oggetto.className.replace("_over", "");
// 	oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className = oggetto.tBodies[0].rows[0].cells[1].getElementsByTagName("div")[0].className.replace("_over", "");
}

function obj_over(oggetto){
	oggetto.className += "_over";
}

function obj_out(oggetto){
	oggetto.className = oggetto.className.replace("_over", "");
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

function normalizza_testo(oggetto_text){
	if(oggetto_text == null)
		return false;
		
	var testo = oggetto_text.value.toLowerCase().split(".");
	
	var testo_formattato = "";
	punteggiatura = /([\.,:;]+)([^0-9\r\n\s\.,:;]+)/g;
	spazio_iniziale = /^[\s^\r\n]*/g;
	spazio_finale = /[\s^\r\n]*$/g;
	
	for(i=0; i<testo.length; i++){
		
		
		if((i == (testo.length-1)) && (testo[i].length == 0))
			continue;
			
	
 		testo[i] = testo[i].replace(/\n/, "[n]");
 		testo[i] = testo[i].replace(/\r/, "");
 		
 		testo[i] = testo[i].replace(spazio_iniziale, "");
 		testo[i] = testo[i].replace(spazio_finale, "");
		
  		testo[i] = testo[i].replace(/\[n\]/, "\n");
		
		testo_formattato += first_upper_case(testo[i]) + ".";
		
	}
		
	testo_formattato = testo_formattato.replace(punteggiatura, "$1 $2");
	
	oggetto_text.value = testo_formattato;
}

function seleziona_radio(nome_radio, valore){
	
	radio_elements = document.getElementsByName(nome_radio);
	
	if(radio_elements == null)
		return false;

	for (i=0; i<radio_elements.length; i++){
		if(radio_elements[i].value==valore)
			radio_elements[i].checked = true;
	}
	
}

function seleziona_valore(nome_lista, valore){
	
	obj_lista = document.getElementById(nome_lista);
	
	if(obj_lista == null)
		return false;
		
	obj_lista.selectedIndex = 0;
	
	for (i=0; i<obj_lista.options.length; i++)
		if (obj_lista.options[i].value == valore){
			obj_lista.selectedIndex = i;
			break;			
		}
}

function first_upper_case(testo){
	k = 1;

	while((testo.substr(k-1, 1) == "\n") && (k < testo.length))
		k++;
	
	return testo.substr(0,k).toUpperCase()+testo.substr(k);
}

function word_upper_case(testo){
	
	parola = testo.toLowerCase().split(" ");
	testo_ritornato = "";
	for(w = 0; w<parola.length; w++)
		testo_ritornato += first_upper_case(parola[w])+" ";
	
		
	return testo_ritornato.substr(0, testo_ritornato.length-1);
}

function detag_testo(oggetto_text){
	if(oggetto_text.focus() == false)
		return false;
	oggetto_text.value = oggetto_text.value.replace(/\[\/?[a-z]+\]/g,"");
}

function maiuscolo_testo(oggetto_text){
	if(oggetto_text.focus() == false)
		return false;
	var startPos = oggetto_text.selectionStart;
	var endPos = oggetto_text.selectionEnd;
	var doc = document.selection;
	
	if(doc && doc.createRange().text.length != 0){
		doc.createRange().text = word_upper_case(doc.createRange().text);
	}else if (!doc && oggetto_text.value.substring(startPos,endPos).length != 0){
		oggetto_text.value = 
			oggetto_text.value.substring(0,startPos)+
			word_upper_case(oggetto_text.value.substring(startPos,endPos))+
			oggetto_text.value.substring(endPos);
		
	}
}


function grassetto_testo(oggetto_text){
	if(oggetto_text.focus() == false)
		return false;
	var startPos = oggetto_text.selectionStart;
	var endPos = oggetto_text.selectionEnd;
	var doc = document.selection;
	
	if(doc && doc.createRange().text.length != 0){
		doc.createRange().text = "[b]"+doc.createRange().text+"[/b]";
	}else if (!doc && oggetto_text.value.substring(startPos,endPos).length != 0){
		oggetto_text.value = 
			oggetto_text.value.substring(0,startPos)+
			"[b]"+oggetto_text.value.substring(startPos,endPos)+"[/b]"+
			oggetto_text.value.substring(endPos);
		
	}
}

function get_keycode(e) {
	if(e.which)
		return e.which;
	else
		return e.keyCode;
}

function imposta_valore(nome_check, valore){
	
	obj_check = document.getElementById(nome_check);
	
	if(obj_check == null)
		return false;
	
	if(valore == 1)
		obj_check.checked = true;
	else
		obj_check.checked = false;
	
}

	
function pop_scheda(id_utente){
	window.open("/engine/scheda_utente.php?id="+id_utente, "scheda_"+id_utente, "width=100, height=100, scrollbars=no, resizable=yes");
}

function zoom_photo(id_utente, username){
	window.open("/engine/scheda_utente.php?photo="+id_utente+"&amp;username="+username, "foto_"+id_utente, "width=100, height=100, scrollbars=no, resizable=yes");
}

function immagine_annuncio(id_annuncio, ext){
	window.open("/engine/immagine_annuncio.php?id="+id_annuncio+"&ext="+ext, "annuncio_"+id_annuncio, "width=100, height=100, scrollbars=no, resizable=yes");
}

function messaggio_utente(username, userid){
	parent.frames.messaggio.document.getElementById('nome_destinatario').value = username;
	parent.frames.messaggio.document.getElementById('destinatario').value = userid;
}

function leggi_messaggio(id_messaggio){
	parent.frames.messaggio.location = "/engine/messaggi_corpo.php?id="+id_messaggio;
}



// var stringa = new Array();
// stringa[0] = "Benvenuto su quelsito!";
// stringa[1] = "Quale sito?";
// stringa[2] = "Questo sito!";
// stringa[3] = "     ";

// var i_stringa = 0;

// var slide = 100;
// var pause = 2000;
// function status_anim(char, time){
// 	if(window.status == null)
// 		return false;
// 	
// 	if(char == null)
// 		char = 0;
// 		
// 	if((time == null) || (char >= 0))
// 		time = slide;
// 		
// 	window.status = stringa[i_stringa].substr(0, char);
// 	
// 	char++;
// 	
// 	if(char > stringa[i_stringa].length){
// 		time = pause;
// 		char = 0;
// 		i_stringa++;
// 		if(i_stringa >= stringa.length)
// 			i_stringa = 0;
// 	}
// 	
// 	setTimeout("status_anim("+char+", "+time+")",time);
// }
