$( function()
{
	
	var current;

	$( '#zoekVakmanFrm' ).submit( function()
	{ 
		if( $( ':checkbox:checked' ).length >= 1 )
		{
			return true;
		}
		else
		{
			alert( 'U moet minimaal 1 groep selecteren' );
			return false;
		}
	});
	
	$( 'area' ).click( function()
	{
		// Doorsturen
		window.location='/adressen/regio/' + $( this ).attr( 'id' ) + '.htm'; 
		//alert($( this ).attr( 'id' ));
		
		$( '#provincie' ).data("current", $( this ).attr( 'id' ) );
		$( '#provincie' ).text( $( this ).attr( 'title' ) );
		$( '#hiddenInputProvincie' ).val( $( this ).attr( 'title' ) );
		$( '.selected_provincie' ).css( 'display', 'inline' );
	});
	
	$( '.selected_provincie' ).click( function()
	{
		if( $( ':checkbox:checked' ).length < 1 )
		{
			alert( 'Selecteer een klusthema.');
			return false;
		}
		else
		{
			return true;
		}
	});

	$( 'area' ).hover( function()
	{
		var left = 0;
		
		$( this ).css( 'cursor', 'pointer' );
		$( '#provincie' ).text( $( this ).attr( 'title' ) );
		
		kleur_provincie( $( this ).attr( 'id' ) );
	}
	, function()
	{
		var current = $( '#provincie' ).data( "current" );
		if (current) {
			$('#provincie').text($('#' + current).attr('title'));
		}
		else
		{
			$('#provincie').text('');
		}
		$( '#nederland' ).css( 'background', 'url(/images/kaart/nederland.png) left top no-repeat' );
	});
	
	function kleur_provincie( provincie )
	{
		var left = 0;
	
		switch( provincie )
		{
			case 'brabant':	left = 231; break;
			case 'drenthe':	left = 462; break;
			case 'flevoland': left = 693; break;
			case 'limburg':	left = 924; break;
			case 'noord-holland': left = 1155; break;
			case 'friesland': left = 1386; break;
			case 'overijssel': left = 1617; break;
			case 'groningen': left = 1848; break;
			case 'utrecht': left = 2079; break;
			case 'zeeland': left = 2310; break;
			case 'gelderland': left = 2541; break;
			case 'zuid-holland': left = 2772; break;
		}
		
		$( '#nederland' ).css( 'background', 'url(/images/kaart/nederland.png) -' + left + 'px top no-repeat' );
	}
});
