function LoadImageRotator(photos)
{
	function init_ImageStack() {
		cvi_istack.add(document.getElementById('slideshow'),{
			imagearray: photos,
			mainwidth: 150,
			mainheight: 150,
			playdelay: 4000,
			playscript: 'cvi_instant',
			noiefade: true
		});
	}
	if(window.attachEvent) {
		window.attachEvent("onload", init_ImageStack);
	}else {
		window.addEventListener("load", init_ImageStack, false);
	}
}

function LoadBackgroundImage(imageUrl)
{
	$('#loading').show();
	
	img = new Image();
	$(img).load(function () {
		$('body').css('background-image', 'url("' + imageUrl + '")');
		$('#loading').hide();
    }).error(function () {
      // notify the user that the image could not be loaded
    }).attr('src', imageUrl);
}

if (isIE == "undefined") {
    var isIE = false
}
if (isIE6 == "undefined") {
    var isIE6 = false
}
if (lightbox == "undefined") {
    var lightbox = 0
}

(function (b) {
    b.fn.superfish = function (k) {
        var g = b.fn.superfish,
            j = g.c,
            f = b(['<span class="', j.arrowClass, '"> &#187;</span>'].join("")),
            i = function () {
                var c = b(this),
                    l = d(c);
                clearTimeout(l.sfTimer);
                c.showSuperfishUl().siblings().hideSuperfishUl()
            },
            e = function () {
                var c = b(this),
                    m = d(c),
                    l = g.op;
                clearTimeout(m.sfTimer);
                m.sfTimer = setTimeout(function () {
                    l.retainPath = (b.inArray(c[0], l.$path) > -1);
                    c.hideSuperfishUl();
                    if (l.$path.length && c.parents(["li.", l.hoverClass].join("")).length < 1) {
                        i.call(l.$path)
                    }
                }, l.delay)
            },
            d = function (c) {
                var l = c.parents(["ul.", j.menuClass, ":first"].join(""))[0];
                g.op = g.o[l.serial];
                return l
            },
            h = function (c) {
                c.addClass(j.anchorClass).append(f.clone())
            };
        return this.each(function () {
            var c = this.serial = g.o.length;
            var m = b.extend({}, g.defaults, k);
            m.$path = b("li." + m.pathClass, this).slice(0, m.pathLevels).each(function () {
                b(this).addClass([m.hoverClass, j.bcClass].join(" ")).filter("li:has(ul)").removeClass(m.pathClass)
            });
            g.o[c] = g.op = m;
            b("li:has(ul)", this)[(b.fn.hoverIntent && !m.disableHI) ? "hoverIntent" : "hover"](i, e).each(function () {
                if (m.autoArrows) {
                    h(b(">a:first-child", this))
                }
            }).not("." + j.bcClass).hideSuperfishUl();
            var l = b("a", this);
            l.each(function (n) {
                var o = l.eq(n).parents("li");
                l.eq(n).focus(function () {
                    i.call(o)
                }).blur(function () {
                    e.call(o)
                })
            });
            m.onInit.call(this)
        }).each(function () {
            var c = [j.menuClass];
            b(this).addClass(c.join(" "))
        })
    };
    var a = b.fn.superfish;
    a.o = [];
    a.op = {};
    a.c = {
        bcClass: "sf-breadcrumb",
        menuClass: "sf-js-enabled",
        anchorClass: "sf-with-ul",
        arrowClass: "arrow"
    };
    a.defaults = {
        hoverClass: "sfHover",
        pathClass: "overideThisToUse",
        pathLevels: 1,
        delay: 333,
        speed: "normal",
        autoArrows: true,
        disableHI: false,
        onInit: function () {}, onBeforeShow: function () {}, onShow: function () {}, onHide: function () {}
    };
    b.fn.extend({
        hideSuperfishUl: function () {
            var e = a.op,
                d = (e.retainPath === true) ? e.$path : "";
            e.retainPath = false;
            if (isIE) {
                css1 = {
                    marginLeft: 20
                }
            } else {
                css1 = {
                    opacity: 0,
                    marginLeft: 20
                }
            }
            var c = b(["li.", e.hoverClass].join(""), this).add(this).not(d).removeClass(e.hoverClass).find(">ul").animate(css1, 150, "swing", function () {
                b(this).css({
                    display: "none"
                })
            });
            e.onHide.call(c);
            return this
        }, showSuperfishUl: function () {
            var d = a.op,
                c = this.addClass(d.hoverClass).find(">ul:hidden").css("visibility", "visible");
            d.onBeforeShow.call(c);
            if (isIE) {
                css1 = {
                    display: "block",
                    marginLeft: 20
                };
                css2 = {
                    marginLeft: 0
                }
            } else {
                css1 = {
                    display: "block",
                    opacity: 0,
                    marginLeft: 20
                };
                css2 = {
                    opacity: 1,
                    marginLeft: 0
                }
            }
            c.css(css1).animate(css2, 150, "swing", function () {
                d.onShow.call(c)
            });
            return this
        }
    })
})(jQuery);
