//	$.jFu
//		-Done!
//	$.jFuForm
//		-Done!
//	$.jFuMessage
//		-Done!
//	$.jFuTransparent
//		-Done!
//	$.fn.jFuDatepicker
//		-Done!
//	$.fn.jFuDialog
//		-Done!

//	$.fn.jFuTabs
//		- In progress

//	$.fn.jFuText
//	$.fn.jFuPassword
//	$.fn.jFuButton
//	$.fn.jFuSubmit
//	$.fn.jFuCheckbox
//		(http://aaronweyenberg.com/90/pretty-checkboxes-with-jquery)
//	$.fn.jFuRadio
//	$.fn.jFuSelect
//	$.fn.jFuTextarea
//	$.fn.jFuTimepicker

//	$.jFuLabel
//	$.jFuPreload
//	$.fn.jFuHorizontalSlider
//	$.fn.jFuScroll
//	$.fn.jFuSearch
//	$.fn.jFuTooltip
//	$.fn.jFuValidate
//		- Send hele formen, så værdier felter imellem kan tjekkes?
//	$.fn.jFuVerticalSlider


/*
 * jFu Library version 1.0.0 for jQuery 1.3.2
 * 	(Released: 2009-09-28)
 * 	http://www.jfu.icevision.dk/1.0.0/
 *
 * Copyright © 2009 by Ice Vision ApS
 * 	Developed by Kasper M. Nyboe
 */


/*
 * jFu
 *	Initializes jFu modules
 */
	$.jFu = function(Arguments) {
// Tjek browsersupport!
// Skift sprog undervejs?
// Singleton?
		Arguments =	$.extend(	{
							country:	'dk',
							form:		{
										text:		true,
										password:	true,
										button:		true,
										submit:		true,
										checkbox:	true,
										radio:		true,
										select:		true,
										textarea:	true,
										datepicker:	true,
										timepicker:	true										
									}
						},
						Arguments
				);

		Date.Country = Countries[Arguments.country];

		// $.jFuMessage
		if ($('div#jFuMessage').length == 0) {
			$('div:first').before('<div id="jFuMessage"></div>');
		}


		// $.jFuTransparent
		$.jFuTransparent();


		// $.fn.jFuDialog
		$(document)
			.bind(	'keypress.jFu',
				function(e) {
					if ((e.keyCode ? e.keyCode : e.which) == 27 && typeof $('div.jFuDialogFocus').data('jFu') != 'undefined' && $.isFunction($('div.jFuDialogFocus').data('jFu').closeOnEscape)) {
						$('div.jFuDialogFocus').data('jFu').closeOnEscape($('div.jFuDialogFocus'));
					}
				}
			)
			.bind(	'mousedown.jFu',
				function(e) {
					$('div.jFuDialog')
						.each(	function() {
								if (typeof $(this).data('jFu') != 'undefined' && $.isFunction($(this).data('jFu').closeOnBlur)) {
									if ($.inArray($('div').index($(this)), $.map($(e.target).add($(e.target).parents()), function(n) { return $('div').index($(n)); })) == -1) {
										$(this).data('jFu').closeOnBlur($(this));
									}
								}
							}
						);
				}
			);

		// $.fn.jFuText
		if (Arguments.form.text == true) {
			$('input[type=text]')
				.each(	function() {
						$(this).jFuText();
					}
				);
		}

		// $.fn.jFuPassword
		if (Arguments.form.password == true) {
			$('input[type=password]')
				.each(	function() {
						$(this).jFuPassword();
					}
				);
		}

		// $.fn.jFuPassword
		if (Arguments.form.button == true) {
			$('input[type=button],button')
				.each(	function() {
						$(this).jFuButton();
					}
				);
		}

		// $.fn.jFuSubmit
		if (Arguments.form.submit == true) {
			$('input[type=submit]')
				.each(	function() {
						$(this).jFuSubmit();
					}
				);
		}

		// $.fn.jFuCheckbox
		if (Arguments.form.checkbox == true) {
			$('input[type=checkbox]')
				.each(	function() {
						$(this).jFuCheckbox();
					}
				);
		}

		// $.fn.jFuRadio
		if (Arguments.form.radio == true) {
			$('input[type=radio]')
				.each(	function() {
						$(this).jFuRadio();
					}
				);
		}

		// $.fn.jFuSelect
		if (Arguments.form.select == true) {
			$('select')
				.each(	function() {
						$(this).jFuSelect();
					}
				);
		}

		// $.fn.jFuTextarea
		if (Arguments.form.textarea == true) {
			$('textarea')
				.each(	function() {
						$(this).jFuTextarea();
					}
				);
		}

		// $.fn.jFuDatepicker
		if (Arguments.form.datepicker == true) {
			$('input[type=text].jFuDatepicker')
				.each(	function() {
						$(this).jFuDatepicker();
					}
				);
		}

		// $.fn.jFuTimepicker
		if (Arguments.form.timepicker == true) {
			$('input[type=text].jFuTimepicker')
				.each(	function() {
						$(this).jFuTimepicker();
					}
				);
		}
	};


/*
 * jFuMessage (jFu 1.0.0)
 *	Displays a message to the user at the top of the page. No action is taken if either parameter to jFuMessage is empty.
 */
	$.jFuMessage = function(html, type) {
		if (html != '' && type != '') {
			if ($('#jFuMessage').data('jFu') != null) {
				clearTimeout($('#jFuMessage').data('jFu').timeout);
			}
			$('div#jFuMessage')
				.removeData('jFu')
				.stop()
				.empty()
				.removeClass()
				.addClass('jFu' + type.charAt(0).toUpperCase() + type.substr(1).toLowerCase())
				.append(	$('<div class="jFuIconClose16x16" style="cursor: pointer; float: right; margin-top: 8px;"></div>')
							.bind(	'click',
									function(e) {
										$('div#jFuMessage')
											.stop()
											.animate(	{opacity: 0},
													300,
													function() {
														$(this).css('display', 'none');
													}
											);
									}
							)
				)
				.append(	$('<div class="jFuIcon' + type.charAt(0).toUpperCase() + type.substr(1).toLowerCase() + '32x32" style="float: left; margin-left: 5px;" /></div>')
				)
				.append(	$('<div style="display: table; margin-left: auto; margin-right: auto; height: 32px;"></div>')
							.append(	$('<div style="display: table-cell; vertical-align: middle;">' + html + '</div>'))
				)
				.css(	{
						display:	'block',
						height:		'1px',
						opacity:	0.9,
						textAlign:	'center'
					}
				)
				.animate({height: '32px'}, 800);

			if (type == 'success') {
				$('div#jFuMessage')
					.data(	'jFu',
						$.extend(	{
									timeout:	setTimeout(	function() {
														$('div#jFuMessage')
															.stop()
															.animate(	{opacity: 0},
																	300,
																	function() {
																		$(this).css('display', 'none');
																	}
															);
													},
													6000
											)
								}
						)
					);
			}
		}
	};

/*
 * jFuTransparent (jFu 1.0.0)
 *	All elements with class jFuTransparent:xx are set to xx opacity when jQuery is loaded.
 */
	$.jFuTransparent = function() {
		$('[class*=\'jFuTransparent:\']')
			.each(	function() {
					$(this)
						.css(	{
								opacity:	$(this).attr('class').replace(/ /g, ':').split(':')[$.inArray('jFuTransparent', $(this).attr('class').replace(/ /g, ':').split(':')) + 1],
								visibility:	'visible'
							}
						);
				}
			);
	};


/*
 * jFuDatepicker (jFu 1.0.0)
 *	Displays a calendar on click and displays the selected value in the inputfield.
 */
	$.fn.jFuDatepicker = function(Argument) {
		if (typeof Argument == 'object' || Argument == null) {
			$(this)
				.attr('readonly', 'true')
				.addClass('jFuDatepicker')
				.unbind('click.jFu')
				.bind(	'click.jFu',
					function(e) {
						e.stopPropagation();
						$(this)
							.trigger('blur')
							.jFuDatepicker('open');
					}
				)
				.data(	'jFu',
					$.extend(	{
								date:			new Date(),
								format:			Date.Country.formats.shortDate,
								left:			null,
								maxDate:		new Date(2037, 11, 31),
								minDate:		new Date(1970, 0, 1),
								selectWeek:		false,
								showWeekNumbers:	false,
								top:			null
							},
							$(this).data('jFu'),
							Argument
					)
				)
				.jFuDatepicker('setDate', $(this).data('jFu').date);
		}
		else {
			if (typeof $(this).data('jFu') == 'undefined') {
				$(this).jFuDatepicker();
			}
			switch (Argument) {

				case 'close':
					if ($(this).data('jFu').Datepicker != null) {
						$(this)
							.data('jFu').Datepicker
								.jFuDialog('close')
								.animate(	{
											opacity:	0
										},
										1,
										function() {
											$(this).remove();
										}
								);
					}

					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										Datepicker:	null
									}
							)
						);
				break;

				case "getDate":
					return $(this).data('jFu').date.clone();
				break;

				case 'open':
					if ($(this).data('jFu').Datepicker == null) {
						$(this)
							.data(	'jFu',
								$.extend(	$(this).data('jFu'),
										{
											Datepicker:	$('<div></div>')
														.addClass('jFuDatepicker')
														.data(	'jFu',
															{
																date:	$(this).data('jFu').date.clone(),
																owner:	$(this)
															}
														)
														.append('<table style="width: 100%;"></table>')
														.prependTo($('div:first').parent())
														.bind(	'update',
															{
																owner:	$(this)
															},
															function(e) {
																$(this)
																	.jFuDialog('setTitle', $(this).data('jFu').date.format(Date.Country.formats.yearMonth).substring(0, 1).toUpperCase() + $(this).data('jFu').date.format(Date.Country.formats.yearMonth).substring(1))
																	.find('table > tbody > tr > td')
																		.unbind('click')
																	.end()
																	.children('table')
																		.empty()
																		.append(	$('<thead></thead>')
																					.append('<tr></tr>')
																		);

																if (e.data.owner.data('jFu').showWeekNumbers) {
																	$(this).find('table > thead > tr:last')
																		.append('<th>&nbsp;</th>');
																}
																for (var day = Date.Country.firstDayOfWeek; day < 7; day++) {
																	$(this).find('table > thead > tr')
																		.append('<th>' + Date.Country.abbreviatedDayNames[day] + '</th>');
																}
																for (var day = 0; day < Date.Country.firstDayOfWeek; day++) {
																	$(this).find('table > thead > tr')
																		.append('<th>' + Date.Country.abbreviatedDayNames[day] + '</th>');
																}

																$(this).children('table')
																	.append('<tbody></tbody>');

																var date = new Date($(this).data('jFu').date.clone().clearTime().setDate(1)).setDay(Date.Country.firstDayOfWeek);
																for (var week = 0; week < 6; week++) {
																	$(this).find('table > tbody')
																		.append('<tr></tr>');
																	if (e.data.owner.data('jFu').showWeekNumbers) {
																		$(this).find('table > tbody > tr:last')
																			.append('<th style="padding-right: 2px;">' + date.clone().setDay(1).W() + '</th>');
																	}
																	for (var day = 0; day < 7; day++) {
																		$(this).find('table > tbody > tr:last')
																			.append(	$('<td></td>')
																						.append(	$('<input style="width: 100%;" type="button" value="' + date.format('d') + '" />')
																									.addClass('jFuDate')
																									.addClass(date.getTime() == new Date().clearTime().getTime() ? 'jFuDateToday' : '')
																									.addClass(date.getTime() > new Date().clearTime().getTime() ? 'jFuDateFuture' : '')
																									.addClass(date.getTime() < new Date().clearTime().getTime() ? 'jFuDatePast' : '')
																									.addClass(date.getMonth() != $(this).data('jFu').date.getMonth() ? 'jFuDateOff' : '')
																									.addClass(date.getTime() == e.data.owner.data('jFu').date.clearTime().getTime() || (e.data.owner.data('jFu').selectWeek == true && date.getTime() >= e.data.owner.data('jFu').date.clone().setDay(Date.Country.firstDayOfWeek).getTime() && date.getTime() <= e.data.owner.data('jFu').date.clone().setDay(Date.Country.firstDayOfWeek).addDays(6).getTime()) ? 'jFuDateSelected' : '')
																									.addClass(date < e.data.owner.data('jFu').minDate || date > e.data.owner.data('jFu').maxDate ? 'jFuDateDisabled' : '')
																									.bind(	'click',
																										{
																											date:	date.clone(),
																											owner:	e.data.owner
																										},
																										function(e) {
																											if (!$(this).hasClass('jFuDateDisabled')) {
																												e.stopPropagation();
																												e.data.owner
																													.jFuDatepicker('setDate', e.data.date)
																													.jFuDatepicker('close');
																											}
																										}
																									)
																									.bind(	'mouseover',
																										{
																											owner:	e.data.owner
																										},
																										function(e) {
																											$(e.target).addClass('jFuDateHover');
																											if (e.data.owner.data('jFu').selectWeek) {
																												$(e.target).parent().siblings().children().addClass('jFuDateHover')
																											}
																										}
																									)
																									.bind(	'mouseout',
																										{
																											owner:	e.data.owner
																										},
																										function(e) {
																											$(e.target).removeClass('jFuDateHover');
																											if (e.data.owner.data('jFu').selectWeek) {
																												$(e.target).parent().siblings().children().removeClass('jFuDateHover')
																											}
																										}
																									)
																						)
																			);
																			date.addDays(1);
																	}
																}
																return $(this);
															}
														)
														.trigger('update')
														.jFuDialog(	{	closeOnBlur:	function() {
																				arguments[0].data('jFu').owner.jFuDatepicker('close');
																			},
																	closeOnEscape:	function() {
																				arguments[0].data('jFu').owner.jFuDatepicker('close');
																			},
// Skift draggable i næste version!
																	draggable:	true,
																	left:		($(this).data('jFu').left == null ? $(this).offset()['left'] - $('html').css('margin-left').slice(0, -2) + 'px' : $(this).data('jFu').left + 'px'),
																	modal:		false,
																	title:		$(this).data('jFu').date.format(Date.Country.formats.yearMonth).substring(0, 1).toUpperCase() + $(this).data('jFu').date.format(Date.Country.formats.yearMonth).substring(1),
																	top:		($(this).data('jFu').top == null ? $(this).offset()['top'] + $(this).outerHeight() - $('html').css('margin-top').slice(0, -2) + 'px' : $(this).data('jFu').top + 'px'),
																	width:		'auto',
																	Buttons:	{
																				'_&lt;':	function() {
																							arguments[0]
																								.data(	'jFu',
																									$.extend(	arguments[0].data('jFu'),
																											{
																												date:	arguments[0].data('jFu').date.clone().addMonths(-1)
																											}
																									)
																								)
																								.trigger('update');
																						},
																				'_&gt;':	function() {
																							arguments[0]
																								.data(	'jFu',
																									$.extend(	arguments[0].data('jFu'),
																											{
																												date:	arguments[0].data('jFu').date.clone().addMonths(1)
																											}
																									)
																								)
																								.trigger('update');																				}
																			}
																}
														)
														.jFuDialog('open')
										}
								)
							);
					}
				break;


				case 'setDate':
					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										date:	(arguments[1] == null || arguments[1] == '' ? new Date() : arguments[1])
									}
							)
						)
						.val($(this).data('jFu').date.format($(this).data('jFu').format));

					if ($(this).data('jFu').Datepicker != null) {
						$(this).data('jFu').Datepicker
							.data(	'jFu',
								$.extend(	$(this).data('jFu').Datepicker.data('jFu'),
										{
											date:	$(this).data('jFu').date.clone()
										}
								)
							)
							.trigger('update');
					}

					$(this).trigger('change');
				break;


				case 'setFormat':
					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										format:	(arguments[1] == null || arguments[1] == '' ? Date.Country.formats.shortDate : arguments[1])
									}
							)
						)
						.jFuDatepicker('setDate', $(this).data('jFu').date.clone());
				break;


				case 'setMaxDate':
					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										maxDate:		(arguments[1] == null || arguments[1] == '' ? new Date(2037, 11, 31) : arguments[1])
									}
							)
						);
					if ($(this).data('jFu').Datepicker != null) {
						$(this).data('jFu').Datepicker
							.trigger('update');
					}
				break;


				case 'setMinDate':
					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										minDate:		(arguments[1] == null || arguments[1] == '' ? new Date(1970, 0, 1) : arguments[1])
									}
							)
						);
					if ($(this).data('jFu').Datepicker != null) {
						$(this).data('jFu').Datepicker
							.trigger('update');
					}
				break;
			}
		}
		return $(this);
	};


/*
 * jFuDialog (jFu 1.0.0)
 *	Displays a modal with the contents of the node it is invoked upon.
 */
	$.fn.jFuDialog = function(Argument) {
		if ((typeof Argument == 'object' || Argument == null) && !$(this).hasClass('jFuDialog')) {
			$(this)
				.data(	'jFu',
					$.extend(	{	closeOnBlur:	null,
								closeOnEscape:	null,
								draggable:	true,
								height:		'auto',
								left:		null,
								modal:		true,
								title:		null,
								top:		null,
								width:		'400px',
								Buttons:	{
											_X:	function() {
													arguments[0].jFuDialog('close');
												},
											Ok:	function() {
													arguments[0].jFuDialog('close');
												}
										}
							},
							$(this).data('jFu'),
							Argument
					)
				);
		}
		else {
			if (typeof $(this).data('jFu') == 'undefined') {
				$(this).jFuDialog();
			}

			switch (Argument) {

				case 'close':
					if ($('div.jFuModal:visible').length == 1 && $(this).hasClass('jFuModal')) {
						$('div.jFuOverlay')
							.removeClass('jFuOverlay')
							.animate(	{
										opacity:	0
									},
									200,
									function() {
										$(this).remove();
									}
							);
					}

					$(this)
						.removeClass('jFuModal')
						.removeClass('jFuDialogFocus')
						.unbind()
						.animate(	{
									opacity:	0
								},
								200,
								function() {
									if ($(this).data('jFu') != null && $(this).data('jFu').title != null) {
										$(this).children('div:first.jFuHeader').remove();
									};

									$(this)
										.removeClass('jFuDialog')
										.css('display', 'none')
										.children('div:last.jFuPanel')
											.remove()
										.end()
										.children('div:last')
											.remove();
								}
						);
				break;


				case "disable":
					if ($(this).hasClass('jFuDialog')) {
						$(this)
							.prepend(	$('<div></div>')
										.addClass('jFuOverlay')
										.css(	{
												height:		'100%',
												left:		'0px',
												opacity:	0.33,
												position:	'absolute',
												top:		'0px',
												width:		'100%'
											}
										)
							)
							.find('input,button,select,textarea')
							.attr('disabled', 'disabled');
					}
				break;


				case "enable":
					if ($(this).hasClass('jFuDialog')) {
						$(this)
							.children('div.jFuOverlay')
								.remove()
							.end()
							.find('input,button,select,textarea')
							.removeAttr('disabled');
					}
				break;


				case 'getButtons':
					return $(this).data('jFu').Buttons;
				break;


				case 'getDraggable':
					return $(this).data('jFu').draggable;
				break;


				case 'getHeight':
					return $(this).data('jFu').height;
				break;


				case 'getLeft':
					return $(this).data('jFu').left;
				break;


				case 'getTitle':
					return $(this).data('jFu').title;
				break;


				case 'getTop':
					return $(this).data('jFu').top;
				break;


				case 'getWidth':
					return $(this).data('jFu').width;
				break;


				case 'open':
					if (!$(this).hasClass('jFuDialog')) {
						if ($(this).data('jFu').modal == true) {
							$(this).addClass('jFuModal');
							if ($('div.jFuOverlay').length == 0) {
								$('div:first')
									.before(	$('<div>&nbsp;</div>')
												.addClass('jFuOverlay')
												.css(	{
														display:	'block',
														height:		'100%',
														left:		'0px',
														opacity:	0,
														position:	'fixed',
														top:		'0px',
														width:		'100%'
													}
												)
												.animate({opacity: 0.33}, 200)
									);
							}
						}

						$(this)
							.addClass('jFuDialog')
							.addClass('jFuContent')
							.css(	{
									display:	'block',
									height:		$(this).data('jFu').height,
									opacity: 	0,
									position:	'absolute',
									width:		$(this).data('jFu').width
								}
							)
							.css(	{
									left:		($(this).data('jFu').left == null ? ($(window).width() / 2 - $(this).width() / 2) + 'px' : $(this).data('jFu').left),
									top:		($(this).data('jFu').top == null ? ($(window).height() / 2 - $(this).height() / 2) + 'px' : $(this).data('jFu').top)
								}
							)
							.append(	$('<div></div>'))
							.append(	$('<div></div>')
										.addClass('jFuPanel')
										.css(	{	bottom:		$(this).css('padding-bottom'),
												position:	'absolute',
												textAlign:	'center',
												width:		$(this).data('jFu').width
											}
										)
							)
							.bind(	'mousedown',
								function(e) {
									$('div.jFuDialog')
										.removeClass('jFuDialogFocus');
									$(e.target).add($(e.target).parents('div.jFuDialog'))
										.filter('div.jFuDialog:first')
											.addClass('jFuDialogFocus');
								}
							)
							.jFuDialog('setTitle', $(this).data('jFu').title)
							.animate(	{opacity: 1},
									200,
									function() {
										$(this).css('filter', '');
									}
							);
					}
					$(this).trigger('mousedown');
				break;


				case 'setButtons':

					if ($(this).data('jFu').title != null) {
						$(this).children('div:first.jFuHeader')
							.children('input.jFuButton')
								.remove();
					}

					$(this).children('div:last.jFuPanel')
						.empty();

					if (typeof arguments[1] == 'object' && arguments[1] != {}) {
						for (var key in arguments[1]) {
							if (arguments[1][key] != null) {
								$(this).children(key.substring(0, 1) != '_' ? 'div:last.jFuPanel' : 'div:first.jFuHeader')
									.prepend(	$('<input type="button" value="' + key.substring(key.substring(0, 1) == '_' ? 1 : 0) + '" />')
												.addClass('jFuButton')
												.bind(	'click',
													{
														Action:	arguments[1][key],
														This:	$(this)
													},
													function(e) {
														e.stopImmediatePropagation();
														e.data.Action(e.data.This);
													}
												)
									);
							}
						}

						$(this)
							.children('div:last.jFuPanel')
							.prev()
							.css('height', $(this).children('div:last').outerHeight());
					}

					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										Buttons:	arguments[1]
									}
							)
						);
				break;

				case 'setDraggable':
					if ($(this).data('jFu').title != null) {
						if (arguments[1] == true) {
							$(this)
								.data(	'jFu',
									$.extend(	$(this).data('jFu'),
											{
												draggable:	true
											}
									)
								)
								.children('div:first.jFuHeader')
									.css('cursor', 'move')
									.bind(	'mousedown',
										function(e) {
											$(e.target)
												.bind(	'mouseup',
													function(e) {
														$(this)
															.unbind('mouseup')
															.unbind('mousemove');
													}
												)
												.bind(	'mousemove',
													{
														left:	e.pageX - $(e.target).parent().offset()['left'],
														top:	e.pageY - $(e.target).parent().offset()['top']
													},
													function(e) {
														$(this).parent()
															.data(	'jFu',
																$.extend(	$(this).parent().data('jFu'),
																		{
																			left:	e.pageX - e.data.left - $(document).scrollLeft(),
																			top:	e.pageY - e.data.top - $(document).scrollTop()
/*																			left:	e.pageX - e.data.left - $('html').css('margin-left').slice(0, -2) - $(document).scrollLeft(),
																			top:	e.pageY - e.data.top - $('html').css('margin-top').slice(0, -2) - $(document).scrollTop()
*/																		}
																)
															)
															.css(	{
																	left:	$(this).parent().data('jFu').left,
																	top:	$(this).parent().data('jFu').top
																}
															);
													}
												);
										}
									);
						}
						else {
							$(this)
								.data(	'jFu',
									$.extend(	$(this).data('jFu'),
											{
												draggable:	false
											}
									)
								)
								.children('div:first.jFuHeader')
									.css('cursor', 'default')
									.unbind('mousedown')
									.unbind('mouseup')
									.unbind('mousemove');
						}
					}
				break;


				case 'setHeight':
					$(this)
						.css('height', arguments[1])
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										height:	arguments[1]
									}
							)
						);
				break;


				case 'setLeft':
					$(this)
						.css('left', arguments[1])
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										left:	arguments[1]
									}
							)
						);
				break;


				case 'setTitle':
					if (arguments[1] == null) {
						$(this).children('div:first.jFuHeader')
							.remove();
					}
					else {
						if ($(this).children('div:first.jFuHeader').length == 0) {
							$('<div></div>')
								.addClass('jFuHeader')
								.prependTo($(this));
						}

						$(this).children('div:first.jFuHeader')
							.contents()
								.filter(	function() {
//											return this.nodeType == Node.TEXT_NODE;
											return this.nodeType == 3;
										}
								)
								.remove();

						$(this).children('div:first.jFuHeader')
								.append(arguments[1]);
					}

					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										title:	arguments[1]
									}
							)
						)
						.jFuDialog('setDraggable', $(this).data('jFu').draggable)
						.jFuDialog('setButtons', $(this).data('jFu').Buttons);
				break;


				case 'setTop':
					$(this)
						.css('top', arguments[1])
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										top:	arguments[1]
									}
							)
						);
				break;


				case 'setWidth':
					$(this)
						.css('width', arguments[1])
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										width:	arguments[1]
									}
							)
						);
				break;
			}
		}
		return $(this);
	};

/*
 * jFuTabs (jFu 1.0.0)
 *	
 */

/*
	jFuTabs(	{
				selected:	index,				
				Tabs:		{
							Label0:	function() { ... },
							Label1:	function() { ... },
							...

						}
			}
	)


	jFuTabs('disable')
	jFuTabs('enable')
	jFuTabs('getSelected')
	jFuTabs('getTabs')
	jFuTabs('setTabs', {Label0: function() { ... }, Label1: function() { ... }})
	jFuTabs('setSelected', index)

*/

	$.fn.jFuTabs = function(Argument) {
/*		if ((typeof Argument == 'object' || Argument == null) && !$(this).hasClass('jFuTabs')) {
			$(this)
				.data(	'jFu',
					$.extend(	{
								selected:	-1,
								Tabs:		{
										}
							},
							$(this).data('jFu'),
							Argument
					)
				)
				.addClass('jFuTabs');

			$('<div></div>')
				.addClass('jFuHeader')
				.append(	$('<div></div>')
							.jFuHorizontalSlider()
				)
				.prependTo($(this));

			$(this).jFuTabs('setTabs', $(this).data('jFu').Tabs);

			$(this)
				.prepend(	$('<input type="button" value="&lt;" style="float: left;" />')
							.bind(	'click',
								function(e) {
									$(this).next().jFuHorizontalSlider('position', -$(this).next().width());
								}
							)
							.jFuButton()
				)
				.prepend(	$('<input type="button" value="&gt;" style="float: right;" />')
							.bind(	'click',
								function(e) {
									$(this).next().next().jFuHorizontalSlider('position', $(this).next().next().width());
								}
							)
							.jFuButton()
				)
				.jFuTabs('setSelected', $(this).data('jFu').selected);
		}
		else {
			if (typeof $(this).data('jFu') == 'undefined') {
				$(this).jFuTabs();
			}

			switch (Argument) {

				case 'disable':
				break;


				case 'enable':
				break;


				case 'getSelected':
				break;


				case 'getTabs':
				break;


				case 'setTabs':
					$(this)
						.data(	'jFu',
							$.extend(	$(this).data('jFu'),
									{
										Tabs:	arguments[1]
									}
							)
						);

					$(this).children('div.jFuHorizontalSlider > input.jFuTab')
						.remove();

					for (var key in arguments[1]) {
						$(this).children('div.jFuHorizontalSlider > input.jFuTab')
							.after(	$('<input type="text" value="' + key + '" />')
									.addClass('jFuTab')
									.bind(	'click',
										{
											Action: arguments[1][key]
										},
										function(e) {
											$(this)
												.addClass('jFuTabsSelected')
												.siblings()
													.removeClass('jFuTabsSelected');
											if (!$(this).hasClass('jFuTabDisabled')) {
												e.data.Action($(this).parents('div.jFuTabs:first'));
											}
										}
									)
							);
					}
				break;


				case 'setSelected':
				break;
			}
		}
*/
		return $(this);
	};




/*
 *	jFu Date Extensions
 *	Exstensions to the Date-class.	
 */
	Date.prototype.clone = function() {
		return new Date(this.getTime());
	};

	Date.prototype.addMinutes = function(days) {
		this.setMinutes(this.getMinutes() + (days == null ? 0 : days));
		return this;
	};

	Date.prototype.addHours = function(hours) {
		this.setHours(this.getHours() + (hours == null ? 0 : hours));
		return this;
	};

	Date.prototype.addDays = function(days) {
		this.setDate(this.getDate() + (days == null ? 0 : days));
		return this;
	};

	Date.prototype.addMonths = function(months) {
		this.setMonth(this.getMonth() + (months == null ? 0 : months));
		return this;
	};

	Date.prototype.addYears = function(years) {
		this.setFullYear(this.getFullYear() + (years == null ? 0 : years));
		return this;
	};

	Date.prototype.clearTime = function() {
		this.setHours(0, 0, 0, 0);
		return this;
	};

	Date.prototype.setDay = function(day) {
		this.addDays(day - (this.getDay() < Date.Country.firstDayOfWeek ? 7 : this.getDay()));
		return this;
	};

	Date.prototype.d = function () {
		return ('0' + this.j()).slice(-2);
	};

	Date.prototype.D = function () {
		return Date.Country.abbreviatedDayNames[this.w()];
	};

	Date.prototype.j = function () {
		return this.getDate();
	};

	Date.prototype.l = function () {
		return Date.Country.dayNames[this.w()];
	};

	Date.prototype.N = function () {
		return this.w() ? this.w() : 7;
	};

	Date.prototype.S = function () {
		return ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'][f.j().slice(-1)];
	};

	Date.prototype.w = function () {
		return this.getDay();
	};

	Date.prototype.z = function () {
		return Math.floor((this - new Date(this.getFullYear() + '/1/1')) / 86400000);
	};

	Date.prototype.W = function() {
		return Math.floor(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / 604800000) - Math.floor(Date.UTC((new Date(Math.floor(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / 604800000) * 604800000)	).getUTCFullYear(), 0, 7) / (604800000)) + 1;
	};

	Date.prototype.F = function () {
		return Date.Country.monthNames[this.n() - 1];
	};

	Date.prototype.m = function () {
		return ('0' + this.n()).slice(-2);
	};

	Date.prototype.M = function () {
		return Date.Country.abbreviatedMonthNames[this.n() - 1];
	};

	Date.prototype.n = function () {
		return this.getMonth() + 1;
	};

	Date.prototype.t = function () {
		return [31, (this.L() == 1 ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()];
	};

	Date.prototype.L = function () {
		return ((this.getFullYear() % 4 == 0 && this.getFullYear() % 100 != 0) || this.getFullYear() % 400 == 0 ? 1 : 0);
	};

	Date.prototype.o = function () {
		return this.getFullYear() + (this.n() === 12 && this.W() === 1 ? 1 : 0) + (this.n() === 1 && this.W() >= 52 ? 1 : 0);
	};

	Date.prototype.Y = function () {
		return this.getFullYear();
	};

	Date.prototype.y = function () {
		return (String)(this.getFullYear()).slice(-2);
	};

	Date.prototype.a = function () {
		return this.A().toLowerCase();
	};

	Date.prototype.A = function () {
		return this.getHours() > 11 ? Date.Country.PM : Date.Country.AM;
	};

	Date.prototype.B = function () {
		return ('00' + ((Math.floor(((this.getHours() * 3600) + (this.getMinutes() * 60) + this.getSeconds() + (this.getTimezoneOffset() * 60) + 3600) / 86.4) + 1000) % 1000)).slice(-3);
	};

	Date.prototype.g = function () {
		return this.getHours() % 12 || 12;
	};

	Date.prototype.G = function () {
		return this.getHours();
	};

	Date.prototype.h = function () {
		return ('0' + this.g()).slice(-2);
	};

	Date.prototype.H = function () {
		return ('0' + this.getHours()).slice(-2);
	};

	Date.prototype.i = function () {
		return ('0' + this.getMinutes()).slice(-2);
	};

	Date.prototype.s = function () {
		return ('0' + this.getSeconds()).slice(-2);
	};

	Date.prototype.u = function () {
		return ('00000' + this.getMilliseconds() * 1000).slice(-6);
	};

	Date.prototype.e = function () {
// STUB
		return 'UTC';
	};

	Date.prototype.I = function () {
// STUB
		return false;
	};

	Date.prototype.O = function () {
		return (this.getTimezoneOffset() > 0) ? '-' + ('000' + Math.abs(this.getTimezoneOffset()/60*100)).slice(-4) : '+' + ('000' + Math.abs(this.getTimezoneOffset()/60*100)).slice(-4);
	};

	Date.prototype.P = function () {
		return this.O().substr(0, 3) + ':' + this.O().substr(3, 2);
	};

	Date.prototype.T = function () {
// STUB
		return 'UTC';
	};

	Date.prototype.Z = function () {
		return -this.getTimezoneOffset() * 60;
	};

	Date.prototype.c = function () {
		return this.Y() + '-' + this.m() + '-' + this.d() + 'T' + this.h() + ':' + this.i() + ':' + this.s() + this.P();
	};

	Date.prototype.r = function () {
		return this.D() + ', ' + this.d() + ' ' + this.M() + ' ' + this.Y() + ' ' + this.H() + ':' + this.i() + ':' + this.s() + ' ' + this.O();
	};

	Date.prototype.U = function () {
		return Math.round(this.getTime() / 1000);
	};

/*
 *	jFu Date format
 *	Formats a date like the PHP-function date() (www.php.net/date)
 */
	Date.prototype.format = function(format) {
		if (format == null) {
			return this.format(Date.Country.formats.shortDate);
		}
		else {
			var date = this;
			return format.replace(	/[\\]?([a-zA-Z])/g,
						function (t, s) {
							return (t != s ? s : (date[s] ? date[s]() : s));
						}			
			);
		}
	};

/*
 *	Country Specific Settings
 */
	Countries =	{
				dk:	{
						dayNames:		["søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"],
						abbreviatedDayNames:	["søn", "man", "tir", "ons", "tor", "fre", "lør"],
						shortestDayNames:	["sø", "ma", "ti", "on", "to", "fr", "lø"],
						firstLetterDayNames:	["s", "m", "t", "o", "t", "f", "l"],

						monthNames:		["januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"],
						abbreviatedMonthNames:	["jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"],

						firstDayOfWeek:		1,
						AM:			"",
    						PM:			"",
						formats:		{
										shortDate:			'd-m-Y',
										longDate:			"j. F Y",
										shortTime:			"H:i",
										longTime:			"H:i:s",
										fullDateTime:			"j. F Y H:i:s",
										monthDay:			"j. F",
										yearMonth:			"F Y"

									}
					},
				us:	{
						dayNames:		["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
						abbreviatedDayNames:	["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
						shortestDayNames:	["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
						firstLetterDayNames:	["S", "M", "T", "W", "T", "F", "S"],

						monthNames:		["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
						abbreviatedMonthNames:	["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],

						firstDayOfWeek: 	0,
						AM:			"AM",
    						PM:			"PM",
						formats:		{
										shortDate:	'n/j/Y',
										longDate:	'l, F d, Y',
										shortTime: 	'g:i A',
										longTime:	'g:i:s A',
										monthDay:	'F d',
										yearMonth:	'F, Y'
									}
					}
			};


	$.fn.jFuText = function(Argument) {
		$(this).addClass('jFuText');
		return $(this);
	};

	$.fn.jFuPassword = function(Argument) {
		$(this).addClass('jFuPassword');
		return $(this);
	};

	$.fn.jFuButton = function(Argument) {
		$(this).addClass('jFuButton');
		return $(this);
	};

	$.fn.jFuSubmit = function(Argument) {
		$(this).addClass('jFuSubmit');
		return $(this);
	};

	$.fn.jFuCheckbox = function(Argument) {
		$(this).addClass('jFuCheckbox');
		return $(this);
	};

	$.fn.jFuRadio = function(Argument) {
		$(this).addClass('jFuRadio');
		return $(this);
	};

	$.fn.jFuSelect = function(Argument) {
		$(this).addClass('jFuSelect');
		return $(this);
	};

	$.fn.jFuTextarea = function(Argument) {
		$(this).addClass('jFuTextarea');
		return $(this);
	};

	$.fn.jFuTimepicker = function(Argument) {
		$(this).addClass('jFuTimepicker');
		return $(this);
	};
