	var dataReferer		= { };
	var dataDisabled	= { };
	
	var checkDependence = function ( )
		{
			dataReferer.each ( function ( key , elem )
				{
					showElement	= false;
					switch ( elem.tagName.toLowerCase( ) )
						{
							case 'input'	:
								switch ( elem.type.toLowerCase( ) )
									{
										case 'checkbox'	:
											showElement	= ( this.checked )
														? true
														: false;
											break;
									}
								break;
							default			:
								break;
						}
					if ( ! showElement )
						{
							$( '#' + $( this ).attr( 'data-referer' ) ).hide( );
						}
					else
						{
							$( '#' + $( this ).attr( 'data-referer' ) ).show( );
						}
				} );
		};

	$ ( document ).ready ( function ( )
		{
			/* Popup-Layer */
			$( '#popup_layer' ).hide ( );
			$( '#popup_layer_close' ).click ( function ( )
				{
					$( '#popup_layer' ).hide ( 400 , function ( )
						{
							$( '#popup_title' ).html ( '' );
							$( '#popup_frame' ).attr ( 'src' , '' );
						
						} );
				} );
				
			/* Behandlung von Eingabefeldern */
			var inputElements	= $( 'input , textarea' ).not( ':input[type=checkbox] , :input[type=radio]' );
			
			inputElements.each ( function ( key , elem )
				{
					if ( $( elem ).val ( ) !== '' )
						{
							$ ( elem ).next ( ).addClass ( 'transparent' );
						}
					else
						{
							$ ( elem ).next ( ).removeClass ( 'transparent' );
						}
				} );
				
			inputElements.keyup ( function ( )
				{
					if ( $ ( this ).val ( ) !== '' )
						{
							$ ( this ).next ( ).addClass ( 'transparent' );
						}
					else
						{
							$ ( this ).next ( ).removeClass ( 'transparent' );
						}
				} );
			
			/* Popup-Klick Events */
			$( '.clickable' ).click ( function ( )
				{
					$( '.hidden_row' , $( this ).parent( ) ).toggle( );
				} );
			
			/* Data-Disabled */
			dataDisabled	= $( '[data-disabled]' , '.data_active' );
			dataDisabled.each ( function ( )
				{
					$( this ).hide( );
				} );
			
			/* Data-Referer */
			dataReferer		= $( '[data-referer]' );
			checkDependence( );
			
			dataReferer.click ( function ( )
				{
					showElement	= false;
					switch ( this.tagName.toLowerCase( ) )
						{
							case 'input'	:
								switch ( this.type.toLowerCase( ) )
									{
										case 'checkbox'	:
											showElement	= ( this.checked )
														? true
														: false;
											break;
									}
								break;
							default			:
								break;
						}
					if ( showElement )
						{
							$( '#' + $( this ).attr( 'data-referer' ) ).show( 400 );
						}
					else
						{
							$( '#' + $( this ).attr( 'data-referer' ) ).hide( 400 );
						}
				} );
				
			/* Abhängigkeiten */
			$( 'input[type=checkbox]' , '.checkDependencies' ).click( function ( )
				{
					node	= this.parentNode;
					switch ( this.checked )
						{
							case true	:
								while ( node = node.parentNode )
									{
										if ( typeof ( node.tagName ) !== 'undefined' && node.tagName.toLowerCase( ) === 'li' )
											{
												$( node ).find( 'input' )[ 0 ].checked	= true;
												checkDependence( );
											}
									}
								break;
							case false	:
								while ( node = $( node ).find ( 'li' )[ 0 ] )
									{
										$( node ).find( 'input' )[ 0 ].checked	= false;
										checkDependence( );
									}
								break;
						}
				} );
			
			$( '.all_rights' ).each( function( )
				{
					if ( $( this )[ 0 ].checked )
						{
							$( '#' + $( this ).attr( 'id' ).replace( 'Type_ALL' , '_outer' ) ).hide( );
							if ( $( this ).attr( 'id' ) === 'user_portalRightsType_ALL' )
								{
									$( '.websiteRights' ).show( );
								}
						}
				} );
				
			$( 'input[type=checkbox]' , '.websiteRights' ).click( function ( )
				{
					input	= this;
					node	= this.parentNode;
					
					elems	= $( 'input' , $( node ) );
					switch ( this.checked )
						{
							case true	:
								$( elems ).each ( function ( key , value )
									{
										if ( value !== input )
											{
												value.checked = true;
												value.disabled	= true;
											}
									} );
								break;
							case false	:
								$( elems ).each ( function ( key , value )
									{
										if ( value !== input )
											{
												value.checked = false;
												value.disabled = false;
											}
									} );
								break;
						}
				} );
			
			/* Auf- und Zuklappen von Navigationspunkten */
			$( 'ul' , 'li.hasChild' ).hide( );
			
			$( document ).on( 'click' , 'li.hasChild' , function ( event )
				{
					if ( event.target === this )
						{
							$( event.target ).removeClass( 'hasChild' );
							$( event.target ).addClass( 'showChild' );
							$( event.target ).children( 'ul' ).show( );
						}
				} );
			
			$( document ).on( 'click' , 'li.showChild' , function ( event )
				{
					if ( event.target === this )
						{
							$( event.target ).removeClass( 'showChild' );
							$( event.target ).addClass( 'hasChild' );
							$( event.target ).children( 'ul' ).hide( );
						}
				} );
		} );
	
	/* Popup-Layer */
	function fnc_showLayer ( popup , navId )
		{
			$( '#popup_title' ).html ( lang[ 'popup' ][ popup ] );
			$( '#popup_layer' ).show ( 400 , function ( )
				{
					$( '#popup_frame' ).attr ( 'src' , 'popups/' + popup + '/index.php?siteId=' + navId );
				
				} );
		}
	
	function fnc_openEditorView ( navId )
		{
			var open;
			open	= window.open ( 'popups/editor/index.php?siteId=' + navId , 'editorView' , 'height=700,left=0,location=nomenubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,top=0,width=1100' );
		}