window.defaultStatus = "Hemfibra";

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 frm_cancelar()
{
   if (window.history.length)
   {
      history.back();

   } else if (window.opener && !window.opener.closed)
   {
      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 EnqueteSubmit() {
  var i = 0;
	var voto_ok = false;

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

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

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

   win = window.open (''+s_url+'','popup',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 vld_tamanho (s_cmp, n_tam_cmp, n_len)
{
   if (n_tam_cmp < n_len)
   {
      alert('Você precisa informar ao menos 3 caracteres\nno campo "' + s_cmp + '"!');
      return 0;
   }
   return 1;
}

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

function AddBookmark()
{
	var bookmarkurl   = "http://www.site.com"
	var bookmarktitle = "Titulo do Site"

	if (document.all)
   {
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
   }
}

function numbersOnly(myfield, e)
{
    if (myfield.length ==0)
	    myfield.value=0;  
	  var key;
	  var keychar;
    if (window.event)
     key = window.event.keyCode;
    else if (e)
     key = e.which;
    else
     return true;
	  keychar = String.fromCharCode(key);
    if ((key==null) || (key==0) || (key==8) || 
		      (key==9)|| (key==13)|| (key==27) )
     return true;
    else if ((("0123456789").indexOf(keychar) > -1))
	     return true;
	else
   return false;
}

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 show(id)
{
   if (!id) return;
   var el = document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : null;
   if (el) el.style.display = '';
}

function show_id () {

   div_show = document.frm_orçamento.tipo.options[document.frm_orçamento.tipo.selectedIndex].value;

   if (div_show == 1)
   {
	 		divB.style.display = 'none';
			divC.style.display = 'none';
			divA.style.display = '';
			
   } else if (div_show == 2)
   {
	 		divA.style.display = 'none';
			divC.style.display = 'none';
			divB.style.display = '';
   } else if (div_show == 3)
   {
	 		divA.style.display = 'none';
			divB.style.display = 'none';
			divC.style.display = '';
   } else
   {
	 		divA.style.display = 'none';
			divB.style.display = 'none';
			divC.style.display = 'none';
   }
	 
}


/*
window.onerror = killErrors;
function killErrors()
{
   return true;
}
*/
