/*
	========================
	User Interface Functions
	=================================================================
	
	Description:	Userinterface Scripts für LEB - Gallati
	
	-----------------------------------------------------------------
	
	Dependencies:	Benötigt jQuery
	-----------------------------------------------------------------
	
	Author:			Sascha Merkofer, end if Design & Code

	Datum:			11. 12. 2009

	Version:		0.1
	
	-----------------------------------------------------------------
	
*/


/*	-----------------------------------------------------------------
	Window ready - content animations
	----------------------------------------------------------------- */

$(window).load( function() {
    
    var info_pos = 1;
    var last_pos = 1;
    var num_of_flds = 0;
    var left_steps = 450;
    var goto_pix = 0;
    
    $('li.Info-Button a').map( function() {
        num_of_flds += 1;
    });
    
    $('li.Info-Button a').click( function() {
        last_pos = info_pos;
        info_pos = $(this).parent('li').attr('id').replace( /Button\-/,  '' );
        goto_pix = left_steps * ( info_pos - 1 ) * (-1);
        $('div#Info-Wrapper').animate({
            'left': goto_pix
        });
        $('li.Info-Button a').removeClass('active');
        $(this).addClass('active');
        return false;
    });
    
});


/*	-----------------------------------------------------------------
	Document Ready - center content
	----------------------------------------------------------------- */


$(document).ready( function() {
    
    var min_content_h = 686;
    var doc_h = $(window).height();

    WinResize( min_content_h, doc_h );
    
    $(window).resize( function() {
        doc_h = $(window).height();
        WinResize( min_content_h, doc_h );
    });
    
    // Bildnachweis
    $('#Bildnachweis .slide').css('display', 'none');
    $('#Bildnachweis .Button').click( function() {
    	$(this).next('.slide').slideToggle(400);
    	$(this).toggleClass('active');
	});    
});

function WinResize( mch, dh) {
    
    
    if ( mch < dh ) {
        $('#Content').css({
            'margin-top': ( ( dh - mch ) / 2 ) + 43 + 'px'
        });
    }
    else {
        $('#Content').css({
            'top': '0',
            'margin-top': '43px'
        });
    }
}
