(function($){
	var initLayout = function() {
		//alert('Hej');
	


		$('#foreground_color').ColorPicker({
			onShow: function (colpkr) {
				$(colpkr).show();
				return false;
			},
			onHide: function (colpkr) {
				$(colpkr).hide();
				return false;
			},
			onChange: function (hsb, hex, rgb) {
				$('#foreground_color div').css('backgroundColor', '#' + hex);
				$('#foreground_color input').val(hex);
				
				$('.fgc').css('backgroundColor', '#' + hex);
			}
		});

		$('#background_color').ColorPicker({
			onShow: function (colpkr) {
				$(colpkr).show();
				return false;
			},
			onHide: function (colpkr) {
				$(colpkr).hide();
				return false;
			},
			onChange: function (hsb, hex, rgb) {
				$('#background_color div').css('backgroundColor', '#' + hex);
				$('#background_color input').val(hex);
				$('.bgc').css('backgroundColor', '#' + hex);
			}
		});
		

		// Hent farve fra eksisterende form!
		ids = ['#foreground_color', '#background_color'];
		preview_classes = ['.fgc', '.bgc'];
		for (var i in ids)
		{
			if ($(ids[i]).length > 0)
			{
				hex = $(ids[i] + ' input').val();
				if (hex != '')
				{		
					$(ids[i]).ColorPickerSetColor(hex);
					$(ids[i] + ' div').css('backgroundColor', '#' + hex);
					$(preview_classes[i]).css('backgroundColor', '#' + hex);
				}
			}
		}
		
		
		$("#top .button a").click(function(){		// kører ikke til toppen af siden
		
		   if ($("#top").hasClass("full")) {
		   	$("#top").removeClass("full");
		   } else {
		   	$("#top").addClass("full");
		   }
		   return false;
		});
		
		$(".demolink").click(function(){		// kører til toppen af siden
		
		   if ($("#top").hasClass("full")) {
		   	$("#top").removeClass("full");
		   } else {
		   	$("#top").addClass("full");
		   }
		});
		
		
	};
	
	EYE.register(initLayout, 'init');
})(jQuery)
