﻿/*
CSS Browser Selector v0.3.1
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

// Formatando o Fone
function Formato_Fone(input, e)
{
    var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	
    if (keyCode != 8)
	{ 
	    if(input.value.length == 4)
	        input.value = input.value+'-';		
	}
}

function Formato_CEP(input, e)
{
    var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	
    if (keyCode != 9)
	{ 
	    if(input.value.length == 5)
	        input.value = input.value+'-';		
	}
}

function onlynumber(myfield, e,tolerado)
{

	 var tecla  = window.event?event.keyCode:event.which;
	if (tecla == 13 || tecla == 8 || tecla == 37 || tecla == 39 || tecla == 9)
        return true;
        
	//else if (tecla>47 && tecla<58 || tecla > 95 && tecla < 106)
	else if (tecla>47 && tecla<58)
           return true;	
    else
           return false;
}      
function Trim(str){return str.replace(/^\s+|\s+$/g,"");}   
function verificaCampo(campo,valor,comparacao){
    if(valor==comparacao){
        document.getElementById(campo).value="";
        document.getElementById(campo).style.fontStyle = "normal";

    }else if(Trim(valor)==""){
        document.getElementById(campo).value=comparacao;
        document.getElementById(campo).style.fontStyle = "italic";
    }
}

function clickButton(e, buttonid){ 

      var evt = e ? e : window.event;

      var bt = document.getElementById(buttonid);

      if (bt){ 

          if (evt.keyCode == 13){ 

                bt.click(); 

                return false; 

          } 

      } 

}

function show(e){
    document.getElementById(e).style.display='block';
}
function hide(e){
    document.getElementById(e).style.display='none';
}