﻿/*
Jscript常用函数。
建议使用<script language="JavaScript" src="public/script.js" type="text/JavaScript"></script>方式使用此文件，不要直接包含。否则box函数可能找不到文件，但若能保证box能找到dialog.htm文件，可以将此文件包含。
*/
function checkBroswer() {
	if (navigator.userAgent.indexOf("MSIE")==-1) {
		alert("警告：本系统在Internet Explorer 5以上版本的系统下才能保证所有功能正常运行，您使用的浏览器不符合要求。");
	}
}

function regi(par,str) {
	var r,re; 
 	re= new RegExp(par);
 	return re.test(str);
	}

function win(url,width,height,scrollbar,wtop,wleft,wname) {	
	if (width==null || width=="") width=screen.availWidth-100;
	if (height==null || height=="") height=screen.availHeight-100;
	if (scrollbar!="no") scrollbar="yes";
	if (wname==null) wname="";
	if (wleft==null) wleft=(screen.availWidth-width)/2;
	if (wtop==null) wtop=(screen.availHeight-height-30)/2;
	if (!window.open(url,wname,'width='+width+',height='+height+',top='+wtop+',left='+wleft+',scrollbars='+scrollbar+',status=no,resizable=yes,toolbar=no,menubar=no,location=no')) {
		alert("窗口没有弹出成功，\n如果你正在使用某些拦截窗口的软件，请关闭它们。\n\n建议将本站列入受信任站点列表，以便防止类似错误。");
	}
	return;
}

function winMax(url,scrollbar) {	
	if (scrollbar!="no") scrollbar="yes";
	win(url,screen.availWidth-10,screen.availHeight-30,scrollbar,0,0);
	return;
}

function disableRight() {
	try {
		document.ondragstart = new Function("return false;");
		document.onselect = new Function("return false;");
		document.oncontextmenu = new Function("return false;");
	} catch (e) {
	}
	return;
}

function dialog(url,width,height,argu) {
	if (url==null || url=="") return false;
	if (width==null || width=="") width="450px";
	if (height==null || height=="") height="300px";
	if (argu==null || argu=="") argu=window;
	try {
		showModalDialog(url,argu,"dialogHeight:"+height+";dialogWidth:"+width+";scroll:0;center:1;resizable:0;status:0;help:0");
	} catch (e) {
		alert("窗口没有弹出成功，\n如果你正在使用某些拦截窗口的软件，请关闭它们。\n\n建议将本站列入受信任站点列表，以便防止类似错误。");
		return null;
	}
}

var boxUrl="";//加载文件的路径，供dialog.htm调用
var scriptUrl="";//dialog.htm和loading.htm文件的相对路径
var boxScroll="";//是否滚动，供dialog.htm调用
var boxTitle="";//标题，供dialog.htm调用
var boxIsLoading="";//是否滚动，供dialog.htm调用
function box(url,dialogUrl,width,height,scrollbar,t, isLoading, isReturnVal) {
	/*此函数返回一个模式对话框，并将url放置于dialog.htm的框架中，可用于提交表单或刷新
	但dialog.htm必须主动通过dialogArguments.boxUrl加载url
	注意：url相对于原文件，而不是相对于dialog.htm
	如果isLoading!="N"则先将loading.htm载入到框架中，url下载完毕再切换界面。
	*/
	if (url==null || url=="" || dialogUrl==null) { alert("调用box函数的参数不全"); return false;}
	if (width==null || width=="") width="450px";
	if (height==null || height=="") height="300px";
	if (scrollbar==null || scrollbar!="yes") scrollbar="no";
	if (t!=null) {boxTitle=t;}//标题
	if (isLoading!=null) {boxIsLoading=isLoading;}//是否显示欲载入画画，如果需要loading.htm必须和dialog.htm在同一目录
	
	argu=window;
	//如果需要欲载入而且不是绝对路径先切换成绝对路径 
	boxUrl=(isLoading=="N" || url.indexOf(":")!=-1 || url.substring(0,1)=="/") ? url : location.pathname.substring(0,location.pathname.lastIndexOf("/")+1)+url;
	scriptUrl=dialogUrl;
	boxScroll=scrollbar;
	try {
		var returnVal=showModalDialog(scriptUrl+"dialog.htm",argu,"dialogHeight:"+height+";dialogWidth:"+width+";scroll:0;center:1;resizable:1;status:0;help:0");
		if (!returnVal) {
			alert("窗口没有弹出成功，\n如果你正在使用某些拦截窗口的软件，请关闭它们。\n\n建议将本站列入受信任站点列表，以便防止类似错误。");
			return null;
		} else if (isReturnVal=='Y') {
			return returnVal;
		}
	} catch (e) {
		alert("窗口没有弹出成功，\n如果你正在使用某些拦截窗口的软件，请关闭它们。\n\n建议将本站列入受信任站点列表，以便防止类似错误。");
		return null;
	}
}

function resizeFont() {
	if (navigator.userAgent.indexOf("MSIE 5.5")!=-1 || navigator.userAgent.indexOf("MSIE 6")!=-1 || navigator.userAgent.indexOf("MSIE 7")!=-1) {
		document.write("<style type=\"text/css\"><!--body,div,span,input,select,option,textarea,pre,table {font-size: 9pt; font-family:Tahoma, Arial, Verdana;}--></style>");
	} else if (navigator.userAgent.indexOf("MSIE 5")!=-1) {
		//document.write("<style type=\"text/css\"><!--body,div,span,input,select,option,textarea,pre,table {font-size: 9pt; font-family:Tahoma, Arial, Verdana;}--></style>");
	}
}

function setDivWidth(divID, objLeft) {
	var obj=document.getElementById(divID);
	if (obj) {
		try {
			obj.style.width=document.body.clientWidth-obj.offsetLeft*2-(objLeft!=null ? objLeft : 0);
		} catch (e) {}
	}
}


function setDivHeight(divID, objTop) {
	var obj=document.getElementById(divID);
	if (obj) {
		try {
			obj.style.height=document.body.clientHeight-obj.offsetTop*2-(objTop!=null ? objTop : 0);
		} catch (e) {}
	}
}
//自动调用的函数
//checkBroswer();
//disableRight();
//resizeFont();