window.defaultStatus = "Nataltrip.com";

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) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function delCookie (NameOfCookie)
{
   if (getCookie(NameOfCookie))
   {
      document.cookie = NameOfCookie + "=" + "; 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 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!');
   }
}
