// JavaScript Document

var intervalID = false;
var intervalTimer = 5000;

$(document).ready(function() {
						   
	// SLIDER
	if($('.slides > li').length > 1){		
		intervalID = setInterval(function(){header(false)}, intervalTimer);
	}

	$('a[rel="extern"]').attr('target', '_blank');
	
	// IMAGE ROLLOVER
	
	$("IMG.hover").hover(function() {
		var tmp = $(this).attr('src');
		tmp = tmp.replace('normal','hover');
		$(this).attr('src', tmp);
	},
	function() {
		var tmp = $(this).attr('src');
		tmp = tmp.replace('hover','normal');
		$(this).attr('src', tmp);
	
	});
	
	// ZOEKSCHERM
	
	$("#header-search-input").focus(function() {
		if ($(this).val() == 'Zoeken in de site') {
			$(this).val('');
		}
	});
	
	$("#header-search-input").blur(function() {
		if ($(this).val() == '') {
			$(this).val('Zoeken in de site');
		}
	});
	
	
	/* FLASH ELEMENTEN */
	
	/*
	$(".title").each(function() {
		var tekst = $(this).text();
		$(this).text('');
		$(this).flash(
			{src: '/images/flash/title.swf',
			width: 500,
			height: 35, 
			flashvars: { title: tekst },
			wmode: 'transparent'},
			{ version: 8 }
		);
	});
	
	$(".bar").each(function() {
		var tekst = $(this).text();
		$(this).text('');
		$(this).flash(
			{src: '/images/flash/h2.swf',
			width: 500,
			height: 30, 
			flashvars: { title: tekst },
			wmode: 'transparent'},
			{ version: 8 }
		);
	});
	
	$("H1").each(function() {
		var tekst = $(this).text();
		$(this).text('');
		$(this).flash(
			{src: '/images/flash/h1.swf',
			width: 250,
			height: 30, 
			flashvars: { title: tekst },
			wmode: 'transparent'},
			{ version: 8 }
		);
	});
	
	$("H2").each(function() {
		var tekst = $(this).text();
		$(this).text('');
		$(this).flash(
			{src: '/images/flash/h2.swf',
			width: 500,
			height: 30, 
			flashvars: { title: tekst },
			wmode: 'transparent'},
			{ version: 8 }
		);
	});
	*/
	
	
	var jmaps = $("#jmaps").html();
	
	$('#jmaps').jmap('init', {mapCenter:[51.958858,3.162302], mapShowjMapIcon:false, mapEnableType:true}, function(el, options){							
			$(el).jmap("searchAddress", {address: jmaps}, function(options, point) {								   		
				$("#jmaps").jmap("moveTo", {mapCenter: [point.y, point.x]});
        		$("#jmaps").jmap('addMarker', {pointLatLng:[point.y, point.x], pointHTML: '' + options.address + ' '});
			});
	});
	
	
	/* MENU FIX */
	
	//$("#content-left-menu UL LI A.active").parent().prev().children("A").css('background','none');
	
	
	/* PNG HACK */
	
	//$('#site-bg, #menu UL LI A IMG').pngfix();
	
	
	// PDF LINKS
	
	$("A[@href$='.pdf']").addClass('pdf').attr('target','_blank');
	$("A[rel='extern']").attr('target','_blank');
	
	
	// TEAM OVERZICHT
	
	$(".team:odd").css('margin-right','0');
	
	$("#select-team").change(function() {
		location = $("OPTION:selected").eq(0).val();
	});
	
	
	
	// Form checker
	
	$('form').submit(function(){					
		var txt = '';


		// standaard form check
		$(this).find('input, textarea').each(function(){
			if( $(this).attr('title') && $(this).val().length == 0 ){
				txt += ' - ' + $(this).attr('title') + '\n';
			}
		});
		
		
		if(txt && txt.length > 0){
			var header = '___________________________________________________________\n\n De volgende velden zijn verplicht: \n\n';
			var footer = '___________________________________________________________\n\n ';
			alert(header + txt + footer);
			return false;
		}
	});
	


});


var header = function(next){
		
	var total = $('.slides > li').length;
	var current = parseInt($('.slides .active').removeClass('active').fadeOut(750).attr('id').replace('slide-',''));
	
	if(!next){
		next = current + 1;
	}
	
	if(next > total){
		next = 1;	
	}
	
	$('.slides-nav a').removeClass('active');
	$('a[href=#slide-'+next+']').addClass('active');
	$('#slide-'+next).addClass('active').fadeIn(750);
	
}


