ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ie5=(ie4 && (navigator.userAgent.indexOf('MSIE 5')>0 || navigator.userAgent.indexOf('MSIE 6')>0));
var x = 0;
var y = 0;
var trk = 0;
var over;
var offsetx=-85;
var offsety=18;
if (ns4 || ie4) {
   if (ns4) over = document.layers['overDiv']
   if (ie4) over = overDiv.style
   document.onmousemove = mouseMove
   if (ns4) document.captureEvents(Event.MOUSEMOVE)
}

function nd() {
	if (ns4 || ie4) {
		trk = 0;
		hideObject(over);
	}
}

function convEuros(ptas) {
	return formatEuros(ptas/166.386);
}

function formatEuros(euros) {
	eur=""+Math.round(euros*100);
	while (eur.length<3) eur="0"+eur;
	eur=eur.substring(0,eur.length-2)+"."+eur.substring(eur.length-2,eur.length);
	return eur;
}

function convPtas(eur) {
	return Math.round(eur*166.386);
}

function big_tip(lyr) {
	if (ns4 || ie4) {
		if (ns4) {
			over = document.layers[lyr];
			overWidth=over.clip.width
			windowWidth=window.innerWidth;
			offsety=-over.clip.height+40
			offsetx=-overWidth-20
		}
		if (ie4) {
			over = document.all[lyr].style
			overWidth=(ie5 ? document.all[lyr].offsetWidth : document.all[lyr].pixelWidth)
			windowWidth=(ie5 ? document.body.offsetWidth : document.body.style.pixelWidth)
			offsety=25
			offsetx=-overWidth/2
		}
		if (trk==0) {
			goTo(over,x,y+offsety);
			showObject(over);
			trk = 1;
		}
	}
}

function euro_t(text) {
	if (text.indexOf("<br>")==-1) text="&nbsp;"+text+"&nbsp;";
	layerWrite("<TABLE WIDTH=70 BORDER=0 CELLPADDING=2 CELLSPACING=0 bgcolor='#FFFFFF'><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0><TR><TD nowrap align=center BGCOLOR=#C6E8FC><FONT face=Verdana COLOR=#000000 size=1>"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>");
	displz();
}

function tip(text) {
	if (text.indexOf("<br>")==-1) text="&nbsp;"+text+"&nbsp;";
	layerWrite("<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=#333366><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0><TR><TD nowrap BGCOLOR=#99ccff><FONT size=1 face=Verdana COLOR=#333366>"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>");
	displz();
}

function ampliar_t() { tip("ampliar foto"); }

function galeria_t() { tip("Galería: Todo en imágenes"); }

function euros(ptas) {
	euro_t(convEuros(ptas)+" euros.");
}

function pesetas(eur) {
	euro_t(Math.round(eur*166.386)+" ptas.");
}
function displz() {
	if (ns4 || ie4) {
		if (ns4) {
			over = document.layers['overDiv'];
			overWidth=over.clip.width
			windowWidth=window.innerWidth;
		}
		if (ie4) {
			over = overDiv.style
			overWidth=(ie5 ? overDiv.offsetWidth : over.pixelWidth)
			windowWidth=(ie5 ? document.body.offsetWidth : document.body.style.pixelWidth)
		}
		if (trk==0) {
			offsety=18;
			offsetx=-overWidth/2
			goTo(over,x,y+offsety);
			showObject(over);
			trk = 1;
		}
	}
}

function mouseMove(e) {
	if (ns4) {x=e.pageX; y=e.pageY;}
	if (ie4) {x=event.x; y=event.y;}
	if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
	if (trk) {
		goTo(over,x,y+offsety);
	}
}

function layerWrite(txt) {
	if (ns4) {
		var lyr = document.layers['overDiv'].document
		lyr.open()
		lyr.writeln("<html><body>"+txt+"</body></html>")
		lyr.close()
	}
	else if (ie4) document.all["overDiv"].innerHTML = txt
}

function showObject(obj) {
	if (ns4) obj.visibility = "show"
	else if (ie4) obj.visibility = "visible"
}

function hideObject(obj) {
	if (ns4) obj.visibility = "hide"
	else if (ie4) obj.visibility = "hidden"
}

function goTo(obj,xL,yL) {
	xL+=offsetx
	if (xL+overWidth>windowWidth-50)
		xL=windowWidth-50-overWidth;
	if (xL<10) xL=10;
	obj.left = xL
	obj.top = yL
}

