$(function() {

	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$("a[rel]").overlay({
		mask: '#2d2d2d',
		effect: 'apple',
		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".content");
			// load the page specified in the trigger
			wrap.load(this.getTrigger().attr("href"));
		},
			onClose: function() {
			if ($('#videoPlayer').length){
			// grab wrapper element inside content
			var wrap = this.getOverlay().find("#videoPlayer");
			// load the page specified in the trigger
			wrap.remove();
			}
		}
	});
});
