
Background = function() {
    jQuery("#background").fadeIn(800);
    var self = this;
    this.body = jQuery("body");
    this.container = jQuery("#background");
    jQuery("#background").css({ position: "fixed" });
    this.image = jQuery("img", this.container);
    //  this.image.css({ position: "absolute", left: "-10000px" });
    this.alternate = false;
    this.check = function() {
        if (this.alternate && this.image.width() < this.container.width()) {
            this.image.removeClass("alternate");
            this.alternate = false;    
            

        }
        this.alternate = true;
    
        //jQuery("#background").fadeIn(800);
        //alert('a')
        if (!this.alternate && this.image.height() < this.container.height()) {
            this.image.addClass("alternate");
        }
        var margin = -(this.image.height() - this.container.height()) / 2 + "px 0 0 " + -(this.image.width() - this.container.width()) / 2 + "px";
        this.image.css({ margin: margin });
    }
    jQuery(window).scroll(function() { jQuery("#background").css({ position: "fixed" }); });
    jQuery(window).resize(function() { self.check(); });
    
    this.image.load(function() {
        self.check();
        jQuery(this).css({ position: "static" });
    });
}

