/* 
 * Function to check wether there is support for a specific attribute
 * in the browser. This function is used to check wether fallback code
 * is required
 */

function elementSupportsAttribute(element,attribute) {
	var test	=	document.createElement(element);
	if (attribute in test) {
		return true;
	} else {
		return false;
	}
}

if (!elementSupportsAttribute('input','placeholder')){
$(function() {
		$('input[placeholder], textarea[placeholder]').each(function() {
			var text = this.getAttribute('placeholder');
			var fld = $(this);

			function setPlaceholder() {
				if (fld.val() == text || fld.val() == '') {
					fld.addClass('placeholder');
					fld.val(text);
				}
			}

			function removePlaceholder() {
				if (fld.val() == text || fld.val() == '') {
					fld.val('');
					fld.removeClass('placeholder');
				}
			}
			setPlaceholder();

			$(this).focus(removePlaceholder);
			$(this).blur(setPlaceholder);
			$(this).parents("form").submit(removePlaceholder);
		});
	});
}


