function initUI() {

	$('img.ui-thumbnail').each(
			function(i, v) {

				var sourceImage = $(this);

				var img = $("<img />", {
					border : 0,
					width : sourceImage.width(),
					height : sourceImage.height(),
					src : sourceImage.attr("src"),
					title : sourceImage.attr("title"),
					style : sourceImage.attr("style")
				});

				var newThumb = $("<a />", {

					class : "ui-thumbnail ui-lightBox",
					href : (sourceImage.attr("preview") != null) ? sourceImage
							.attr("preview") : sourceImage.attr("src"),
					title : img.attr("title")

				});

				newThumb.append(img);

				if (!sourceImage.hasClass("ui-thumbnail-noStyle"))
					newThumb.addClass("ui-thumbnail-style");
				
				if (sourceImage.hasClass("ui-thumbnail-title"))
					newThumb.append($("<div />", {
						class : "ui-thumbnail-label",
						html : img.attr("title")
					}));

				sourceImage.after(newThumb);
				sourceImage.remove();

			});

	/*
	 * // Ist erforderlich, da der Internet Explorer kein Load-event ausführt
	 * bei // Bildern im Cache. if ($.browser.msie == true || $.browser.opera ==
	 * true) $('img.ui-thumbnail').each(function(i, v) { $(v).attr('src',
	 * $(v).attr('src') + '?' + new Date().getTime()); });
	 * 
	 * $('img.ui-thumbnail') .load( function() {
	 * 
	 * var sourceImage = $(this); var withShadow = sourceImage
	 * .hasClass('ui-thumbnail-shadow');
	 * 
	 * var image = $('<img />', { border : 0, width : sourceImage.width(),
	 * height : sourceImage.height(), src : sourceImage.attr('src'), title :
	 * sourceImage.attr('title') });
	 * 
	 * var thumb = $( '<div />', { class : 'ui-thumbnail', style : 'width: ' +
	 * (parseInt(image.width()) + ((withShadow) ? 28 : 18)) + 'px;' }); var
	 * background = $( '<div />', { class : 'ui-thumbnail-background
	 * ui-thumbnail-load', style : 'width: ' + (parseInt(image.width()) + 18) +
	 * 'px;height: ' + (parseInt(image.height()) + ((withShadow) ? 18 : 18)) +
	 * 'px;'
	 * 
	 * }); var img = $('<div />', { class : 'ui-thumbnail-image', style :
	 * 'width: ' + (parseInt(image.width())) + 'px;height: ' +
	 * (parseInt(image.height())) + 'px;' });
	 * 
	 * background.append(img); // background.append($('<div />', {class : //
	 * 'floatClear'}));
	 * 
	 * thumb.append(background);
	 * 
	 * if (withShadow) {
	 * 
	 * thumb .append($( '<div />', { style : 'float: left;', html : '<div
	 * class=\"ui-thumbnail-shadowRightTop\"></div>' + '<div style="height: ' +
	 * (parseInt(image .height()) + 12) + 'px;"
	 * class="ui-thumbnail-shadowRight"></div>' })); thumb.append($('<div />', {
	 * class : 'floatClear' })); thumb.append($('<div />', { class :
	 * 'ui-thumbnail-shadowLeftBottom' }));
	 * 
	 * thumb.append($('<div />', { style : 'width: ' + (parseInt(image.width()) +
	 * 12) + 'px;', class : 'ui-thumbnail-shadowBottom' })); thumb.append($('<div
	 * />', { class : 'ui-thumbnail-shadowRightBottom' })); }
	 * 
	 * thumb.append($('<div />', { class : 'floatClear' })); /* thumb_ += '<div
	 * style=\"float: left;\">' + '<div class=\"ui-thumbnail-shadowRightTop\"></div>' + '<div
	 * style="height: 141px;" class="ui-thumbnail-shadowRight"></div>' + '</div>' + '<div
	 * class="floatClear"></div>' + '<div
	 * class="ui-thumbnail-shadowLeftBottom"></div>' + '<div style="width: ' +
	 * (parseInt(image.width()) + 12) + 'px;" class="ui-thumbnail-shadowBottom"></div>' + '<div
	 * class="ui-thumbnail-shadowRightBottom"></div>';
	 * 
	 * thumb_ += '<div class="floatClear"></div>' + '<div
	 * class="ui-thumbnail-title">Lammpee</div>' + '</div>';
	 * 
	 * if (image.attr('title') != null ||
	 * image.hasClass('ui-thumbnail-noTitle')) thumb.append($('<div>', { class :
	 * 'ui-thumbnail-title', text : image.attr('title') }));
	 * 
	 * if (true || sourceImage.attr('href') != null) {
	 * 
	 * var thumb = $('<a />', { href : sourceImage.attr('src'), class :
	 * 'ui-lightBox' }).lightBox().append(thumb); }
	 * 
	 * image.load(function() { thumb.find('.ui-thumbnail-image').append(image);
	 * 
	 * thumb.find('.ui-thumbnail-image').fadeIn( 'slow', function() {
	 * 
	 * thumb.find('.ui-thumbnail-background') .removeClass(
	 * 'ui-thumbnail-load');
	 * 
	 * }); /*
	 * 
	 * image .fadeIn( 'slow', function() {
	 * 
	 * thumb .find( '.ui-thumbnail-image') .removeClass( 'ui-thumbnail-load');
	 * 
	 * });
	 * 
	 * 
	 * 
	 * thumb.fadeIn('slow', function() { }); });
	 * 
	 * sourceImage.after(thumb); sourceImage.remove();
	 * 
	 * });
	 */
	var controls = $('.ui-collapseField');
	controls.each(function(i, v) {

		if ($(v).hasClass('collapsible') == false)
			if ($(v).hasClass('ui-collapseField-collapsed')) {
				$(v).collapse({
					closed : true
				});
				$(v).removeClass('ui-collapseField-collapsed');
			} else
				$(v).collapse();
	});

	$('[datePicker]').datepicker({

		dateFormat : 'dd.mm.yy',
		defaultDate : +7
	});

	$('[datePicker]').mask('99.99.9999', {
		placeholder : '-'
	});

	var controls = $('.ui-colorpicker');
	controls.each(function(i, v) {

		$(v).ColorPicker({
			color : '#000000',
			onShow : function(colpkr) {
				$(colpkr).fadeIn(500);
				return false;
			},
			onHide : function(colpkr) {
				$(colpkr).fadeOut(500);
				return false;
			},
			onChange : function(hsb, hex, rgb) {
				$(v).val('#' + hex);
			}
		});
		$(this).ColorPickerSetColor(this.value);
	});

	$('.ui-colorpicker').mask('#******', {
		placeholder : '0'
	});

	/*
	 * 
	 * $('iframe').iframeAutoHeight({ heightOffset : 10 });
	 */

	function sizeIFrame(obj) {
		try {
			var helpFrame = $(obj);
			var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame
					.get(0).contentDocument
					: helpFrame.get(0).contentWindow.document;
			helpFrame.height(innerDoc.body.scrollHeight + 35);
		} catch (e) {
			console.log('Can\'t change iframe size');
		}
	}

	$("iframe").each(function(i, v) {

		sizeIFrame(v);
		$(v).load(function() {
			sizeIFrame(v);
		});
	});

	$('.ui-lightBox').lightBox();

	$('table.ui-table-sort').tablesorter();

	$('.ui-frame-content')
			.each(
					function(i, v) {

						if (($(v).html() == "<p></p>" && $(v).text() == "" || $(
								v).html() == "")
								&& $(v).parent('.ui-frame').find(
										'.ui-frame-actions').length < 1)

							$(v).parent('.ui-frame').remove();

					});

	$('.ui-scrollWith').each(
			function(i, v) {

				var control = $(v);

				if ((control.height() + control.offset().top) < $(window)
						.height()
						&& !control.parent().hasClass('.ui-scrollWith')) {

					var wrapper = $('<div />', {
						class : control.attr('class'),
						style : 'height: 50px;'
					});

					control.after(wrapper);
					control.css({
						position : 'fixed'
					});

					wrapper.append(control);
				}

			});
	/*
	 * $(window).resize(function(){
	 * 
	 * if ($('.test2000').length < 1){
	 * 
	 * $('body').append($('<div />', {class : 'test2000'})); }
	 * 
	 * $('.test2000').text($(window).height());
	 * 
	 * });
	 * 
	 */
}

