$(document).bind("contextmenu",function(e){  
     //return false;  
});

var ajaxformTimer;
$(function(){
	$('.showhide').live('click',function(){
		if($(this).parent().find('div:first').hasClass('show')){	
			$(this).html('&laquo; minder');
		}else{
			$(this).html('meer &raquo;');			
		}
		$(this).parent().find('div').toggleClass('hide show');
		/*$(this).parent().find('div.show').removeClass('show').addClass('hide').hide();*/
			
		return false;
		
	});

	
	$('form.validate').submit(function(){
		return formValidate($(this).attr('id'));
	});

	$('.submit').livequery('click',function(){
		$(this).blur();	
		$(this).parents('form').submit();	
		return false;
	});
	
	$('.button-disabled, a.disabled').livequery('click',function(e){
		return false;									
	});	
	
	$('textarea').autogrow();
});

var timer;
showMessage = function(data, delay){
	if(timer) clearInterval(timer);
	if(!delay) delay=10000;
	
	if($('#returnMessage').length<1) $('body').prepend('<div id="returnMessage" />');
	$this = $('#returnMessage');
	$this.hide();
	$this.html(data).slideDown();
	timer = setInterval(function(){hideMessage()},delay);
	$this.click(function(){
		hideMessage();							   
	});
}
hideMessage = function(){
	if(timer) clearInterval(timer);
	$this = $('#returnMessage');
	$this.slideUp();
}


function mailer(_class, user,domain){
	emailAdres=user+'@'+domain;
	$("."+_class).html('<a href="mailto:'+emailAdres+ '">' + emailAdres + '</a>');
}
function gotoUrl(url, ajax){
	window.location.href=baseurl()+url;
}
function loadCss(url){
	$("head").append('<link href="'+url+'" rel="stylesheet" type="text/css" />');
}

function baseurl(){
	return document.getElementsByTagName('base')[0].href;	
}

function checkemail(adres){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(adres))
		return true;
	else{
		return false;
	}
}
function checkDate(_date){
	var date = _date.split("-");
	var JDate = new Date(parseInt(date[2]), parseInt(date[1]) -1, parseInt(date[0]))
	valid = (parseInt(date[1]) - 1 == JDate.getMonth() && parseInt(date[0]) == JDate.getDate() && parseInt(date[2]) == JDate.getFullYear());
	return valid;
}

function strpos (haystack, needle, offset) {
    var i = (haystack + '').indexOf(needle, (offset || 0));
    return i === -1 ? false : i;
}

function loader($elem){
	$elem.parent().prepend('<div class="loading"> Bezig met laden ..</div>');
}
function loaderRemove($elem){
	$elem.parent().find('.loading').fadeOut().remove();
}
