$(function(){
	$("#documentation").tabs();
	$("#contact").attr("href","mailto:jan.sundman@aland.net");
})

$(function() {
	$.getJSON("./formwizard_changelog.html",function(data){
		$("#changelog_for_date").html("The latest version of the plugin was released on " + data.changelog[0].date + ". Release dates are marked in red, click marked dates to see the changelog for that particular release." );
		$("#calendar").datepicker({
			beforeShowDay: function(date) {
				var changelogEntry = $.grep(data.changelog,function(d){var a = new Date(d.date);return (date.toString() == a.toString())});
				if (changelogEntry.length > 0) {
					return [true, 'changelogEntry', changelogEntry[0].version];
				}
				return [true,''];
			},	
			onSelect: function(dateText, inst){
				$("#changelog_for_date").slideUp(function(){
					var entries = $.grep(data.changelog,function(d){
																														var dateString = $.datepicker.formatDate('mm/dd/yy', new Date(d.date));

																														return (dateText == dateString);
																													});
					var entry = "No new version released on this date.";

					if(entries.length > 0){
							entry = "";
							$.each(entries, function(){ 
								entry = entry + this.entry;
							});
						}
					$("#changelog_for_date").html(entry).slideDown();
				});
			}
		});
	});
});		

$(function(){
	$("#demoForm").formwizard({ //wizard settings
	 	historyEnabled : true, 
	 	formPluginEnabled: true, 
	 	validationEnabled : true,
	 	focusFirstInput : true,
	 	validationOptions : {
			messages: {	email: "Felaktig email (localized into Swedish)"}																
	 	},
		formOptions : {
			success: function(data){alert(data.registration.statusMessage);},
			beforeSubmit: function(data){alert("about to send the following data: \n\n" + $.param(data))},
			dataType: 'json',
			resetForm: true
		}
	 });
});

