﻿$(document).ready(function() {

    var startval = $("#startvalue").html();

    $(".rating").rating({ showCancel: false, startValue: startval });

    $("#StarRatingControl").val(startval).change();

    //Show that we can bind on the select box  
    $("#StarRatingControl").bind("change", function() {

        var val = $("#StarRatingControl").val();
        var idstring = $("#startvalue").attr('class');

        // send request
        $.post("/rate.aspx", { id: idstring, value: val }, function(data) {
            // format and output result
            alert("Danke für deine Stimme!");
        });

        //$('#serialString2').text( $('#serialStar2').serialize() );  
    });

    $(".NewsCaptionLink").click(function() {
        var stringid = this.id.replace('NewsCaptionLink', "");
        // send request
        $.post("/controls/RaiseViewCount.aspx?id=" + stringid, {}, function(data) {
            // format and output result
        });
    });

    $(".partnerLink").click(function() {
        var stringid = this.id.replace('partnerLink', "");
        // send request
        $.post("/controls/RaiseViewCount.aspx?partner=" + stringid, {}, function(data) {
            // format and output result
        });
    });

    $("#txtEingabe").focus(function() {
        var val = $("#txtEingabe").val();
        if (val == "Suche...")
            $("#txtEingabe").val("");
    });
    $('#txtEingabe').blur(function() {
        var val = $("#txtEingabe").val();
        if (val == "") {
            $("#txtEingabe").val("Suche...");
            MakeSearchUnselected();
        }
        else
            MakeSearchSelected();
    });
    $('#txtEingabe').keypress(function() {
        var val = $("#txtEingabe").val();
        if (val == "Suche...") {
            MakeSearchUnselected();
        }
        else {
            MakeSearchSelected();
        }
    });
    function MakeSearchSelected() {
        $("#txtEingabe").removeClass("SearchBoxNoEntry");
        $("#txtEingabe").addClass("SearchBoxEntry");
    }
    function MakeSearchUnselected() {
        $("#txtEingabe").removeClass("SearchBoxEntry");
        $("#txtEingabe").addClass("SearchBoxNoEntry");
    }

    var setfocus = $("#setfocus");
    if (setfocus != null) {
        if (setfocus.length > 0)
            $("#txtEingabe").focus();
    }




    $(".mailerTextbox").focus(function(event) {
        var txt = $(this).val();
        if ((txt == "Name") ||
            (txt == "E-Mail") ||
            (txt == "Song-Title") ||
            (txt == "Link") ||
            (txt == "Band-Name")) {
            $(this).val("");
        }
    });
    $(".mailerTextbox").blur(function(event) {

        var txt = $(this).val();
        var defval = $(this).attr("DefaultValue");

        if (txt == "") {
            $(this).val(defval);
            $(this).removeClass("mailerTextboxActive");
            $(this).addClass("mailerTextbox");
        } else if (txt == defval) {
            $(this).removeClass("mailerTextboxActive");
            $(this).addClass("mailerTextbox");
        } else {
            $(this).addClass("mailerTextboxActive");
            $(this).removeClass("mailerTextbox");
        }
    });

});
