document.createElement("article");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("nav");


function valEmpty(value) {
    return ($.trim(value)==='') ? true : false;
}

function checkPlaceholderFunc(form) {
    var events = $(form).data("events");
    if(events && events.submit) {
        for(var i=0; i < events.submit.length; i++) {
            if((events.submit[0].handler + '').indexOf("func_placeholder"))
                return true;
        }

    }
}

// Adds support for placeholder in older browsers
$(document).ready(function($) {
    var inputs = $(":input[placeholder]");
    $.each(inputs, function(index, input) {
        // Check if the browser natively supports the placeholder tag
        if(("placeholder" in document.createElement(this.tagName.toLowerCase()))) return true;

        var $this = $(input);
        var ph = this.getAttribute('placeholder');

        $this.addClass('placeholder');        

        // On focus
        $this.focusin(function() {
            if($this.hasClass('placeholder')) {
                $this.removeClass('placeholder');
                $this.val('');
            }
        });

        // When we lose focus
        var phset = function() {
            if(valEmpty($this.val())) {
                $this.addClass('placeholder');
                $this.val(ph);
            }
        };




        var form = $this.closest("form");

        // Ensure we haven't already attached the event when attaching to another input[placeholder]
        if(!checkPlaceholderFunc(form))
            $(form).submit(function() {
                //func_placeholder - important, used in form submit check
                var elements = $(form).find(":input[placeholder]");

                $.each(elements, function(index, control) {
                    var phText = control.getAttribute("placeholder");
                    control.value = (phText == control.value) ? "" : control.value;
                });
            });

        $this.focusout(phset)
        phset();
    });
});

