// JavaScript Document

$(document).ready(function(){
	
	$('#container').show()
	
	/**************************************************************
		  Plugins
	**************************************************************/
	function resetContainer(){
		var windowHeight = $(window).height()
		var marginTop = (windowHeight / 2) - (560 / 2)
		
		marginTop = (marginTop > 0) ? marginTop : 0
		
		$('#container').css({marginTop: marginTop+'px'})
	}
	
	function setupSlider(){
		$('#slider').nivoSlider({
			manualAdvance:true,
			effect:'boxRainGrowReverse',
			directionNavHide:false,
			prevText: '',
			nextText: ''
		})
	}
	
	function textCheck(){
		var number = $('.nivo-controlNav .nivo-control.active').text()
		var activeNumber = $('#text p:visible').attr('data-no')
		
		if (number != activeNumber)
		{
			$('#text p:visible').hide('fade', 300)
			$('#text p[data-no="'+number+'"]').show('fade', 300)
		}
		
		setTimeout(function(){
			textCheck()
		},500)
	}
	
	/**************************************************************
		  Execute Plugins
	**************************************************************/
	resetContainer()
	setupSlider()
	textCheck()
	
	/**************************************************************
		  Events
	**************************************************************/
	$(window).resize(function(){
		resetContainer()
	})
	
})
