$(document).ready(function() {
	
	/* =================================================================================
		  Plugins
	================================================================================= */
	function menu(){
		$('#menu li li').mouseenter(function(){
			$(this).addClass('active')
		})
		
		$('#menu li li').mouseleave(function(){
			$(this).removeClass('active')
		})
		
		$('li').mouseenter(function(){
			$(this).find('ul:first').fadeIn(200)
		})
		
		$('li').mouseleave(function(){
			$(this).find('ul:first').fadeOut(200)
		})
		
		$('#menu ul').closest('li').find('a:first').addClass('arrow')
		
		menuItems = $('#aroundMenu > ul').size()
		menuWidth = 920
		$('#aroundMenu > ul > li').width(menuWidth / menuItems)
		$('#aroundMenu > ul > li:last').css('background', 'none')
		$('#aroundMenu > ul ul').css('minWidth', menuWidth / menuItems+'px')
	}
	
	function fancyboxPdf(){
		$('.pdf').click(function(e){
			e.preventDefault()
			
			href = $(this).attr('href')
			href = 'http://www.nicvin.dk/' + href
			
//			$('#result').load('http://docs.google.com/viewer?url='+href+'&embedded=true', function(response, status, xhr) {})
			
			$.fancybox(
					'<iframe scrolling="no" class="hiddenpdf" style="width: 100%; height: 100%; display:block;" src="http://docs.google.com/viewer?url='+href+'&embedded=true"></iframe>',
					{
						autoDimensions: false,
						width: '90%',
						height: '90%'
					}
				)
			
			
			setTimeout(function(){$('.hiddenpdf').fadeIn(500)}, 1000)
		})
	}
	
	/* =================================================================================
		  Execute Plugins
	================================================================================= */
	menu()
	fancyboxPdf()
	
	/* =================================================================================
		  Function
	================================================================================= */
	
})
