﻿var clickable = {
    bind: function(anchorclass, targetbox) {
        var $anchor = $("a." + anchorclass);
        var $target = $("#" + targetbox);
        var $hidden = $target.children(".hidden");
        $anchor.click(function(e) {
            var $id = $(this).attr("href");
            var $div = $($id);
            $hidden.hide();
            $div.show();
            e.preventDefault();
        });
    }
}

var overlay = {
    build: function(overlayid) {
        var $overlay = $("#" + overlayid);
        var $close = $overlay.children(".close");
        $close.click(function() {
            $overlay.slideUp(300);
        });
        var $left = $(window).width() / 2 - $overlay.width() / 2;
        var $top = 300;
        $overlay.offset({ top: $top, left: $left });
    },
    bind: function(anchorclass, overlayid) {
        var $overlay = $("#" + overlayid);
        var $anchor = $("a." + anchorclass);
        var $hidden = $overlay.children(".hidden");
        $anchor.click(function(e) {
            var $id = $(this).attr("href");
            var $div = $($id);
            $hidden.hide();
            $div.show();
            $overlay.slideDown(300);
            e.preventDefault();
        });
    }
}

$(document).ready(function() {
    $("#home").show();
    clickable.bind("button", "content-box");
    overlay.build("overlay");
    overlay.bind("open", "overlay");
});
