function onlogin_started() {
 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {
                    var res=xmlhttp.responseText;
					if(res=="0")
						window.location="index.php?ch=trabalheconosco";
               } 
          }
     };
     xmlhttp.open("GET", "worksource/home/includes/cheq_login.php");
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); 
     xmlhttp.send(null);
}

function window_report(obj){
 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {
                    document.getElementById(obj).innerHTML=xmlhttp.responseText;
               } 
          }
     };
     xmlhttp.open("GET", "worksource/home/includes/window_report.php");
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
     xmlhttp.send(null);	
}

function sendreport(obj) {

	var yourmail=document.getElementById('yourmail').value;
	var abouerror=document.getElementById('abouterror').value;

	if(yourmail!=""){
		if(yourmail.indexOf('@')==-1 || yourmail.indexOf('.')==-1 ) {
			alert("O e-mail informado não é válido");
			document.getElementById('yourmail').focus(); 
			return false; 
		}
	}
	
	if(abouerror==""){
		alert("Para continuar é necessário descrever o(s) erro(s) motivador(es) deste contato");
		document.getElementById('abouterror').focus(); 
		return false; 		
	}
	
	if(yourmail==""){
		if (!confirm('Nenhum e-mail foi inserido, o que sugere que este contato não exigirá retorno.\nDeseja continuar sem inserir um e-mail para contato?')){
			document.getElementById('yourmail').focus();
			return false;
		}
	}

	var params;
	params = "yourmail="+yourmail;
	params+= "&aerror="+abouerror;

 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {
					document.getElementById(obj).innerHTML=xmlhttp.responseText;             	
               } 
          }
     };
     xmlhttp.open("POST", "worksource/home/includes/send_report.php", true);
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     xmlhttp.send(params);
}

function masknumbers(e,src,mask) {
	if(window.event) { 
		_TXT = e.keyCode; 
	} else if(e.which) { 
		_TXT = e.which; 
	}
	
	if(_TXT > 47 && _TXT < 58) { 
		var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
		if (texto.substring(0,1) != saida) {
			src.value += texto.substring(0,1); 
		} 
		return true; 
	} else { 
		if (_TXT != 8) { 
			return false; 
		} else {
			return true; 
		}
	}
}

function masktel(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


	if(document.all) { // Internet Explorer
	    nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
	    nTecla = evtKeyPress.which;
	} else {
	    nTecla = evtKeyPress.which;
	    if (nTecla == 8) {
	        return true;
	    }
	}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } 
      else { // qualquer caracter...
        return true;
      } 
    }
    else {
      return true;
    }
}

function convertField(field) {
	field.value = field.value.toUpperCase();
}
