function navControl()
{
	// VARS
	this.tempX = 0;
	this.widthBroswer = 0;
	this.currentPageWidth = 0;
	this.buttonAtivo = false;
	this.useVisible = false;
	this.firstTime = true;
	this.overStatus = false;
	
	
	
	
	//--------------------------------------
	// INIT
	//--------------------------------------
	
	this.init = function()
	{
		// Init SIDE CONTROLS NAVIGATION
		if( !_iphone && !_ipad ) this.initSideControlsNavigation();
	}
	
	
	
	
	//--------------------------------------
	// SET POSITIONS
	//--------------------------------------
	
	this.setPositions = function()
	{
		var containerPosition = 0;
		var containerInsidePosition = 0;
		
		
		// Posts
		for( i = 1; i <= postsTotal; i++ )
		{
			$( "#post_" + i ).css( "margin-right", ( postDistance - postWidth ) );
			$( "#post_" + i ).css( "width", postWidth );
		}
		
		
		// Containers Position
		if( post == 1 )
		{
			containerPosition = ( postsTotal * postDistance ) + postDistance;
			containerInsidePosition = ( postsTotal * postDistance ) * -1;
		}
		else
		{
			containerPosition = ( ( postsTotal - ( post - 1 ) ) * postDistance ) + postDistance;
			containerInsidePosition = ( postsTotal * postDistance ) * -1;
		}
		
		
		// Display
		$( "#post_container" ).css( "display", "block" );
		
		
		// Containers
		$( "#post_container" ).css( "left", containerPosition );
		$( "#post_container_inside" ).css( "left", containerInsidePosition );
	}
	
	
	
	//--------------------------------------
	// CONTROLES
	//--------------------------------------
	
	// NAV LEFT
	this.navControlLeft = function()
	{
		// POST
		post--;
		
		
		// Control
		this.navControl();
		
		
		// Motion
		this.navMotion();
	}
	
	
	// NAV RIGHT
	this.navControlRight = function()
	{
		// POST
		post++;
		
		
		// Control
		this.navControl();
		
		
		// Motion
		this.navMotion();
	}
	
	
	// GO TO POST
	this.goToPost = function()
	{
		if( post > 1 )
		{
			// Control
			this.navControl();
	
			// Motion
			this.navMotion();
		}
	}
	
	
	// NAV CONTROL
	this.navControl = function()
	{
		if( post <= 1 )
		{
			post = 1;
			this.navControlLeftBlock();
		}
		else
		{
			this.navControlLeftUnblock();
		}
		

		if( post >= ( postsTotal - postsOnScreen + 2 ) && postsTotal >= postsMaxTotal )
		{
			this.navControlRightBlock();
		}
		else
		{
			this.navControlRightUnblock();
		}
	}
	
	this.navControlLeftBlock = function()
	{
		navLeftStatus = false;
		this.sideControlsNavigationArrowsBlock( "left" );
	}
	
	this.navControlLeftUnblock= function()
	{	
		this.sideControlsNavigationArrowsUnblock( "left" );
		navLeftStatus = true;
	}
	
	this.navControlRightBlock = function()
	{
		navRightStatus = false;
		this.sideControlsNavigationArrowsBlock( "right" );
	}
	
	this.navControlRightUnblock = function()
	{
		this.sideControlsNavigationArrowsUnblock( "right" );
		navRightStatus = true;
	}
	
	
	// NAV MOTION
	this.navMotion = function()
	{
		// Position
		var delay = 300;
		var containerPosition = ( ( postsTotal - ( post - 1 ) ) * postDistance ) + postDistance;
		
		
		// Motion
		$( '#post_container' ).stop().animate(
			{
				left: containerPosition
			},
			delay, 
			'easeOutCubic'
		);
		
		
		// TOP WINDOW
		var windowY = $( window ).scrollTop();
		var windowMotionTime = 500 * ( windowY / 1000 );
		if( windowY > 0 )
		{
			$( 'html,body' ).animate( { scrollTop: 0 }, windowMotionTime);
		}
	}
			
	
	
	
	//--------------------------------------
	// SIDE CONTROLS INITIAL MOTION
	//--------------------------------------
		
	this.sideControlsInitialMotion = function()
	{
		if(  !_iphone && !_ipad )
		{				
			// Show Nav Buttons
			sideControlsNavigationShowMotion();
	
			// Takes off SIDE CONTROLS NAVIGATION
			setTimeout(function()
			{	
				var currentPageWidth =  document.getElementById( 'nav_current_page' ).offsetWidth * ( -1 );
				
				if( currentPageWidth > -200 )
				{
					// Black Box Container
					$( '#nav_controllers' ).stop().animate( { marginLeft: 129 }, 300, 'easeInCubic' );
					
					// Arrows
					$( '#left_arrow' ).stop().animate( { marginLeft: 200 }, 200, 'easeInCubic' );
					//$( "#left_normal" ).stop().fadeTo( 300, 0.1 );
					$( '#right_arrow' ).stop().animate( { marginLeft: -200 }, 200, 'easeInCubic' );
					//$( "#right_normal" ).stop().fadeTo( 300, 1 );
					
					// Set Visibility as FALSE
					useVisible = false;	
				}
				else
				{
					setTimeout(function()
					{	
						
							// Black Box Container
							$( '#nav_controllers' ).stop().animate( { marginLeft: 129 }, 300, 'easeInCubic' );
							
							// Arrows
							$( '#left_arrow' ).stop().animate( { marginLeft: 200 }, 200, 'easeInCubic' );
							//$( "#left_normal" ).stop().fadeTo( 300, 0.1 );
							$( '#right_arrow' ).stop().animate( { marginLeft: -200 }, 200, 'easeInCubic' );
							//$( "#right_normal" ).stop().fadeTo( 300, 1 );
							
							// Set Visibility as FALSE
							useVisible = false;	
					
					}, 300);
				}
				
			
			}, 2800);
			
			
			// Init SIDE CONTROLS NAVIGATION
			this.initSideControlsNavigation();
		}
	}
			
	
	
	
	//--------------------------------------
	// INIT SIDE CONTROLS
	//--------------------------------------
	
	this.initSideControlsNavigation = function()
	{
		// Get Mouse X Position To Show Side Controls
		this.setSideControlsNavigationVisibility();
		
		// Re-position Side Controls
		window.onscroll = function(){ sideControlsNavigationPagePositioning(); };	
		$( window ).bind( 'resize', function(){ sideControlsNavigationPagePositioning(); } );
	}
					
	
	
	
	//--------------------------------------
	// SIDE CONTROLS GET MOUSE X
	//--------------------------------------
	
	this.setSideControlsNavigationVisibility = function()
	{
		var IE = document.all ? true:false;
		if ( !IE ) document.captureEvents( Event.MOUSEMOVE )
		document.onmousemove = getMouseX;
	
		function getMouseX( e ) 
		{
			widthBroswer = $(window).width();
			
			// FOR INTERNET EXPLORER
			if ( IE ) 
			{ 
				tempX = event.clientX + document.body.scrollLeft;
			}
			else 
			{  
				tempX = e.pageX;
			}  
			
			
			// NO NEGATIVE NUMBER
			if (tempX < 0){ tempX = 0; }

			
			// VISIBLE POSITION MOTION
			if( tempX >= widthBroswer - postWidth )
			{
				buttonAtivo = true;
				if( useVisible == false )sideControlsNavigationShowMotion();
				useVisible = true;
			}
			else
			{
				sideControlsNavigationHideMotion();
				buttonAtivo = false;
				useVisible = false;	
			}
			
			return true;
		}
	}
							
	
	
	
	//--------------------------------------
	// SIDE CONTROLS UNBLOCK N' BLOCK MODES
	//--------------------------------------
	
	this.sideControlsNavigationArrowsUnblock = function( id )
	{
		if( id == "left" && navLeftStatus == false )
		{
			// Left Arrow
			$( "#left_over" ).stop().fadeTo( 100, 0 );
			$( "#left_normal" ).stop().fadeTo( 100, 1 );
			$( "#navegaLeft" ).css( "cursor", "pointer" );
		}
		else if( id == "right" && navRightStatus == false  )
		{	
			// Right Arrow
			if( this.overStatus == true )
			{
				$( "#right_over" ).stop().fadeTo( 100, 1 );
				$( "#right_normal" ).delay(100).stop().fadeTo( 0, 1 );
				$( "#navegaRight" ).css( "cursor", "pointer" );
			}
			else
			{
				$( "#right_over" ).stop().fadeTo( 100, 0 );
				$( "#right_normal" ).stop().fadeTo( 100, 1 );
				$( "#navegaRight" ).css( "cursor", "default" );
			}
		}
			
	}
	
	this.sideControlsNavigationArrowsBlock = function( id )
	{
		if( id == "left" )
		{
			// Left Arrow
			$( "#left_over" ).stop().fadeTo( 100, 0 );
			$( "#left_normal" ).stop().fadeTo( 100, 0.1 );
			$( "#navegaLeft" ).css( "cursor", "default" );
		}
		else
		{
			
			// Right Arrow
			$( "#right_over" ).stop().fadeTo( 100, 0 );
			$( "#right_normal" ).stop().fadeTo( 100, 0.1 );
			$( "#navegaRight" ).css( "cursor", "default" );
		}
	}
			
	
	
	
	//--------------------------------------
	// SIDE CONTROLS ARROWS OVER/OUT MOTIONS
	//--------------------------------------
	
	this.motionSetaOver = function( id )
	{
		if( !_iphone && !_ipad )
		{	
			if( id == "navegaLeft" && post > 1 )
			{	
				$( "#navegaLeft" ).css( "cursor", "pointer" );
				$( "#left_over" ).stop().fadeTo( 100, 1 );
			}
			
			if( post < ( postsTotal - postsOnScreen + 2 ) || postsTotal < postsMaxTotal )
			{
				if( id == "navegaRight")
				{
					$( "#navegaRight" ).css( "cursor", "pointer" );
					$( "#right_over" ).stop().fadeTo( 100, 1 );
					this.overStatus = true;
				}
			}
			else
			{
				$( "#navegaRight" ).css( "cursor", "default" );
			}
		}
	}
	
	this.motionSetaOut = function( id )
	{
		if( !_iphone && !_ipad )
		{
			if( id == "navegaRight" ) $( "#right_over" ).stop().fadeTo( 100, 0 );
			else if( id == "navegaLeft" ) $( "#left_over" ).stop().fadeTo( 100, 0 );
			
			this.overStatus = false;
		}
	}
				
	
	this.motionSetaClick = function( id )
	{
		if( !_iphone && !_ipad )
		{
			//$( "#right_over" ).stop().fadeTo( 100, 1 );
			//$( "#left_over" ).stop().fadeTo( 100, 1 );
		}
	}
	
	//--------------------------------------
	// SIDE CONTROLS SHOW N' HIDE
	//--------------------------------------
	
	sideControlsNavigationShowMotion = function()
	{	
		// Black Box Container
		$( '#nav_controllers' ).stop().animate( { marginLeft: -129 }, 150, 'easeOutCubic' );
		
		// Arrows
		$( '#left_arrow' ).stop().animate( { marginLeft: 0 }, 300, 'easeOutCubic' );
		$( '#right_arrow' ).stop().animate( { marginLeft: 0	}, 500, 'easeOutCubic' );
		
	}
	
	sideControlsNavigationHideMotion = function()
	{
		if( this.buttonAtivo == true )
		{
			// CurrentPage
			this.currentPageWidth = document.getElementById( 'nav_current_page' ).offsetWidth * ( -1 );
			$( '#nav_current_page' ).stop().animate( { marginRight: this.currentPageWidth  }, 200, 'easeInCubic' );
			
			// Black Box Container
			$( '#nav_controllers' ).stop().animate( { marginLeft: 129 }, 200, 'easeInCubic' );
			
			// Arrows
			$( '#left_arrow' ).stop().animate( { marginLeft: 200 }, 150, 'easeInCubic' );
			$( '#right_arrow' ).stop().animate( { marginLeft: -200 }, 150, 'easeInCubic' );
			
			// Sets Button as FALSE
			this.buttonAtivo = false; 
		}	
	}
				
	
	
	
	//--------------------------------------
	// SIDE CONTROLS PAGE POSITIONING
	//--------------------------------------
	
	sideControlsNavigationPagePositioning = function()
	{
		var pageY = ( $( window ).scrollTop() - 64 ) + "px";
		
		$( '#clip_controllers' ).stop().animate( { "marginTop": pageY }, 650, 'easeInOutQuint' );
	}
}
