window.defaultStatus = 'Abadalação.com';

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.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; }
}

function setmsg_status(msg)
{
   window.status = window.defaultStatus + " - " + msg;
}

function update_parent()
{
   if (window.opener && !window.opener.closed)
   {
      window.opener.location.href = window.opener.document.URL;
   }
   self.close();
}

function getCookie(NameOfCookie)
{
   if (document.cookie.length > 0)
   {
      begin = document.cookie.indexOf(NameOfCookie+"=");
      if (begin != -1)
      {
         begin += NameOfCookie.length+1;
         end = document.cookie.indexOf(";", begin);
         if (end == -1)
         {
            end = document.cookie.length;
         }
         return unescape(document.cookie.substring(begin, end));
      }
   }
   return null;
}

function setCookie(NameOfCookie, value, expiredays)
{
   var ExpireDate = new Date ();
   ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
   document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; path=/; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie)
{
   if (getCookie(NameOfCookie))
   {
      document.cookie = NameOfCookie + "=" + "; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

function href_popup(s_url, n_largura, n_altura, s_scroll, s_nome)
{
   var win  = null;
   var winl = (screen.width - n_largura)/2;
   var wint = (screen.height - n_altura)/2;
   // var s_janela = href_popup.arguments[5];
   settings = 'height='+n_altura+',width='+n_largura+',top='+wint+',left='+winl+',scrollbars='+s_scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=yes'

   if (s_nome == '')
   {
      var s_nome = 'jan';
   }

   win = window.open (''+s_url+'', ''+s_nome+'', settings);
   if (parseInt(navigator.appVersion) >= 4)
   {
      win.window.focus();
   }
}

function change_fa (Fa, form)
{
   form.Fa.value=Fa;
   form.submit();
}

function textCounter(s_cmp, countfield, maxlimit)
{
   if (s_cmp.value.length > maxlimit) // if too long...trim it!
   {
      s_cmp.value = s_cmp.value.substring(0, maxlimit);
      // otherwise, update 'characters left' counter
   } else
   {
      countfield.value = maxlimit - s_cmp.value.length;
   }
}

function Go (popurl)
{
   if (window.opener.closed == false)
   {
      window.opener.location.href = popurl;
   } else
   {
      document.write(window.opener.closed);
      var linkPop = window.open(popurl,'linkPopAe');
   }
}

function mCont(objMenu)
{
   if (objMenu.style.display == "none")
   {
       objMenu.style.display = "";
   } else
   {
       objMenu.style.display = "none";
   }
}

function frm_busca (frm)
{
   lenCon = frm.CONTEUDO.value.length;
   if (lenCon < 3)
   {
      alert('Voce precisa informar no mínimo \n3 caracteres para a busca!');
      return false;
   } else
   {
      frm.submit();
      return true;
   }
}

function frm_cancelar()
{
   if (window.history.length)
   {
      history.back();

   } else if (window.opener && !window.opener.closed)
   {
      self.close();
   }
}

function mostrar_item(s_prefixo, n_item)
{
   var o_subitens = document.all.item(s_prefixo + n_item);

   if (o_subitens.style.display == 'none')
   {
      o_subitens.style.display = '';
   } else
   {
      o_subitens.style.display = 'none';
   }
}

function OpenFile( fileUrl )
{
	window.top.opener.SetUrl( fileUrl ) ;
	window.top.close() ;
	window.top.opener.focus() ;
}

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.

        if (document.body)
        {
           xMousePos = window.event.x + document.body.scrollLeft;
           yMousePos = window.event.y + document.body.scrollTop;
           xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
           yMousePosMax = document.body.clientHeight+document.body.scrollTop;
        } else if (document.documentElement)
        {
           xMousePos = window.event.x + document.documentElement.scrollLeft;
           yMousePos = window.event.y + document.documentElement.scrollTop;
           xMousePosMax = document.documentElement.clientWidth + document.documentElement.scrollLeft;
           yMousePosMax = document.documentElement.clientHeight + document.documentElement.scrollTop;
        }
    } else if (document.getElementById)
    {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

function img_mostrar (s_arquivo, n_largura, n_altura)
{
   var n_left = (screen.width - n_largura)/3;
   var n_top  = (screen.height - n_altura)/3

   xWidth('box_img', n_largura + 6);
   xHeight('box_img', n_altura + 6 + 20);
   xWidth('box_img_visualizar', n_largura);
   xHeight('box_img_visualizar', n_altura);
   xWidth('box_img_fechar', n_largura);
   xLeft('box_img', n_left);
   xTop('box_img', n_top);

   xInnerHtml('box_img_visualizar','<a href="#" onclick="javascript:img_fechar()"><img src="' + s_arquivo + '" width="' + n_largura + '" height="' + n_altura + '" border="0" /></a>')
   xShow('box_img');
}

function img_fechar()
{
   xHide('box_img');
}

function vld_frm_ean()
{
   frm    = document.frm_eventoandamento;
   lenCon = frm.EAN_DESCRICAO.value.length;
   if (lenCon < 1)
   {
      frm.EAN_DESCRICAO.style.borderColor = 'red';
      alert('Você precisa informar a mensagem.');
      frm.EAN_DESCRICAO.focus();
      return false;
   } else
   {
      frm.submit();
      return true;
   }
}

function move_top(s_div)
{
   xGetElementById(s_div).scrollTop = 0;
}

function dsp_opc_class(s_form)
{
	switch (s_form.ANU_TRANSACAO.selectedIndex)
	{
		case 0:
		xNoDisplay('div_opc_troca_tenho');
		xNoDisplay('div_opc_troca_quero');
		break;

		case 1:
		xNoDisplay('div_opc_troca_tenho');
		xDisplay('div_opc_troca_quero');
		break;

		case 2:
		xDisplay('div_opc_troca_tenho');
		xNoDisplay('div_opc_troca_quero');
		break;

		case 3:
		xDisplay('div_opc_troca_tenho');
		xDisplay('div_opc_troca_quero');
		break;
	}
}

function EnqueteSubmit()
{
   var i = 0;
	var voto_ok = false;

	for ( ; i < document.frm_enquete.ENQ_VOTO.length ; ++i )
   {
      if ( document.frm_enquete.ENQ_VOTO[i].checked )
      {
         voto_ok = true;
		}
	}

   if ( voto_ok )
   {
      document.frm_enquete.submit();
   } else
   {
      alert('Escolha uma opção da enquete.');
   }
}

function isTipoNumero(form)
{
	pVal = form.OPT_DATE.value;
	var reTipo = /^\d+$/; 

	if (reTipo.test(pVal)) {
		form.submit();
	} else {
		alert("O campo tem que ser preenchido com dígitos!");
	}
}
function changeColunistas()
{
	col1 = (col1+1) % col_size;
	
	xGetElementById('img_col1').innerHTML		= img_tag[col1];
	xGetElementById('box_lnk_col1').innerHTML		= lnk_tag[col1];
	
	setTimeout("changeColunistas()", 5000);
}

function changeEventos()
{
	eve1 = (eve1+1) % eve_size;
	
	xGetElementById('box_eve1').innerHTML		= eve_tag[eve1];
	
	setTimeout("changeEventos()", 5000);
}

function writeAudio(file,type,w,h,id)
{
	document.write('<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="FileName" value="'+file+'" valuetype="ref" ref><param name="AutoStart" value="false"><embed src="'+file+'" type="'+type+'" wmode="true" width="'+w+'" height="'+h+'" align="" ></embed></object>');
}