﻿/// 表示层 - 用户界面相关JS
/// 开始时间：2009-07-08
/// 结束时间：
/// 说　　明：负责处理客户端页面对象的相关操作的JS函数集合
/// 包　　括：LightBox显示、关闭及选项卡相关内容

/********************LightBox处理开始********************/
/***********************************************
显示MessageBox
All rights reserved

开始时间：2009-07-10
结束时间：2009-07-10
说　　明：显示MessageBox，并根据参数显示相应的
　　　　　按钮以及执行回调函数。在Buttons和
　　　　　ReturnValues中将各按钮相关内容以从右
　　　　　向左的方向书写。
参　　数：Icon:图标名（当前支持ok/err/info三种）
　　　　　Title:标题
　　　　　Message:文字信息，支持HTML
　　　　　Buttons:要显示的按钮文字，以“|||”分
　　　　　        隔
　　　　　ReturnValues:点击按钮后传入回调函数的
　　　　　             参数值，以“|||”分隔，
　　　　　             如需返回字符串，请将返回
　　　　　             值以引号包起来，例：
　　　　　             "'中文'|||'返回'|||'值'"
　　　　　CallBackFunction:回调函数
　　　　　ShowBlackBox:是否显示变暗的黑底
返 回 值：无
经测试的浏览器：ie6+, firefox2.0+,Opera9,Chrome
************************************************/
function MessageBox(Icon,Title,Message,Buttons,ReturnValues,CallBackFunction,ShowBlackBox)
{
	//显示对话框
	if(ShowBlackBox==1)
	{
		ShowLightBox("500","200",Title,1);
	}
	else
	{
		ShowLightBox("500","200",Title,0);
	}
	//生成对话框内容
	strHTML='<br /><table width="95%" border="0" cellspacing="0" cellpadding="0" style="margin:0;"><tr>';
	strHTML+='<td width="128" height="128" rowspan="2" align="center" valign="top">';
	strHTML+='<img src="/images/msgbox_icon_'+Icon+'.gif" width="128" height="128" />';	//对话框图标
	strHTML+='</td><td><p style="width:95%;margin:10px auto 0 auto;font-size:12px;color:#000;">';
	strHTML+=Message;	//对话框内容
	strHTML+='</p></td></tr><tr><td height="30" align="center" valign="middle">';
	/*处理按钮文本及返回值列表*/
	strBottonTexts=Buttons.split("|||");
	strReturnValues=ReturnValues.split("|||");
	for(i=0;i<strBottonTexts.length;i++)
	{
		strHTML+='<a href="javascript:'+CallBackFunction+'('+strReturnValues[i]+');" class="msgbox_botton">'+strBottonTexts[i]+'</a>';
	}
	strHTML+='</td></tr></table>';
	//显示内容
	setInnerHTML(Content,strHTML);
}

/***********************************************
显示Loading框
开始时间：2009-07-10
结束时间：2009-07-10
说　　明：在页面上显示Loading框
参　　数：MessageText:要显示的信息
返 回 值：无
经测试的浏览器：ie6+, firefox2.0+,Opera9,Chrome
************************************************/
function ShowLoadingBox(MessageText){
	//显示底框
	ShowLightBox("500","100","",1);
	//进度条图片及文字
	strTemp='<div class="loading"><p id="LoadingText">' + MessageText + '</p><img src="/images/loading.gif" alt="" /></div>';
	//输出内容
	LightBox.innerHTML=strTemp;
}

/***********************************************
显示LightBox及其背后的黑底
开始时间：2009-07-10
结束时间：2009-07-10
说　　明：显示LightBox及其背后的黑底
参　　数：BoxWidth:LightBox的宽度
　　　　　BoxHight:LightBox的高度
　　　　　BoxTitle:LightBox的标题文本
　　　　　ShowBlackBox:是否显示黑底
返 回 值：无
经测试的浏览器：ie6+, firefox2.0+,Opera9,Chrome
************************************************/
function ShowLightBox(BoxWidth,BoxHight,BoxTitle,ShowBlackBox){
	//隐藏下拉框
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) { 
		selects[i].style.display = "none"; 
	}
	if(ShowBlackBox==1){
		//显示变暗的底
		PageBody=document.getElementsByTagName("body")[0];
		BlackBox=document.createElement("div");
		BlackBox.id="BlackBox";
		BlackBox.style.height=window.screen.availHeight+"px";
		PageBody.appendChild(BlackBox);
	}
	//显示高亮框
	LightBox = document.createElement('div'); 
	LightBox.id = 'LightBox'; 
	//定位及尺寸
	LightBox.style.width=BoxWidth+"px";
	LightBox.style.height=BoxHight+"px";
	LightBox.style.top=((window.screen.availHeight-BoxHight)/2-100)+"px";
	LightBox.style.left=((document.body.clientWidth-BoxWidth)/2)+"px";
	if(BoxTitle!=''){
		//显示标题栏
		LightBox.innerHTML = '<div class="title"><h1>' + BoxTitle + '</h1><a href="javascript:CloseLightBox();" title="关闭" id="LightBoxClose"><img src="images/lightboxclose.gif" alt="" /></a></div>'; 
	}
	PageBody.appendChild(LightBox);
	//加入内容层
	Content=document.createElement("div");
	Content.id="Content";
	LightBox.appendChild(Content);
}

/***********************************************
关闭整个LightBox包括黑底
开始时间：2009-07-10
结束时间：2009-07-10
说　　明：关闭整个LightBox包括黑底
参　　数：无
返 回 值：无
经测试的浏览器：ie6+, firefox2.0+,Opera9,Chrome
************************************************/
function CloseLightBox(){
	//取页面对象
	PageBody=document.getElementsByTagName("body")[0];
	//删除高亮框和暗底
	if(document.getElementById("BlackBox")!=null)
		PageBody.removeChild(BlackBox);
	PageBody.removeChild(LightBox);
	//显示下拉框
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) { 
		selects[i].style.display = ""; 
	}
}
/********************LightBox处理结束********************/

/***********************************************
切换选项卡函数
开始时间：2009-07-10
结束时间：2009-07-10
说　　明：切换选项卡的显示状态及样式
参　　数：tabName 要切换的选项卡组的id前缀
　　　　　contentName 要切换的选项卡组的内容id前缀
　　　　　tabid 要切换为当前选项卡的编号
　　　　　currentStyle 当前选项卡的CSS Class
　　　　　normalStyle 非当前选项卡的CSS Class
　　　　　totalTabNumber 选项卡总数
返 回 值：无
经测试的浏览器：ie6+, firefox2.0+,Opera9,Chrome
************************************************/
function showtab(tabName,contentName,tabid,currentStyle,normalStyle,totalTabNumber)
{
	for(i=1;i<=totalTabNumber;i++)
	{
		if(i==tabid)
		{//当前选项卡
			document.getElementById(tabName+i).className=currentStyle;
			document.getElementById(contentName+i).style.display="";
		}
		else
		{//非当前选项卡
			document.getElementById(tabName+i).className=normalStyle;
			document.getElementById(contentName+i).style.display="none";
		}
		//消除焦点虚框
		document.getElementById(tabName+i).blur();
	}
}


/********************************************************/
function ShowScreenInfo(){
	var  s = ""; 
	s += "\r\n网页可见区域宽："+ document.body.clientWidth; 
	s += "\r\n网页可见区域高："+ document.body.clientHeight; 
	s += "\r\n网页可见区域宽："+ document.body.offsetWidth  +" (包括边线和滚动条的宽)"; 
	s += "\r\n网页可见区域高："+ document.body.offsetHeight +" (包括边线的宽)"; 
	s += "\r\n网页正文全文宽："+ document.body.scrollWidth; 
	s += "\r\n网页正文全文高："+ document.body.scrollHeight; 
	s += "\r\n网页被卷去的高："+ document.body.scrollTop; 
	s += "\r\n网页被卷去的左："+ document.body.scrollLeft; 
	s += "\r\n网页正文部分上："+ window.screenTop; 
	s += "\r\n网页正文部分左："+ window.screenLeft; 
	s += "\r\n屏幕分辨率的高："+ window.screen.height; 
	s += "\r\n屏幕分辨率的宽："+ window.screen.width; 
	s += "\r\n屏幕可用工作区高度："+ window.screen.availHeight; 
	s += "\r\n屏幕可用工作区宽度："+ window.screen.availWidth; 
	s += "\r\n你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色"; 
	s += "\r\n你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸"; 
	alert(s); 
}
/********************************************************/
 

