﻿// JScript File
// It 
//$(document).ready(function()
//	{
//		// Set specific variable to represent all iframe tags.
//		var iFrames = document.getElementsByTagName('iframe');

//		// Resize heights.
//		function iResize()
//		{
//			// Iterate through all iframes in the page.
//			for (var i = 0, j = iFrames.length; i < j; i++)
//			{
//				// Set inline style to equal the body height of the iframed content.
//				iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
//			}
//		}

//		// Check if browser is Safari or Opera.
//		if ($.browser.safari || $.browser.opera)
//		{
//			// Start timer when loaded.
//			$('iframe').load(function()
//				{
//					setTimeout(iResize, 0);
//				}
//			);

//			// Safari and Opera need a kick-start.
//			for (var i = 0, j = iFrames.length; i < j; i++)
//			{
//				var iSource = iFrames[i].src;
//				iFrames[i].src = '';
//				iFrames[i].src = iSource;
//			}
//		}
//		else
//		{
//			// For other good browsers.
//			$('iframe').load(function()
//				{
//					// Set inline style to equal the body height of the iframed content.
//					this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
//				}
//			);
//		}
//	}
//);

//Its working
//function doIframe(){
//	
//	o = document.getElementsByTagName('iframe');
//	for(i=0;i<o.length;i++){
//		if (/\bautoHeight\b/.test(o[i].className)){
//			setHeight(o[i]);
//			addEvent(o[i],'load', doIframe);
//		}
//	}

//}

function setHeight(e){
	if(e.contentDocument){
		e.height = e.contentDocument.body.offsetHeight + 24;
	} else 
	{
	    if ( e.contentWindow.document.body != null){
		    e.height = e.contentWindow.document.body.scrollHeight;
		    }
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}

if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}
function SetCwinHeight(){
  var cwin=document.getElementById("cwin");
  if (document.getElementById){
      if (cwin) {
          if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
              cwin.height = cwin.contentDocument.body.offsetHeight;
          else if(cwin.Document && cwin.Document.body.scrollHeight)
              cwin.height = cwin.Document.body.scrollHeight;
      }
  }
}

function doIframe(){
	
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			resizeIframe(o[i]);			
		}
	}

}


 function resizeIframe(ifr){
//      var ifr = document.getElementById(id);
      var ifrBody = ifr.contentWindow.document[getDocBody(ifr.contentWindow)];
      //  alert('offsetHeight : '+ ifrBody.offsetHeight +'scrollHeight : '+ifrBody.scrollHeight);
      if( ifrBody != null)
      {
          if(ifrBody.scrollHeight == 150)
          {
            ifr.style.height = ifrBody.offsetHeight+"px";
          }
          else
          {
            ifr.style.height=ifrBody.scrollHeight+"px";
          }
      }
    }

    function getDocBody(win){
      if (!win) win=window;
      if (win.document.compatMode && win.document.compatMode != 'BackCompat') { //standards compliant mode 
        return "documentElement";
      }
      return "body";
    }





