﻿

function displayLayer(obj,layer){
	
	var dv = document.getElementById(layer);

	//如果没有对应的层，以layer参数为内容创建新层


	if(!dv){
		dv = CreateLayer(layer);
	}
	
	DivSetVisible(dv);
	//如果指定了参照对象，位置在参照对象下
	if(obj){
		GetObjXY_ForLayer(obj, dv);
	}
	else{
		GetCenterXY_ForLayer(dv);
	}
	
	
	/*下面是添加阴影代码，如果不需要阴影可以删除*/
	if(!dv.getAttribute("AllowDrop")){	//对于可拖动的层，不能加阴影


		BuidShadow(dv);	
	}
	
}

/*
function hiddenLayer(layerID){
	showElementAll();

	var dv = document.getElementById(layerID);

	dv.style.display = "none";
	
	//销毁层的阴影，如果没有设置阴影删除这段代码
	if(!dv.getAttribute("AllowDrop")){	//对于可拖动的层，不能加阴影


		DestroyShadow(dv);
		
	}else{
		//如果是可拖动的层，一般是对话框


		//销毁对话框底下的锁定层(如果有的话)
		var lockPageDiv = document.getElementById("LockPageDiv");
		if(lockPageDiv){
			if(window.event){
				//IE
				lockPageDiv.removeNode(true);
			}else{
				//FireFox
				lockPageDiv.parentNode.removeChild(lockPageDiv)
			}
		}
		
	}
	
}
*/

function hiddenLayer(layerID,gotoUrl){

	showElementAll();

	var dv = document.getElementById(layerID);

	dv.style.display = "none";
	
	/*销毁层的阴影，如果没有设置阴影删除这段代码*/
	if(!dv.getAttribute("AllowDrop")){	//对于可拖动的层，不能加阴影


		DestroyShadow(dv);
		
	}else{
		//如果是可拖动的层，一般是对话框


		//销毁对话框底下的锁定层(如果有的话)
		var lockPageDiv = document.getElementById("LockPageDiv");
		if(lockPageDiv){
			if(window.event){
				//IE
				lockPageDiv.removeNode(true);
			}else{
				//FireFox
				lockPageDiv.parentNode.removeChild(lockPageDiv)
			}
		}
		
	}
	
	if(gotoUrl)
	{
		location.href = gotoUrl;
	}
}

//将悬浮层的位置定位在屏幕中央
function GetCenterXY_ForLayer(objdiv){
	var ww,wh,bgX,bgY;
	var dde = document.documentElement;
	
	if (window.innerWidth) {
	   ww = window.innerWidth;
	   wh = window.innerHeight;
	   bgX = window.pageXOffset;
	   bgY = window.pageYOffset;
	} else {
	   ww = dde.offsetWidth;
	   wh = dde.offsetHeight;
	   bgX = dde.scrollLeft;
	   bgY = dde.scrollTop;
	}
	
	var t_DiglogW = parseInt(objdiv.offsetWidth);
	var t_DiglogH = parseInt(objdiv.offsetHeight);
	
	var t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
	var t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
	
	if(t_DiglogY > 100){
		//Y轴位置取黄金分割点


		t_DiglogY *= 0.658;
	}
	
	objdiv.style.top = t_DiglogY + "px";
	objdiv.style.left = t_DiglogX + "px";
	
	//把层覆盖下的表单元素隐藏
	hideElementAll(objdiv);
	
	//设置对话框底下的锁定层宽度和高度(如果有的话)
	//使其平铺整个窗口。


	var lockPageDiv = document.getElementById("LockPageDiv");
	if(lockPageDiv){
		var arrPageSize = getPageSize();
		var width = arrPageSize[0] > arrPageSize[2] ? arrPageSize[0] : arrPageSize[2];
		var height = arrPageSize[1] > arrPageSize[3] ? arrPageSize[1] : arrPageSize[3];
		lockPageDiv.style.width = width + "px";
		lockPageDiv.style.height = height + "px";
		//alert(arrPageSize + "\n" + width + "," + height);
		
	}
	
}



//将悬浮层的位置定位在指定对象旁边
function GetObjXY_ForLayer(obj, div){
	
	//var left = obj.offsetWidth - 2; 
	//var top = 5; 
	
	//就放在左下方的位置


	var left = -2; 
	var top = obj.offsetHeight - 2; 
	
	if(inLayer(obj)){
		var pos = getPosLeft_Top(obj);
		left += pos.left;
		top += pos.top;
	}else{
		left += getPosLeft(obj); 
		top += getPosTop(obj); 
	}
	
	var pageSize = getPageSize()[2];
	//alert(pageSize);
	if(left + div.offsetWidth >= pageSize - 6){
		left = pageSize - div.offsetWidth - 6;
	}
	
	div.style.top = top  + "px";
	div.style.left = left + "px";
	
	//把层覆盖下的表单元素隐藏
	hideElementAll(div);
	
}


//返回X，Y坐标（在浮动层上面的元素）


function getPosLeft_Top(obj){
	var l = obj.offsetLeft; 
	var t = obj.offsetTop; 
	while(obj = obj.offsetParent) 
	{ 
		if(obj.className == "DragLayer" || obj.style.position == "absolute"){
			break;
		}
		l += obj.offsetLeft; 
		t += obj.offsetTop; 
	} 
	
	return {left:l,top:t};

}

//检查对象是否在浮动层之中


function inLayer(obj){
	var inlayer = false;
	while(obj = obj.offsetParent) 
	{ 
		if(obj.className == "DragLayer" || obj.style.position == "absolute"){
			inlayer = true;
			break;
		}
	} 
	
	return inlayer;
}

function getPosLeft(obj) 
{ 
	var l = obj.offsetLeft; 
	while(obj = obj.offsetParent) 
	{ 
		l += obj.offsetLeft; 
	} 
	return l; 
}

function getPosTop(obj) 
{ 
	var t = obj.offsetTop; 
	while(obj = obj.offsetParent) 
	{ 
		t += obj.offsetTop; 
	} 
	return t; 
}


//检查两个对象是否重叠


function CheckOverlay(a,b){

	if(a.style.display == "none"){
		a.style.display = "block";
	}
	var a_left = getPosLeft(a);
	var a_width = parseInt(a.offsetWidth);
	var a_top = getPosTop(a);
	var a_height = parseInt(a.offsetHeight);
	
	if(b.style.display == "none"){
		b.style.display = "block";
	}
	var b_left = getPosLeft(b);
	var b_width = parseInt(b.offsetWidth);
	var b_top = getPosTop(b);
	var b_height = parseInt(b.offsetHeight);
	
	//alert(b.id);
	//alert(a_left + "," + a_top + "," + a_width + "," + a_height + "\n" + b_left + "," + b_top + "," + b_width + "," + b_height);
	
	if(
		a_left <= (b_left + b_width) && 
		(a_left + a_width) >= b_left && 
		a_top <= (b_top + b_height)  &&
		(a_top + a_height) >= b_top
	  ){
		return true;
	}
	else{
		return false;
	}
	
	
}



//检查一个对象中是否包了子对象


function Contains(parent, child){
	var ret = false;
	var upNode = child;
	while(upNode){
		if(upNode == parent){
			ret = true;
			break;
		}
		
		upNode = upNode.parentNode;
	}
	
	return ret;
}

function DivSetVisible(objDiv){
	objDiv.style.display = "block";
}


function hideElementAll(overlayDiv){
	HideElement("SELECT",overlayDiv);
	HideElement("OBJECT",overlayDiv);
	//HideElement("IFRAME");
	
	//Hide scroll
	
	window.HiddenElementAll = true;
	
	
}

function showElementAll(){


	ShowElement("SELECT");
	ShowElement("OBJECT");
	//ShowElement("IFRAME");
	
	//Show scroll
	
	window.HiddenElementAll = false;
}


function HideElement(strElementTagName, overlayDiv){
	
	try{
		var tags = document.getElementsByTagName(strElementTagName);
		for(i=0;i<tags.length; i++){
			var objTemp = tags[i];
			if(overlayDiv){
				//检查是在遮罩层下面，且不是层的子元素


				if(CheckOverlay(objTemp,overlayDiv) && !Contains(overlayDiv, objTemp)){
					objTemp.style.visibility = "hidden";
				}
			}
			else{
				objTemp.style.visibility = "hidden";
			}
			//objTemp.style.display = "none";
			
		}
	}catch(e){
		alert(e.message);
	}
	
}

function ShowElement(strElementTagName){
	try{
		var tags = document.getElementsByTagName(strElementTagName);
		for(i=0;i<tags.length; i++){
			
			var objTemp = tags[i];
			objTemp.style.visibility = "visible";
			//objTemp.style.display = "";
			
		}
	}catch(e){
		alert(e.message);
	}
	
}


function CreateLayer(layerHTML){
	var doc = document;
	var div = doc.createElement("DIV");
	div.id = "_tempLayer";
	//div.zIndex = "0";
	//div.style.left = "0px";
	//div.style.top = "0px";
	//div.style.width = doc.documentElement.scrollLeft;
	//div.style.height = doc.documentElement.scrollHeight;
	div.style.position = "absolute";
	//div.style.backgroundColor = "#EFEFEF";
	div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	div.innerHTML = layerHTML;
	
	doc.body.appendChild(div);

	return div;
	
}


// Example:
// onMouseOver="PopFloatMenu(this, 'tool tip text here')";
// onMouseOut="PopFloatMenu()"; 
function PopFloatMenu(obj, msg)
{

	var floatMenuSTYLE="";
  	var floatMenuDIV = document.getElementById(msg);
	
	if(!floatMenuDIV)		//如果没有DIV则先创建
  	{
		var doc = document;
		var floatMenuDIV = doc.createElement("DIV");
		floatMenuDIV.style.position = "absolute";
		doc.body.appendChild(floatMenuDIV);
		
		//填充内容
		floatMenuDIV.innerHTML=msg;
	}
	
    floatMenuDIV.style.display = "";
	
	GetObjXY_ForLayer(obj, floatMenuDIV);
	
	/*下面是添加阴影代码，如果不需要阴影可以删除*/
	BuidShadow(floatMenuDIV);	
	
	window.floatMenuSender = obj;

	floatMenuDIV.onmouseout = function (event){
		var e = event || window.event;
		HiddenFloatMenu(e, floatMenuDIV);
	}
	obj.onmouseout = floatMenuDIV.onmouseout;
	document.body.onmouseover = floatMenuDIV.onmouseout;
	//floatMenuDIV.onclick = floatMenuDIV.onmouseout;
	
}

function HiddenFloatMenu(e, floatMenuDIV){
	if(floatMenuDIV.style.display == "")
  	{
		//e = e ? e : window.event;
		var onObj = e.srcElement ? e.srcElement : e.target;
		
		//获取当前鼠标位置
		var mouseLoc = getMouseLoc(e);
		
		//当鼠标没离开远时不关闭菜单
		var sender = window.floatMenuSender;
		var left = getPosLeft(sender);
		var width = parseInt(sender.offsetWidth);
		var top = getPosTop(sender);
		var height = parseInt(sender.offsetHeight);
		
		var left1 = getPosLeft(floatMenuDIV);
		var width1 = parseInt(floatMenuDIV.offsetWidth);
		var top1 = getPosTop(floatMenuDIV);
		var height1 = parseInt(floatMenuDIV.offsetHeight);

		
		var mouseX = mouseLoc.x;
		var mouseY = mouseLoc.y;

		//如果是IE，加上已滚动过的页面区域
		if(window.event){
			mouseX += document.documentElement.scrollLeft;
			mouseY += document.documentElement.scrollTop;
		}
			
		if(
			(mouseX < left - 10 || mouseX > left + width + 10 || mouseY < top - 10 || mouseY > top + height + 10) &&
			(mouseX < left1 - 10 || mouseX > left1 + width1 + 10 || mouseY < top1 - 10 || mouseY > top1 + height1 + 10)
		)
		{	
			floatMenuDIV.style.display = "none";
			//document.onclick = null;
				
			/*销毁层的阴影，如果没有设置阴影删除这段代码*/
			DestroyShadow(floatMenuDIV)

			showElementAll();
		}
	}
	
}



// Example:
// onMouseOver="PopFloatMenu(this, 'tool tip text here')";
// onMouseOut="PopFloatMenu()"; 
function DropDownMenu(e, obj, msg)
{
  	var floatMenuDIV = document.getElementById(msg);
	
	if(!floatMenuDIV)		//如果没有DIV则先创建
  	{
		var doc = document;
		var floatMenuDIV = doc.createElement("DIV");
		floatMenuDIV.style.position = "absolute";
		floatMenuDIV.className = "DropDownMenu";
		doc.body.appendChild(floatMenuDIV);
		
		//填充内容
		floatMenuDIV.innerHTML=msg;
		floatMenuDIV.style.display = "none";
	}
	
	//如果是点击事件，且已经显示了，则隐藏
	if(floatMenuDIV.style.display == "none"){
		floatMenuDIV.style.display = "";

		GetObjXY_ForLayer(obj, floatMenuDIV);
		
		
		//把层覆盖下的表单元素隐藏
		hideElementAll(floatMenuDIV);

		document.onclick = function DocClick_HiddenDownMenu (event){
			var ev = event || window.event;
			var onObj = ev.srcElement ? ev.srcElement : ev.target;
			if(!Contains(floatMenuDIV, onObj) && onObj != obj){
				HiddenDownMenu(ev, floatMenuDIV);
			}
		}
		
	}
	else if(!e.keyCode){
		HiddenDownMenu(null, floatMenuDIV);
	}
	
	
	
}


function HiddenDownMenu(e, floatMenuDIV){
	if(floatMenuDIV.style.display == "none"){
		return;
	}
	
	//e = e ? e : window.event;
	//如果没有指定事件，直接隐藏


	if(!e){
		floatMenuDIV.style.display = "none";
		showElementAll();
	}
	else{
		var onObj = e.srcElement ? e.srcElement : e.target;
		var container = floatMenuDIV.parentNode;
		
		//如果触发对象是内部组件，不作处理
		if(Contains(container, onObj)){
			return;
		}
		else{
			floatMenuDIV.style.display = "none";
			showElementAll();
		}
	}
		
}


//鼠标位置对象
function Point(x,y) 
{   
	var x,y;
	this.x = x; 
	this.y = y; 
}

//获取鼠标位置
function getMouseLoc(e)
{

	var mouseLocation = new Point(0,0);
	
	e = e ? e : (window.event ? window.event : null);
	
	if(e.pageX)		//FireFox浏览器




	{
		mouseLocation.x = e.pageX + document.body.scrollLeft;
		mouseLocation.y = e.pageY + document.body.scrollTop;
	}
	else			//IE
	{
    	mouseLocation.x = event.x + document.body.scrollLeft;
    	mouseLocation.y = event.y + document.body.scrollTop;
	}
	
	return mouseLocation;
}

//获取页面大小或窗口大小，返回是一个长度为4的数组


function getPageSize(){

	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}



//为指定层建造阴影


function BuidShadow(div){
	var shadowDiv = document.getElementById(div.id + "_shadow");
	if(!shadowDiv){
		shadowDiv = document.createElement("DIV");
		shadowDiv.id = div.id + "_shadow";
		div.parentElement.insertBefore(shadowDiv, div);
	}
	
	
	shadowDiv.style.position = "absolute";
	if(div.style.zIndex > 0){
		shadowDiv.style.zIndex = div.style.zIndex - 1;
	}
	shadowDiv.style.width = div.offsetWidth;
	shadowDiv.style.height = div.offsetHeight;
	shadowDiv.style.backgroundColor = "#AAAAAA";
	
	shadowDiv.style.top = (parseInt(div.style.top) + 3) + "px";
	shadowDiv.style.left = (parseInt(div.style.left) + 2) + "px";
	
	//alert(div.style.top);
}


//销毁指定层阴影
function DestroyShadow(div){
	//var shadowDiv = div.previousSibling;
	var shadowDiv = document.getElementById(div.id + "_shadow");
	if(shadowDiv){
		if(window.event){
			//IE
			shadowDiv.removeNode(true);
		}else{
			//FireFox
			shadowDiv.parentNode.removeChild(shadowDiv)
		}
	}
}














































function displayLayer(obj,layer){
	
	var dv = document.getElementById(layer);
	
	//如果没有对应的层，以layer参数为内容创建新层

	if(!dv){
		dv = CreateLayer(layer);
	}
	
	DivSetVisible(dv);
		
	//如果指定了参照对象，位置在参照对象下
	if(obj){
		GetObjXY_ForLayer(obj, dv);
	}
	else{
		GetCenterXY_ForLayer(dv);
	}
	
}

function hiddenLayer(layerID){

	showElementAll();

	var dv = document.getElementById(layerID);

	dv.style.display = "none";
	
}

function hiddenLayer(layerID,gotoUrl){

	showElementAll();

	var dv = document.getElementById(layerID);

	dv.style.display = "none";
	if(gotoUrl)
	{
		location.href = gotoUrl;
	}
}


//将悬浮层的位置定位在屏幕中央
function GetCenterXY_ForLayer(objdiv){
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
	
	//获取屏幕宽度
	//availWidth = parseInt(window.screen.availWidth);
	//availHeight = parseInt(window.screen.availHeight);

	availWidth = parseInt(document.body.clientWidth);
	availHeight = parseInt(document.body.clientHeight);
	
	tblWidth = parseInt(objdiv.offsetWidth);	
		
	y = y + availHeight/10;
	x = (availWidth - tblWidth)/2;
	objdiv.style.top = y + "px";
	objdiv.style.left = x + "px";
}



//将悬浮层的位置定位在指定对象旁边
function GetObjXY_ForLayer(obj, div){
	
	//var left = obj.offsetWidth - 2; 
	//var top = 5; 
	
	//就放在左下方的位置

	var left = -2; 
	var top = obj.offsetHeight - 1; 
	
	left += getPosLeft(obj); 
	top += getPosTop(obj); 
	
	div.style.top = top  + "px";
	div.style.left = left + "px";
	
}


function getPosLeft(obj) 
{ 
	var l = obj.offsetLeft; 
	while(obj = obj.offsetParent) 
	{ 
		l += obj.offsetLeft; 
	} 
	return l; 
}

function getPosTop(obj) 
{ 
	var t = obj.offsetTop; 
	while(obj = obj.offsetParent) 
	{ 
		t += obj.offsetTop; 
	} 
	return t; 
}


function DivSetVisible(objDiv){
	hideElementAll();
	objDiv.style.display = "block";
}

function hideElementAll(){
	HideElement("SELECT");
	HideElement("OBJECT");
	HideElement("IFRAME");
}

function showElementAll(){
	ShowElement("SELECT");
	ShowElement("OBJECT");
	ShowElement("IFRAME");
}


function HideElement(strElementTagName){
	/*
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "hidden";
		}
	}catch(e){
		alert(e.message);
	}
	*/
}

function ShowElement(strElementTagName){
	/*
	try{
		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){
			var objTemp = window.document.all.tags(strElementTagName)[i];
			objTemp.style.visibility = "visible";
		}
	}catch(e){
		alert(e.message);
	}
	*/
}


function CreateLayer(layerHTML){
	var doc = document;
	var div = doc.createElement("DIV");
	div.id = "_tempLayer";
	//div.zIndex = "0";
	//div.style.left = "0px";
	//div.style.top = "0px";
	//div.style.width = doc.documentElement.scrollLeft;
	//div.style.height = doc.documentElement.scrollHeight;
	div.style.position = "absolute";
	//div.style.backgroundColor = "#EFEFEF";
	div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
	div.innerHTML = layerHTML;
	
	doc.body.appendChild(div);

	return div;
	
}


// Example:
// onMouseOver="PopFloatMenu(this, 'tool tip text here')";
// onMouseOut="PopFloatMenu()"; 

function PopFloatMenu(obj, msg)
{

	var floatMenuSTYLE="";
  	var floatMenuDIV = document.getElementById(msg);
	
	if(!floatMenuDIV)		//如果没有DIV则先创建
  	{
		var doc = document;
		var floatMenuDIV = doc.createElement("DIV");
		floatMenuDIV.style.position = "absolute";
		doc.body.appendChild(floatMenuDIV);
		
		//填充内容
		floatMenuDIV.innerHTML=msg;
	}
	
    floatMenuDIV.style.display = "";
	
	GetObjXY_ForLayer(obj, floatMenuDIV);
	//document.onmouseover = HiddenFloatMenu;
	floatMenuDIV.onmouseout = HiddenFloatMenu;
}


function HiddenFloatMenu(e){
	
	e = e ? e : window.event;
	var floatMenuDIV = e.srcElement ? e.srcElement : e.target;
	
	if(floatMenuDIV.href){
		return;
	}
	
	//获取当前鼠标位置
	var mouseLoc = getMouseLoc(e);
	
	if(floatMenuDIV)
  	{
		//当鼠标没离开远时不关闭菜单

		var left = getPosLeft(floatMenuDIV);
		var width = parseInt(floatMenuDIV.offsetWidth);
		var top = getPosTop(floatMenuDIV);
		var height = parseInt(floatMenuDIV.offsetHeight);
		
				
		if(mouseLoc.x < left + 2 || mouseLoc.x > left + width - 2 || mouseLoc.y < top + 2 || mouseLoc.y > top + height - 2)
		{	
			floatMenuDIV.style.display = "none";
			document.onmouseover = null;
		}
	}
	
}



//鼠标位置对象
function Point(x,y) 
{   
	var x,y;
	this.x = x; 
	this.y = y; 
}

//获取鼠标位置
function getMouseLoc(e)
{

	var mouseLocation = new Point(0,0);
	
	e = e ? e : (window.event ? window.event : null);
	
	if(e.pageX)		//FireFox浏览器

	{
		mouseLocation.x = e.pageX + document.body.scrollLeft;
		mouseLocation.y = e.pageY + document.body.scrollTop;
	}
	else			//IE
	{
    	mouseLocation.x = event.x + document.body.scrollLeft;
    	mouseLocation.y = event.y + document.body.scrollTop;
	}
	
	return mouseLocation;
}


//获取页面大小或窗口大小，返回是一个长度为4的数组

function getPageSize(){

	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}


/************拖拽层(只限IE)*************/
var  ms; 
function  MoveWithMouse(obj,e){
	e = e ? e : (window.event ? window.event : null);
	ms = document.getElementById(obj);

	var srcEle = e.srcElement ? e.srcElement : e.target;
	 
    srcEle.setCapture();  
    x = ms.style.pixelLeft - e.clientX; 
    y = ms.style.pixelTop - e.clientY;
} 
 
function  document.onmousemove(){ 
    if(ms){  
      ms.style.pixelLeft=x+window.event.clientX; 
      ms.style.pixelTop=y+window.event.clientY;
   } 
} 
 
function  document.onmouseup(e){ 
   if(ms){ 
	 e = e ? e : (window.event ? window.event : null);
	 var srcEle = e.srcElement ? e.srcElement : e.target;
     srcEle.releaseCapture(); 
     ms = null; 
    } 
}
           
/*************************页框选择*******************/
	function SelectTab(obj, panel){
	
		//高亮度显示TAB
		var tabList = obj.parentNode;
		for (var i=0;i<tabList.childNodes.length;i++) 
		{ 
			var node = tabList.childNodes[i]; 
						
			if (node.tagName == obj.tagName) 
			{ 
				node.className = "";
			} 

		} 
					
		obj.className = "Current";
		
		
		//显示当前面板
		var currentDiv = document.getElementById(panel);
		var parentDiv = currentDiv.parentNode;

		for (var i=0;i<parentDiv.childNodes.length;i++) 
		{ 
			var node = parentDiv.childNodes[i]; 
						
			if (node.tagName == currentDiv.tagName && node.className == currentDiv.className) 
			{ 
					node.style.display = "none";
			} 

		}
		
		currentDiv.style.display = "";

	}

           

/*************************自定义窗口*****************/

//弹出错误信息
function MessageBox(msg, type){
	var Message = document.getElementById("Message");
	if(Message){
		var PopMessage = document.getElementById("PopMessage");
		var MessageIcon = document.getElementById("MessageIcon");
		Message.innerHTML = msg;
		switch(type){
			case 0:
				PopMessage.className="PopInformation";
				MessageIcon.src="/Skins/" + language + "/" + skin + "/images/infoicon.gif";
				break;
			case 1:
				PopMessage.className="PopSuccess";
				MessageIcon.src="/Skins/" + language + "/" + skin + "/images/successicon.gif";
				break;
			case 2:
				PopMessage.className="PopError";
				MessageIcon.src="/Skins/" + language + "/" + skin + "/images/erroricon.gif";
				break;
		}
		displayLayer(null,"PopMessage");
	}else{
		alert(msg);
	}
}
function MessageBox(){
	displayLayer(null, "PopMessage");
}
