
/* iframe size control */
var ds;
var ifname = "reflectiframe";

function reSize() 
{
	ds = new DocumentSizeObserver(document, list_onload, "ds");
}

function reSizeFrame(framename)
{
	iframe = framename;
	ds = new DocumentSizeObserver(document, list_onload, "ds");
}	

function DocumentSizeObserver(document, eventFunc, instanceName) 
{

	this.document = document;
	this.limit = 10;
	this.wf = false;				// width ¿Ï·á ¿©ºÎ 
	this.hf = false;				// height ¿Ï·á ¿©ºÎ
	this.prew = 0;					// ÀÌÀü ÁÖ±âÀÇ width
	this.preh = 0;					// ÀÌÀü ÁÖ±âÀÇ width
	this.check = checkDocumentSize;	// resize ¸Þ¼Òµå. SetInterval¿¡ ÀÇÇØ ÁÖ±âÀû È£Ãâ 
	this.execute = eventFunc; 		// ·»´õ¸µ ¿Ï·á ÆÇ´Ü ÈÄ È£Ãâ 
	this.instanceName = instanceName;

	setTimeout(this.instanceName + '.check()', 100);
}

function list_onload(width, height) 
{
	try
	{
	    parent.document.getElementById(ifname).height = height;	
		//alert(parent.document.getElementById(ifname).height);
		parent.top.document.getElementById(ifname).height = height;
		//alert(parent.top.document.getElementById(ifname).height);
	}
	catch(e)
	{
		//alert(e);
	}	
}

function checkDocumentSize()
{
	// À©µµ¿ì°¡ ¿ÏÀüÈ÷ ·»´õ¸µ µÇ¾î »çÀÌÁî°¡ °íÁ¤µÉ¶§±îÁö
	if (this.limit-- <= 0) 
	{
		// ´õÀÌ»ó ±â´Ù¸®Áö ¾Ê°í, ¸¶Áö¸·¿¡ ÀÐÀº Å©±â Àü´Þ 
		this.execute(this.prew, this.preh);
		return;
	}
	
	var cw = document.body.scrollWidth;
	var ch = document.body.scrollHeight;
	var dw = cw - this.prew;
	var dh = ch - this.preh;
	
	this.prew = cw; 
	this.preh = ch; 

	if (cw > 0 && dw == 0) 
		this.wf = true;
	if (ch > 0 && dh == 0) 
		this.hf = true;
		
	if (this.wf && this.hf)
		this.execute(cw, ch);
	else 
		setTimeout(this.instanceName + '.check()', 100);
}	




