﻿function toggleField(obj,val)
{
    if(obj.value == val)
    {
	    obj.value = "";
    }
    else if(obj.value == "")
    {
	    obj.value = val;
    }
}
function swapImage(obj,val)
{
    if(document.images){
        obj.src = val;
    }
}

function openDiv(objName, id) {
    if ($("#" + objName + id).css("display") == 'none') {
        $("#arrow" + id).attr('src', 'images/reply-arrow-down.jpg');
        $("#" + objName + id).slideDown("5000", null);
    }
    else {
        $("#arrow" + id).attr('src', 'images/reply-arrow-right.jpg');
        $("#" + objName + id).slideUp("5000", null);
    }
}
function expandAllReplies() {
    if ($(".expander").css("display") == 'none') {
        $(".expander").slideDown("5000", null);
        $("#expand").html("Close All");
    }
    else {
        $(".expander").slideUp("5000", null);
        $("#expand").html("Expand All");
    }
}

function keyCounter(texts) {
    document.getElementById("subjectCounter").innerHTML = 40 - texts.length + " character(s) left.";
}
function keyCounter2(texts) {
    if (texts.length > 1000) {

    }
    document.getElementById("subjectCounter2").innerHTML = 1000 - texts.length + " character(s) left.";
}
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
    var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
    var countBody = opt_countBody ? opt_countBody : "countBody";
    var maxSize = opt_maxSize ? opt_maxSize : 1024;

    var field = document.getElementById(countedTextBox);

    if (field && field.value.length >= maxSize) {
        field.value = field.value.substring(0, maxSize);
    }
    var txtField = document.getElementById(countBody);
    if (txtField) {
        txtField.innerHTML = field.value.length;
    }
}