// JavaScript Document


//numero do linhas já setada
var niLin = 5
//numero inicial de linhas dadas por enters
var niLin_ = 0
//Função de resize no textarea
function cText(obj,evtKeyPress) {
    //puxa o que seria a quantidade de linhas e adiciona a já setada pelos enters...
    nLin = ((obj.value.length)/30)+niLin_;
    //puxa o tamanho em pixels que já foi definido no ta
    cTam = obj.style.height;
    //faz verificação de tecla pressionada (crossbrowser)
    if(evtKeyPress.keyCode) { // Internet Explorer
      nTecla = evtKeyPress.keyCode; }
    else if(evtKeyPress.which) { // Nestcape / firefox
      nTecla = evtKeyPress.which;
    }
    //se a tecla não for o enter
    if (nTecla !== 13) {
        // se o numero de "nLin" ou seja, caracteres digitados, dividido por 30 (uma media de caracteres por linha). for maior que o numero inicial de linhas:
    if (nLin >= niLin) {
        //retira o px da propiedade para poder fazer adição matematica
        cTam = cTam.replace("px","")
        //tranforma em "numero"
        cTam = Math.floor(cTam);
        //faz adição. tamanho segundo a fonte que eu usei.
        obj.style.height = cTam + 18;
        //aumenta o numero "inicial" de linhas
        niLin++;
    }
    } else { //se a tecla digitada for enter.
        //retira o px da propiedade para poder fazer adição matematica
        cTam = cTam.replace("px","")
        //tranforma em "numero"
        cTam = Math.floor(cTam);
        //faz adição. tamanho segundo a fonte que eu usei.
        obj.style.height = cTam + 18;
        //aumenta o numero "inicial" de linhas
        niLin++;
        //aumenta o numero colocado por "enters"
        niLin_++;
    }
}

function cText2(obj,evtKeyPress){
	//nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if(evtKeyPress.which){
		var key = evtKeyPress.which;
	}
	else{
		var key = evtKeyPress.keyCode;
	}
	
	var Height = obj.style.height;
	//obj.style.height = Height;
	
	if(key != 13){
		obj.style.height = parseInt(obj.scrollHeight)+'px';
	}
	else{
		//alert(obj.scrollTop);
		obj.style.height = String( parseInt(obj.scrollHeight)+parseInt(obj.scrollTop) )+'px';
	}
}


