

/***************************************************************************************************************
* Function					: - 
* Description				: Change the height of the iframe automatically , depends on the content.
*								  Change the min height by variable - minHeight	
* Parameter Usage		: -							
* Location					: /js/iframe_auto.js
* Author					: Steve Y
* Creation Date			: 19 June 2010
* Side effect				: N/A
* Dependency File		: -
* Amendment History	:
* Date By Description
* ---------	------------	--------------------------------------------------------------------------------
***************************************************************************************************************/

// iframe auto height
	var coos = function(){this.version = "0.2";};  
	var minHeight = 2625;
	
  
/** 
 * @param id 
 * @return DOM element 
 */  
	coos.$id = function(id)
	{  
	  return document.getElementById(id);  
	};  
	  
	/** 
	 * @return DOM element 
	 */  
	coos.$obj = function(el)  
	{  
		var obj = el;  
		if(typeof(el) == "string")  
			obj = document.getElementById(el);  
		return obj;  
	};  
	  
	/** 
	 * 
	 */  
	coos.iframe = {  
		autoHeights : function(els)  
		{  
			for (var i = 0; i < arguments.length; i++)   
			{  
				coos.iframe.autoHeight(arguments[i]);  
			}  
		},  
		autoHeight : function(el)  
		{  
			var obj = coos.$obj(el);  
			var id = obj.id;  
			var subWeb = document.frames ? document.frames[id].document : obj.contentDocument;     
			if(obj != null && subWeb != null)  
			{  
				// resize iframe to content height
				if (parseInt(subWeb.body.offsetHeight) > minHeight){
					
					obj.height = parseInt(subWeb.body.offsetHeight) + "px";  
				} else {
					obj.height = minHeight + "px";  
				}
			}     
		}  
	};  
