
function openForm(idForm,idCmdLink,idHref,idTxtFocus){
    
    document.getElementById("profileForm:"+idForm).style.display = '';
    document.getElementById("profileForm:"+idCmdLink).style.display = 'none';
    location.href="#"+idHref;
    document.getElementById("profileForm:"+idTxtFocus).focus();
    return false;
}

function closeForm(idForm,idCmdLink){
    
    document.getElementById("profileForm:"+idForm).style.display = 'none';
    document.getElementById("profileForm:"+idCmdLink).style.display = '';
    location.href="#headerProfileForm";
    var txtBoxes_ = new Array("subject","bodyMessage");
    for(var i=0; i<txtBoxes_.length; i++){
        document.getElementById("profileForm:"+txtBoxes_[i]).value="";
    }
    return false;
}

function validateAddToColleaguesMaxChars(){
    
    var _count = "255";
    var _tex = document.getElementById("profileForm:addToColleaguesBodyMsg").value;
    var _len = _tex.length;
    
    if(_len > _count){
        _tex = _tex.substring(0,_count);
        document.getElementById("profileForm:addToColleaguesBodyMsg").value = _tex;
        return false;
    }
    
    document.getElementById("profileForm:addToColleaguesCounter").firstChild.nodeValue = "Characters typed "+_len+" of "+_count;
    
    if(_len==255){
        document.getElementById("profileForm:addToColleaguesCounter").style.color='red';
        document.getElementById("profileForm:addToColleaguesCounter").firstChild.nodeValue = "Max characters 255 reached.";
    }else{
        document.getElementById("profileForm:addToColleaguesCounter").style.color='#505050';
    }
}

function swapOn(id){    
    document.getElementById("profileForm:"+id).src = '/WatProfilePortlet/images/RadioButtonON.png';
}

function swapOff(id){  
    document.getElementById("profileForm:"+id).src = '/WatProfilePortlet/images/RadioButtonOFF.png';
}
