var sifr = { src: 'flash/sifr.swf' };
sIFR.activate(sifr);

$(document).ready(function(){
	initSIFR();
	menu();
});

function radioButtons() {
	$('.radio').click(function() {
		$('label.radio').removeClass('checked');	
		$('label.radio').find('input').attr('checked','');
		$(this).addClass('checked');
		$(this).find('input').attr('checked','checked');
	});
	$('.radio2').click(function() {
		$('label.radio2').removeClass('checked');	
		$('label.radio2').find('input').attr('checked','');
		$(this).addClass('checked');
		$(this).find('input').attr('checked','checked');
	});
	$('.checkbox').toggle(
		function() {
			$(this).prev().attr('checked','checked');
			$(this).addClass('checked');
			$(this).children('input').val('Ja');
		},
		function(){
			$(this).prev().attr('checked','');
			$(this).removeClass('checked');
			$(this).children('input').val('');
		}	
	);
}

function menu() {
	$('.menu_item:not(.active)').hover(function() {
		$(this).addClass('active');
		$(this).children('.submenu').show();
	}, function() {
		$(this).removeClass('active');
		$(this).children('.submenu').hide();
	});
}
function initSIFR(){
	sIFR.replace(sifr, {
		selector: 'h1',
		css: '.sIFR-root { color: #86c5e6; font-size: 20px; }',
		wmode: 'transparent'
	});	
	sIFR.replace(sifr, {
		selector: 'h2',
		css: '.sIFR-root { color: #86c5e6; font-size: 27px; }',
		wmode: 'transparent'
	});	
}
function initSelectboxes(){
	$('div.select select').selectbox();
	var zIndex = 9999;
	$('div.form div.entry').each(function(){
		$(this).css('z-index',zIndex);
		zIndex--;
	});
}

function validateForm(p_sForm) {

	switch(p_sForm) {
		case 'contactform':

			var rules = {};
			rules[oFields[p_sForm][1]] = {
				required: true,
				notags: true
			};
			rules[oFields[p_sForm][2]] = {
				required: true,
				notags: true,
				nonumber: true,
				minlength: 2
			};
			rules[oFields[p_sForm][4]] = {
				required: true,
				email: true,
				notags: true
			};
			
			var messages = {};
			messages[oFields[p_sForm][1]] = {
				required: 'Selecteer de aanhef.',
				notags: 'U mag geen tags invoeren.'
			};
			messages[oFields[p_sForm][2]] = {
				required: 'Vul uw naam in.',
				notags: 'U mag geen tags invoeren.',
				nonumber: 'Vul een geldige naam in',
				minlength: 'Vul minimaal 2 karakters in.'
			};
			messages[oFields[p_sForm][4]] = {
				required: 'Vul een e-mailadres in.',
				email: 'Vul een geldig e-mailadres in.',
				notags: 'U mag geen tags invoeren.'
			};
		
		break;
	}
	
	$('#'+p_sForm).validate({
		rules: rules,
		messages: messages,
		errorPlacement: function(error, element) {
			var obj = element.parent().next('div.icon');
			error.insertAfter(obj);
			obj.attr('class','icon invalid');
		},
		success: function(label) {
			label.prev('div.icon').attr('class','icon valid');
			label.remove();
		},
		submitHandler: function(form) {
			form.trigger('submit');
		}
	});	
}

function googlemaps(){
	var myCenter = new google.maps.LatLng(51.74988, 4.11749);
	var myOptions = {
	  zoom: 14,
	  center: myCenter,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,	  
	  mapTypeControl: false,
	  scrollwheel: false
	}
	var myLatlng = new google.maps.LatLng(51.74996, 4.11770);
	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	var image = new google.maps.MarkerImage('images/template/marker_ic-automatisering.png',
		new google.maps.Size(43, 46),
		// The origin for this image is 0,0.
		new google.maps.Point(0,0),
		// The anchor for this image is the base of the flagpole at 0,32.
		new google.maps.Point(29, 45)
	);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		icon: image
	});
}
