﻿//类定义
var floatFrame=JSObject.create();
floatFrame.prototype=
{
	init: function(options) {
		
        this.fullDiv=top.document.getElementById("cFunllDiv")||top.document.createElement("div");
        this.frameDiv=top.document.getElementById("cFrameDiv")||top.document.createElement("div");
		this.frame=null;
		this.frameName='cFrame';
		
		this.setOptions(options);////设置默认属性
		
		this.src=this.options.src;
		this.param=this.options.param;
		this.width=this.options.width;
		this.height=this.options.height;
		this.fnClose=this.options.fnClose;
		this.title=this.options.title;
		
		this.set();
	},
	//设置默认属性
	setOptions: function(options) {
		this.options = {
			src:"",//框架路径
			param:"",//参数
			width:0,//框架宽度
			height:0,//框架高度
			title:'提示信息',
			fnClose:this.hide//关闭时触发的函数
		};
		JSExtend(this.options, options || {});
	},
	set:function(){
		
	    this.frame=top.frames[this.frameName];
		
		if(!this.frame)
		{
		    this.fullDiv.style.cssText="position:absolute;top:0px;left:0px;display:none;background-color:#000;filter:alpha(opacity=10);-moz-opacity:0.1;opacity: 0.1;";
		    this.frameDiv.style.cssText="position:absolute;display:none;background-color:#fff;";
			
		    this.frameDiv.innerHTML='<iframe id="cFrame" name="cFrame" scrolling="no" frameborder="0"></iframe>';
			/*'<div class="float01">'
				+'<div class="float01-01">'
					+'<div id="float01-title" class="float01-title">'
						
					+'</div>'
					+'<div class="float01-frame">'
						+'<iframe id="cFrame" name="cFrame" scrolling="no" frameborder="0"></iframe>'
					+'</div>'
				+'</div>'
			+'<div>';*/
 
			this.fullDiv.setAttribute("id","cFunllDiv");
			top.document.body.appendChild(this.fullDiv);
			this.frameDiv.setAttribute("id","cFrameDiv");
			top.document.body.appendChild(this.frameDiv);
		    this.frame=top.frames[this.frameName];
		}
	},
	hide:function()
	{
		this.fullDiv.style.display="none";
		this.frameDiv.style.display="none";
		top.document.getElementById(this.frameName).src="";
		//this.frame.src="";
	},
	show:function()
	{
		/*top.document.getElementById('float01-title').innerHTML=
		<table id="title-tab" height="30" width="'+this.width+'"><tr><td>'+this.title+'</td><td align="right">'
			+'<a title="关闭" id="cClose" href="javascript:void(0)">'
			+'<img src="images/float/close.gif" /></a>'
		+'</td></tr></table>'*/
		
		//top.document.getElementById("cClose").onclick=function(o){return function(){o.fnClose()}}(this);
		
		var iClientWidth=fnGetDocumentClient().width;
		var iClientHeight=fnGetDocumentClient().height;
		
		var iScrollWidth=fnGetDocumentScroll().width;
		var iScrollHeight=fnGetDocumentScroll().height;
		
		var iFullDivWidth=iScrollWidth;
		var iFullDivHeight=iScrollHeight>iClientHeight?iScrollHeight:iClientHeight
		
		with(this.fullDiv.style)
		{
			width=iFullDivWidth+"px"
			height=iFullDivHeight+"px";
			display="";
		}
		var iTop=(iClientHeight-this.height)*(1-0.618)+document.documentElement.scrollTop;
		var iLeft=(iClientWidth-this.width)*0.5;
		iTop=iTop>0?iTop:0;
		iLeft=iLeft>0?iLeft:0;
		var f=top.document.getElementById(this.frameName);
		f.src=this.src+"?r="+Math.random()+"&"+this.param;
		f.width=this.width+"px";
		f.height=this.height+"px";
		with(this.frameDiv.style)
		{
			top=iTop+"px";
			left=iLeft+"px";
			display="block";
		}
	}
}
