ie = (document.all) ? 1:0 ;
ei=new Array();
ei[0] ={txt:':black_eye',		link:'Emoticon/black_eye.gif'};
ei[1] ={txt:':worshippy',		link:'Emoticon/worshippy.gif'};	
ei[2] ={txt:':whistling',		link:'Emoticon/whistling.gif'};
ei[3] ={txt:':offtopic2',		link:'Emoticon/offtopic2.gif'};
ei[4] ={txt:':thumbdown',		link:'Emoticon/thumbdown.gif'};
ei[5] ={txt:':hypocrite',		link:'Emoticon/hypocrite.gif'};
ei[6] ={txt:':clapping',		link:'Emoticon/clapping.gif'};
ei[7] ={txt:':ranting', 		link:'Emoticon/ranting.gif'};
ei[8] ={txt:':console', 		link:'Emoticon/console.gif'};
ei[9] ={txt:':bllaugh', 		link:'Emoticon/bllaugh.gif'};
ei[10]={txt:':crybaby', 		link:'Emoticon/crybaby.gif'};
ei[11]={txt:':naughty',			link:'Emoticon/naughty.gif'};
ei[12]={txt:':thumbup', 		link:'Emoticon/thumbup.gif'};
ei[13]={txt:':vampire', 		link:'Emoticon/vampire.gif'};
ei[14]={txt:':victory', 		link:'Emoticon/victory.gif'};
ei[15]={txt:':hammer',  		link:'Emoticon/hammer.gif'};
ei[16]={txt:':dntknw',  		link:'Emoticon/dntknw.gif'};
ei[17]={txt:':diablo',  		link:'Emoticon/diablo.gif'};
ei[18]={txt:':frusty',  		link:'Emoticon/frusty.gif'};
ei[19]={txt:':cincin',  		link:'Emoticon/cincin.gif'};
ei[20]={txt:':stupid',  		link:'Emoticon/stupid.gif'};
ei[21]={txt:':angelo',  		link:'Emoticon/angelo.gif'};
ei[22]={txt:':alcool',  		link:'Emoticon/alcool.gif'};
ei[23]={txt:':crazy', 			link:'Emoticon/crazy.gif'};
ei[24]={txt:':jason', 			link:'Emoticon/jason.gif'};
ei[25]={txt:':climb', 			link:'Emoticon/climb.gif'};
ei[26]={txt:':sleep', 			link:'Emoticon/sleep.gif'};
ei[27]={txt:':tease', 			link:'Emoticon/tease.gif'};
ei[28]={txt:':sorry', 			link:'Emoticon/sorry.gif'};
ei[29]={txt:':pizza', 			link:'Emoticon/pizza.gif'};
ei[30]={txt:':plane', 			link:'Emoticon/plane.gif'};
ei[31]={txt:':smoke', 			link:'Emoticon/smoke.gif'};
ei[32]={txt:':yahoo', 			link:'Emoticon/yahoo.gif'};
ei[33]={txt:':this', 				link:'Emoticon/this.gif'};
ei[34]={txt:':beer', 				link:'Emoticon/beer.gif'};
ei[35]={txt:':stop', 				link:'Emoticon/stop.gif'};
ei[36]={txt:':bleh', 				link:'Emoticon/bleh.gif'};
ei[37]={txt:':spam', 				link:'Emoticon/spam.gif'};
ei[38]={txt:':bye1', 				link:'Emoticon/bye1.gif'};
ei[39]={txt:':help', 				link:'Emoticon/help.gif'};
ei[40]={txt:':rofl', 				link:'Emoticon/rofl.gif'};
ei[41]={txt:':poke', 				link:'Emoticon/poke.gif'};
ei[42]={txt:':dots', 				link:'Emoticon/dots.gif'};
ei[43]={txt:':fart', 				link:'Emoticon/fart.gif'};
ei[44]={txt:':moil', 				link:'Emoticon/moil.gif'};
ei[45]={txt:':fuck', 				link:'Emoticon/fuck.gif'};
ei[46]={txt:':lamo', 				link:'Emoticon/lamo.gif'};
ei[47]={txt:':sisi', 				link:'Emoticon/sisi.gif'};
ei[48]={txt:':boh', 				link:'Emoticon/boh.gif'};
ei[49]={txt:':gun', 				link:'Emoticon/gun.gif'};
ei[50]={txt:':arg', 				link:'Emoticon/arg.gif'};
ei[51]={txt:':heh', 				link:'Emoticon/heh.gif'};
ei[52]={txt:':9', 					link:'Emoticon/9.gif'};
var sponsor={x:-9999,y:0,	passo:50, centro:0, x_max:0, x_min:0, n:0}
//--------------------------------------------------------------------------------------------------
function sostEIjs(s) {
//sostituisco le emoticon in s
	var i,ss,t,l;
//	alert(ei.lenght);	
	for (i=-1;i<53;i++) {
		ss='';
		if (i==-1) {t=String.fromCharCode(10);l='<br>'} else {t=ei[i].txt;l='<img src="'+ei[i].link+'" />';} 
		while (s!=ss) { ss=s;  s=s.replace(t,l); }
//		if (i==-1) {alert(s+'-'+ss);} 	
	}
//	alert(s+'-'+ss);
	return s;
}
//--------------------------------------------------------------------------------------------------
function insAtCur(stringa) {
//inserisco stringa nella posizione del cursore e sposto il cursore alla fine dell'inserimento
	var campo = document.getElementById('inTxt');
	if (document.selection) {// per IE
		campo.focus();
		sel = document.selection.createRange();
		sel.text = stringa;
		sel.setEndPoint();
		campo.focus();
	}
	else if (campo.selectionStart || campo.selectionStart == '0') {// per Mozilla
		var startPos = campo.selectionStart;
		var endPos = campo.selectionEnd;
		campo.value = campo.value.substring(0,startPos)+stringa+campo.value.substring(endPos,campo.value.length);
		campo.focus(); endPos+=stringa.length;
		campo.selectionStart = endPos;
		campo.selectionEnd = endPos;
	} 
	else { // alle brutte... brutte brutte 
		campo.value += stringa;
	}
	GAntep();
}
//--------------------------------------------------------------------------------------------------
function GAntep(e){
var txt = document.getElementById('inTxt');
var ant = document.getElementById('antep');
ant.innerHTML=sostEIjs(txt.value);
}
//--------------------------------------------------------------------------------------------------
function getCoords(obj,liv) {
//restituisce le coordinate riferite: se liv=vuoto:alla pagina, se liv<>vuoto all'oggetto padre di livello liv
	var coords = {x:0, y:0, w:0, h:0, xf:0, yf:0};
	if (!liv) liv=999999;
	coords.w = parseInt(obj.offsetWidth);
  	coords.h = parseInt(obj.offsetHeight);
  while (obj && liv>0) {
  		alert('x='+obj.offsetLeft+' y='+obj.offsetTop+' liv='+liv);
  		coords.x += parseInt(obj.offsetLeft);
  		coords.y += parseInt(obj.offsetTop);
  		obj = obj.offsetParent;  liv-=1;
    }
  	coords.xf= coords.x+coords.w;
  	coords.yf= coords.y+coords.h;
	return coords;
}
//--------------------------------------------------------------------------------------------------
function G_Sponsor_init(n,t,r){
if (t!=0) {setTimeout('G_Sponsor_init('+n+',0,'+r+')', t);return;}
sponsor.centro=155+getCoords(document.getElementById('container')).x;
for (sponsor.x_max=sponsor.centro;sponsor.x_max<getCoords(document.getElementById('container')).xf;sponsor.x_max+=sponsor.passo) {}
for (sponsor.x_min=sponsor.centro;sponsor.x_min>-500;sponsor.x_min-=sponsor.passo) {}
sponsor.y=100+(ie? document.body.scrollTop : window.pageYOffset);
if (n<0) sponsor.n=Math.ceil(10*Math.random()); else sponsor.n=n;
G_Sponsor(r);
}
//--------------------------------------------------------------------------------------------------
function G_Sponsor(r){
var obj = document.getElementById('sponsor');
var s;
if (sponsor.x==-9999) { //primo
	sponsor.x=sponsor.x_max
	s=''+
	'<div style="position:absolute;top:0px;left:0px;width:490px;">'+
		'<div class="articleheader">Sponsor</div>'+
		'<div class="articletext">';
	switch (sponsor.n) {
			case 0 :s=s+'<b>OFAR - Onoranze funebri</b> <br>';break;
			case 1 :s=s+'<b>Luca Paggini posa in opera</b> <br>';break;
			default:s=s+'<b>VdR di Sestini Simone e C. sas</b> <br>';break;
	}		
	s=s+	'</div>'+
  		'<div class="articlesign">&nbsp;</div>'+
	'</div>';
	obj.innerHTML=s;
	pageYOffset
}
else { // non primo
	sponsor.x-=sponsor.passo; 
}
	obj.style.top=sponsor.y;
	obj.style.left=sponsor.x;
//alert(cm+" _ "+x_sponsor+" _ "+cp);
if (sponsor.x==sponsor.centro) {setTimeout('G_Sponsor('+r+')', 3000);return;} 
if (sponsor.x_min<sponsor.x) {setTimeout('G_Sponsor('+r+')', 50);return;} 
obj.innerHTML='&nbsp;';sponsor.x=-9999;
if (r==1) {G_Sponsor_init(-1,20000,1);}
}
//--------------------------------------------------------------------------------------------------
function Sovrapponi(dst,org){
var obj=document.getElementById(dst);
var corg=getCoords(document.getElementById(org),0);
alert(corg.y+"#"+corg.x+"#"+corg.h+"#"+corg.w);
	obj.style.top=corg.y;
	obj.style.left=corg.x;
	obj.style.height=corg.h;
	obj.style.width=corg.w;
}
