/*
Script Placeholder 1.0.2
2011 djm Web sprl

Need jQuery
*/
(function ($) {
    $.fn.placeholderInit = function () {
        this.each(function () {
            var color = $(this).css('color');

            var placeholder = function (f, t) {
                switch (f) {
                    case 0:
                        if (t.val() == t.attr('placeholder')) {
                            t.val('');
                            t.css('color', '#000');
                            if (t.hasClass('placeholder_pwd') || t.hasClass('placeholder_wrong')) {
                                placeholder_pwd(0, t);
                            }
                        }
                        break;
                    case 1:
                        if (t.val() == '') {
                            t.val(t.attr('placeholder'));
                            t.css('color', color);
                            if (t.hasClass('placeholder_pwd')) {
                                placeholder_pwd(1, t);
                            }
                        }
                        else if (t.val() != '' && t.val() != t.attr('placeholder') && !t.hasClass('placeholder_pwd')) {
                            t.css('color', '#000');
                        }
                        break;
                }
            };

            var placeholder_pwd = function (f, t) {
                switch (f) {
                    case 0:
                        t.parent().children('.placeholder_pwd').css('display', 'block').val('').css('color', '#000').focus();
                        t.parent().children('.placeholder_wrong').remove();
                        break;
                    case 1:
                        t.css('display', 'none');
                        t.parent().append('<input type="text" class="placeholder placeholder_wrong" value="' + t.attr('placeholder') + '" placeholder="' + t.attr('placeholder') + '">');
                        placeholder_action(t.parent().children('.placeholder_wrong'));
                        break;
                }
            };

            placeholder_action = function (t) {
                t.focus(function (e) {
                    placeholder(0, $(this));
                }).blur(function (e) {
                    placeholder(1, $(this));
                });
            };

            var $this = $(this);

            placeholder(1, $this);
            $this.focus(function (e) {
                placeholder(0, $this);
            }).blur(function (e) {
                placeholder(1, $this);
            });

            $this.parents('form').submit(function () {
                if ($this.val() == $this.attr('placeholder')) {
                    $this.val('');
                }
            });
        });
    };

    $(function () {
        $('.placeholder').placeholderInit();
		$('#Form_ContactPageForm_Email').placeholderInit();
    });
})(jQuery);
