//"Enables" a reply box
function makeTextAreaActive() {
    if (document.getElementById("fast-reply_textarea")) {
        var area = document.getElementById("fast-reply_textarea");
        if(area.value == area.initialText) {
            area.value = '';
        }
        area.style.backgroundColor = "#FFF";
        area.style.color = "#000";
    }
}

//Greys out reply box
function DeactivateTextArea() {
    var area = document.getElementById("fast-reply_textarea");
    area.style.backgroundColor = "#EFEFEF";
    area.style.color = "#515151";
	if(area.value == '') {
	    area.value = area.initialText;
	}
}


//Saves orignal reply box text
function initTextArea() {
    if (document.getElementById("fast-reply_textarea")) {
        var area = document.getElementById("fast-reply_textarea");
    }
}

//Adds a smiley to the reply box
function addSmiley(text) {
    if (document.getElementById("fast-reply_textarea")) {
        var area = document.getElementById("fast-reply_textarea");
        area.value += " "+text+" ";
    }
}

// Changes the comment list height based on the user's screen.height
function changeCommentListHeight() {
    var area = document.getElementById("articleDiscussion");
    var commentList = area.getElementsByTagName("ol")[0];
    var screenHeight;
    if (document.documentElement.clientHeight)
        screenHeight = document.documentElement.clientHeight;
    else
        screenHeight = window.innerHeight;

    var multiplier = (window.screen.height > 1024) ? 0.6 : 0.5; 
    var height = screenHeight * multiplier;
    commentList.style.height = height + "px";
}

window.onload = function() {
        var area = document.getElementById("fast-reply_textarea");
	area.initialText = area.value;
    changeCommentListHeight();
}
