// JavaScript Document
/**
 * keepRatio - jQuery plugin
 *
 * http://stilbuero.de/ratio/
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create Flash objects and image elements in a container having a constant ratio
 * while resizing the window.
 *
 * @example $('#container').keepRatio();
 * @desc Making the Flash object inside #container having a constant ratio.
 *
 * @type jQuery
 *
 * @name keepRatio
 * @cat Plugins/keepRatio
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.fn.keepRatio = function() {
    var that = this;
    return this.each(function() {
        var el = jQuery('img, object', this);
        var ratio = el.attr('width') / el.attr('height');
        el.css({width: '100%', height: '100%'});

        // Fix click-to-activate for Flash objects in IE...
        /*if (jQuery.browser.msie && el.is('object')) {
            that[0].innerHTML = that[0].innerHTML;
        }*/

        function resize() {
            that.height((that.width() / ratio) + 'px');
        }

        // Bind to window's resize event and trigger once immediatly
        $(window).bind('resize', resize).trigger('resize');

    });
};



 $(function() {
                $('#background').keepRatio();
            });
