document.domain="qq.com"

function FloatShow(sUrl, iWidth, iHeight, OnOK, OnCancel, iLeft, iTop, oWin, fras)
{

	oWin = oWin || window;
//	iLeft = typeof(iLeft)=="number" ? iLeft : 75;
	iLeft = typeof(iLeft)=="number" ? iLeft : GetTopLeftCorner(iWidth);
	iTop = typeof(iTop)=="number" ? iTop : 45;
	var ifras = null;
	if (typeof(fras) != "undefined" && fras != null && fras != "null")
	{
	  ifras = fras;
	}else
	{
		ifras = [window, top.mainfra, top.leftfra, top.topfra];
	}
	FloatShow.Show = function(sUrl, iWidth, iHeight, iLeft, iTop)
	{
		MaskStart(ifras);
		var e = DivCreate(oWin, oWin.document.body, "ID_QQLOVE_FLOAT_WIN", 65530, 0, 50, "100%", "1", "none");
		e.style.top = (Math.max(Math.min(oWin.document.documentElement.scrollTop+100, oWin.document.body.offsetHeight-100), 50))+"px";
		if(iHeight<50)
		{
			e.innerHTML = '<div id="loading" style="position:absolute;left:'+iLeft+'px;top:'+(iTop+100)+'px;background:url(http://source2.qq.com/a/images/icon_loading.gif) #FFF 20px 50% no-repeat;padding:21px 20px 13px 50px;line-height:16px;width:130px; height:20px;border:1px solid #d0d0d0;">正在处理中……</div>';
			}
		else{
		e.innerHTML = '<table id="w_head" align="left" style="position:absolute;left:'+iLeft+'px;top:'+iTop+'px;"><tr><td align="center"><iframe id="ID_QQLOVE_FLOAT_IFRAME" name="ID_QQLOVE_FLOAT_IFRAME" width="'+iWidth+'" height="'+iHeight+'" frameborder="0" scrolling="no"></iframe></td></tr></table><div id="d_border" style="display:none;border:1px dotted #000000; position:absolute;"></div>';
		e.getElementsByTagName("IFRAME")[0].src = sUrl;
		}
		e.style.display = "block";		
	};
	
	FloatShow.Hide = function()
	{
	  MaskEnd([window, top.mainfra, top.leftfra, top.topfra]);
	  
		if (arguments[0])
		{
		  var fra = arguments[0];
		  if (fra && fra.document)
		  {
		    fra.document.getElementById("ID_QQLOVE_FLOAT_WIN").style.display = "none";	
		  }
		}else
		{
			document.getElementById("ID_QQLOVE_FLOAT_WIN").style.display = "none";	
		}
	};
	
	FloatShow.DireOnCancel = function()
	{
		OnCancel && OnCancel(arguments[0]);
	};

	FloatShow.OnOK = function()
	{
		FloatShow.Hide();
		OnOK && OnOK(arguments[0]);
	};

	FloatShow.OnCancel = function()
	{
		FloatShow.Hide();
		OnCancel && OnCancel(arguments[0]);
	};

	FloatShow.AutoSize = function()
	{
		try
		{
			function FindIFrame(sName) { for (var i=0; i<window.frames.length; ++i) { if (window.frames[i].name==sName) { return window.frames[i]; } } return null; };
			var e = document.getElementById("ID_QQLOVE_FLOAT_IFRAME");
			var w = _MSIE() ? window.frames["ID_QQLOVE_FLOAT_IFRAME"] : FindIFrame("ID_QQLOVE_FLOAT_IFRAME");
			if ((w.document.documentElement.scrollTop=500) && (w.document.documentElement.scrollTop!=0))
			{
				e.height = parseInt(e.height)+w.document.documentElement.scrollTop+"px";
				w.document.documentElement.scrollTop = 0;
			}
			if ((w.document.documentElement.scrollLeft=500) && (w.document.documentElement.scrollLeft!=0))
			{
				e.width = parseInt(e.width)+w.document.documentElement.scrollLeft+"px";
				w.document.documentElement.scrollLeft = 0;
			}
		}
		catch(e)
		{
		}
	};

	FloatShow.Show(sUrl, iWidth, iHeight, iLeft, iTop);
};

function MaskStart(lWin)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		try{ PageMaskShow(arguments[0][i]); } catch(e) { }
	}
};

function PageMaskShow(oWin)
{
	var e = PageMaskCreate(oWin);
	if(e)
	{
		e.style.height = Math.max((oWin.document.body.offsetHeight), oWin.document.documentElement.clientHeight)+"px";
		e.style.display = "block";
	}
};

function MaskEnd(lWin)
{
	for (var i=0; i<arguments[0].length; ++i)
	{
		try{ PageMaskHide(arguments[0][i]); } catch(e) { }
	}
};

function PageMaskHide(oWin)
{
	var e = PageMaskCreate(oWin);
	e.style.display = "none";
};

function PageMaskCreate(oWin)
{
	if(oWin && oWin.document)
	{
		var ebg;
		if (!oWin.document.getElementById("ID_QQLOVE_WAIT_BACKGND"))
		{
			ebg = DivCreate(oWin, oWin.document.body, "ID_QQLOVE_WAIT_BACKGND", 65529, 0, 0, "100%", "100%", "none");
		}
		else ebg =oWin.document.getElementById("ID_QQLOVE_WAIT_BACKGND");
		ebg.id = "ID_QQLOVE_WAIT_BACKGND";
		ebg.style.position = "absolute";
		ebg.style.zIndex = 65529;
		ebg.style.left = 0;
		ebg.style.top = 0;
		ebg.style.width = "100%";
		ebg.style.height =  "100%";
		ebg.style.display = "none";
		ebg.style.backgroundColor = "#000";
		ebg.style.opacity = 0.35;
		ebg.style.filter = "alpha(opacity=35)";
		return ebg;
	}
	else return null;
};


function DivCreate(oWin, oParent, sID, zIndex, iLeft, iTop, sWidth, sHeight, sDisplay)
{
	var e;
	if (!oWin.document.getElementById(sID))
	{
		e = oWin.document.createElement("DIV");
		try{ oParent && oParent.appendChild(e); } catch(e) { }
	}
	else e = oWin.document.getElementById(sID);
	e.id = sID;
	e.style.position = "absolute";
	e.style.zIndex = zIndex;
	e.style.left = iLeft;
	e.style.top = iTop;
	e.style.width = sWidth;
	e.style.height = sHeight;
	e.style.display = sDisplay;
	return e;
};

function GetTopLeftCorner(width)
{
	var clientWidth = document.body.clientWidth;
	var left = (clientWidth - width )/ 2;
	return Math.round(left);
}

