// header.php --- prevent default first three menu items
$(document).ready(function() {
	var menu_items = ['menu-item-4686', 'menu-item-4687', 'menu-item-3369'];
	$.each(menu_items, function(){
		$('li#' + this + ' a').addClass('preventdef');
		$('li#' + this + ' ul li a').removeClass('preventdef');
		$('a.preventdef').click(function(e) {
			e.preventDefault();
		});
	});
});

// home.php --- contactform
var defaultNaam = 'Naam';
$(document).ready(function(){
	$('#contacthome-naam').attr("value", defaultNaam)
	.focus(function(){
		if (defaultNaam == $(this).attr("value")) {
			$(this).attr("value", "");
		}
	}).blur(function(){
		if ($(this).attr("value") == '') {
			$(this).attr("value", defaultNaam);
		}
	});
});
var defaultEmail = 'Email';
$(document).ready(function(){
	$('#contacthome-email').attr("value", defaultEmail)
	.focus(function(){
		if (defaultEmail == $(this).attr("value")) {
			$(this).attr("value", "");
		}
	}).blur(function(){
		if ($(this).attr("value") == '') {
			$(this).attr("value", defaultEmail);
		}
	});
});

// home.php --- headlines rollover
$(document).ready(function(){
	// projecten
	$('.headlines li').hover(function() {
		$('.headline > .headline-overlay', this).addClass('rollover').removeClass('default');
		$('.headline > .cc-overlay', this).addClass('rollover').removeClass('default');
	}, function () {
		$('.headline > .headline-overlay', this).addClass('default').removeClass('rollover');
		$('.headline > .cc-overlay', this).addClass('default').removeClass('rollover');
	});
});

// home.php --- cc:live images
$(document).ready(function() {
	$('.headline-foto img').each(function() {
		var maxWidth = 240; // Max width for the image
		var maxHeight = 180;    // Max height for the image
		var ratio = 0;  // Used for aspect ratio
		var width = $(this).width();    // Current image width
		var height = $(this).height();  // Current image height

		if(width > maxWidth){
			ratio = maxWidth / width;
			$(this).css("width", maxWidth);
			$(this).css("height", height * ratio);
			height = height * ratio;
		}

		if(height > maxHeight){
			ratio = maxHeight / height;
			$(this).css("height", maxHeight);
			$(this).css("width", width * ratio);
			width = width * ratio;
		}
	});
});

// cases.php --- fixed sidebar when scrolling
/*$(window).scroll(function() {
	var y_pos = $(window).scrollTop() > 371 ? $(window).scrollTop() : 0;
	if (y_pos > 371) {
		$('#caseselection').addClass('fixedPosition');
		$('#portfolioholder').addClass('stayPut');
		$('#sidebarPortfolio').addClass('sidebarNewPos');
	}
	if (y_pos < 371) {
		$('#caseselection').removeClass('fixedPosition');
		$('#portfolioholder').removeClass('stayPut');
		$('#sidebarPortfolio').removeClass('sidebarNewPos');
	}
});*/
