﻿$(document).ready(function() {
 if (!elementsupportsAttribute('input','placeholder')) {fallbackPlaceholders();}
});

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

function fallbackPlaceholders() {
 $('input[placeholder]').each(function() {
  $(this).focusin(function() {
   if ($(this).val() == $(this).attr('placeholder'))
    {$(this).attr('value', '').removeClass('placeheld');}
  }).focusout(function() {
   if ($(this).val() == '')
    {$(this).attr('value', $(this).attr('placeholder')).addClass('placeheld');}
  }).focusin().focusout();
 });
  $('textarea[placeholder]').each(function() {
  $(this).focusin(function() {
   if ($(this).val() == $(this).attr('placeholder'))
    {$(this).attr('value', '').removeClass('placeheld');}
  }).focusout(function() {
   if ($(this).val() == '')
    {$(this).attr('value', $(this).attr('placeholder')).addClass('placeheld');}
  }).focusin().focusout();
 });
 $('input[type=submit]').click(function(e) {
  $('input.placeheld').attr('value', '');
 });
}
