$(document).ready(function () {

    var planetscript = new planet4one();

    planetscript.hideSiteMap();
    planetscript.attachClickEventsToSitemap();
    planetscript.createMouseOverMenu();
    planetscript.attachClickEventToWarenkorb();

});

planet4one = function () { };

planet4one.prototype.sitemapVisible = false;
planet4one.prototype.warenkorbVisible = false;

planet4one.prototype.hideSiteMap = function () {

    $("#sitemap-complete").css('height', '80px');
    $("#sitemap-complete").css('overflow', 'hidden');
    this.sitemapVisible = false;

}

planet4one.prototype.showSiteMap = function () {

    $("#sitemap-complete").css('height', 'auto');
    $("#sitemap-complete").css('overflow', 'visible');
    this.sitemapVisible = true;

}

planet4one.prototype.attachClickEventsToSitemap = function () {
    var t = this;
    $("#sitemap-complete .klapp").css("cursor", "pointer");
    $("#sitemap-complete .klapp").click(function () {
        if (t.sitemapVisible) t.hideSiteMap()
        else t.showSiteMap();
    });
}

planet4one.prototype.createMouseOverMenu = function () {

    $(".navigation-oben-menu a").mouseenter(function () {
        var pos = $(this).offset();
        var $menubox = $(this).parent().find(".navigation-oben-menu-box");

        $menubox.css("visibility", "visible");
        $menubox.css("top", pos.top + 31);
        $menubox.css("left", pos.left - 150);

        $menubox.parent().mouseleave(function () {
            $menubox.css("visibility", "hidden");
        });
    });
}

planet4one.prototype.attachClickEventToWarenkorb = function () {
    var t = this;

    $("#warenkorb h444").css("cursor", "pointer")
    $("#warenkorb h444").click(function () {
        if (t.warenkorbVisible) t.hideWarenkorb()
        else t.showWarenkorb();
    });
}

planet4one.prototype.hideWarenkorb = function () {
    $("#warenkorb").css("bottom", "-149px");
    this.warenkorbVisible = false;
}

planet4one.prototype.showWarenkorb = function () {
    $("#warenkorb").css("bottom", "0px");
    this.warenkorbVisible = true;
}
