document.writeln("<div id=\"__LayoutRoot\" style=\"display:none;width:100%; height:100%; position:absolute;top:0;left:0;z-index:1000; margin: 0 auto;\"><iframe id=\"iframe___\" src=\"\" frameborder=\"0\" scrolling=\"no\"  style=\"width:100%; height:100%; position:absolute;z-index:-10;top:0; left:0; background-color:#000;\"></iframe><div style=\"width:100%;height:100%;background-color:#CCCCCC;position:absolute;left:0;top:0;margin: 0 auto;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;\"></div> <div id=\"__Table\" style=\"position: Absolute; text-align:center; vertical-align:middle;margin: 0px auto; \">  <table style=\"border: 8px solid #7CA1C3; background-color: #ffffff; margin: 0px auto; \"> <thead><tr style=\"height:28px\"><td id=\"__Title\" style=\"text-align:left;vertical-align:bottom;padding-left:10px; padding-top:3px; color:#7CA1C3; font-weight:bold; font-size:18px;\">Title</td><td style=\"padding:2px 10px 0px 0px; text-align:right\"><span style=\"color:blue;cursor:hand;font-weight:bold; font-size:20px; \" id=\"__btnClose\">X</span></td></tr><tr><td colspan=\"2\" style=\"padding-left:10px; padding-right:10px\"><div style=\"background-color:#7CA1C3; height:1px;\"></div></td></tr></thead> <tbody><tr><td colspan=\"2\"><iframe id=\"__iframe\" src=\"about:blank\" frameborder=\"0\" scrolling=\"auto\"></iframe></td></tr></tbody> </table> </div> </div>");

Function.prototype.bind = function(obj) {	var method = this,	temp = function() {		return method.apply(obj, arguments); 	};	return temp;}

var CurrentChildWindow;

function ChildWindow(url, title, width, height, afCloseHandle) {
	this.Title = title;	this.Url = url;	
	this.Width = width;	this.Height = height;	this.AfCloseHandle = afCloseHandle;
	this.LayoutRoot = document.getElementById("__LayoutRoot");	 
	
	this.SetTitle = function(t){
		var tbTitle = document.getElementById("__Title");		if(tbTitle.textContent){				tbTitle.textContent = t;		}else{			tbTitle.innerText = t;		}
	};
	
	this.SetUrl = function(_url){		document.getElementById("__iframe").src = _url;	}

	this.Init = function(){
		this.SetUrl(this.Url);
		this.SetTitle(this.Title);

    window.onscroll = function(){  // add window event
      var obj=document.getElementById("__Table");
			if(obj){
				ifrm=document.getElementById("__iframe");
				obj.style.top = parseInt(($(document).scrollTop() + $(window).height()/2 - ifrm.height/2)) + "px";
				document.getElementById("iframe___").style.top = obj.style.top;
			}
     };//end window.onscroll

		$(this.LayoutRoot).height($(document).height());
		$(this.LayoutRoot).width($(document).width());

//    document.getElementById("__Table").style.top = ($(document).height() - this.Height) / 2 + "px";
    document.getElementById("__Table").style.top = ($(document).height() - this.Height) / 5 + "px"; 
    document.getElementById("__Table").style.width= (this.Width + 20)+"px";
    document.getElementById("__Table").style.left = (($(document).width() - this.Width) /2 - 10) + "px";

    document.getElementById("iframe___").style.top = document.getElementById("__Table").style.top;
    document.getElementById("iframe___").style.left=document.getElementById("__Table").style.left;
    document.getElementById("iframe___").style.height = (this.Height + 40)+"px";
    document.getElementById("iframe___").style.width = (this.Width + 22)+"px";
    
		var _if = document.getElementById("__iframe");		
		_if.width = this.Width;		
		_if.height = this.Height;
	
		document.getElementById("__btnClose").onclick = this.Close.bind(this);

//		ChildWindowItems.push(this);
		CurrentChildWindow = this;
	};

	this.Show = function(){this.LayoutRoot.style.display = "block"; 		return this;	};
	this.Close = function(){
		document.getElementById("__LayoutRoot").style.display = "none";
		if(this.AfCloseHandle && typeof(this.AfCloseHandle) != "undefined"){
			this.AfCloseHandle();
		}
		window.onscroll =null;  // delete event
	};

//	this.Dispose = function(){
//		ChildWindowItems
//	};
	

	
	
	this.Init();
}


