
function textCounter(obj_textarea, maxlimit) {

    if (obj_textarea.value.length > maxlimit){
        obj_textarea.value = obj_textarea.value.substring(0, maxlimit);
        alert("You have reached the maximum amount of characters for this field");
    }
    else{
        //placeholder
    }
}


function popup(url, type){
    //if(type=="incident"){
    //    window.open(url, "", "width=380,height=380,resizable=no,scrollbars=yes,menubar=no,status=no");
    //}
    //else if(type=="customer" || type=="user"){
    //    window.open(url, "", "width=380,height=380,resizable=no,scrollbars=yes,menubar=no,status=no");
    //}
    //else if(type=="calendar"){
        window.open(url, "", "width=210,height=230,resizable=no,scrollbars=yes,menubar=no,status=no");
    //}
    //else if(type == "upload")
    //    window.open(url, "", "width=380,height=254,resizable=no,scrollbars=no,menubar=no,status=no");
    
}



function highlightlist(e)
{
    var r = null;
    var size = 0;
    var i = 0;
    var checked = 0;

    checked = e.checked;

    if (e.parentNode && e.parentNode.parentNode) {
        r = e.parentNode.parentNode;
        size = r.childNodes.length;

        if (r) {
            //lets do all the cells, if you dont do it this way you cant have borders on your cells
            for(i=0; i < size; i++){

                if (checked == 1) {
                    if(r.childNodes.item(i).className == "listingcontent" || r.childNodes.item(i).className == "highlightrow")
                        r.childNodes.item(i).className = "highlightrow";
                    else
                        r.childNodes.item(i).className = "highlightrowleft";
                }
                else{
                    if(r.childNodes.item(i).className == "highlightrow" || r.childNodes.item(i).className == "listingcontent")
                        r.childNodes.item(i).className = "listingcontent";
                    else
                        r.childNodes.item(i).className = "listingcontentleft";
                }
            }
        }
    
    }
    else if (e.parentElement && e.parentElement.parentElement) {
        r = e.parentElement.parentElement;
        size = r.elements.length;

        if (r) {
            //lets do all the cells, if you dont do it this way you cant have borders on your cells
            for(i=0; i < size; i++){

                if (r[i].className == "listingcontent") {
                    r[i].className = "highlightrow";
                }
                else
                    r[i].className = "listingcontent";
            }
        }
    
    }
}

function getIndex(list, value){
    for(i=0; i < list.options.length; i++){
        if(list.options[i].value == value)
            return i;
    }
    return 0;
    
}

function focusnext(field, max, nextfield){
    if((field.value.length) == max){
        document.forms[1].elements(nextfield).focus();
    }
    
}

function forwardUrl(url){
    top.frames["view"].location = url;    
}


function hoverlink(object){
    if(object.className == "applink")
        object.className = "applinkhover";
    else
        object.className = "applink";
    
}


function toggleField(checkField, field){

    if(document.forms[0].elements(checkField).value == 0){
        document.forms[0].elements(field).disabled = true;
        document.forms[0].elements(field).className = "disabled";
    }
    else{
        document.forms[0].elements(field).disabled = false;
        document.forms[0].elements(field).className = "enabled";
    }
}