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 convDolares(psos, valor) {
	return formatDolares(psos/valor);
}

function formatDolares(dolares) {
	dol=""+Math.round(dolares*100);
	while (dol.length<3) dol="0"+dol;
	dol=dol.substring(0,dol.length-2)+"."+dol.substring(dol.length-2,dol.length);
	return dol;
}

function conv_psos(dol, valor) {
	return format_pesos(dol*valor);
}
function format_pesos(pesos) {
	return number_format(pesos,'0','','.');
}



function number_format(number, laenge, sep, th_sep){
  var pre = "";
  if(number < 0){
    pre = "-";
    number *= (-1)
  }
	number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
	str_number = number+"";
	arr_int = str_number.split(".");
	if(!arr_int[0]) arr_int[0] = "0";
	if(!arr_int[1]) arr_int[1] = "";
	if(arr_int[1].length < laenge){
		nachkomma = arr_int[1];
		for(i=arr_int[1].length+1; i <= laenge; i++){	nachkomma += "0";	}
		arr_int[1] = nachkomma;
	}
	if(th_sep != "" && arr_int[0].length > 3){
		Begriff = arr_int[0];
		arr_int[0] = "";
		for(j = 3; j < Begriff.length ; j+=3){
			Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
			arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
		}
		str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
		arr_int[0] = str_first + arr_int[0];
	}
	return pre+arr_int[0]+sep+arr_int[1];
}






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 dolar_t(text) {
	if (text.indexOf("<br>")==-1) text="&nbsp;"+text+"&nbsp;";
	layerWrite("<TABLE WIDTH=80 BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=#FFFF00><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0><TR><TD nowrap BGCOLOR=#200B67><FONT face=Verdana COLOR=#ffffff size=2>"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>");
	disp();
}

function tip(text) {
	if (text.indexOf("<br>")==-1) text="&nbsp;"+text+"&nbsp;";
	layerWrite("<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=#FF9900><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0><TR><TD nowrap BGCOLOR=#15685B><FONT face=Verdana COLOR=#ffffff>"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>");
	disp();
}

function ampliar_t() { tip("Haz click en la foto y manda una postal <br>de este lugar a quien tú quieras."); }

function galeria_t() { tip("Galería: Todo en imágenes"); }

function dolares(psos, valor) {
	dolar_t("US " +convDolares(psos, valor)+" dolares.");
}
function pesos(dol, valor) {
	dolar_t("$ "+conv_psos(dol, valor)+" pesos.");
}

/*
function pesos(dol, valor) {
	dolar_t(Math.round(dol*valor)+" pesos.");
}*/
function disp() {
	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
}

