HM_PG_FontFamily = "Arial,sans-serif";
HM_PG_FontSize = 8;
HM_PG_FontBold = 0;
HM_PG_FontItalic = 0;
HM_PG_ItemPadding = 3;
HM_PG_BorderWidth = 1;
HM_PG_BorderStyle = "solid";
HM_PG_SeparatorSize = 1;

HM_PG_ImageSize = 5;
HM_PG_ImageHorizSpace = 0;
HM_PG_ImageVertSpace = 2;

HM_PG_KeepHilite = true; 
HM_PG_ClickStart = 0;
HM_PG_ClickKill = false;
HM_PG_ChildOverlap = 20;
HM_PG_ChildOffset = 10;
HM_PG_ChildPerCentOver = null;
HM_PG_TopSecondsVisible = .5;
HM_PG_StatusDisplayBuild =0;
HM_PG_StatusDisplayLink = 0;
HM_PG_UponDisplay = null;
HM_PG_UponHide = null;
HM_PG_RightToLeft = false;

HM_PG_CreateTopOnly = 1;
HM_PG_ShowLinkCursor = 1;
HM_PG_NSFontOver = true;

//HM_a_TreesToBuild = [2];

function view() {
	var a=view.arguments; size="\"menubar=no,scrollbars=yes,toolbars=no,width="+a[1]+",height="+a[2]+"\"";
	window.open (a[0],"view",size);
  }

  // VALIDAÇÃO DE CAMPOS
    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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve ser um endereço de email válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter números.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter números entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é requerido.\n'; }
  } if (errors) alert('Os seguintes erros ocorreram:\n'+errors);
  document.MM_returnValue = (errors == '');
}*/

function MM_validateForm(args) { //v4.0
  var i,p,q,nm,test,num,min,max,errors=''; //,args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um endereço de email válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter um número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter um número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é necessário.\n'; }
  } if (errors) alert('Os seguintes erros ocorreram:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function envia() {
	var argv = envia.arguments;
	fObj = MM_findObj(argv[0]);
	
	aObj = new Array();

	for (i=0; i < (argv.length - 1); i++){
		aObj[i] = argv[i+1];
	}
	MM_validateForm(aObj);
	if (document.MM_returnValue) fObj.submit();
}

function envia1() {
	erros = false;
	if ( !erros && document.form_email.Nome.value == "" )
	{
		erros = true;
		alert ( "O campo Nome não esta preenchido." );
		document.form_email.Nome.focus();
	}
	if ( !erros && valida_email( document.form_email.Email.value ) )
	{
		erros = true;
		alert ( "O campo email não é valido. Favor digitar um email valido." );
	}
	else if( !erros )
	{
//		document.form_email.action="http://www.labcon.com.br/xtras/php/mail_cadastro.php"
		document.form_email.submit();
	}
}

function makeIt() {
  MM_validateForm('Nome','','R','EMail','','RisEmail','','','R','','','R');
  if (document.MM_returnValue) document.form1.submit();
 }

 function verifica_cadastro ()
 {
	 form = document.form1;

	 erros = false;
	 if ( !erros && form.Nome.value == "" )
	 {
		 erros = true;
		 alert( "O campo NOME não esta preenchido corretamente" );
		 form.Nome.focus();
	 }

	 if ( !erros && form.EMail.value == "" )
	 {
		 erros = true;
		 alert ( "O campo EMAIL não esta preenchido corretamente" );
		 form.EMail.focus();
	 }

	 if ( !erros && form.Endereco.value == "" )
	 {
		 erros = true;
		 alert ( "O campo RUA/AV não esta preenchido corretamente" );
		 form.Endereco.focus();
	 }

	 if ( !erros && form.Numero.value == "" )
	 {
		 erros = true;
		 alert ( "O campo Nº não esta preenchido corretamente" );
		 form.Numero.focus();
	 }

	 if ( !erros && form.Bairro.value == "" )
	 {
		 erros = true;
		 alert ( "O campo BAIRRO não esta preenchido corretamente" );
		 form.Bairro.focus();
	 }
	 
	 if ( !erros && form.CEP.value == "" )
	 {
		 erros = true;
		 alert ( "O campo CEP não esta preenchido corretamente" );
		 form.CEP.focus();
	 }
	 
	 if ( !erros && form.Cidade.value == "" )
	 {
		 erros = true;
		 alert ( "O campo CIDADE não esta preenchido corretamente" );
		 form.Cidade.focus();
	 }
	 
	 if ( !erros && form.Estado.value == "" )
	 {
		 erros = true;
		 alert ( "O campo ESTADO não esta preenchido corretamente" );
		 form.Estado.focus();
	 }

	 if ( !erros )
	 {
		 form.submit();
	 }
 }

 function valida_email(paCampo) // verifica a validade do e-mail
{
	erros = false;
	if (paCampo == "")
	{
		erros = true;
	}
	else
		{
		prim = paCampo.indexOf("@")
		if(prim < 2)
			{
				erros = true;
			}
		if(paCampo.indexOf("@",prim + 1) != -1)
			{
				erros = true;
			}
		if(paCampo.indexOf(".") < 1)
			{
				erros = true;
			}
		if(paCampo.indexOf(" ") != -1)
			{
				erros = true;
			}
		if(paCampo.indexOf(".@") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("@.") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf(".com.br.") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("/") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("[") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("]") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("(") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf(")") > 0)
			{
				erros = true;
			}
		if(paCampo.indexOf("..") > 0)
			{
				erros = true;
			}
	}
	if (!erros)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function verifica ()
{
	if ( !valida_email( document.form_email.des_email.value ) )
	{
		document.form_email.action="http://www.labcon.com.br/xtras/php/mail_cadastro.php"
		document.form_email.submit();
	}
	else
	{
		alert ( "O campo email não é valido. Favor digitar um email valido." );
	}
}

function enter( paEvento )
{
	if(document.all)  // Internet Explorer
      nTecla = paEvento.keyCode; 
    else if(document.layers) // Nestcape
      nTecla = paEvento.which;

	if ( nTecla == 13 )
	{
		if (!verifica())
		{
			if(document.all)  // Internet Explorer
			  paEvento.keyCode = 27; 
			else if(document.layers) // Nestcape
			  paEvento.which = 27;
			document.form_email.des_email.focus();
		}
	}

	if ( nTecla == 13 )
		return true;
	else
		return false
}

