/* documentReady.js */


$(document).ready(function(){



	// -------------------------------------------------------------------
	// Disable browser context menu for the whole document
	// -------------------------------------------------------------------
	$(document).bind('contextmenu', function(e){
		return false;
	});



	// -------------------------------------------------------------------
	// Disable the selection of text for all elements in the selection
	// -------------------------------------------------------------------
	$('#sidebarHandle'   ).disableTextSelect();	// Geht im Safari/Win
	$('#contentContainer').disableTextSelect();	// Geht im Safari/Win
	//$('.drag').disableTextSelect();			// Disabled - Geht nicht im Safari/Win. Menue kann nicht mehr gedragged werden.



	// -------------------------------------------------------------------
	// Center content vertically in the viewport
	// -------------------------------------------------------------------
	if (1) {
		// Center vertically
		//                         Viewport height                    // Content height
		var newMarginTop = (jQuery(window).height() / 2 ) - ( jQuery('#seite').height()/2 );
		if ( newMarginTop < 0 ) {
			newMarginTop = 0;
		}

		$('#seite').css('margin-top', newMarginTop +'px' ).show();

	} else {

		// Zeigs nur an
		$('#seite').show();
	}


	/*
	var msg = '';
	msg += 'viewportHeight: ' + viewportHeight;
	msg += "\n";
	msg += 'elOffset.top: ' + elOffset.top;
	msg += "\n";
	msg += 'elHeight: ' + elHeight;
	msg += "\n";
	msg += 'newMarginTop: ' + newMarginTop;
	alert( msg );
	*/





	/**************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***
	***  Center content on resize
	***  Set handler function for window.resize() event
	***
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************/
	if (1) {

		// -------------------------------------------------------------------
		// Hint
		//    Firefox fires the resize event if user has stopped resizing.
		//    That's good.
		//
		//    But IE fires the resize event while user is resizing.
		//    So the centerContentVertically() would be called
		//    many times during the process. This consumes computing
		//    resources and might slow down IE.
		//    Solution: Use a resizeTimer via setTimeout()
		//
		// -------------------------------------------------------------------

		function centerContentVertically() {
			//alert("I'm done resizing for the moment");
			var contentHeight = jQuery('#seite').height();

			// Center vertically
			//                         Viewport height            // Content height
			var newMarginTop = (jQuery(window).height() / 2 ) - ( contentHeight/2 );

			if ( newMarginTop < 0 ) {

				newMarginTop = 0;

			}

			$('#seite').css('margin-top', newMarginTop +'px' ).show();

		};


		var resizeTimer = null;
		$(window).bind('resize', function() {
			if (resizeTimer) clearTimeout(resizeTimer);

			resizeTimer = setTimeout( centerContentVertically, 100 );

		});

	}//eoIf (1)



	/**************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***
	***  1. Wiggle on click...
	***  Set handler function for .click events
	***
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************/
	if (1) {
		$('.drag').click(function(){

			// -------------------------------------------------------------------
			// slotty2 - Wiggling on click
			// -------------------------------------------------------------------
			// -------------------------------------------------------------------
			// Set options
			// -------------------------------------------------------------------
			var options = {
				action: 'wiggle'
			};

			$( this ).slottyNavigation( options );

		});

	}//eoIf (1)


	/**************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***
	***  2. Sidebar
	***  Set handler function for .click events
	***
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************/
	$('#sidebarHandleImage').click(function(){

		// -------------------------------------------------------------------
		// Toggle Sidebar
		// -------------------------------------------------------------------
		// Set options
		// -------------------------------------------------------------------
		var options = {
			action: 'toggleSidebar'
		};

		$( this ).slottySidebar( options );


	});




	/**************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***
	***  3. Sidebar initial anzeigen
	***
	***************************************************************************
	***************************************************************************
	***************************************************************************
	***************************************************************************/

	if (1) {

		// -------------------------------------------------------------------
		// slottySidebar.jquery.js - set sidebar
		// -------------------------------------------------------------------
		// Hint
		//  Identisch mit showSidebarAfterOneSecond()
		//  bis auf die naechste Zeile, in der das
		//  stop() statement auskommentiert ist.
		//  Grund: Es gibt sonst kein verzoegertes
		//         Einblenden auf der Startseite.
		// -------------------------------------------------------------------

		var options = {
			action : 'showSidebarAfterOneSecond_startseiteOnly_ohneStop'
		};

		$( this ).slottySidebar( options );


	}//eoIf (1)




});
// eo (document).ready

