﻿// PNG FIX FOR IE 6
$(document).ready(function () {
    $(document).pngFix();

    /* Special treatment for postnummer/sted field */
    var $field = $("#ctl00_ContentAreaPlaceHolder_FormView1_fieldrep_ctl06_ctl01_ctl03").parents(".FormFieldWrapper");
    var $cityInput = $field.next().find("input").addClass("secondInput");
    $field.find(".LabelWrapper label").append(" / sted");
    $field.next().hide();
    $cityInput.appendTo($field.find(".FieldWrapper"));

    $field.find(".ValidatorWrapper span").text("* både postnummer og sted må fylles ut ved bestilling av produkt");
    $field.prev().find(".ValidatorWrapper span").text("* adresse må fylles ut ved bestilling av produkt");

    $("#FormID-5").parents("form").submit(function () {
        if (($("#ctl00_ContentAreaPlaceHolder_FormView1_fieldrep_ctl03_ctl01_ctl03").val().trim() != ""
            && $("#ctl00_ContentAreaPlaceHolder_FormView1_fieldrep_ctl03_ctl01_ctl03").val().trim() != "0")
            || ($("#ctl00_ContentAreaPlaceHolder_FormView1_fieldrep_ctl04_ctl01_ctl03").val().trim() != ""
            && $("#ctl00_ContentAreaPlaceHolder_FormView1_fieldrep_ctl04_ctl01_ctl03").val().trim() != "0")) {
            //user has entered a value into either book order or CD order
            if ($field.find("input").first().val() == "")
                $field.find(".ValidatorWrapper span").show();

            if ($field.find("input").last().val() == "")
                $field.find(".ValidatorWrapper span").show();

            if ($field.prev().find("input").val() == "")
                $field.prev().find(".ValidatorWrapper span").show();
        }
    });

    /* Set a default title for comments */
    $("#ctl00_ContentAreaPlaceHolder_ctl00_ctl00_CommentTitle").val("Innlegg");
});
