$(function(){
	//NAVIGATION DROPDOWN
	/*
	$('#nav li').hover(
		function () { $('ul', this).fadeIn(500);	},
		function () { $('ul', this).fadeOut(200); }
	);
	*/

	//SOCIAL MEDIA HOVER
	if (navigator.appName != "Microsoft Internet Explorer") {
		$('.socialIcon').fadeTo(0, 1);
		$('.socialIcon').hover( function() {
			$(this).stop(true, true).fadeTo(300, 0.7);
		}, function() {
			$(this).stop(true, true).fadeTo(300, 1);
		});
	}

	//CUFON
	/*
	Cufon.replace('h1')('h2');
	Cufon.replace('#subnav a', { hover : true });
	*/

	//TEASER
	var stageHeight = $("#containerRightBg").height();
	$('#header_cycle img').height(stageHeight);
	$(window).resize(function(){
		$('#header_cycle img').height($("#containerRightBg").height());
	});

	//CYCLE ARTIKEL HOME
	$('#header_cycle').cycle({
		fx: 'fade',
		timeout: 4500
	});

	//CYCLE NEWS ARCHIVE
	$('#newsArchive').cycle({
		fx: "scrollVert",
		timeout: 0,
		startingSlide:   0,
		pager:  '.pager',
		pagerAnchorBuilder: function(idx, slide) {
			return '<a href="#"> &bull; </a>';
		},

		before: function(slide,next){
				$("#newsArchive").animate({
				'height' :  $(next).height()
				}, 1000);
		}
	}, 500);

	//FANCYBOX
	$(".fancybox").fancybox();
	$(".fancyboxMovie").fancybox({"type": "iframe"});

	//FANCYBOX FLOORPLANNER
		$("a.fancyboxIframe").fancybox({
			'width'				: '85%',
			'height'			: '85%',
			'autoScale'     	: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});
		$(".swfMovie").fancybox({
					'width'				: 640,
					'height'			: 360,
					'type'			: 'swf',
					'autoScale'     	: false
		});



	//CYCLE SEARCH
	$('#pageSlide').cycle({
		fx: "scrollVert",
		timeout: 0,
		startingSlide:   0,
		pager:  '.pager',
		pagerAnchorBuilder: function(idx, slide) {
			return '<a href="#"> &bull; </a>';
		},

		before: function(slide,next){
			$("#pageSlide").animate({
			'height' :  $(next).height()
			}, 1000);
		}
	}, 500);

	//FANCYBOX PROJECTEN
	$("a.gallery").fancybox({
			titlePosition : 'inside',
			titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft">'+title+'</span></span>';
			}
	});

	//DROPDOWN
	$('#nav ul li').hover( function() {
		$(this).children('ul').stop(true, true).fadeIn(200);
	}, function() {
		$(this).children('ul').stop(true, true).fadeOut(200);
	});

	//LAVALAMP MENU
	$('#nav ul#lavaLampBasicImage').lavaLamp({
		fx: "backout",
		autoResize:true,
		speed: 700
	});

	$.fn.fullBg = function(){
		var bgImg = $(this);

		function resizeImg() {
		var imgwidth = bgImg.width();
		var imgheight = bgImg.height();

		var winwidth = $(window).width();
		var winheight = $(window).height();

		var widthratio = winwidth / imgwidth;
		var heightratio = winheight / imgheight;

		var widthdiff = heightratio * imgwidth;
		var heightdiff = widthratio * imgheight;

		if(heightdiff>winheight) {
			bgImg.css({
				width: winwidth+'px',
				height: heightdiff+'px'
			});
		} else {
			bgImg.css({
				width: widthdiff+'px',
				height: winheight+'px'
			});
		}
	}

		$(window).load(function() {
			resizeImg();
		});

		$(window).resize(function() {
			resizeImg();
		});
	};

	$(".fullBg").fullBg();


});

