var sSelectSeachC=false;
var sFirstRun=false;

function initSearchTabs(){
    $tabs = $('#search-tabs').tabs({
        selected: 0,
        show: function(event, ui) {
            $('#' + ui.panel.id + ' select').each(function(i) {
                if (!$(this).attr('isreplaced')) {
                    $(this).sSelect();
                    $(this).attr('isreplaced', true);
                }
            })
            $('.searchTab-content').each(function(i) {
				if ($(this).css('display') == "block"){
					$('input[type=text]', $(this)).focus();
				}
            });
        }
    });
}
var $tabs = '';
$(document).ready(function() {
$('.searchFormContainer .close').click(function() { $('.searchFormContainer').hide('slow'); });
    /*CMSDesc BugFIX!!!!*/
    if (typeof $('#search-tabs').tabs != 'function') {
        if (typeof jQuery == 'undefined') {
            $.getScript("/App_Themes/Donauchemie/script/jquery-1.3.2.min.js", function() {
                $.getScript("/App_Themes/Donauchemie/script/jquery-ui-1.7.2.min.js", function() {
                    initSearchTabs();
                });
            });
        } else {
            $.getScript("/App_Themes/Donauchemie/script/jquery-ui-1.7.2.min.js", function() {
                initSearchTabs();
            });
        }
    } else {
        initSearchTabs();
    }
    /*CMSDesc BugFIX!!!!*/


    $('.searchControl').click(function() {
        $('.searchFormContainer').show('slow', function() {
            if (!sFirstRun) {
                $tabs.tabs('select', 0);
                sFirstRun = true;
            }
            $('.searchFormContainer .content #search-tabs .searchTab-content .text-field').eq(0).focus();
        });
        if (!sSelectSeachC) {
            sIFR.replace(frutigerlightcondensed, { selector: '.searchFormContainer .content .headline', css: '.sIFR-root { color:#FFFFFF;} ', opaque: true, transparent: true });
            if ($.browser.msie && $.browser.version < 7) { DD_belatedPNG.fix(".newListSelected"); }
            sSelectSeachC = true;
        }
    });

	var currJob=false;
    $('.dvJob').each(function() {
        $(this).find('a.jobTitle,a.btn:first').each(function() {
            $(this).click(function(e) {
                e.preventDefault();
                if ($(this).hasClass('active')) {
                    $(this).removeClass('active');
                } else {
                    $(this).addClass('active');
                }
                if (!$(this).hasClass('btn')) {
                    var $n = $($(this).parent()).find('.btn:first');
                } else {
                    var $n = $(this);
                }
                $n.html((($(this).hasClass('active')) ? '&ndash;<span>&nbsp;</span>' : '+<span>&nbsp;</span>'));
				
				if(currJob && currJob.attr('href')!=$(this).attr('href') && currJob.hasClass('active')){ 
					if (!currJob.hasClass('btn')) { var $n = $(currJob.parent()).find('.btn:first'); var $t = currJob; }else{ var $n = currJob; var $t=$(currJob.parent()).find('.jobTitle:first'); }
					$n.html('+<span>&nbsp;</span>');
					$n.removeClass('active');
					$t.removeClass('active');
					$(currJob.attr('href')).slideToggle('slow'); 
				}
				currJob=$(this);
                $(currJob.attr('href')).slideToggle('slow');
            });
            if ($(this).hasClass('btn')) {
                $(this).mouseover(function() {
                    var $n = $($(this).parent()).find('.jobTitle:first');
                    if (!$n.hasClass('active')) {
                        $n.addClass('active');
                    }
                }).mouseout(function() {
                    var $n = $($(this).parent()).find('.jobTitle:first');
                    if (!$(this).hasClass('active')) {
                        $n.removeClass('active');
                    }
                });
            } else {
                $(this).mouseover(function() {
                    var $n = $($(this).parent()).find('.btn:first')
                    $n.addClass('active');
                }).mouseout(function() {
                    var $n = $($(this).parent()).find('.btn:first');
                    if (!$(this).hasClass('active')) {
                        $n.removeClass('active');
                    }
                });
            }
        });
    });
});

var DD = new Object();
	DD.printPage = function (){
		window.print();
	}