/// <reference path="jquery-1.2.6-vsdoc.js">

// My Catalog
$(document).ready(function() {
    $("a.movebutton").click(function(event) {
        event.preventDefault();
        var me = $(this).parent().parent();

        if ($(this).attr("direction") == "up") {
            var m = me.next();
            if ($(this).attr("type") == "ikon")
                me.insertBefore(me.prev());
            else
                me.insertBefore(me.prev().prev());
            me.next().insertBefore(m);
        }
        else {
            var m = me.next();
            if ($(this).attr("type") == "ikon")
                me.insertAfter(me.next());
            else
                me.insertAfter(me.next().next());
            me.prev().insertBefore(m);
        }

        //me.children("td").css("background-color", "red");

        $.ajax({
            type: "POST",
            url: "produktkatalog.php",
            data: "simple=true&" + $(this).attr("href").substring(1, 100),
            success: function(msg) {

            }
        });

        var followers = ($(this).attr("type") == "ikon") ? 0 : 1;
        me.parent().children().each(
				function() {
				    if ($(this).prevAll().size() > 0)
				        $(this).find("[direction=up]").show();
				    else
				        $(this).find("[direction=up]").hide();

				    if ($(this).nextAll().size() > followers)
				        $(this).find("[direction=down]").show();
				    else
				        $(this).find("[direction=down]").hide();

				}
				)
    });
});
