$(document).ready(function(){
	var fechado     = false;
	var description = $("#div-description");

	abrir = function(description){		
        $(description).css("height","auto");
		$(".moreDescription a").text("[hide]");
		fechado = false;
	};
	fechar = function(description){		
        //$(description).css("height","285px");
        $(description).css("height","290px");
		$(".moreDescription a").text("[more]");
		fechado = true;
	};
	toggle = function(description){        
		if (fechado == false) {
			fechar(description);
		} else {
			abrir(description);
		}
	};	
	verifica = function(programId){        
        var maxChar=859;//911
        var n = parseInt($("#courseDescription").text().length);
        /*var texto = $("#courseDescription").html();
        var l = texto.split("\n").length;
        console.log(texto);*/
        if (programId){
            switch(programId) {
                case 1 :maxChar=1325;break;
                case 2 :maxChar=859;break;
                case 3 :maxChar=859;break;
                default:maxChar=859;break;
            }
        }else{            
            maxChar=859;
        }        
		if (n > maxChar) {
			fechar(description);
			$(".moreDescription").show();
		} else {            
			$(".moreDescription").hide();
		} 
	};
    $(".moreDescription").click(function(){
        toggle(description);
    });
	verifica();
});


