
/* Unitek Scripts Start */
var megaDropDownHtml = '';
var megaDropDownSpeed = 600;



function fillMegaDropDown () {
    
    $('#megaDropDown ul').html(megaDropDownHtml);
    $('#megaDropDown').slideDown(megaDropDownSpeed,"easeOutCubic");
    
}

function findaDocSwitcher () 	{

	$("#findadoc input").keypress( function (event){
		
		 if (event.keyCode == '13') { // ENTER - Key pressed
			 event.preventDefault;
			 var value = $(this).val();
			 if (value.match(/^\d{5}([\-]\d{4})?$/)) {
				 $(".findAdentist input[name='tx_locator_pi1[city]']").attr("name","tx_locator_pi1[zipcode]");
				 $("#findadoc").submit();
			 }
			 else {
				 $("#findadoc").submit();
			 }
		 } 
    });
	
	return false;
}


function initMegaDropDown () {
    
    $('#topMenu ul li a').click(function(){
        
        $(this).blur();
        
        if ($(this).parent().attr('class').toLowerCase().indexOf('active') == -1) {
            
            $('#megaDropDown').slideUp(megaDropDownSpeed);
            
            $(this).parent().parent().children('li.active').removeClass('active');
            $(this).parent().addClass('active');
            megaDropDownHtml = $(this).parent().children('ul').html();
            window.setTimeout("fillMegaDropDown();", megaDropDownSpeed);

        } else {
            
            $('#megaDropDown').slideToggle(megaDropDownSpeed, "easeInOutCubic" );
            
        }
        
        return false;
    
    });
    
    $('#topMenu ul li ul li a, #topMenu ul li ul li ul li a').unbind('click');
    
}

function clearSearchField()	{
	$('#searchPattern').focus(function () {
		$(this).val('');
	});
}



function initTabs () {
    
    $('.tabMenu a').click(function(){
        
        $(this).blur();
        
        $(this).parent().parent().children('li.active').removeClass('active');
        $('.tabContent').hide();
        
        $(this).parent().addClass('active');
        $('#' + $(this).attr('rel')).show();
        
        return false;
        
    });
    
}



function initAnchorLinks () {
    
    $('.scrollTop').click(function(){
        
        // $(document).scrollTop(0);
    	$('html').animate({scrollTop : 0},1000);
        return false;
        
    });
    
}



function resizeBackground () {
    
    $('.subhomeAdultsContentRightBackground').each(function(){
        var imageWidth = $(this).children('img').width();
        var contentHeight = $('.subhomeAdultsContentRightContent').height();
        $(this).children('img').css({height: (contentHeight + 40) + 'px', width: imageWidth + 'px'});
        $(this).css('visibility', 'visible');
    });
    
}


function setTeaserMenuContentHeight () {
    
    $('.teaserMenuMiddle').each(function(){
        
        var availableHeight = $(this).height();
        $(this).children('.teaserMenuContent').css('height', (availableHeight - 2) + 'px');
        
    });
    
}


function initTeaserMenu () {
    
    $('.teaserMenu ul li a').click(function(){
        
        $(this).blur();
        
        $(this).parent().parent().children('li.active').removeClass('active');
        $('.teaserMenuContent').hide();
        
        $(this).parent().addClass('active');
        $('#' + $(this).attr('rel')).show();
        
        setTeaserMenuContentHeight ();
        
        return false;
        
    });
    
}

function onBefore () {
//	$('.moodH1').text("at last...");
	//$('.moodH1').hide();
	//$('.moodH1').fadeIn('4000');
}

function onAfter () {
	
}

function keyVisualSliding( element, transType, easer, duration ) { // jQuery Sliding fuer die Keyvisuals der Startseite
	$(element).cycle({
		fx: transType, // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		easing: easer ,
		speed: duration,
		timeout: 6800,
		delay: -2500,
		after: onAfter,
		before: onBefore
	});
}

function hideNonUsedElements()	{ // jQuery entfernt leere Tags
		
		$("li:empty").remove();
		$("#content a:empty").remove(); // damit der Close-Button in der Lightbox nicht entfernt wird
		$("p:empty").remove();
	
}

/* Unitek Scripts - End */

var timeout = setTimeout(bounce,5000);
var state = 0;

function bounce(){
	if(state == 0) {		
		$('#newsbox div.first').fadeOut(500,function() {
			$('#newsbox div.second').effect("bounce", {times: 3,direction: "right"}, 500)
		});
		state++;
	} else {
		$('#newsbox div.second').fadeOut(500,function() {
			$('#newsbox div.first').effect("bounce", {times: 3,direction: "right"}, 500)
		});
		state = 0;	
	}	
	clearTimeout(timeout);
	timeout = setTimeout(bounce,5000);
}


// Document Ready Element für Funktionsaufrufe beim Seitenaufbau

$(document).ready(function() {
	
	clearSearchField();
	
	/* verstecke alle leeren Link-Elemente im "Projekte"-Akkordion */
	
	$('#accordion div p a[href=""]').remove();
	$('.nav2:empty').remove();
    
	/* --- Accordion Einspaltig --- */
	$( "#accordion" ).accordion({ 
		autoHeight: false,
        clearStyle: true,
        active: false, 
        collapsible: true,
        header: "h3",
    	alwaysOpen: false
	});
		
/* --- Accordion Zweispaltig  --- */
	$( "#accordion-2" ).accordion({ 
		autoHeight: true,
        clearStyle: false,
		header: "h3",
		active: false, 
    	alwaysOpen: false
	});

/* --- Leistungen-Auswahl  --- */
	$('#effort').change(function(){
		var val = this.form.effort.options[this.form.effort.selectedIndex].value;
		if(val=="it"){
			$('.it').toggleClass("key",true);
			$('.it').toggleClass("gray",false);
			$('.mark').toggleClass("gray",true);
			$('.mark').toggleClass("key",false);
		};
		if(val=="mark"){
			$('.it').toggleClass("gray",true);
			$('.it').toggleClass("key",false);
			$('.mark').toggleClass("key",true);
			$('.mark').toggleClass("gray",false);
		};
	});
	
/* --- News-box Home  --- */
	

	
	$('.news-latest-container').cycle({ 
	    fx:    'scrollLeft', 
	    speedIn: 2100,
	    speedOut: 900,
	    easeIn:  'easeOutBounce', 
	    easeOut: 'easeOutQuad', 
	    delay:   -2000,
	    height: '110px',
	    containerResize: 0,
	    timeout: 13000,
	    fit: 0
	 });

});





