function clearInput(obj) {
	obj = $(obj);
	if (obj.data('done')!=1) {
		obj.val('');
		obj.data('done', 1);
	}
}

function clearTextarea(obj) {
	obj = $(obj);
	if (obj.data('done')!=1) {
		obj.html('');
		obj.data('done', 1);
	}
}

function clearForm() {
	$("#fav_email").val('e-mail adres');
	$("#fav_email").data('done', 0);
	$("#fav_bericht").val('tekst toevoegen');
	$("#fav_bericht").data('done', 0);
}

function sendForm() {
	$.post("/ajax_favorieten", { 
		token: $("#fav_token").val(), 
		email: $("#fav_email").val(), 
		bericht: $("#fav_bericht").val()
	}, function(data) {
		if (data.error) $("#error").html(data.error);
		if (data.token) $("#fav_token").val(data.token);
	}, "json");
}

function remove_fav(id) {
	$.get('/index.php?page=ajax_favorieten&collectie_min='+id, function(data) {
		if (data==1) load_favorieten();
	});
}

function load_favorieten() {
	$("#favorieten").load('/ajax_favorieten', function(){
		$("#favorieten").show();
		$("#fav_collectie").smoothDivScroll({
			//autoScroll: "onstart", 
			autoScrollDirection: "backandforth", 
			autoScrollStep: 1, 
			autoScrollInterval: 15, 
			//startAtElementId: "startAtMe", 
			visibleHotSpots: "always"
		});
	});
}

function ballon(id, positie) {
	$('#'+id).bt({
		showTip: function(box){
			var $content = $('.bt-content', box).hide();
			var $canvas = $('canvas', box).hide(); 
			var origWidth = $canvas[0].width; 
			var origHeight = $canvas[0].height;
			$(box).show(); 
			$canvas
				.css({width: origWidth * .5, height: origHeight * .5, left: origWidth * .25, top: origHeight * .25, opacity: .1})
				.show()
				.animate({width: origWidth, height: origHeight, left: 0, top: 0, opacity: 1}, 400, 'easeOutBounce',
					function(){$content.show()} 
				);
		},
		hideTip: function(box, callback) {
			var $content = $('.bt-content', box).hide();
			var $canvas = $('canvas', box);
			var origWidth = $canvas[0].width;
			var origHeight = $canvas[0].height;
			$canvas
				.animate({width: origWidth * .5, height: origHeight * .5, left: origWidth * .25, top: origHeight * .25, opacity: 0}, 400, 'swing', callback);
		},
		shrinkToFit: true,
		hoverIntentOpts: {
			interval: 0,
			timeout: 0
		},
		fill: '#FFF',
		cornerRadius: 10,
		strokeWidth: 1,
		positions: [positie]
		//, trigger: ['mouseover', 'focus']
	});
	$('#'+id).btOn();
	setTimeout ("$('#"+id+"').btOff();", 4000);
}

$(document).ready(function() {
	$("#fav_btn").fancybox({
		//'modal' : true,
		showNavArrows: false,
		//overlayColor : '#ffffff',
		overlayOpacity : 0,
		width: 565,
		height: 400,
		autoDimensions: false,
		onStart : function() {
			load_favorieten();
		},
		onClosed : function() {
            $("#favorieten").hide();
		}

	});
	$("a, div").removeAttr('title');
});

