﻿if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6)
{
    try
    {
        document.execCommand("BackgroundImageCache", false, true);
    }
    catch (err)
    {
    }
}


function fCheckKeyDown(evt, searchform) {

    if ((evt && evt.keyCode == 13) || event.keyCode == 13)
    {
        if (document.activeElement)
        {
            // Schnellsuchmaske
            if (document.activeElement.id == 'query'
                        || document.activeElement.id == 'searchtype_themes'
                        )
            {
                doSearchSubmit(searchform);
                searchform.submit();
            }
            else if (document.activeElement.id == 'MainContent_searchform_Term'
                        || document.activeElement.id == 'MainContent_searchform_Period')
            {
                // Suchmaske service/suche
                __doPostBack('ctl00$MainContent$searchform$SearchButton', '');
                return true;
            }
            else
            {
                // Suche TabbedSearchForm (Unternehmen)
                if (__doPostBack)
                {
                    __doPostBack('ctl00$MainContent$TabbedSearch$ctl00$SearchButton', '');
                    return true;
                }
            }

        }
    }
}

function doSearchSubmit(searchform) {
    if (searchform.id == 'jt4_searchform' || searchform.id == 'jt4_search')
    {
        searchform.target = '_blank';
        searchform.phrase.value = searchform.squery.value;
        if (searchform.squery.value == 'Beruf')
        {
            searchform.phrase.value = '';
        }
    }
    else
    {
        /* T06793/bap */
        if (searchform.searchtype)
        {
            if (searchform.searchtype.value == 'themes')
            {
                searchform.target = '';
                return;
            }
        }

//        var aDatensatzid = (typeof searchform.elements['searchtype'].length == 'undefined') ? [searchform.elements['searchtype']] : searchform.elements['searchtype'];
//        if (aDatensatzid[0].checked)
//        {
//            searchform.target = '';
//        }
//        else
//        {
//            searchform.target = '_blank';
//            searchform.phrase.value = searchform.query.value;
//        }
    }
}


// tplPaycheck functions
var parent;
function fToggle(obj) {

    var id = obj.id;
    var quelle = document.getElementById('QuellePanel');
    var tabbox = document.getElementById('MainContent_TabBoxPanel');
    var static = document.getElementById('MainContent_StaticContentTopOtherPage');
    if (!static)
        static = document.getElementById('MainContent_StaticContentTopFirstPage');
    if (!static)
        static = document.getElementById('StaticContentTopTopFlop');
    var master = document.getElementById('MainContent_OtherMaster');
    var topflopsel = document.getElementById('MainContent_TopFlopSelektion');
    var topflop = document.getElementById('MainContent_TopFlop');
    var topclicked = document.getElementById('MainContent_TopClicked');
    var jt4search = document.getElementById('MainContent_Jobturbo4Search');

    if (id == 'Quelleshow') // Quelle anzeigen
    {
        if (obj.parentElement)
        {
            parent = obj.parentElement.parentElement.parentElement.parentElement.id;
        } else if (obj.parentNode)
        {
            parent = obj.parentNode.parentNode.parentNode.parentNode.id;
        }
        Show(quelle);
        Show(topclicked);
        Hide(tabbox);
        Hide(jt4search);
        Hide(topflopsel);
    }
    if (id == 'Gehaltback') // Gehaltsbox anzeigen
    {
        Hide(quelle);
        Hide(topclicked);

        if (parent == topflopsel.id)
        {
            Show(topflopsel);
        }
        else
        {
            Show(tabbox);
        }
        Show(jt4search);
    }
    if (id.indexOf('topten') == 0)
    {
        var arr = id.split('_');

        if (arr.length > 3)
        {
            arr.length = arr.length - 1;
            id = arr.join('_');
        }

        Hide(static);
        Hide(master);
        Hide(topflop);
        Hide(tabbox);
        Hide(jt4search);

        static = document.getElementById('StaticContentTopTopFlop');
        Show(static);
        Show(topflopsel);
        Show(topclicked);

        var selection = document.getElementById(id + '_sel');

        if (topflopsel)
        {
            var selections = topflopsel.getElementsByTagName('div');
            for (var i = 0; i < selections.length; i++)
            {
                if (selections[i].id.indexOf('topten') == 0)
                {
                    Hide(selections[i]);
                }
            }
        }

        Show(selection);

        location.href = "#";
    }
}

function Show(obj) {
    if (!obj)
        return;
    obj.style.visibility = 'visible';
    obj.style.display = 'block';
}

function Hide(obj) {
    if (!obj)
        return;
    obj.style.visibility = 'hidden';
    obj.style.display = 'none';
}

function fShowInfo(t) {
    var win = window.open('', 'infotext','width=350,height=300,menubar=0,toolbar=1,status=0,scrollbars=1,resizable=1');
    win.document.writeln(t);
    win.focus();
}


