﻿/*
CSS Browser Selector v0.3.4 (Sep 29, 2009)
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 pageLoad()
{
var isAsyncPostback = Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack();
if (isAsyncPostback) {
tb_init('a.thickbox, area.thickbox, input.thickbox');
}
}
function GetXMLHttpRequest(){
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){}
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){}
            try {
                return new XMLHttpRequest();
            }
        catch(e){}       
      
        return null;
    }
var xmlhttp=GetXMLHttpRequest();
     
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',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.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':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 showhidemenu(elmnt)
        {
        if(document.getElementById(elmnt).style.display == "none")
	        document.getElementById(elmnt).style.display = "block";  
	        else
	          document.getElementById(elmnt).style.display = "none";  	
        }  
   
function onlynumber(myfield, e,tolerado)
{
	if (myfield.length ==0)
		myfield.value=0;  
	
	var key;
	var keychar;
	
	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) || (key==9)|| (key==13)|| (key==27) )
		return true;
	else if ((("0123456789"+tolerado).indexOf(keychar) > -1)){
		if (((myfield.value).indexOf(tolerado) > -1)&&(keychar==tolerado))
			return false;
		else if ((myfield.value.length==0)&&(keychar==tolerado))
		{
			myfield.value = "0";
			return true;	
		}
		else
			return true;
	}
	else
		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 Formato_Fone2(input, e)
{
    var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	
    if (keyCode != 9)
	{ 
	if(input.value.length == 1)
			input.value = '('+input.value;
	if(input.value.length == 3)
	    input.value = input.value+') ';
		if(input.value.length == 9)
			input.value = input.value+'-';
	}
}

// Formatando o CPF        
function Formato_CPF(input, e){
	 var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	 if (keyCode != 8){
		if(input.value.length == 3){
			input.value = input.value+'.';
		}
		if(input.value.length == 7){
			input.value = input.value+'.';
		}
		else if(input.value.length == 11){
			input.value = input.value+'-';
		}
	}
}
     
     
// Formatando o Data
function Formato_Data(input, e)
{
    var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	
    if (keyCode != 8)
	{ 
		if(input.value.length == 2 || input.value.length == 5)
			input.value = input.value+'/';
	}
}

// Início do código de Aumentar/ Diminuir a letra  
	var tagAlvo = new Array('p','a','em','div','span','li','strong','b','i','u','h1','h2','h3','h4'); 
	//pega todas as tags p//  
	// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
	var tamanhos = new Array( '9px','11px','13px','15px','17px','19px','21px' );
	var tamanhoInicial = 2;
	function mudaTamanho( idAlvo,acao ){
	if (!document.getElementById) 
	return   
	var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
	tamanho += acao; 
	
	if ( tamanho < 0 )
		tamanho = 0;   
	if ( tamanho > 6 )
			tamanho = 6;
			tamanhoInicial = tamanho;
	if ( !( selecionados = document.getElementById( idAlvo ) ) )
		selecionados = document.getElementsByTagName( idAlvo )[ 0 ];

		if(selecionados!=null){
		selecionados.style.fontSize = tamanhos[ tamanho ];

	for ( i = 0; i < tagAlvo.length; i++ )
	{    
		    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
		    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
	} 
	}
	} 
	// Fim do código de Aumentar/ Diminuir a letra 
	
	function limparPadrao(campo) 
        {
            if (campo.value == campo.defaultValue) 
            {
                campo.value = "";
            }
        }
        
        function escreverPadrao(campo) 
        {
            if (campo.value == "") 
            {
                campo.value = campo.defaultValue;
            }
        } 
        
        function FileStateChanged(uploader, file, httpStatus, isLast){
                    Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
                    if(file.state > Flajaxian.File_Uploading && isLast){
                        salvaUpload(file.name);
                    }
                }
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 clickButtonBusca(e, buttonid,sender){ 

        if(sender == "ctl00_txtBusca"){
      var evt = e ? e : window.event;

      var bt = document.getElementById(buttonid);

      if (bt){ 

          if (evt.keyCode == 13){ 

                bt.click(); 

                return false; 

          } 
      } 
      }
}

function clickButtonLogin(e, buttonid,sender)
{ 
    if(sender == "ctl00_ContentPlaceHolder1_Direita1_txtSenha" || sender == "ctl00_ContentPlaceHolder1_Direita1_txtCodigo")
    {
        var evt = e ? e : window.event;
        var bt = document.getElementById(buttonid);
        if (bt)
        { 
            if (evt.keyCode == 13)
            { 
                bt.click(); 
                return false;
            }
        } 
    }else if(sender == "ctl00_ContentPlaceHolder1_Direita1_txtLogin")
    {
        
    }
}

function salvaUpload(file)
{
    var url="/telas/restrita/salva_upload.aspx?file="+file;
    url=url+"&sid="+Math.random();
    document.getElementById("liMsg").innerHTML="";
     xmlhttp.open("GET",url,false);
    xmlhttp.send(null);
	if(xmlhttp.readyState == 4){ 
            retorno = xmlhttp.responseText;
            if(retorno == "true")
                document.getElementById("liMsg").innerHTML= "Upload efetuado com sucesso!";
            else
                document.getElementById("liMsg").innerHTML= "Erro ao efetuar o upload!";
        }
}
function menuAtivacao(m,d,p,t){
    for(i=1;i<=t;i++)
    {
        div = p+i;
        divM = m+i;
        document.getElementById(div).style.display='none';
        document.getElementById(divM).style.fontWeight='';
        if(d==i){
            document.getElementById(div).style.display='block';
            document.getElementById(divM).style.fontWeight = 'bold';
        }
    }    
}

function limparBuscar(campo) 
        {
            var txt = document.getElementById(campo);
            if (txt.value == "Buscar...") 
            {
                txt.value = "";
            }
        }
        
        function escreverBuscar(campo) 
        {
            var txt = document.getElementById(campo);
            if (txt.value == "") 
            {
                txt.value = "";
                txt.value = "Buscar...";
            }
        }
