﻿/*
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);

function showmenu(elmnt)
        {
            document.getElementById(elmnt).style.display="block";           			
        }
function hidemenu(elmnt)
        {
	        document.getElementById(elmnt).style.display="none";          	
            
        }
        
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;
          }
     }
}

// esta função abre um canal para as chamadas Ajax //
function getRequestXml(){
    if(window.XMLHttpRequest) { // Mozilla, Safari,...
        return new XMLHttpRequest();
        
        if (http_request.overrideMimeType) http_request.overrideMimeType('text/xml');
        
    }else if (window.ActiveXObject) { // IE
        try{
            return new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            try{
                return new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
            }
        }
    }

    if (!http_request) {
        alert('Sem suporte há esta funcionalidade');
        return false;
    }
}

function Popup(url, width, height) {
	window.open(url,"_blank","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=no,width=" + width + ",height=" + height)
}
// Somente Números
function onlynumber(myfield, e, dec)
{
var iKeyCode;
if (!e) {
var e = window.event;
}
if (e.keyCode) {
iKeyCode = e.keyCode;
} else {
if (e.which) {
iKeyCode = e.which;
}
}
switch(iKeyCode) {
case 8:
case 9:
case 37:
case 38:
case 39:
case 40:
case 46:
break;
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
if (e.shiftKey || e.altKey){
return false;
}
break;
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
//return correct numeric from keypad
return iKeyCode - 48; break;
case 110:
case 190:
//if you are supporting decimal points
return '.'; break;
default: return false;
}
}
    
// 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 == 1)
			input.value = '('+input.value;
	if(input.value.length == 3)
	    input.value = input.value+')';
		if(input.value.length == 8)
			input.value = input.value+'-';
	}
}
function showHide(divNivel)
{
    if(document.getElementById(divNivel).style.display == 'block')
        document.getElementById(divNivel).style.display = 'none';
    else
        document.getElementById(divNivel).style.display = 'block';
} 