function gid(s) {
   if(document.layers) {
      return document.layers[s];
   } else if(document.all && !gid) {
      return document.all[s];
   } else {
      return document.getElementById(s);
   }
}
// Get Element Position (pega o x e y do elemento na página)
function gelpos(el) {
   for (var lx=0,ly=0;el!=null;
      lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
   return {x:lx,y:ly}
}
// Form de e-mail
// Media Box
function goURL() {
	location.href=lnkSrc[atual];
}
function changeImg(id) {
	clearTimeout(timeoutId);
	atual += parseInt(id);
	if(atual>imgSrc.length-1) atual = 0;
	if(atual<0) atual = imgSrc.length-1;
	if(document.all) {
		document.images.mb_img.style.filter="blendTrans(duration=1)";
		document.images.mb_img.filters.blendTrans.Apply();
		document.images.mb_img.filters.blendTrans.Play();
	}
	document.mb_img.src = imgDsp[atual].src;
	document.mb_img.alt = document.mb_img.title = altSrc[atual];
	gid('lnkHref_1').href = gid('lnkHref_2').href = gid('lnkHref_3').href = lnkSrc[atual];
	//gid('lnkHref_1').target = gid('lnkHref_2').target = gid('lnkHref_3').target = typSrc[atual];
	gid('mb_text').innerHTML = txtSrc[atual];
	timeoutId = setTimeout("changeImg(1)",4000);
}
function startSlide() {
	timeoutId = setTimeout("changeImg(1)",4000);
}


//Troca imagens
var ic = 2; // Number of alternative images
var choice = getRandomImg(ic);
function getRandomImg(range) {
   if(Math.random) {
      return Math.round(Math.random() * (range-1));
   } else {
      var now = new Date();
      return (now.getTime() / 1000) % range;
   }
}
function randomImg ( nameId, img1, img2 ) {
   var now = new Date();
   var sec = now.getSeconds();
   var img = sec % 2;
   img += 1;
   imgFinal = (img == 1) ? img1 : img2;

   gid(nameId).src = imgFinal;
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// Menu e Submenu

// Tremida
netscape = (navigator.appName == "Netscape");
n4 = netscape && (parseInt(navigator.appVersion) >= 4);
explorer = (navigator.appName == "Microsoft Internet Explorer");
ie4 = explorer && (parseInt(navigator.appVersion) >= 4);
function tremida(n) {
   if(n4 || ie4) {
      top.resizeBy(-30, -30);
      for (i = 20; i > 0; i--) {
         for (j = n; j > 0; j--) {
            top.moveBy(0,i);
            top.moveBy(i,0);
            top.moveBy(0,-i);
            top.moveBy(-i,0);
         }
      }
      top.resizeBy(30, 30);
   }
}
