/*
 * jQuery iFrameAutoHeight plugins 
 * version: 1.0.0
 * Copyright (c) 2011 Muntasir Mohiuddin
 * Dual licensed under the MIT and GsPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.0 or later
 */

/**
 * Enables an iFrame to inherit current browser window height. If a height offset is provided will add the offset to the iFrame height.
 *
 * @example $("#iFrame").iFrameAutoHeight();
 * @desc Set the iFrame to inherit current browser window height.
 *
 *
 * @example $("#iFrame").iFrameAutoHeight({
 *  heightOffset: 120 										 
 * });
 * @desc Set the iFrame to inherit current browser window height plus 120px.
 *
 * @param Int heightOffset The height offset.
 * 
 * @type Utilities
 *
 * @name $.iFrameAutoHeight
 * @cat Plugins/iFrame
 * @author Muntasir Mohiuddin/muntasir@bakedproject.com
 */


(function($){ // block_1
 
	//Attach this new method to jQuery
	$.fn.extend({ 
	
		//This is where you write your plugin's name
		iFrameAutoHeight: function(options) {
			var element = $(this);	
			
			var settings = {
				heightOffset: 0
			}			
			
			//Iterate over the current set of matched elements
			return this.each(function() { // block_2
				if ( options ) { 
        			$.extend( settings, options );
   				}
				
				$(this).css('height', ( ( $(window).height() - settings.heightOffset ) + 'px') );
				
				//display:block; width:100%; border:none;
				
				$(window).resize(function() {
					element.css('height', ( ( $(window).height() - settings.heightOffset ) + 'px') );
				}); // end of $(window).resize				
				
			}); // end of block_2
			
			
		} // end of iFrameAutoHeight:function()
	}); // end of $.fn.extend
	
})(jQuery) // end of block_1
		
