var bv = null;
var linksBV;
var lingua = 0;
var fotos = 1;
function bolaVermelha(id) {
  this.obj = document.getElementById(id);
  this.mapaX = null;
  this.mapaY = null;
  this.bv = null;
  var obj2 = this.obj;
  this.mapaX = 0;
  this.mapaY = 0;
  do {
    this.mapaX += obj2.offsetLeft;
    this.mapaY += obj2.offsetTop;
    obj2 = obj2.offsetParent;
  } while (obj2.tagName != "BODY");
  this.bv = document.createElement("span");
  this.bv.style.position = "absolute";
  this.bv.style.display = "none";
  this.bv.style.left = this.mapaX + "px";
  this.bv.style.top = this.mapaY + "px";
  document.body.appendChild(this.bv);
  var img = document.createElement("img");
  img.src = "images/bolavermelha.gif";
  this.bv.appendChild(img); 
  this.dest = function() {
  	if (this.bv != null) {
	    removeElement(this.bv);
      this.bv = null;
  	}
	  return true;
  }
  this.mOut = function() {
    this.bv.style.display = "none";
  	return true;
  }
  this.mOver = function(ref) {
	  var st = ref.id;
  	st = st.substring(8,st.length);
	  var n = parseInt(st,10);
  	var x = posEsquerdaX(n);
	  var y = posEsquerdaY(n);
    this.bv.style.display = "inline";
  	this.bv.style.left = (x + this.mapaX) + "px";
	  this.bv.style.top = (y + this.mapaY) + "px";
  	return true;
  }
}
function cachoeira(n) {
  var x; var y; var s;
  switch(n) {
    case  1: x=500; y=336; s="cachoeiras/alcantilado.htm"; break;
    case  3: x=420; y=281; s="cachoeiras/escorrega1.htm"; break;
    case  4: x=171; y=209; s="cachoeiras/fumaca1.htm"; break;
    case  5: x=368; y=258; s="cachoeiras/pocodasantas.htm"; break;
    case  6: x=368; y=259; s="cachoeiras/marimbondo1.htm"; break;
    case  7: x=360; y=274; s="cachoeiras/prata.htm"; break;
    case  8: x=357; y=233; s="cachoeiras/santaclara.htm"; break;
    case 10: x=290; y=190; s="cachoeiras/saudade.htm"; break;
    case 11: x=265; y=281; s="cachoeiras/tocadaraposa.htm"; break;
	default: return false;
  }
  var j = window.open(s,"_blank","fullscreen:no,resizable:no");
  j.moveTo(0,0);
  x+=41; y+=140; j.resizeTo(x,y);
  j.focus();
}
function dest() {
//  bv.dest();
}
function init() {
  linksBV = 0;
  percorreEsquerda(document.body);
	fotos--;
  bv = new bolaVermelha("mapaInes");
  var eu = NI_nome();
  if (eu == "index") 
    popLojinha();
    // popPromocao();  // sem promoções -- utlizando lojinha.
}
function NI_nome() {
  var s=window.document.URL;
  var idx = s.indexOf("\?");
  if (idx > -1) s = s.substring(0, idx);
  var l=s.length;
  var m,n;
  if (s.slice(l-4) == '.cgi')
    return ("cgi");
  else if (s.slice(l-4) == '.htm')
    m=l-4;
  else if (s.slice(l-5) == '.html')
    m=l-5;
  else
    m=0;
  if (!m)
    return ("index");
  else {
    n=s.lastIndexOf('/');
    if (n<=6) n=s.lastIndexOf("\\");
    return (s.slice(n+1, m));
  }
}
function percorreEsquerda(obj) {
  var i;
	if (fotos <= 0) return true;
  if ((obj.tagName == "A") && (obj.className == "esquerda")) {
  	obj.id = "esquerda" + (++linksBV);
	  if (linksBV == 1) obj.href = "javascript:cachoeira(" + linksBV + ")";
  	else if (linksBV == 3) obj.href = "javascript:cachoeira(" + linksBV + ")";
	  else if (linksBV == 4) obj.href = "javascript:cachoeira(" + linksBV + ")";
  	else if (linksBV == 5) obj.href = "javascript:cachoeira(" + linksBV + ")";
	  else if (linksBV == 6) obj.href = "javascript:cachoeira(" + linksBV + ")";
  	else if (linksBV == 7) obj.href = "javascript:cachoeira(" + linksBV + ")";
	  else if (linksBV == 8) obj.href = "javascript:cachoeira(" + linksBV + ")";
  	else if (linksBV == 10) obj.href = "javascript:cachoeira(" + linksBV + ")";
	  else if (linksBV == 11) obj.href = "javascript:cachoeira(" + linksBV + ")";
    obj.onmouseover = function() { return bv.mOver(this); };
    obj.onmouseout = function() { return bv.mOut(); };
  	if (!obj.href) obj.href = "javascript:void(0)";
	  else {
			if (lingua == 1) obj.innerHTML += '<font class="verfoto">&nbsp;(photo)</font>';
		  else obj.innerHTML += '<font class="verfoto">&nbsp;(foto)</font>';
		  }
    return true;
  }
  for (i=0; i<obj.childNodes.length; i++) {
    percorreEsquerda(obj.childNodes[i]);
  }
  return false;
}
function popLojinha() {
  var j = window.open("lojinha.htm","_blank","fullscreen:no,resizable:no");
  j.moveTo(0,0);
  j.resizeTo(326,310);
  return true;
}
function popPromocao() {
  return true;  // sem pacotes!
  var j = window.open("promocoes.htm","_blank","fullscreen:no,resizable:no");
  j.moveTo(0,0);
  j.resizeTo(360,250);
  return true;
}
function posEsquerdaX(k) {
  switch(k) {
  	case 1: return 87;
	  case 2: return 97;
  	case 3: return 2;
	  case 4: return 151;
  	case 5: return 69;
	  case 6: return 60;
  	case 7: return 122;
	  case 8: return 20;
  	case 9: return 42;
	  case 10: return 83;
  	case 11: return 47;
	  case 12: return 69;
  	case 13: return 135;
	  case 14: return 55;
  	case 15: return 54;
	  case 16: return 139;
  	case 17: return 143;
	  case 18: return 57;
  	case 19: return 89;
	  case 20: return 70;
  	case 21: return 127;
	  default: return 0;
  }
}
function posEsquerdaY(k) {
  switch(k) {
  	case 1: return 36;
	  case 2: return 38;
  	case 3: return 77;
	  case 4: return 34;
  	case 5: return 105;
	  case 6: return 107;
  	case 7: return 13;
	  case 8: return 24;
  	case 9: return 28;
	  case 10: return 10;
  	case 11: return 39;
	  case 12: return 60;
  	case 13: return 68;
	  case 14: return 63;
  	case 15: return 71;
  	case 16: return 27;
	  case 17: return 42;
  	case 18: return 88;
	  case 19: return 60;
  	case 20: return 92;
	  case 21: return 83;
  	default: return 0;
  }
}
function removeElement(id) {
  var elem = document.getElementById(id);
  elem.parentNode.removeChild(elem);
}
function scrollit(seed) {
var m1 = null;
if (lingua == 1) m1 = "Specials for groups, excursions, and honeymoon couples. Contact us!";
else m1 = "Pacotes especiais para grupos, excursões e casais em lua-de-mel. Consultem-nos!  ";
var m2  = "";
var m3  = "";
var m4  = "";
var msg=m1+m2+m3+m4;
var out = " ";
var c   = 1;
if (seed > 100) {
seed--;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 100 && seed > 0) {
for (c=0 ; c < seed ; c++) {
out+=" ";
}
out+=msg;
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 0) {
if (-seed < msg.length) {
out+=msg.substring(-seed,msg.length);
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else {
window.status=" ";
timerTwo=window.setTimeout("scrollit(100)",75);
      }
   }
}
