////////////////////Ajax////////////Class///////////////////
//Power By Gloot CopyRight @2006
//Edit Section for weiseditor.com
//Blog http://blog.sina.com.cn/tecz
//QQ 345268267
///////////////////////////////////////////////////////////

//scrollTop, w3c Use documentElement Else body
var $ = function(el){return document.getElementById(el);};
window.PWindow = (function(){var win = null;win = window;while(win!=win.parent){if (!win.parent){return  win;}win = win.parent;}return win;})();
window.PDocument = window.PWindow.document;
var $P = function(el){return window.PDocument.getElementById(el);};
window.isIE = (navigator.appName.toLowerCase() == "microsoft internet explorer");

var CoverScreen = function(){this.Config.dialogBColor = '#FFA500';this.Config.dialogHTML = '';}

CoverScreen.prototype.Config = {
	dialogWidth:0,
	dialogHeight:0,
	dialogHTML:"",
	dialogBColor:"#FFA500"
}
CoverScreen.prototype.DialogPanel = function()
{

	var ScreenPanel = $P('Screenfloor');
	if (!ScreenPanel) ScreenPanel = window.PDocument.createElement("div");
	
	ScreenPanel.id = "Screenfloor";
	ScreenPanel.style.display = "block";
	ScreenPanel.style.top = ScreenPanel.style.left = ScreenPanel.style.margin = ScreenPanel.style.padding = "0px";

	var _h ;
	//error in w3c documentElement > body
	var scrollHeight = Math.max(window.PDocument.documentElement.scrollHeight,window.PDocument.body.scrollHeight);
	if (window.PDocument.body.scrollHeight)
	{
		_h = Math.max(scrollHeight,window.screen.availHeight) ;
	}
	else if (window.PWindow.innerHeight)
		_h = window.PWindow.innerHeight;
	else
		_h = "100%";
		
	var hideHeight = Math.max(window.PDocument.documentElement.scrollTop,window.PDocument.body.scrollTop); //滚动条上部隐藏部分
	
	ScreenPanel.style.width = window.isIE ? window.PDocument.body.clientWidth+"px" : "100%";
	
	//alert(_h + ' ' + hideHeight + ' ' + scrollHeight + ' ' + window.screen.availHeight + ' ' + document.body.scrollHeight);
	if (window.isIE)
		ScreenPanel.style.height = (_h + 30) + "px";
	else
		ScreenPanel.style.height = (_h) + "px"; //不加hideHeight，不然document.documentElement.scrollTop会一直增长,firefox
	
	ScreenPanel.style.position = "absolute";
	//ScreenPanel.style.zindex = "3";
	
	ScreenPanel.style.background = "#cccccc";
	
	ScreenPanel.style.filter = "alpha(opacity=50)";
	
	ScreenPanel.style.opacity = 40/100;

	ScreenPanel.style.MozOpacity = 40/100;
	
	ScreenPanel.style.fontSize = '12px';

	//Editor.Config.HideScrollHeight = hideHeight;	
	///////////////////////////////////////////////////////////////////
	
	window.PDocument.body.appendChild(ScreenPanel);
	
	var allselect = window.PDocument.getElementsByTagName("select");

	for (var i=0; i<allselect.length; i++) 
		allselect[i].style.visibility = "hidden";
}

CoverScreen.prototype.dialogShow = function(CS,F)
{

	var hideHeight = Math.max(window.PDocument.documentElement.scrollTop,window.PDocument.body.scrollTop); 
	if (window.innerWidth)
	{	
		var ww = window.PWindow.innerWidth;
		var wh = window.PWindow.innerHeight;
	}
	else
	{
		var ww = window.PDocument.documentElement.offsetWidth;
		var wh = window.PDocument.documentElement.offsetHeight ;	
	}
	
	//alert(wh + ' ' + document.body.offsetHeight + ' ' + document.documentElement.offsetHeight + ' ' + window.innerHeight);
	
	//var CS = new CoverScreen();
	var dialogLeft = ((ww / 2) - (CS.Config.dialogWidth / 2));
	var dialogTop = ((wh / 2) - (CS.Config.dialogHeight / 2));
	
	//alert(dialogLeft + " " + dialogTop)
	
	var dialogPanel = $P('dialogPanel');
	if (!dialogPanel) dialogPanel = window.PDocument.createElement("div");
	
	dialogPanel.id = "dialogPanel";
	if (window.isIE) 
		dialogPanel.style.display = "block"; 
	else 
		dialogPanel.style.display = "table";
		
	dialogPanel.style.background = "#ffffff";

	dialogPanel.style.position = "absolute";

	dialogPanel.style.left = dialogLeft + "px";
	dialogPanel.style.top = (dialogTop + hideHeight) + "px";
	dialogPanel.style.border = "1px solid " + CS.Config.dialogBColor;
	dialogPanel.style.width = CS.Config.dialogWidth + "px";
	dialogPanel.style.fontSize = '12px';
	dialogPanel.style.height = CS.Config.dialogHeight + "px";
	
	dialogPanel.style.padding = "0px";
	//dialogPanel.style.zindex = "5";
	//dialogPanel.tabIndex = '5';
	
	//dialogPanel.innerHTML = CS.Config.dialogHTML;
	dialogPanel.appendChild(F);
	
	window.PDocument.body.appendChild(dialogPanel);
	
}

CoverScreen.prototype.IfrDialog = function(title,type,pageOrHtml,CS)
{
	var F = $P('ifrDialog');
	if(!F) F=window.PDocument.createElement('iframe');
	F.style.display = '';
	
	F.id = 'ifrDialog';
	F.src = '/js/dialog.html?e='+Math.random();
	F.width = '100%';
	F.height = '100%';
	F.frameBorder = '0';
	F.hspace = '0';
	F.vspace = '0';
	F.scrolling = 'no';
	F.unselectable = 'on';
	F.FuncType = '';
	F.CSWindow = {Title:title,Editor:window,Type:type,Page:pageOrHtml,BGColor:CS.Config.dialogBColor};
	return F;
}

CoverScreen.prototype.HidePanel = function()
{
	var ScreenPanel = $P('Screenfloor');
	if (ScreenPanel) 
	{
		ScreenPanel.style.display = "none"; 
		//ScreenPanel.outerHTML = "";
	}
	
	var dialogPanel = $P('dialogPanel');
	if (dialogPanel)
	{
		dialogPanel.style.display = "none"; 
		//dialogPanel.outerHTML = "";
	}
	

	var _fSetID = $P('FSetID'); 
	if (_fSetID) 
	{
		_fSetID.style.display = 'none';
		_fSetID.outerHTML = "";
	}
	var _fsetoutid = $P('fsetoutid'); 
	if (_fsetoutid) 
	{
		_fsetoutid.style.display = 'none';
		_fsetoutid.outerHTML = "";
	}
	
	var F = $P('ifrDialog');
	if (F) 
	{
		F.style.display = 'none';
		F.outerHTML = "";
	}
	
	var allselect = document.getElementsByTagName("select");

	for (var i=0; i<allselect.length; i++) 
		allselect[i].style.visibility = "visible";
	
}

