/**
 * HTML 5 support and fixes for IE6
 *
 * @author Terry Duivesteijn <terry@contactivity.com>
 * @copyright Copyright (c) 2011, Contactivity bv, Leiden
 * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
 * @version $Id: contactivity.html5.ie6.js,v 0.1 29-3-2011 13:18:15
 */
$(document).ready(function() {

	/**
	 * deal with placeholders
	 */
	$("input").bind('focus blur',placeholder);
	$("input").each(function() {
		if(
			$(this).attr('type') == 'search' ||
			$(this).attr('type') == 'email' ||
			$(this).attr('type') == 'text'
		) {
			if($(this).attr("value") == '' && $(this).attr("placeholder") && $(this).attr("placeholder").length && $(this).attr("placeholder").length > 0) {
				$(this).addClass('placeholder').attr("value",$(this).attr("placeholder"));
			}
		}
	});


	/*
	if (!Modernizr.inputtypes.search) {
		$("input[type=search]").each(function() {
			$(this).attr("type",'text');
		});
	}
	*/
});

/**
 * Delete default value when focussed on input. Restore value on blur.
 * @html5 Fallback for HTML5-placeholder
 * @author Terry Duivesteijn <terry@contactivity.com>
 * @category functionality
 * @return void
 **/
function placeholder(event){
	if($(this).attr('placeholder')) {
		if(event.type == 'focus') {
			if($(this).attr('value') == $(this).attr('placeholder')) {
				$(this).attr('value','').removeClass('placeholder');
			}
		} else if(event.type == 'blur') {
			if($(this).attr('value') == '') {
				$(this).attr('value',$(this).attr('placeholder')).addClass('placeholder');
			}
		}
	}
}

