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

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

function initLightbox(){
	var nTotal = $('.content .lightbox').size();		
	for(var nI = 1; nI <= nTotal; nI++){
		$('a.lightbox-'+nI+'').lightBox({
			containerResizeSpeed: 150						 
		});	
	}
}


function initSIFR(){
	sIFR.replace(flux, {
		selector: 'h1.title',
		css: '.sIFR-root { color: #87b4c1; font-size: 23px; font-weight: bold; }',
		wmode: 'transparent'
	});
	sIFR.replace(flux, {
		selector: 'h1.title_small',
		css: '.sIFR-root { color: #87b4c1; font-size: 18px; font-weight: bold; }',
		wmode: 'transparent'
	});
	sIFR.replace(flux, {
		selector: 'h2',
		css: '.sIFR-root { color: #87b4c1; font-size: 27px; font-weight: bold; }',
		wmode: 'transparent'
	});
}

function menu() {
	$('.menu_item:not(.active)').hover(function() {
		$(this).addClass('active');
		$(this).children('.submenu').show();
	}, function() {
		$(this).removeClass('active');
		$(this).children('.submenu').hide();
	});
}

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 validateForm(p_sForm) {
	
	$.validator.addMethod('group', function(value, element) {
		var obj = $('.form');
		return obj.find('.group:filled').length;
	}, '');	

	switch(p_sForm) {
		
		case 'contactform':
		
			var rules = {};
			rules[oFields[p_sForm][2]] = {
				required: true
			};
			rules[oFields[p_sForm][3]] = {
				required: true,
				notags: true,
				nonumber: true
			};
			rules[oFields[p_sForm][5]] = {
				required: true,
				notags: true,
				email: true
			};
			rules[oFields[p_sForm][6]] = {
				required: true,
				notags: true,
				minlength: 5
			};
			
			var messages = {};
			messages[oFields[p_sForm][2]] = {
				required: 'Vul uw naam in.',
				notags: 'Er zijn geen tags toegestaan'
			};
			messages[oFields[p_sForm][3]] = {
				required: 'Vul uw woonplaats in.',
				notags: 'Er zijn geen tags toegestaan',
				nonumber: 'Vul een geldige woonplaats in'
			};
			messages[oFields[p_sForm][5]] = {
				required: 'Vul uw e-mailadres in.',
				notags: 'Er zijn geen tags toegestaan',
				email: 'Vul een geldig e-mailadres in.'
			};
			messages[oFields[p_sForm][6]] = {
				required: 'Typ hier een vraag en/of opmerking',
				notags: 'Er zijn geen tags toegestaan',
				minlength: 'Lengte minimaal 5 karakters'
			};
		
		break;
		case 'contact':
		
			var rules = {};
			rules[oFields[p_sForm][1]] = {
				required: true,
				notags: true
			};
			rules[oFields[p_sForm][2]] = {
				group: true,
				notags: true,
				telephone: true
			};
			rules[oFields[p_sForm][3]] = {
				group: true,
				notags: true,
				email: true
			};
			
			var messages = {};
			messages[oFields[p_sForm][1]] = {
				required: 'Vul uw naam in.'
			};
			messages[oFields[p_sForm][2]] = {
				group: 'Uw telefoonnummer of e-mail is verplicht',
				notags: 'Er zijn geen tags toegestaan',
				telephone: 'Vul een geldig telefoonnummer in'
			};
			messages[oFields[p_sForm][3]] = {
				group: 'Uw telefoonnummer of e-mail is verplicht',
				notags: 'Er zijn geen tags toegestaan',
				email: 'Vul een geldig e-mailadres in.'
			};
		
		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.submit();
		}
	});	
}
function googlemaps(){
	var myCenter = new google.maps.LatLng(51.50190, 4.05572);
	var myOptions = {
	  zoom: 10,
	  center: myCenter,
	  mapTypeId: google.maps.MapTypeId.ROADMAP,	  
	  mapTypeControl: false,
	  scrollwheel: false
	}
	var myLatlng = new google.maps.LatLng(51.45788, 3.89912);
	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	var image = new google.maps.MarkerImage('images/template/marker_cottelli.png',
		new google.maps.Size(94, 63),
		// 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(40, 67)
	);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map,
		icon: image
	});
	var myLatlng2 = new google.maps.LatLng(51.536851, 4.221883);
	var image2 = new google.maps.MarkerImage('images/template/marker_cottelli.png',
		new google.maps.Size(94, 63),
		// 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(50, 65)
	);
	var marker2 = new google.maps.Marker({
		   position: myLatlng2, 
		   map: map,
		   icon: image2
	});     
}
