/*

	Scripts for Talent in Motion
	Copyright:  Netlash <http://www.netlash.com>
	author:	 Johan Ronsse johan@netlash.com>

*/


function watchResolution() {
	if ($('body').width() < 1120) {
		$('body').removeClass('wideScreen');
		// console.log('wide');
	} else {
		$('body').addClass('wideScreen');
		// console.log('narrow');
	}
}

// Adds a class focus to input[type="text"] and textarea when focused
function focusfix(selector, className) {
	$(selector).focus(function() {
		$(this).addClass(className);
	});
	// Removes class when focus is lost
	$(selector).blur(function() {
		$(this).removeClass(className);
	});
}

$(document).ready(function() {
	if($('#domain').length > 0) {
		if($('#domain').val() == 'andere') $('#otherHolder').show();
		else $('#otherHolder').hide();
		
		$('#domain').change(function(evt) {
			if($(this).val() == 'andere') $('#otherHolder').show();
			else $('#otherHolder').hide();
		})
	}

	/*
		General (every page)
	*/

	// Missing CSS selector support for lesser browsers
	$('#subnavigation li:last-child, #footer li:last-child, #jobs li:last-child, .contentBlocks .contentBlock:last-child').addClass('lastChild');
	$('#quote blockquote p span:first-child').addClass('firstChild');

	// Apply focusfix
	focusfix('input.inputText', 'focus');
	focusfix('textarea', 'focus');

	// Watch window resizing
	watchResolution();

	/*
		Manage classnames on #specializations (homepage)
	*/

	$('#specializations ul a').each(function(index) {
		var className = 'hoverChild' + (index + 1);
		$(this).bind({
			focus: function() {
				$(this).parent().parent().addClass(className);
			},
			blur: function() {
				$(this).parent().parent().removeClass(className);
			},
			mouseenter: function() {
				$(this).parent().parent().addClass(className);
			},
			mouseleave: function() {
				$(this).parent().parent().removeClass(className);
			}
		});
	});

});

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

