﻿$(document).ready(function () {
    $("input[placeholder]").each(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("placeholder"));
        }
    })
    $("input[placeholder]").focusin(function () {
        if ($(this).val() == $(this).attr("placeholder")) {
            $(this).val("");
        }
    });
    $("input[placeholder]").focusout(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("placeholder"));
        }
    });

    $("textarea[placeholder]").each(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("placeholder"));
        }
    })
    $("textarea[placeholder]").focusin(function () {
        if ($(this).val() == $(this).attr("placeholder")) {
            $(this).val("");
        }
    });
    $("textarea[placeholder]").focusout(function () {
        if ($(this).val() == "") {
            $(this).val($(this).attr("placeholder"));
        }
    });

    var pwBoxes = $("input[type=password]");
    for (var i = 0; i < pwBoxes.length; i++) {
        var actualID = $(pwBoxes[i]).attr('id');
        $("<input type='text' value='Password' id='" + actualID + "2' title='" + actualID + "' rel='pwReplace' />").insertAfter(pwBoxes);
        $(pwBoxes[i]).blur(function () {
            if ($(this).val() == '') {
                $(this).hide();
                $("#" + $(this).attr('id') + '2').show();
            }
        });
        if ($(pwBoxes[i]).val() == '')
            $(pwBoxes[i]).hide();
        else
            $("#" + $(pwBoxes[i]).attr('id') + '2').hide();

    }
    var rpBoxes = $("input[rel=pwReplace]");
    for (var i = 0; i < rpBoxes.length; i++) {
        $(rpBoxes[i]).focus(function () {
            $("#" + $(this).attr('title')).show();
            $("#" + $(this).attr('title')).focus();
            $(this).hide();
        });
    }
});
        
