$(function() {
	
	// update buttons met style (jQuery UI Buttons)
	$('[type=button], [type=submit], button').button();
	
	// voeg datepickers toe aan alles waarvan de naam eindigt met "datum"
	$('input[name$=datum], input.datumveld').datepicker({
		dateFormat: 'yy-mm-dd'
	});
	
});

window.herlaad = false;

function sluit() {
	self.close();
	
	if( window.herlaad === true ) {
		self.opener.location = self.opener.location + "";
	}
}

function openInPopup( url, breedte, hoogte ) {
	
	var newwin = window.open( url, "_blank", "width=" + breedte + ",height=" + hoogte + ",menubar=no,scrollbars=auto,location=no,toolbar=no,directories=no,status=no,titlebar=no");
	
	if(!newwin) {
		alert('Controleer of er een popup is geblokkeerd');
		return false;
	}
	
	if(!newwin.opener) {
		newwin.opener = window;
	}
	
	return false;
}

// Automatische Popup
jQuery('.auto-popup').live('click', function() {
	
	var url = jQuery(this).attr('href');
	
	return openInPopup( url, 700, 600 );
	
});

jQuery('.auto-popup-1024').live('click', function() {
	
	var url = jQuery(this).attr('href');
	
	return openInPopup( url, 1024, 900 );
	
});

jQuery('.auto-popup-400').live('click', function() {
	
	var url = jQuery(this).attr('href');
	
	return openInPopup( url, 400, 300 );
	
});

