function encaminhar() {
	var link;
	var empresaSelecionada = document.getElementById("empresa").options[document.getElementById("empresa").selectedIndex].value; 
	if("Selecione" == empresaSelecionada) {
		//alert("Seleciona alguma coisa né mano !");
	} else {
		if("Banco Votorantim" == empresaSelecionada) {
			//alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=1");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=1"
		} else if("VAM - Votorantim Asset Management" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=9");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=9"
		} else if("Votorantim Corretora" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=8");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=8"	
		} else if("BV Financeira" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=4");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=4"
		} else if("BV Leasing" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=5");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=5"
		} else if("BV Sistemas" == empresaSelecionada) {
			//		alert("mandei para http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=7");
			link="http://votorantimfinancas.ats.hrsmart.com/cgi-bin/a/viewprofile.cgi?companyid=4?empresa=7"
		}
		var width = 603;
		var height = 450;
		var left   = (screen.width  - width)/2;
		var top    = (screen.height - height)/2;
		var params = 'width='+width+', height='+height;
		params += ', top='+top+', left='+left;
		params += ', directories=no';
		params += ', location=no';
		params += ', menubar=no';
		params += ', resizable=no';
		params += ', scrollbars=yes';
		params += ', status=no';
		params += ', toolbar=no';
	
		newwin=window.open(link,'trabalhe', params);
		if (window.focus) {newwin.focus();}
		return false;			
	}
}

$().ready(function(){
	$.mask.addPlaceholder("~","[+-]");
	$("#txtDDD").mask("99");
	$("#txtTelefone").mask("9999-9999"); 			
});

function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = ""
        return false
    }
    status = ""
    return true
}

var whitespace = " \t\n\r";
function isEmail (s)
{  
	
 if (isEmpty(s)) 
       //if (isEmail.arguments.length == 1) return defaultEmptyOK;
       //else return (isEmail.arguments[1] == true);
   
    if (isWhitespace(s)) return false;
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

 function VerificarForm()
 {
             div = document.getElementById("msgErroEmail");
             div.style.display="none";
             div = document.getElementById("msgErro");
             div.style.display="none";
             
             var flag = 0;
             var flag1 = 0;
             
             for( i=0; i<document.frmEmail.length; i++ )
             {
                         if( document.frmEmail[i].value == "" && document.getElementById("msg_" + document.frmEmail[i].name) )
                         {
                                     var div = document.getElementById("div_" + document.frmEmail[i].name);
                                     div.style.color="#E10101";
                                     div = document.getElementById("msgErro");
                                     div.style.display="block";
                                     if (flag1==0) {
                                                 document.frmEmail[i].focus();
                                                 flag1=1;
                                     }
                                    flag = 1;
                         } else if (document.getElementById("msg_" + document.frmEmail[i].name)) {
                                     var div = document.getElementById("div_" + document.frmEmail[i].name);
                                     div.style.color="#666666";
                         }
             }
             
             if( !isEmail($('#txtEmail').val()) && flag == 0) {
                         div = document.getElementById("msgErroEmail");
                         div.style.display="block";
                         $('#txtEmail').focus();
                         div = document.getElementById("div_txtEmail");
                         div.style.color="#E10101";
             }

             if (flag == 0) {
                         div = document.getElementById("msgErro");
                         div.style.display="none";
                         if(isEmail($('#txtEmail').val())){
                                     div = document.getElementById("msgErroEmail");
                                     div.style.display="none";
                                     document.frmEmail.submit();     
                         }
             }
 }
