$(document).ready(function() {
	$('input[@name=submit]').click( function() {
		Browser=navigator.appName;
		if ( $('input[@name=nome]').val() == ''){
			document.getElementById("nome").style.border="solid #6C7CA2 2px";
			document.location="#xa";
			var teste= 'zero';
		}else{
			document.getElementById("nome").style.border="solid #ADADAD 1px";
		}
		if ( $('input[@id=email1]').val() == ''){
			document.getElementById("email1").style.border="solid #6C7CA2 2px";
			document.location="#xa";
			var teste= 'zero';
		}else{
			document.getElementById("email1").style.border="solid #ADADAD 1px";
		}
		var Email=$('#email1').val();
		if (!Email.match(/^[a-zA-Z0-9]{1}([\._a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+){1,3}$/)) {
			$("#email_msg").html(' * Digite um e-mail válido!');
			$("#email_msg").css('color','#9F0909');
			document.getElementById("email1").style.border="2px solid #6C7CA2";
			document.location="#xa";
			var teste= 'zero';
		}else{
			document.getElementById("email1").style.border="solid #ADADAD 1px";
		}
		if ( $('select[@name=dia]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("dia1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("dia").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("dia1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("dia").style.border="solid #ADADAD 1px";
			}
		}
		if ( $('select[@name=mes]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("mes1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("mes").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("mes1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("mes").style.border="solid #ADADAD 1px";
			}
		}
		if ( $('select[@name=ano]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("ano1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("ano").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("ano1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("ano").style.border="solid #ADADAD 1px";
			}	
		}
		if ( $('select[@name=sexo]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("sexo1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("sexo").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("sexo1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("sexo").style.border="solid #ADADAD 1px";
			}
		}
		if ( $('select[@name=cidade]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("cidade1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("cidade").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("cidade1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("cidade").style.border="solid #ADADAD 1px";
			}
		}
		if ( $('select[@name=estado]').val() == ''){
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("estado1").style.border="solid #6C7CA2 2px";
			}else{
				document.getElementById("estado").style.border="solid #6C7CA2 2px";
			}
			document.location="#xa";
			var teste= 'zero';
		}else{
			if(Browser == "Microsoft Internet Explorer"){
				document.getElementById("estado1").style.border="solid #ADADAD 0px";
			}else{
				document.getElementById("estado").style.border="solid #ADADAD 1px";
			}	
		}
		if ( $('input[@name=resposta]').val() == ''){
			document.getElementById("resposta").style.border="solid #6C7CA2 2px";
			document.location="#xa";
			var teste= 'zero';
		}else{
			document.getElementById("resposta").style.border="solid #ADADAD 1px";	
		}
		if($('input[@name=aceito]').is(':checked') == false){
				document.getElementById("aceito_regulamento").style.border="solid #1967B2 2px";
				document.getElementById("aceito_regulamento").style.color="#000";
				document.location="#x";
				var teste= 'zero';
		}

/*		$("input[@name=aceito]").each( 
		    function() { 
				document.getElementById("aceito_regulamento").style.border="solid #1967B2 2px";
				document.getElementById("aceito_regulamento").style.color="#000";
				document.location="#x";
				var teste= 'zero';
		    } 
		);
		if(document.formulario.aceito.checked == false){
			document.getElementById("aceito_regulamento").style.border="solid #1967B2 2px";
			document.getElementById("aceito_regulamento").style.color="#000";
			document.location="#x";
			var teste= 'zero';
		} */
		if (teste == 'zero'){
			$('#info').show();
			return false;
		}
	});
	$("select[@name=pais]").change( function() {
		var resp = "<option value='99'>Outros</option>";
		if($(this).val() != 1){
			$('select[@name=estado]').html(resp);
			$('select[@name=cidade]').html(resp);
		}else if($(this).val() == 1){
			var resp = '<option value=""> Selecione o estado >></option><option value="ac" > Acre</option><option value="al" > Alagoas</option><option value="ap" > Amapa</option><option value="am" > Amazonas</option><option value="ba" > Bahia</option><option value="ce" > Ceara</option><option value="df" > Distrito Federal</option><option value="es" > Espirito Santo</option><option value="go" > Goias</option><option value="ma" > Maranhao</option><option value="mt" > Mato Grosso</option><option value="ms" > Mato Grosso do Sul</option><option value="mg" > Minas Gerais</option><option value="pa" > Para</option><option value="pb" > Paraiba</option><option value="pr" > Parana</option><option value="pe" > Pernambuco</option><option value="pi" > Piaui</option><option value="rj" > Rio de Janeiro</option><option value="rn" > Rio Grande do Norte</option><option value="rs" > Rio Grande do Sul</option><option value="ro" > Rondonia</option><option value="rr" > Roraima</option><option value="sc" > Santa Catarina</option><option value="sp" > Sao Paulo</option><option value="se" > Sergipe</option><option value="to" > Tocantins</option>';
			$('select[@name=estado]').html(resp);
			$('select[@name=cidade]').html('<option value="">Selecione o estado >></option>');
		
		}
	});
});
function is_email(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return 1; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return 1;
                }
    }else{
        return 0;
        }
}
