// TODO: 
// Firefox: Speichern von Logindaten möglich, diese werden aber nicht wider ausgegeben, da die Felder bereits einen Wert (das Label) haben
// Safari: speichern von Logindaten nicht möglich
// IE Test

jQuery.fn.label_inside = function(options) {
	var elems = this;

	var settings = jQuery.extend({
			// k: v
		}, options);

	return elems.each(function(index) {
		var el = jQuery(this)
		
		if (!el.hasClass("userdefined")) {
			if (el.attr('type') != 'password') {
			
				var label = el.val();

				el.focus(function() {
					if (el.val() == label) {
						el.val('');
						el.addClass("userdefined")
					}
				})

				el.blur(function() {
					if (el.val() == '') {
						el.val(label);
						el.removeClass("userdefined")
					}
				})
			
			} else {
				// var a = el.clone();
				
				// händischer klon wg ie (der keine ändeurng des typs erlaubt)
				var a = jQuery('<input type="text" />').insertAfter(el)
						.val(el.val())
						.attr('size', el.attr('size'))
//						.attr('style', el.attr('style')) kommt show/hide in die Quere
						.attr('class', el.attr('class'))
						.attr('name', el.attr('name') + '_input_label')
						.attr('id', el.attr('id') + '_input_label')
				
				el.val('');
				el.hide();
				
				el.parents('form').submit(function() {
					el.show()
					a.remove();
				})

				a.focus(function() {
					a.hide();
					el.show().focus();
				})

				el.blur(function() {
					if (el.val() == '') {
						el.hide();
						a.show();
					}
				})

			}
			
		}
	});
}
