$(document).ready(function() {
    $.fn.setCursorPosition = function(pos) {
        if ($(this).get(0).setSelectionRange) {
            $(this).get(0).setSelectionRange(pos, pos);
        } else if ($(this).get(0).createTextRange) {
        var range = $(this).get(0).createTextRange();
        range.collapse(true);
        range.moveEnd('character', pos);
        range.moveStart('character', pos);
        range.select();
        }
    }
   $(".gform_wrapper label").each(function () {
	id = '#'+$(this).attr('for');
		$(id).val($(this).text() + '...');
		$(id).data({val:$(this).text()});
//        $(this).next("input").val($(this).text()+"...");
        $(this).hide();
    });
    $(".gform_wrapper input").focus(function() {
        if($(this).data('val')+'...' == $(this).val()){
			$(this).val('');
            $(this).addClass("focus").setCursorPosition(0);
        }
    });
    $(".gform_wrapper input").keypress(function() {
        if($(this).data('val')+'...' == this.value){
            $(this).val();
            $(this).removeClass("focus").addClass("typing");
        }
    });
    $(".gform_wrapper input").blur(function() {
        $(this).removeClass("focus").removeClass("typing");
        if($(this).val() == ""){
        $(this).val($(this).data('val')+'...') = $(this).data('val')+'...';
        }
    });
});
