// Get ID
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
function BValidar() {
	if (webmail.LOGIN.value=="") {
		alert("Por favor, preencha o campo username.");
		webmail.LOGIN.focus();
		return false;
	} else {
		if (webmail.PASSWD.value=="") {
			alert("Por favor, preencha o campo senha.");
			webmail.PASSWD.focus();
			return false;
		}
	}
}
// 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];
	gid('mb_title').innerHTML = titSrc[atual];
	timeoutId = setTimeout("changeImg(1)",7000);
}
function startSlide() {
	timeoutId = setTimeout("changeImg(1)",7000);
}

//Menu - Submenu
function submenu(smenu,estado) {
   if ((estado == 'none')||( estado == '' )) {
      gid(smenu).style.display = 'block'; 
      return true;
   }else {
      gid(smenu).style.display = 'none'; 
      return false;
   }
}

//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;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
// Menu e Submenu
function showSubmenu() {
   var arrValues = new Array("agito","blog","compor","afiliadas","noticias","vestib","vglhot");
   var arrCorrec = new Array(0,0,0,382,0,0,0);

   for(var i = 0; i < arrValues.length; i++) {
      var obj = 'li_' + arrValues[i];
      var lay = 'lay_' + arrValues[i];
      var cor = parseInt(arrCorrec[i]);
      myLiDim = gelpos(gid(obj));
      gid(lay).style.top  = parseInt(myLiDim.y - cor) + 'px';
      gid(lay).style.left = myLiDim.x + 'px';
   }
}
// Troca cor do fundo do menu e submenu
function muda_fundo(e,c) {
	e.style.background = c;
}
// 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);
   }
}