var searchFieldDefaultText = 'Suchwort für Forensuche hier eingeben';
var searchFormJob = null;

function closeSearchOptions() {
    $("div#searchboxoptions").slideUp(750, "easeOutBounce", function(){});
    clearTimeout(searchFormJob);
    searchFormJob = null;
}

function toggleCell(layerid)
{
    if (document.getElementById(layerid).style.display == 'none')
    {
        document.getElementById(layerid + "img").src = "images/layout/button_mini_minus.gif";
        document.getElementById(layerid + "img").alt = "Details verbergen";
        document.getElementById(layerid).style.display = "";
    }
    else
    {
        document.getElementById(layerid + "img").src = "images/layout/button_mini_plus.gif";
        document.getElementById(layerid + "img").alt = "Details anzeigen";
        document.getElementById(layerid).style.display = "none";
    }
}

function toggle(layerid)
{
    $('#' + layerid).toggle();
    /*if (document.getElementById(layerid).style.display == 'none')
    {
        document.getElementById(layerid).style.display = "";
    }
    else
    {
        document.getElementById(layerid).style.display = "none";
    }*/
}

function ajax_update_specials()
{
    $('div#specials').fadeOut(250);
    var path = getWebRoot() + 'ajax.php?do=specials'
    $.get(path, null, function(data){
        $('div#specials').html(data);
        $('div#specials').fadeIn(250);
    });
}
function autorefresh_specials_init()
{
    var secs = 60;
    var t = setTimeout("autorefresh_specials()", (secs*1000));
}
function autorefresh_specials()
{
    var secs = 60;
    var t = setTimeout("autorefresh_specials()", (secs*1000));
    ajax_update_specials();
}

function ajax_update_ads()
{
    $('div#ads').fadeOut(500);
    var path = getWebRoot() + 'ajax.php?do=ads'
    $.get(path, null, function(data){
        $('div#banner').html(data);
        $('div#banner').fadeIn(750);
    });
}
function autorefresh_ads_init()
{
    var secs = 3;
    var t = setTimeout("autorefresh_ads()", (secs*1000));
}
function autorefresh_ads()
{
    var secs = 30;
    var t = setTimeout("autorefresh_ads()", (secs*1000));
    ajax_update_ads();
}

$(function(){
    // do ie detection lower than 7.0
    if ($.browser.msie && $.browser.version < 7)
    {
        // remove searchbox feature
        $("div#searchbox").remove();
        //$("div#slogan").css('right', '5px');

        // png fix
        $(document).pngFix();

        // add an ie6 warning
        $("#header").append('<div class="important"><p><img src="images/icons/important.gif" class="icon16" />&nbsp;Internet Explorer 6.0 wurde erkannt. Unsere Webseite wurde für <strong>moderne Browser</strong> optimiert. Überdenke den Einsatz eines moderneren Browsers.</p></div>');
    }
    else
    {
        // show searchbox feature
        $("div#slogan").css('right', '245px');
        $("div#searchbox").show();

        // search box
        /*$("div#searchbox").hover(
                function(){
                    if (searchFormJob == null) {
                        $("div#searchboxoptions").slideDown(1000, "easeOutBounce", function(){});
                    }
                    else {
                        clearTimeout(searchFormJob);
                        searchFormJob = null;
                    }
                },
                function(){
                    searchFormJob = setTimeout("closeSearchOptions()",3500)

                }
        );*/
        $("input#keyword").focus(function(){
            var text = $("input#keyword").val();
            if (text == searchFieldDefaultText) {
                $("input#keyword").val('');
                $("input#keyword").css('color', '#333');
                $("input#keyword").css('font-size', '12px');
            }

        });
        $("input#keyword").blur(function(){
            var text = $("input#keyword").val();
            if (text == '') {
                $("input#keyword").css('color', '#888');
                $("input#keyword").css('font-size', '10px');
                $("input#keyword").val(searchFieldDefaultText);

            }
        });
    }

    // remap login button
    $("a#login_button").click(function(){
        $("div#loginbox").show();
        $("input#login_user").focus();
        return false;
    });

    // remap cancel login button
    $("input#cancel_login").click(function(){
        $("div#loginbox").hide();
        return false;
    });

    autorefresh_ads_init();

});
