/*
 * READ ME
 * How to use
 * Add the following code and give iframes id(use array) 
 * to your page that has iframe
 * 
 * (This is an example)
 * <script type="text/javascript">
 * resizeCaller(["hotProductFrame","contentFrame"]);   
 * </script>
 * 
 */

/*
 * Because the $ sign in SCMPortal was conflict with the other js
 * so replace $ to jQuery to make it works
 */

function resizeCaller(iframeids) {
	for (i = 0; i < iframeids.length; i++) {
		if (jQuery('#' + iframeids[i]).length >0) {
			addiFrameLoadEvent(iframeids[i]);
		}
	}
	
}

//add load event to iFrame
function addiFrameLoadEvent(iFrameId){
    jQuery('#' + iFrameId).load(function(){
    	  setTimeout(function(){resizeIframe(iFrameId);},1000);
    	  
    	  setTimeout(function(){resizeIframe(iFrameId);},3000);
//        resizeIframe(iFrameId);
    });
}

//resize iFrame
function resizeIframe(iFrameId){
    var iFrame=jQuery('#' + iFrameId);
	if (iFrame.length > 0) {
		
		//Let height reset
		iFrame.css({
      height: 0
    });
		
    iFrame.css({
      display: "block",
      height: iFrame.contents().height()
    });
    
    
 }
	
}

