var siteFunctions = {
	
	fontResize : function()  {
		var cookieName = 'bilgaardnet-font-size';
		var cookieParams = { expires: 7, path: '/', domain: 'bilgaardnet.nl', secure: true }
		
		var currentFontSize = $('#mid').css('font-size');
		if (!$.cookie(cookieName)) {
			$.cookie(cookieName, currentFontSize);
		}
		else {
			currentFontSize = $.cookie(cookieName);
		}
		
		$('#mid').css( { fontSize: currentFontSize } );

		$('#font-default').click(function() {
			$('#mid').css({fontSize: "12px"});
			$.cookie(cookieName, "12px");
			return false;
		});
		
		$('#font-smaller').click(function() {
			var currentFontSize = $('#mid').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 2);
			var newFontSize = currentFontSizeNum - 2;

			if (newFontSize > 9) {
				$('#mid').css({
					fontSize: newFontSize + ("px")
				});
				$.cookie(cookieName, newFontSize + ("px"));
			}
			
			return false;
		});
		
		$('#font-larger').click(function() {
			var currentFontSize = $('#mid').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 2);
			var newFontSize = currentFontSizeNum + 2;
			
			if (newFontSize < 22) {
				$('#mid').css({
					fontSize: newFontSize + ("px")
				});
				$.cookie(cookieName, newFontSize + ("px"));
			}
			return false;
		});
	},

	menuSize : function() {
		// Breedte vh menu instellen
		var menu_breedte = 0;
		$("#mul").children("li").each(function(index) {
			var $li = $(this);
			menu_breedte += $li.width();
		});
		menu_breedte += 10;
		$("#mul").width(menu_breedte);
		
		$(".curimage a.lftctr, .curimage a.rgtctr").height($(".curimage img").height());
		
		$("#mul").children("li").each(function(index) {
			//console.log($(this).width());
		});
		
	}
}

	$(document).ready(function(){
		// PNG Fix
		$(document).pngFix();
		
		// news foto's breedte geven
		//var img = $('.news_image .img img');
		//$('.news_image .img').css('width', img.width() + parseInt(img.css('padding-left')) + parseInt(img.css('padding-right')));
		
		// Background laten overlopen
		$("#topimagebackground").innerfade({
			animationtype: 'fade',
			speed: 1000,
			timeout: 10000,
			type: 'random',
			containerheight: '135px'
		})
		
		$('.interests_toggle').toggle(
			function(event)
			{
				event.preventDefault();
				var boxname = '.interests_list_' + $(this).attr('title');
				$(this).text('minder...');
				$(boxname).slideDown();
			},
			function(event)
			{
				event.preventDefault();
				var boxname = '.interests_list_' + $(this).attr('title');
				$(this).text('meer...');
				$(boxname).slideUp();
			}
		);
		
		$('.blogitem img').each(
			function(el, item){
				$(item).removeAttr('height')
			}
		);
		
		$(".imagescroll .jcarousel").jCarouselLite({
		    btnNext: ".imagescroll .downctr",
		    btnPrev: ".imagescroll .upctr",
			vertical: true,
			visible: 4,
			scroll: 2
		});
		
		// Set the date picker.
		$('input.Mct_Form_Element_Date').each( function () {
			$(this).datepicker();
		});
		
		$('a.lightbox').lightBox({fixedNavigation:true});
		
		siteFunctions.menuSize();
		siteFunctions.fontResize();
	});
	
	$(".item a:not(.nhl)").mouseover(function() {
		var parent = $(this).parent();
		while (!$(parent).hasClass("item")) { 
			parent = $(parent).parent();
		}

		$(parent).find("a, .item_img, .appointment .item_img" ).addClass("highlight");
	});
	
	$(".item a:not(.nhl)").mouseout(function() {
		var parent = $(this).parent();
		while (!$(parent).hasClass("item")) { 
			parent = $(parent).parent();
		}
		$(parent).find("a, .item_img, .appointment .item_img").removeClass("highlight");
	});
	
	$("#mul li").hover (
		function() {
			$(this).addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		}
	);
	
	$(".post_delete").click( function() {
		return confirm('Weet je zeker dat je deze post wilt verwijderen?');
	});
	
	$(".icon.photo_delete").click( function() {
		return confirm('Weet je zeker dat je deze foto wilt verwijderen?');
	});
	
	$(".icon.delete_gallery").click( function() {
		return confirm('Weet je zeker dat je de galerij wilt verwijderen?');
	});
	
	$(".appointment_delete").click( function() {
		return confirm('Weet je zeker dat je dit agendapunt wilt verwijderen?');
	});

	$(".delete_news").click( function() {
		return confirm('Weet je zeker dat je dit nieuwsitem wilt verwijderen?');
	});
	
	$(".delete_product").click( function() {
		return confirm('Weet je zeker dat je deze aanbieding wilt verwijderen?');
	});	
