function validarData( str ){
	var valor = new String( str );
	var valores = valor.split('/');
	var dia = parseInt( valores[0] );
	var mes = parseInt( valores[1] );
	var ano = parseInt( valores[2] );
	if( mes < 1 || mes > 12 ) return false;
	var max = (mes in [4, 6, 9, 11])?(30):(mes == 2)?(28 + (( ano % 4 ) == 0 )):(31);
	if( dia < 1 || dia > max ) return false;
	return true;
}


function mascarar(){
	var inps = document.getElementsByTagName("input");
	for( var i=0; i < inps.length; i++ ){
		var str = new String( inps[i].id );
		if( str.indexOf('telefone') >= 0 ){
			jQuery(function($){     
			$.mask.addPlaceholder("~","[+-]"); 
			$("#"+inps[i].id).mask("(99) 9999.9999");			 
			}); 
			inps[i].size = 14;
		}
		if( str.indexOf('data') >= 0 || str.indexOf('dt_') >= 0 ){
			jQuery(function($){     
			$.mask.addPlaceholder("~","[+-]"); 
			$("#"+inps[i].id).mask("99/99/9999");			 
			}); 
			inps[i].size = 10;
		}
		if( str.indexOf('hora') >= 0 ){
			jQuery(function($){     
			$.mask.addPlaceholder("~","[+-]"); 
			$("#"+inps[i].id).mask("99:99 - 99:99");			 
			}); 
			inps[i].size = 14;
		} 
	}
	
}

function validarForm( form ) {
	for(i=0; i < form.elements.length; i++) {	
		if(typeof(form.elements[i].name) != "undefined") {
			if(form.elements[i].className == "requerido" && form.elements[i].value == "") {
				alert("Preencha todos os campos obrigatórios");
				form.elements[i].focus();
				return false;
			}
		}
	}
	return true;
}


//Permite digitao de nmeros apenas com aviso
function permitirNumero(e){
	var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)){
		return true;
	}else{
    	if (tecla != 8 && tecla !=13 && tecla != 0){ 
			return false;
		}else{
			return true;
		}
	} 
}

//Permite digitao de nmeros e vrgulas
function permitirNumeroVirgula(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)){
		return true;
	}else{
    	if (tecla != 8 && tecla !=13 && tecla != 0 && tecla != 44){ 
			return false;
		}else{ 
			return true;
		}
	} 
}


addEventLis( window, 'load', function(){
	mascarar();
	if( document.getElementById( 'apresentacao' ) ) {
		var so = new SWFObject("images/apre.swf", "movie", "820", "270", "7", "#FFFFFF");		   	   
		so.addParam("wmode", "transparent");
		so.write("apresentacao");
	}
});
