
/**
 * show and hide fields for spezified securitytypes when change the
 * dropdown securitytype in search-form.
 *
 * @param selectElement dropdown-element securitytype
 */
function searchChangeType(selectElement, stocks, bonds) {
    var value = $('option:selected', '#' + selectElement).val();
    if (value == stocks) {
        $("._bonds").hide();
        $("._stocks").show();
        $("._stocks ._bonds").show();
        $("._noBonds").show();
    } else if (value == bonds) {
        $("._stocks").hide();
        $("._bonds").show();
        $("._noBonds").hide();
    } else {
        $("._stocks").hide();
        $("._bonds").hide();
        $("._noBonds").show();
    }
}


/**
 * set the selected tab and content.
 * tabs: <ul id="tabs_[key]"><li id="tab1">...
 * content: <ul id="tabct_[key]><li id="tabct1">...
 *
 * @param tab selected tab (1|2|3|...)
 * @param key tab-box-key (search|style|...)
 */
function switchTab(tab, key) {
    // set selected tab
    var tabsKey = "#tabs_" + key;
    $(tabsKey + " > *").removeClass("selected");
    $("#tab" + tab).addClass("selected");
    // set selected tab-content
    var tabctKey = "#tabct_" + key;
    $(tabctKey + " > *").hide();
    $("#tabct" + tab).show();
}

/**
 * reset all input- and select-fields on a form.
 * on a input-field, the value "" to be set.
 * on a select field, the value "-1" to be set.
 *
 * @param form the form to be reset
 */
function resetForm(form) {
    $("#" + form).find("input.large,input.small,select").each(function(index,element) {
        if (!$(element).hasClass("ignore"))
            _clearInput(this);
    });
}

/**
 * reset the value of a field.
 * on a input-field, the value "" to be set.
 * on a select field, the value "-1" to be set.
 *
 * @param field the field to be reset.
 */
function _clearInput(field) {
    if (field.tagName.toLowerCase() == "select") {
        $("option:first", field).attr("selected", "selected");
    } else
        field.value = "";
}
