function soNumeros(e){
 //Caso Internet Explorer(IE) outros (Other)
 if (navigator.appName.indexOf('Microsoft') != -1){
 	clientNavigator = "IE";
 }else{
 	clientNavigator = "Other";
 }

 //Função permite digitação de números
 	if (clientNavigator == "IE"){
 		if (e.keyCode < 48 || e.keyCode > 57){
 			return false
 		}
 	}else{
 		if ((e.charCode < 48 || e.charCode > 57) && e.keyCode == 0){
 			return false
 		}
 	}

}  


function FormataCampo(Campo,teclapres,mascara, sai) {

	if (sai == "S" && consistente == "N") {
		if (obrigatorio == "N" && Campo.value.length > 0) {
			obrig_fixo = "S";
			Consist(Campo.maxLength, Campo);
			obrig_fixo = "N";
		}
		if (obrigatorio == "S" || Campo.value.length > 0) {
			if (sai == "S") {
				if (Campo.value.length != mascara.length) {
					alert('O campo precisa estar neste formato:\n\n       '+ mascara);
					Campo.value = "";
				}
				erro = "S";
				return false;
			}
		}
	}
	if (sai == "S" && obrigatorio == "N" && Campo.value.length > 0) {
		obrig_fixo = "S";
		Consist(Campo.maxLength, Campo);
		obrig_fixo = "N";
		if (consistente == "N") {
			alert('O campo precisa estar neste formato:\n\n       '+ mascara);
		}
	}


	strtext = Campo.value;
	tamtext = strtext.length;
	tammask = mascara.length;
	arrmask = new Array(tammask);
	for (var i = 0 ; i < tammask; i++) {
		arrmask[i] = mascara.slice(i,i+1)
	} 

	//alert(teclapres.keyCode );
	if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9"))))) {
		if ((teclapres.keyCode >= 35 && teclapres.keyCode <= 40)||(teclapres.keyCode >= 48 && teclapres.keyCode <= 57)||(teclapres.keyCode >= 96 && teclapres.keyCode <= 105)||(teclapres.keyCode == 8)||(teclapres.keyCode == 9) ||(teclapres.keyCode == 46) ||(teclapres.keyCode == 13)||(teclapres.keyCode == 16)){
			Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext)		
		} else {
			Detona_Event(Campo,strtext)
		}
	} else {
		if ((arrmask[tamtext] == "A")) {
			charupper = event.valueOf()
			Detona_Event(Campo,strtext)
			masktext = strtext + charupper 
			Campo.value = masktext
		}
	}
}

function Organiza_Casa(Campo,arrpos,teclapres_key,strtext){
     if (((arrpos == "/") || (arrpos == ".") || (arrpos == ",") || (arrpos == ":") || (arrpos == " ") || (arrpos == "-")) && !(teclapres_key == 8)){
       separador = arrpos
       masktext = strtext + separador
       Campo.value = masktext
     }
}

function Detona_Event(Campo,strtext){
     event.returnValue = false
     if (strtext != "") {
       Campo.value = strtext
     }
}

//SAFARI WEB BROWSER
$(function(){ 
	if($.browser.safari) {
		$(function(){
			$("head").append("<link rel='stylesheet' href='../../css/safari.css' type='text/css' />");
		});
	}
});
