// JavaScript Document

function expandit(folder) {
    if (folder.style.display == "none")
        folder.style.display = "";
    else
        folder.style.display = "none";
}

function id(e) {
    return document.getElementById(e);
}

function dropBula(o) {
    window.open(id(o.id).value);
}

function deportMeTo(where) {
    //top.location.href = where.options[where.selectedIndex].value;
    window.open(where.options[where.selectedIndex].value);
    where.options.selectedIndex = 0;
}

function abreChat() {
				var pop_window = window.open("http://www4.directtalk.com.br/server/directtalk_chatr.dll/user?S=I&id_s=68&origem=Fale%20Conosco","janela","width=350,height=350,resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0");
				pop_window.focus();
				//document.getElementById('auto').submit();
			}

function FormataCampo(Campo,teclapres,mascara){ 

    strtext = Campo.value 
    tamtext = strtext.length 
    //pegando o tamanho da mascara 
    tammask = mascara.length 
    //criando um array para guardar cada caractere da máscara 
    arrmask = new Array(tammask) 
    //jogando os caracteres para o vetor 
    for (var i = 0 ; i < tammask; i++){ 
        arrmask[i] = mascara.slice(i,i+1) 
    } 
    
    //alert (teclapres.keyCode) 
    //começando o trabalho sujo 
    if (((((arrmask[tamtext] == "#") || (arrmask[tamtext] == "9"))) || (((arrmask[tamtext+1] != "#") || (arrmask[tamtext+1] != "9")))))
    { 
        if ((teclapres.keyCode >= 37 && 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)){ 
            Organiza_Casa(Campo,arrmask[tamtext],teclapres.keyCode,strtext) 
            } 
        else { 
            Detona_Event(Campo,strtext) 
            } 
    } 
    else{//Aqui funcionaria a mascara para números mas eu ainda não implementei 
    
    if ((arrmask[tamtext] == "A")) { 
        charupper = event.valueOf() 
        //charupper = charupper.toUpperCase() 
        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 
    } 
}  

function somente_numero(campo){
    var digits="0123456789,-"
    var campo_temp 
    for (var i=0;i<campo.value.length;i++){
        campo_temp=campo.value.substring(i,i+1) 
        if (digits.indexOf(campo_temp)==-1){
        campo.value = campo.value.substring(0,i);
        break;
        }
    }
}

function montaMascara( objCampo, tpMascara ) 
{			   					   
	var teclaSeparador;
							   
	if( tpMascara == 'C' )	
		teclaSeparador = 5;
	else
		teclaSeparador = 2;
	
	if ( document.all ) // Internet Explorer
		tecla = event.keyCode;
	else if( document.layers ) // Nestcape
		tecla = event.which;
	
	if( objCampo.value.length == teclaSeparador || ( tpMascara == 'T' && objCampo.value.length == 7 ) )
	{
		if( tecla == 45 ) // Caracter -
			return true;
		else
		{
			objCampo.value += "-";	
			return false;
		}
	}

	if ( tecla > 47 && tecla < 58 ) // numeros de 0 a 9	
		return true;
	else if ( tecla != 8 ) // backspace
		event.keyCode = 0;
	else
		return true;
}
