window.defaultStatus = 'Minha História';

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() ;
}

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

function img_mostrar (s_arquivo, n_largura, n_altura, s_titulo)
{
   var n_left = xPageX('img0'); // tempX;
   var n_top  = xPageY('img0'); // tempY;

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

   xInnerHtml('box_img_visualizar','<div class="box_img_400x300" style="margin: 0px"><a href="javascript:void(0)" onclick="javascript:img_fechar()"><img src="' + s_arquivo + '" width="' + n_largura + '" height="' + n_altura + '" hspace="0" border="0" /></a></div>');
   if (s_titulo)
   {
   	xInnerHtml('box_img_titulo', s_titulo);
   } else
   {
   	xHide('box_img_titulo');
   }
   xShow('box_img_janela');
   scrollTo(n_left, n_top);
}

function img_mostrar2 (s_arquivo, n_largura, n_altura, s_titulo)
{
   var n_left = xPageX('2img0'); // tempX;
   var n_top  = xPageY('2img0') - 130; // tempY;

   xWidth('box_img_janela2', n_largura + 6);
   xHeight('box_img_janela2', n_altura + 6 + 20);
   xWidth('box_img_visualizar2', n_largura);
   xHeight('box_img_visualizar2', n_altura);
   xLeft('box_img_janela2', n_left);
   xTop('box_img_janela2', n_top);

   xInnerHtml('box_img_visualizar2','<div class="box_img_400x300" style="margin: 0px"><a href="javascript:void(0)" onclick="javascript:img_fechar2()"><img src="' + s_arquivo + '" width="' + n_largura + '" height="' + n_altura + '" hspace="0" border="0" /></a></div>');
   if (s_titulo)
   {
   	xInnerHtml('box_img_titulo2', s_titulo);
   } else
   {
   	xHide('box_img_titulo2');
   }
   xShow('box_img_janela2');
   scrollTo(n_left, n_top);
}

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

function img_fechar2()
{
   xHide('box_img_janela2');
}