var SERVER_ERRORS = new Array();
function initContact(subjectId,errs) {
    try {
        var errors = new Array();
        var combo = document.getElementById("subjectCombo");
        if(errs == ""){
            errs = getCGIValue(document.location.href,"err");
        }
        if (errs) {
            errors = errs.split(",");
        }
        if (combo) {
            combo.value = subjectId;
        }
        cfv.config({fail:cfv.failHandler,failMessageHandler : showError})
        //    cfv.add("contact_username", ["blur"], ["not_empty","is_length", 6, 12], {messages:"User name length should be between 6 and 12 characters"});
            cfv.add("contact_email", ["blur"], ["not_empty","is_email"], {messages:"Please enter a valid email"});
        cfv.add('captcha', ['blur'], ['not_empty'], {messages:"Please type the text here"});
        cfv.add('contact_comments', ['blur'], ['not_empty'], {messages:"Please enter your comments"});
        if (errors.include(2)) {
            SERVER_ERRORS.push({id:"captcha",err:"The text does not match the image"});
        }
        if (errors.include(4)) {
            SERVER_ERRORS.push({id:"contact_comments",err:"There was a problem sending your message<br/>Try again later"});
        }
        if (errors && errors.include(0)) {
            SERVER_ERRORS.push({id:"contact_comments",err:"Your message was sent successfully",cls:"infoBubble"});
        }
        for (var i = 0; i < SERVER_ERRORS.length; i++) {
            showError(SERVER_ERRORS[i].id, SERVER_ERRORS[i].err, SERVER_ERRORS[i].cls);
        }
    } catch(ex) {
    }
}

function setSubject(val){
    if(val){
        $('subjectCombo').value = val;
        setContactSubject($('subjectCombo'));
    }
}

function sortList(elem) {
    var li = getParentNode(elem);
    var lis = gebi("blogsList").getElementsByTagName("li");

    for (var i = 0; i < lis.length; i++)
        lis[i].className = (lis[i] == li) ? "selected" : "";
}


