function airbox(e) {
    var ab_closeButtonURL = "/images/ab_closeButton.png";
    var ab_windowWidth = $(window).width();
    var ab_windowHeight = $(window).height();
    var ab_url = $(e).attr("href");
    var ab_tourWidth = $(e).attr('class').split(/\s+/)[1];
    var ab_tourHeight = $(e).attr('class').split(/\s+/)[2];
    $("body").append("<div class=\"ab_shadow\" style=\"width: 100%;height: 100%;opacity: 0.75;filter: alpha(opacity=75);display: none;background-color: black;position: fixed;left: 0;top: 0;z-index: 9998;\"></div>");
    var ab_frameCont = "<div class=\"ab_frameCont\" style=\"margin:0;padding:0;width:" + ab_tourWidth + "px; height:" + ab_tourHeight + "px;position: fixed;left:0;top:0;z-index:9999;border:5px solid white;display:none;-moz-border-radius:10px;-webkit-border-radius:10px;-khtml-border-radius:10px;border-radius:10px;\"></div>";
    $("div.ab_shadow").css("display", "block");
    $("body").append(ab_frameCont);
    $("div.ab_frameCont").append("<div class=\"ab_closeButton\" style=\"width: 35px;height: 59px;background-image: url('" + ab_closeButtonURL + "');position: absolute;right: -35px;top: 20px;cursor: pointer;z-index: 1;\"></div>");
    $("div.ab_frameCont").append("<iframe src=\"" + ab_url + "\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" class=\"ab_iframe\" style=\"padding:0;margin:0;border: none;width: " + ab_tourWidth + "px;height: " + ab_tourHeight + "px;background-color: white;\"><p>Your browser doesn't support iFrames</p></iframe>");
    $("div.ab_frameCont").css("left", (($("div.ab_shadow").width() - ab_tourWidth) / 2) - 30 + "px");
    if (parseInt($("div.ab_frameCont").css("height")) >= ab_windowHeight) {
        $("div.ab_frameCont").css("height", (ab_windowHeight - 30) + "px");
    } else {
        $("div.ab_frameCont").css("top", (ab_windowHeight - ab_tourHeight) / 2 + "px");
    }
    $("div.ab_frameCont").css("display", "block");
    $("div.ab_closeButton").click(function () {
        $("div.ab_frameCont").remove();
        $("div.ab_shadow").remove();
    })
}
$(document).ready(function () {
    $("a.airbox").click(function (event) {
        event.preventDefault();
        if ($(event.target).attr("tagName") == "A") {
            airbox($(event.target));
        } else {
            airbox($(event.target).closest("a.airbox"));
        }
    })
});
