﻿function formInit() {
    $(".lightmedia_form input[type=checkbox]").css("border", "none");

    $(".lightmedia_form span").each(function() {
        var $this = $(this);

        if ($this.next().length > 0) {
            if ($this.next().attr("type") == "checkbox") {
                $this.add($this.next()).add($this.next().next()).wrapAll("<div class=\'form_group\' />");
                $this.next().next().css("font-weight", "bold");
            } else {
            if (($this.next().get(0).tagName == "INPUT") || ($this.next().get(0).tagName == "SELECT")) {
                    $this.add($this.next()).wrapAll("<div class=\'form_group\' />");
                }
            }
        }
    });

    $(".lightmedia_form input[type=submit]").addClass("form_button");

    $(".lightmedia_form br").each(function() {

        if ($(this).parent().get(0).tagName != "SPAN") {
            if ($(this).prev().length > 0) {
                if ($(this).prev().html().substr(0, 20) == "Enter the code shown") {
                    return;
                }
            }

            $(this).replaceWith("<div style=\'clear:both\'>&nbsp;</div>");
        }
    });

    $(".lightmedia_form").each(function() {
        $(this).append("<div style=\'clear:both\'></div>");
    });
}
