var firstPage = true;

$(document).ready(function(){
	
	$('#navmenu li').hover(
		function() 
		{
			$(this).addClass('iehover');
		},
		function() 
		{ 
			$(this).removeClass('iehover'); 
		}
	);
	
	$('#breadcrumb li:lt('+($('#breadcrumb li').length-1)+')').each( function (i) {
		$(this).append('>');
	});
	
	$('form td').each( function (i) {
		if ( $(this).find('.error').length > 0 )
			$(this).addClass('error');
	});
	
	$('#fade_1').cycle({ 
	    speed:   1000, 
	    timeout: 10000,
	    before:  function(currSlideElement, nextSlideElement, options, forwardFlag) {
			if (!firstPage) {
				$('#slogan').fadeTo(1000, 0);
			}
			if (firstPage) {
				firstPage = false;
			}
		},
	    after:  function(currSlideElement, nextSlideElement, options, forwardFlag) {
			var slogan = $('#slogan');
			slogan.fadeTo(0, 0);
			slogan.html(nextSlideElement.title);
			_typeface_js.replaceText(document.getElementById('slogan'));
			slogan.fadeTo(1000, 1);
		}
	});
	
	$('input[type=text]').addClass('text');
	
	var url = document.location.href;
	var new_url = url.replace('detail', 'print');

	$('#vacature-print').attr('href', new_url);
	
	autoFill('nieuwsbrief_btn', 'Vul uw e-mailadres in...', '#');
});

function printVacature(vacatureId) {
	window.open('/fileadmin/bosmanvos.nl/php/vacature.print.php?vacatureId='+vacatureId,'vacature','width=800,height=600');
}

function autoFill(veld, invoer, type) {
	if (type != '.') {
		type = '#';
	}
	
	$(type+veld).each(function() {
		// standaard tekst
		if ($(this).val() == invoer || $(this).val() == '') {
			$(this).val(invoer).css('color','gray');
		}
		
		// onfocus
		$(this).focus(function() {
			if ($(this).val() == invoer) {
				$(this).val('').css('color','black');
			}
		});
		
		// onblur
		$(this).blur(function() {
			if ($(this).val() == '') {
				$(this).val(invoer).css('color','gray');
			}
		});
	});
}
