/**
 * UICC Core Javascript Library
 * 
 * @package All_Packages
 * @subpackage PresentationScripts
 * @copyright UICC 2006 - 2008 unless external source specified
 */

/**
 * Source: http://www.somacon.com/p143.php
 * 
 * return the value of the radio button that is checked
 * return an empty string if none are checked, or
 * there are no radio buttons
 */
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/**
 * Select all and copy to clipboard
 * Source: http://www.geekpedia.com/tutorial126_Clipboard-cut-copy-and-paste-with-JavaScript.html
 */
function copyToClipboard(obj_p) {
    obj_p.focus();
    obj_p.select();
    var copiedTxt = document.selection.createRange();
    copiedTxt.execCommand("Copy");
}

function isIE() {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf ( "MSIE " );
    return (0 < msie);
}

/**
 * Partial fix for IE's getElementsByName()
 * Source: http://www.dreamincode.net/code/snippet293.htm
 */
function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

/**
 * Source: [Goo03], page 205
 */
function submitViaEnter(evt) {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = document.forms[0]; // target.form;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
        //if (validateForm(form)) {
            form.submit();
            return false;
        //}
    }
    return true;
}

function setValueAndSubmitViaEnter(name, value, evt) {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = document.forms[0]; // target.form;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) {
        //if (validateForm(form)) {
            eval('form.'+ name + ' .value=\''+ value + '\';');
            form.submit();
            return false;
        //}
    }
    return true;
}

/**
 * Is the pressed key the enter or return key?
 */ 
function isEnter(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
    return (charCode == 13 || charCode == 3);
}

/**
 * Source: http://www.java2s.com/Code/JavaScript/Form-Control/FocusNextControl.htm
 */
function focusNext(form, elemName, evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13) {
        form.elements[elemName].focus();
        return false;
    }
    return true;
}

/**
 * Search for a specific value in an array
 *
 * @param mixed needle_p 
 * @param array haystack_p
 * @param int initial_p The initial search position, default 0
 * @return int The position found, or -1
 */
function searchInArray(/* mixed */ needle_p, /* array */ haystack_p, /* int */ initial_p) {
    if ( ! haystack_p) {haystack_p = [];}
    if ( ! initial_p) {initial_p = 0;}
    var nbFields = haystack_p.length;
    var i = 0;
    for(i = 0 ; i < nbFields ; i++) {
        var j = (i + initial_p) % nbFields;
        if (haystack_p[j] == needle_p) {return j;}
    }
    return -1;
}

/**
 * Search for a specific string start in an array
 *
 * @param mixed needle_p 
 * @param array haystack_p
 * @param int initial_p The initial search position, default 0
 * @return int The position found, or -1
 */
function searchBeginWithInArray(/* mixed */ needle_p, /* array */ haystack_p, /* int */ initial_p) {
    if ( ! haystack_p) {haystack_p = [];}
    if ( ! initial_p) {initial_p = 0;}
    var nbFields = haystack_p.length;
    var i = 0;
    var len = needle_p.length;
    for(i = 0 ; i < nbFields ; i++) {
        var j = (i + initial_p) % nbFields;
        if (haystack_p[j].substr(0, len) == needle_p) {return j;}
    }
    return -1;
}

/**
 * Search for a specific substring in an array
 *
 * @param mixed needle_p 
 * @param array haystack_p
 * @param int initial_p The initial search position, default 0
 * @return int The position found, or -1
 */
function searchSubstringInArray(/* mixed */ needle_p, /* array */ haystack_p, /* int */ initial_p) {
    if ( ! haystack_p) {haystack_p = [];}
    if ( ! initial_p) {initial_p = 0;}
    var nbFields = haystack_p.length;
    var i = 0;
    var len = needle_p.length;
    for(i = 0 ; i < nbFields ; i++) {
        var j = (i + initial_p) % nbFields;
        if (0 <= haystack_p[j].indexOf(needle_p)) {return j;}
    }
    return -1;
}

/**
 * Is the specied value in the specified array
 *
 * @param mixed needle_p 
 * @param array haystack_p
 * @return boolean
 */
function inArray(/* mixed */ needle_p, /* array */ haystack_p) {
    if ( ! haystack_p) {haystack_p = [];}
    return (0 <= searchInArray(needle_p, haystack_p));
}

/**
 * Similar to the PHP array_diff function 
 */
function arrayDiff(/* array */ array1_p, /* array */ array2_p) {
    if ( ! array1_p) {array1_p = [];}
    if ( ! array2_p) {array2_p = [];}
    var size = array2_p.length;
    var i = 0;
    var pos = 0;
    for (i = 0 ; i < size ; i++) {        
        pos = searchInArray(array2_p[i], array1_p);
        if (0 > pos) {continue;}
        array1_p.splice(pos, 1);
    }
    return array1_p;
}

/**
 * Similar to the PHP implode function
 *
 * @param string sep
 * @param array arr
 * @return string
 */
function implode(/* string */ sep, /* array */ arr) {
    if ( ! arr) {arr = [];}
    var out = '';
    var s = '';
    var size = arr.length;
    for (var i = 0; i < size; i++) {
        out += s + arr[i];
        s = sep;
    }
    return out;
}

/**
 * Tests whether the specified field name exists in the specified form
 *
 * @param string sep
 * @param array arr
 * @return string
 */
function fieldInForm(form_p, fieldName_p) {
    var size = form_p.length;
    for (var i = 0; i < size; i++) {
        if (fieldName_p == form_p[i].name) {return true;}
    }
    return false;
}

/**
 * Disable all selects in a form
 *
 * Select boxes whose names are listed in the "exceptions" array are skipped. 
 * Additionally, NON-select-box fields that are NOT listed in the "exceptions" array 
 * are skipped as well.
 *
 * This means that if the "exceptions" array is empty, all select boxed are affected, 
 * but no other field is. 
 *
 * @param boolean value True if the select boxes must be DISABLED, and false if
 * they must be ENABLED. 
 * @param array exceptions Already explained
 * @param int timeout_to_disable The timeout to disable all selects again. Set this value to 99999999 
 * if you don't want any timeout
 * @return boolean Success flag
 */
function disableAllSelects(/* boolean */ value, /* array */ exceptions, /* int */ timeout_to_disable) {     
    if ( ! exceptions) {exceptions = [];}
    if ( ! timeout_to_disable )                 {timeout_to_disable = 15000;}
    else if (timeout_to_disable >= 99999999)    {timeout_to_disable = 0;}
    
    var form = document.forms[0];
    
    if ( ! form) return false;
    
    var size = form.length;
    for (var i = 0; i < size; i++) {
        if ( ! form[i].name) {continue;}
        if (('select-one' == form[i].type) || ('select-multiple' == form[i].type)) {
            if (inArray(form[i].name, exceptions)) {continue;}    // Do not disable the exceptions
            form[i].disabled=value;
        } else {
            if ( ! inArray(form[i].name, exceptions)) {continue;} // Disable the exceptions only
            form[i].disabled=value;
        }
    }
    var size = form.length;
    for (var i = 0; i < size; i++) {
        if ( ! form[i].name) continue;
        if ('select_box_lock' == form[i].name.substr(0, 15)) {form[i].checked = ( ! value );}
    }
    var arg2 = implode("', '", exceptions);
    if (arg2) {arg2 = "'" + arg2 + "'";}
    if ( ! value && 0 < timeout_to_disable)  {window.setTimeout("disableAllSelects(true, [" + arg2 + "]);", timeout_to_disable);}
    return true;
}

/**
 * Disable specific fields in a form
 *
 * It is possible to have several locks for several arrays of field names
 *
 * @param string  lock_name The name of the lock field (typically a check box)
 * @param boolean value     True if the fields must be DISABLED, and false if
 *                          they must be ENABLED. 
 * @param array   names     The names of the fields that must be disabled or
 *                          enabled
 * @return boolean Success flag
 */
function disableSpecificFields(/* string */ lock_name, /* boolean */ value, /* array */ names, /* int */ timeout_to_disable) {
    if ( ! names) {names = [];}
    if ( ! timeout_to_disable) {timeout_to_disable = 15000;} 
    var form = document.forms[0];
    var size = form.length;
    for (var i = 0; i < size; i++) {
        if ( ! inArray(form[i].name, names)) {continue;}    // Disable the names
        form[i].disabled=value;
    }
    if (fieldInForm(form, lock_name)) {eval("form." + lock_name + ".checked = ( ! value );");}
    var arg2 = implode("', '", names);
    if (arg2) {arg2 = "'" + arg2 + "'";}
    if ( ! value && 0 < timeout_to_disable)  {window.setTimeout("disableSpecificFields('" + lock_name + "', true, [" + arg2 + "]);", timeout_to_disable);}
    return true;
}

/**
 * Source: http://www.actulab.com/les-cookies-en-javascript.php
 */ 
function getCookieVal(offset) {
    var endstr=document.cookie.indexOf (";", offset);
    if (endstr==-1) endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr)); 
}
/**
 * Source: http://www.actulab.com/les-cookies-en-javascript.php
 */ 
function readCookie(name_p) {
    var arg=name_p+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen) {
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
    }
    return null; 
}
/**
 * Source: http://www.actulab.com/les-cookies-en-javascript.php
 */ 
function writeCookie(name_p, value_p) {
    var argv=writeCookie.arguments;
    var argc=writeCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=name_p+"="+escape(value_p)+
    ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
    ((path==null) ? "" : ("; path="+path))+
    ((domain==null) ? "" : ("; domain="+domain))+
    ((secure==true) ? "; secure" : "");
    return true;
}

function makeCollapsableObjectVisible(obj) {
    if (isIE()) obj.style.display = 'inline';
    else        obj.style.visibility = 'visible';
    return true;
}

function makeCollapsableObjectInvisible(obj) {
    if (isIE()) obj.style.display = 'none';
    else        obj.style.visibility = 'collapse';
    return true;
}

/**#@+
 * Get and set the status of the given collapsable block
 *
 * @copyright UICC 2008
 * @author FC
 */
function readCollapsableBlockStatus(block_name_p) {
    var cname = collapsable_library + '_' + block_name_p;
    var cval = readCookie(cname);
    if ( ! cval || '1' != cval) return false;
    return true;
}
function writeCollapsableBlockStatus(block_name_p, status_p) {
    var cname = collapsable_library + '_' + block_name_p;
    return writeCookie(cname, (status_p ? '1' : '0')); 
}
/**#@-*/
function getCollapsableBrokenRefBlockControlValue(status_p) {
    return (status_p ? 'Click here to hide all broken reference issues' : 'Click here to display all broken reference issues'); 
}
/**
 * Switch the status of the given collapsable block
 *
 * @copyright UICC 2008
 * @author FC
 */
function switchCollapsableBlockStatus(img_p, block_name_p) {
    var status_visible = readCollapsableBlockStatus(block_name_p);
    // Switch
    status_visible = ! status_visible;
    writeCollapsableBlockStatus(block_name_p, status_visible);
    // Update image and visibility
    img_p.src =(status_visible ? collapsable_img_src_visible : collapsable_img_src_collapsed); 
    var blocks = getElementsByName_iefix('tr', block_name_p);
    for (var block_id in blocks) {
        if ( ! blocks[block_id].style) continue; 
        if (status_visible) makeCollapsableObjectVisible(blocks[block_id]);
        else                makeCollapsableObjectInvisible(blocks[block_id]);
    } 
    
    // Now the broken reference blocks
    block_name_p = 'broken_ref_' + block_name_p;
    var broken_ref_visible = readCollapsableBlockStatus(block_name_p);
    // Update visibility
    blocks = getElementsByName_iefix('tr', block_name_p);
    for (var block_id in blocks) {
        if ( ! blocks[block_id].style) continue; 
        if (broken_ref_visible && status_visible)   makeCollapsableObjectVisible(blocks[block_id]);
        else                                        makeCollapsableObjectInvisible(blocks[block_id]);
    } 
    return true;
}
/**
 * Switch the status of the given collapsable block
 *
 * @copyright UICC 2008
 * @author FC
 */
function switchCollapsableBrokenRefBlockStatus(btn_p, block_name_p) {
    try {
        var status_visible = true;
        if (0 < collapsable_block_names.length) status_visible = readCollapsableBlockStatus(block_name_p);
        block_name_p = 'broken_ref_' + block_name_p;
        var broken_ref_visible = readCollapsableBlockStatus(block_name_p);
        // Switch
        broken_ref_visible = ! broken_ref_visible;
        writeCollapsableBlockStatus(block_name_p, broken_ref_visible);
        btn_p.value = getCollapsableBrokenRefBlockControlValue(broken_ref_visible); 
        var blocks = getElementsByName_iefix('tr', block_name_p);
        var l = blocks.length;
        for (var i = 0; i < l; i++) {
            if ( ! blocks[i].style) continue; 
            if (broken_ref_visible && status_visible)   makeCollapsableObjectVisible(blocks[i]);
            else                                        makeCollapsableObjectInvisible(blocks[i]);
        } 
    } catch (err) {
        return false;
    }
    return true;
}
/**
 * Initialize all collapsable blocks
 *
 * @copyright UICC 2008
 * @author FC
 */
function initAllCollapsableBlockStatus() {
    try {
        for (var bnid in collapsable_block_names) {
            var bname = collapsable_block_names[bnid];
            var img = document.getElementById('collapsable_image_' + bname);
            if ( ! img) continue;
            var bstatus = readCollapsableBlockStatus(bname);
            img.src = (bstatus ? collapsable_img_src_visible : collapsable_img_src_collapsed);
            var blocks = getElementsByName_iefix('tr', bname); 
            var l = blocks.length;
            for (var i = 0; i < l; i++) {
                if ( ! blocks[i].style) continue; 
                if (bstatus)    makeCollapsableObjectVisible(blocks[i]);
                else            makeCollapsableObjectInvisible(blocks[i]);
            } 
        }
        if ( ! broken_ref_block_names) return false;
        for (var bnid in broken_ref_block_names) {
            var bname = broken_ref_block_names[bnid];
            var btn = document.getElementById('collapsable_broken_ref_button_' + bname);
            if ( ! btn) continue;
            
            var status_visible = true;
            if (0 < collapsable_block_names.length) status_visible = readCollapsableBlockStatus(bname);
            bname = 'broken_ref_' + bname;
            var broken_ref_visible = readCollapsableBlockStatus(bname);
            btn.value = getCollapsableBrokenRefBlockControlValue(broken_ref_visible); 
            var blocks = getElementsByName_iefix('tr', bname); 
            var l = blocks.length;
            for (var i = 0; i < l; i++) {
                if ( ! blocks[i].style) continue; 
                if (broken_ref_visible && status_visible)   makeCollapsableObjectVisible(blocks[i]);
                else                                        makeCollapsableObjectInvisible(blocks[i]);
            } 
        }
    } catch (err) {
        return false;
    }
    return true;
}

/**#@-*/
/**
 * Choose a specific tab
 *
 * @copyright UICC 2008
 * @author FC
 */
function choose_tab(id_p, a_prefix_p, div_prefix_p, all_tabs_ids_p) {  
    for (var i in all_tabs_ids_p) {
        if (document.getElementById(div_prefix_p + all_tabs_ids_p[i]))  document.getElementById(div_prefix_p + all_tabs_ids_p[i]).style.display = (all_tabs_ids_p[i] == id_p) ? 'inline' : 'none';
        if (document.getElementById(a_prefix_p   + all_tabs_ids_p[i]))  document.getElementById(a_prefix_p   + all_tabs_ids_p[i]).className     = (all_tabs_ids_p[i] == id_p) ? 'current_tab' : 'other_tab';
    }
    if (('addresses' == id_p) && uicc_initialize_google_maps) {
        uicc_initialize_google_maps();
    }
}

function clear_multiple_select(name_p) {
    var obj = document.getElementById(name_p);
    if ( ! obj) return false;
    for (var i=0; i < obj.options.length; i++) {
        obj.options[i].selected=false;
    }
    return true;
}

function fill_multiple_select(name_p) 
{
    var obj = document.getElementById(name_p + '_all');
    if ( ! obj) return false;
    if ( ! obj.checked) {
        return clear_multiple_select(name_p);
    }
    
    obj = document.getElementById(name_p);
    if ( ! obj) return false;
    for (var i=0; i < obj.options.length; i++) {
        obj.options[i].selected=true;
    }
    return true;
}

function update_size_message(selector_name_p) 
{
    if ( ! all_multiselects) alert('The list of multiple selector is not defined.');
    
    var selector = document.getElementById(selector_name_p);
    if ( ! selector) return false;
    
    var target = document.getElementById(selector_name_p + '_size_message');
    if ( ! target) return false;
    
    var singular            = all_multiselects[selector_name_p].singular;
    var plural              = all_multiselects[selector_name_p].plural;
    var color_if_empty      = all_multiselects[selector_name_p].color_if_empty;
    var color_if_not_empty  = all_multiselects[selector_name_p].color_if_not_empty;
    
    if ( ! singular)  singular   = 'element';
    if ( ! plural)    plural     = 'elements';

    var num = 0;
    
    for (var i=0; i < selector.options.length; i++) {
        if (selector.options[i].selected) {
            num++;
        }
    }
    
    msg = '';
    switch (num) {
    case 0: 
        msg = '<span style="font-weight: bold; font-style: italic; color: ' + color_if_empty + ';">No ' + singular + ' selected.</span>';
        break;
        
    case 1: 
        msg = '<span style="font-weight: bold; font-style: italic; color: ' + color_if_not_empty + ';">1 ' + singular + ' selected.</span>';
        break;
        
    default: 
        msg = '<span style="font-weight: bold; font-style: italic; color: ' + color_if_not_empty + ';">' + num.toString() + ' ' + plural + ' selected.</span>';
    }

    target.innerHTML = msg;
    
    return true;
}

/**
 * Get the index of a DOM Node 
 * Source: http://stackoverflow.com/questions/378365/finding-dom-node-index
 */
function indexOfNode(theNode) {
    var k = 0;
    while(theNode.previousSibling){
        k++;
        theNode = theNode.previousSibling;
    }
    return k;
}

function hideBlock(container_id_p, duration_p, image_id_p) {
    if (image_id_p) $(image_id_p).src = '../gfx/ajax/container_closed.gif';
    Effect.SlideUp(container_id_p, {duration: duration_p});
}

function showBlock(container_id_p, duration_p, image_id_p) {
    if (image_id_p) $(image_id_p).src = '../gfx/ajax/container_open.gif';
    Effect.SlideDown(container_id_p, {duration: duration_p});
}

function strip_tags (str, allowed_tags) {
    // Strips HTML and PHP tags from a string  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strip_tags
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Marc Palau
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Eric Nagel
    // +      input by: Bobby Drake
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Tomasz Wesolowski
    // *     example 1: strip_tags('<p>Kevin</p> <b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'
    // *     example 4: strip_tags('1 < 5 5 > 1');
    // *     returns 4: '1 < 5 5 > 1'
    var key = '', allowed = false;
    var matches = [];
    var allowed_array = [];
    var allowed_tag = '';
    var i = 0;
    var k = '';
    var html = '';
 
    var replacer = function (search, replace, str) {
        return str.split(search).join(replace);
    };
 
    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi);
    }
 
    str += '';
 
    // Match tags
    matches = str.match(/(<\/?[\S][^>]*>)/gi);
 
    // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;
        }
 
        // Save HTML tag
        html = matches[key].toString();
 
        // Is tag not in allowed list? Remove from str!
        allowed = false;
 
        // Go through all allowed tags
        for (k in allowed_array) {
            // Init
            allowed_tag = allowed_array[k];
            i = -1;
 
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
            if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) { i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}
 
            // Determine
            if (i == 0) {
                allowed = true;
                break;
            }
        }
 
        if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }
 
    return str;
}

function uicc_do_contact_report_locking(contact_p, compare_p, attendee_id, report_id)
{
    var selector_name_1 = (('organization' == contact_p) ? 'organization_id_'    : 'person_id_')       + report_id + '_' + attendee_id;
    var selector_name_2 = (('organization' == contact_p) ? 'person_id_'          : 'organization_id_') + report_id + '_' + attendee_id;
    var textarea_name   = (('organization' == contact_p) ? 'unref_organization_' : 'unref_person_')    + report_id + '_' + attendee_id;
    var selector_obj_1 = document.getElementById(selector_name_1);
    var selector_obj_2 = document.getElementById(selector_name_2);
    var textarea_obj   = document.getElementById(textarea_name);
    
    if ( ! selector_obj_1)                return false;
    if (0 > selector_obj_1.selectedIndex) return false;
    
    if ( ! textarea_obj)                  return false;
    textarea_obj.style.display = (('in_details' === selector_obj_1.options[selector_obj_1.selectedIndex].value) ? 'inline' : 'none');
    
    if ( ! selector_obj_2)  return false;
    if ('select-one' != selector_obj_2.type) {
        // Certainly a hidden input
        return false;
    }
    selector_obj_2.disabled = (compare_p !== selector_obj_1.options[selector_obj_1.selectedIndex].value);

    return true;
}
