﻿/**
* FlashResize (http://www.think2loud.com)
* A jQuery plugin for Full Browser Flash.
* 
* Version 1.0
* September 9, 2008
*
* Copyright (c) 2008 Josh Lyford & Think2Loud (http://www.think2loud.com)
* Dual licensed under the MIT and GPL licenses.
* http://www.opensource.org/licenses/mit-license.php
* http://www.opensource.org/licenses/gpl-license.php
* 
**/
(function($) {
    $.fn.flashResize = function(options) {
        var defaults = {
            minWidth: "100%",
            minHeight: "100%"
        };

        var options = $.extend(defaults, options);

        return this.each(function() {
            var obj = $(this);
            var theWindow = $(window)

            if (theWindow.width() < options.minWidth && options.minWidth != "100%") {
                obj.width(options.minWidth);
            }

            if (theWindow.height() < options.minHeight && options.minHeight != "100%") {
                obj.height(options.minHeight);
            }

            theWindow.resize(function() {
                if (options.minWidth != "100%") {
                    if ($(this).width() < options.minWidth) {
                        obj.width(options.minWidth);
                    }
                    else if (obj.width() != "100%") {
                        obj.width("100%");
                    }
                }
                if (options.minHeight != "100%") {
                    if ($(this).height() < options.minHeight) {
                        obj.height(options.minHeight);
                    }
                    else if (obj.height() != "100%") {
                        obj.height("100%");
                    }
                }
            });
        });
    };
})(jQuery);

