(function (a) {
    if (!document.defaultView || !document.defaultView.getComputedStyle) {
        var b = jQuery.curCSS;
        jQuery.curCSS = function (e, c, f) {
            if (c !== "backgroundPosition" || !e.currentStyle || e.currentStyle[c]) {
                return b.apply(this, arguments)
            }
            var d = e.style;
            if (!f && d && d[c]) {
                return d[c]
            }
            return b(e, "backgroundPositionX", f) + " " + b(e, "backgroundPositionY", f)
        }
    }
})(jQuery);

(function (b) {
    function a(d) {
        d = d.replace(/left|top/g, "0px");
        d = d.replace(/right|bottom/g, "100%");
        d = d.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
        var c = d.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(c[1], 10), c[2], parseFloat(c[3], 10), c[4]]
    }
    b.fx.step.backgroundPosition = function (d) {
        if (!d.bgPosReady) {
            var f = b.curCSS(d.elem, "backgroundPosition");
            if (!f) {
                f = "0px 0px"
            }
            f = a(f);
            d.start = [f[0], f[2]];
            var c = a(d.options.curAnim.backgroundPosition);
            d.end = [c[0], c[2]];
            d.unit = [c[1], c[3]];
            d.bgPosReady = true
        }
        var e = [];
        e[0] = ((d.end[0] - d.start[0]) * d.pos) + d.start[0] + d.unit[0];
        e[1] = ((d.end[1] - d.start[1]) * d.pos) + d.start[1] + d.unit[1];
        d.elem.style.backgroundPosition = e[0] + " " + e[1]
    }
})(jQuery);

jQuery.cookie = function (b, j, m) {
    if (typeof j != "undefined") {
        m = m || {};
        if (j === null) {
            j = "";
            m.expires = -1
        }
        var e = "";
        if (m.expires && (typeof m.expires == "number" || m.expires.toUTCString)) {
            var f;
            if (typeof m.expires == "number") {
                f = new Date();
                f.setTime(f.getTime() + (m.expires * 24 * 60 * 60 * 1000))
            } else {
                f = m.expires
            }
            e = "; expires=" + f.toUTCString()
        }
        var l = m.path ? "; path=" + (m.path) : "";
        var g = m.domain ? "; domain=" + (m.domain) : "";
        var a = m.secure ? "; secure": "";
        document.cookie = [b, "=", encodeURIComponent(j), e, l, g, a].join("")
    } else {
        var d = null;
        if (document.cookie && document.cookie != "") {
            var k = document.cookie.split(";");
            for (var h = 0; h < k.length; h++) {
                var c = jQuery.trim(k[h]);
                if (c.substring(0, b.length + 1) == (b + "=")) {
                    d = decodeURIComponent(c.substring(b.length + 1));
                    break
                }
            }
        }
        return d
    }
};


if ($.cookie("css")) {
    $("link.scenery_css").attr("href", $.cookie("css"))
};



$(document).ready(function () {
	
	if ($.cookie("bodyclass")) {
          $("body").removeClass();
		  $("body").addClass($.cookie("bodyclass"));
	};
	
	
    $("#switcha li a").click(function () {
        $("link.scenery_css").attr("href", $(this).attr("rel"));
        $("body").removeClass();
        $("body").addClass($(this).attr('id'));
        $.cookie("css", $(this).attr("rel"), {
            expires: 7,
            path: "/"
        });
        $.cookie("bodyclass", $(this).attr('id'), {
            expires: 7,
            path: '/'
        });
        if ($("body").hasClass("kite_anim")) {
            $('#foreground').animate({
                backgroundPosition: '(-110% 0)'
            },
            15000);
            $('#background').animate({
                backgroundPosition: '(-50% 0)'
            },
            15000);
        };
        if ($("body").hasClass("rain_anim")) {
            $('#midground').animate({
                backgroundPosition: '(50% 0)'
            },
            15000);
        };
        if ($("body").hasClass("cloud_anim")) {
            $('#foreground').animate({
                backgroundPosition: '(100% 0)'
            },
            15000);
            $('#midground').animate({
                backgroundPosition: '(78% 0)'
            },
            20000);
        };
        return false
    });

    $("#about_link").click(function () {
        $("#about").slideToggle("slow");
        $("#about_head").toggleClass("active");
        return false
    });
    if ($("body").hasClass("kite_anim")) {
        $('#foreground').animate({
            backgroundPosition: '(-110% 0)'
        },
        15000);
        $('#background').animate({
            backgroundPosition: '(-50% 0)'
        },
        15000);
    };
    if ($("body").hasClass("rain_anim")) {
        $('#midground').animate({
            backgroundPosition: '(50% 0)'
        },
        15000);
    };
    if ($("body").hasClass("cloud_anim")) {
        $('#foreground').animate({
            backgroundPosition: '(100% 0)'
        },
        15000);
        $('#midground').animate({
            backgroundPosition: '(78% 0)'
        },
        20000);
    };
});
