function colorpicker_open(form_element_id) {
    url = './colorpicker.php?sid=q5di01rs8ec5859vsdh1fmn7a6ku3opa';
    if (url.indexOf('?')==-1) url = url + '?' + 'form_element_id=' + form_element_id;
    else                      url = url + '&' + 'form_element_id=' + form_element_id;
    url = url + '&' + 'form_element_format=' + 'hex';
    options = 'dependent=yes,width=330,height=230,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no';
    if (window.opera) {
        options = options + ',left=0';
        options = options + ',top=0';
    }
    else {
        options = options + ',left=' + Math.floor((screen.width-330)/2);
        options = options + ',top=' + Math.floor((screen.height-230)/2);
    }
    window.open(url, 'colorpicker', options);
}

function onkeyup_form_element(form_element_id) {
    var val = document.getElementById(form_element_id).value;
    id = form_element_id + '_colorbox';
    if(YAHOO.util.Color.isValidHex(val)) {
        if(document.getElementById(id)){
            hex = '#' + val;
            document.getElementById(id).style.backgroundColor = hex;
        }
    }
    else if(YAHOO.util.Color.isValidHexSharp(val)) {
        if(document.getElementById(id)){
            hex = val;
            document.getElementById(id).style.backgroundColor = hex;
        }
    }
    else if(YAHOO.util.Color.isValidColorStr(val)) {
        if(document.getElementById(id)){
            hex = YAHOO.util.Color.ColorStr_to_HexSharp(val);
            document.getElementById(id).style.backgroundColor = hex;
        }
    }
}