$(function() {
    $("input[name=mp3]").filestyle({
        image: "images/upload-knop.gif",
        imageheight: 19,
        imagewidth: 55,
        titel: "MP3 Bestand",
        width: 127
    });

    $("input[name=bandfoto]").filestyle({
        image: "images/upload-knop.gif",
        imageheight: 19,
        imagewidth: 55,
        titel: "Bandfoto",
        width: 127
    });

    $(".uploaden-tracks input[type!=file]").focus(function() {
        if ($(this).val().toLowerCase() == $(this).attr("name")) {
            $(this).val("")
        }
    }).blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this).attr("name"));
        }
    });

    //begin demo , stemmen
    $(".demo-item").click(function() {
        if ($(this).attr("class").match("open") == null) {
            $(".ster").removeClass("actief");
            $(".demo-item.open").removeClass("open");
            $(this).addClass("open").find("input[name='email'],input.verzenden, .nieuwsbrief *").hide();
            $('.scrollt').jScrollPane();
        }
    });

    $(".beoordeel input[name='email']").focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("");
        }
    }).blur(function() {
        if ($(this).val() == "") {
            $(this).val($(this).attr("title"));
        }
    });

    $(".beoordeel .ster").mouseover(
        function() {
            $(this).parent().find(".ster").removeClass("actief").end();
            $(this).addClass("actief").prevAll(".ster").addClass("actief");
        }).click(function() {
            $(this).parent().find("input[name='email'],input.verzenden, .nieuwsbrief *").show().parent().find("input[name='Beoordeling']").val($(".ster.actief").size());
        });

    $(".beoordeel form").submit(function() {
        var Dit = $(this);
        var Email = $(this).find("input[name='email']")
        if (Email.val() !== Email.attr("title") && validateEmail(Email.val())) {
            $(this).find(".fout-email").hide();
            $.ajax({
                type: "POST",
                url: "kickstart_stemmen.asp",
                data: $(this).serialize(),
                success: function(resultaat) {
                    if (resultaat == "goed") {
                        Dit.find(".melding-ajax").html("je stem is ingevoerd.");
                    }
                    else if (resultaat == "fout") {
                        Dit.find(".melding-ajax").html("je hebt al gestemd.");
                    }
                }
            });
        } else {
            $(this).find(".fout-email").show();
        }
        return false;
    });
    //einde demo , stemmen

    // kickstart inzending afspelen
    $(".icoon-afspelen").click(function() {
        if ($(this).hasClass("icoon-stop")) {
            window.open("about:blank", "mp3_afspelen");
            $(this).removeClass("icoon-stop")
            return false;
        }
        else {
            $(".icoon-stop").removeClass("icoon-stop");
            $(this).addClass("icoon-stop");
            return true;
        }
    });
});
