jQuery( function()
{
 /*
  * Input and textarea default values.
  */
 
 $("input[alt],textarea[alt]").bind( 'focus', function()
 {
  if( $(this).data( "isEmpty" ) )
  {
   $(this).data( "isEmpty", false );
   $(this).removeClass( "defaultValue" );
   $(this).val( "" );
  }
 } );
 
 $("input[alt],textarea[alt]").bind( 'blur', function()
 {
  if( $(this).val() == "" )
  {
   $(this).data( "isEmpty", true );
   $(this).val( $(this).attr( "alt" ) );
   $(this).addClass( "defaultValue" );
  }
  else
   $(this).data( "isEmpty", false );
 } );
 
 $("input[alt],textarea[alt]").each( function()
 {
  /*
  //NEW.. Not finished
  
  var defaultValue = $("<div/>").addClass( "default-value" ).html( $(this).attr( "alt" ) ).insertBefore( $(this) );
  defaultValue.data( "defaultValue.field", $(this) );
  $(this).data( "defaultValue.handle", defaultValue );
  
  defaultValue.css(
  {
   "position": "absolute",
   "width": $(this).width(),
   "height": $(this).height(),
   "paddingLeft": parseInt( $(this).css( "paddingLeft" ), 10 ),
   "paddingTop": parseInt( $(this).css( "paddingTop" ), 10 ),
   "paddingRight": parseInt( $(this).css( "paddingRight" ), 10 ),
   "paddingBottom": parseInt( $(this).css( "paddingBottom" ), 10 ),
   "marginLeft": parseInt( $(this).css( "marginLeft" ), 10 ) + parseInt( $(this).css( "borderLeftWidth" ), 10 ),
   "marginTop": parseInt( $(this).css( "marginTop" ), 10 ) + parseInt( $(this).css( "borderTopWidth" ), 10 ),
   "marginRight": parseInt( $(this).css( "marginRight" ), 10 ) + parseInt( $(this).css( "borderRightWidth" ), 10 ),
   "marginBottom": parseInt( $(this).css( "marginBottom" ), 10 ) + parseInt( $(this).css( "borderBottomWidth" ), 10 ),
   "backgroundColor": $(this).css( "backgroundColor" ),
   "cursor": "text"
  } );
  
  defaultValue.click( function()
  {
   $(this).css( "display", "none" );
   $(this).data( "defaultValue.field" ).focus();
  } );
  
  $(this).blur( function()
  {
   if( $(this).val().length == 0 )
   {
    $(this).data( "defaultValue.handle" ).css( "display", "block" );
   }
  } );
  
  $(this).focus( function()
  {
    $(this).data( "defaultValue.handle" ).css( "display", "none" );
  } );*/
  
  if( $(this).val() == "" || $(this).val() == $(this).attr( "alt" ) )
  {
   $(this).data( "isEmpty", true );
   $(this).val( $(this).attr( "alt" ) );
   $(this).addClass( "defaultValue" );
  }
  else
   $(this).data( "isEmpty", false );
 } );
} );

function clearDefaultValues( form, data )
{
 for( var i = 0 ; i < data.length ; i++ )
 {
  if( form.find( "[name='" + data[ i ].name + "']" ).data( "isEmpty" ) )
   data[ i ].value = "";
 }
}

function resetFormWithDefaultValues( form, force )
{
 if( typeof force == "undefined" ) force = false;
 
 form.reset();
 
 if( force );
 {
  form.find( "input[type='text'],textarea" ).attr( "value", "" );
  form.find( "select option" ).removeAttr( "selected" );
 }
 
 form.find( "input[alt],textarea[alt]" ).trigger( "blur" );
}