$(document).ready(function() {

function GetFilename(url)
{
   if (url)
   {
      var m = url.toString().match(/.*\/(.+?)\./);
      if (m && m.length > 1)
      {
         return m[1];
      }
   }
   return "";
}
$('div.partnerss a img').hover(function(){
		var page = $(this).attr('src');
		var file = GetFilename(page);
		$(this).attr('src', '/img/c/'+file+'.png');
	}, function(){
		var page = $(this).attr('src');
		var file = GetFilename(page);
		$(this).attr('src', '/img/'+file+'.png');
	});
	$('#menu li a:not(#menu li ul li a):not(#menu li.current a)').click(function() {
		location.href=$(this).attr('href');
		$('#menu li.current ul').slideUp("slow");
		$('#menu li.current').removeClass("current");
		$('#top img.show').fadeOut("fast");
	});
	$('.testimonials, #testimonials div').click(function(){
		location.href=$(this).find('a').attr('href');
	});
	$('#menu li.current ul').fadeIn("slow");
		$('#query').click(function(){
		$(this).attr('value',''); 
	});
	$('#searchsite').submit(function() {
		$.google({q:'site:reogroep.nl '+$('#query').val(),rsz:'large',callback:function(result) {
			$('#content').children().remove();
			$('#content').append('<h1>Zoeken</h1>');
			if(!result.total) { result.total = 'geen'; }
			$('#content').append('<p><strong>Er zijn '+result.total+' resultaten gevonden voor "'+$('#query').val()+'".</strong></p>')
			var s = ['<ol>'];
			for(var i = 0; i < result.results.length; i++) s.push('<li><p><a href="'+result.results[i].url+'">'+result.results[i].title+'</a></p><p>'+result.results[i].content+'</p></li>')
			s.push('</ol>');
			$('#content').append(s.join(''));
		}});
		return false;
	});
	$('#news div.newsarticle').click(function() {
		location.href=$(this).find('a').attr('href');
	});
	$('div.newsitem').click(function() {
		location.href=$(this).find('a').attr('href');
	});
	$('#mapr').jmap('init', {'mapType':'map','mapShowjMapsIcon':false,'mapZoom':9,'mapCenter':[52.04092,4.71804]});
	$('#mapr').jmap('AddMarker', {
			'pointLatLng': [52.04092,4.71804],
			'pointHTML': '<img src="/img/logo.intro.png" />'
	});
});



