﻿/*
Import("LeadingMIS");
Import("LeadingMIS.Error");
Import("LeadingMIS.ValueType");
Import("LeadingMIS.ValueType.SQL");
Import("LeadingMIS.UI");
Import("LeadingMIS.UI.ButtonList");
Import("LeadingMIS.UI.Validate");
Import("LeadingMIS.WebService");
Import("LeadingMIS.WebService.Convert");
Import("LeadingMIS.Cookie");
*/
function Import(nameSpace)
{
	window.execScript(Load(getNameSpaceSource(nameSpace)),"javascript");
}

function getNameSpaceSource(nameSpace)
{
	var strPath = "";
	strPath = "/Common/BaseClassLibrary/" + nameSpace + ".js";
	return strPath;
}

function Load(nameSpaceSource, SetXml)
{
	var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttp.open("GET",nameSpaceSource,false);
	xmlHttp.send(SetXml);
	// 如果编码类型是 ASCII,用 ASCIICoding(xmlHttp.responseBody) 进行编码
	// 如果编码类型是 Unicode,用 xmlHttp.responseText
	if(xmlHttp.status == 200 || xmlHttp.status == 0)
	{
		return ASCIICoding(xmlHttp.responseBody);
	//	return xmlHttp.responseText;
	}
	else
	{
		return null;
	}
}

 
/*

返回两个日期之间的时间间隔。 

	DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])

	interval

		必选项。String expression 表示用于计算 date1 和 date2 之间的时间间隔。有关数值，请参阅“设置”部分。

	date1, date2

		必选项。日期表达式。用于计算的两个日期。

	Firstdayofweek

		可选项。指定星期中第一天的常数。如果没有指定，则默认为星期日。有关数值，请参阅“设置”部分。

	Firstweekofyear

		可选项。指定一年中第一周的常数。如果没有指定，则默认为 1 月 1 日所在的星期。有关数值，请参阅“设置”部分。
 */
function DateDiff(interval,date1,date2,firstdayofweek,firstdayofyear)
{
 	if((typeof(firstdayofweek) == "undefined") && (typeof(firstdayofyear) == "undefined"))
	{
		return vbDateDiff(interval, date1, date2, 1, 1);
	}
	else if((typeof(firstdayofweek) == "undefined") && (typeof(firstdayofyear) != "undefined"))
	{
		return vbDateDiff(interval, date1, date2, 1, firstdayofyear);
	}
	else if((typeof(firstdayofweek) != "undefined") && (typeof(firstdayofyear) == "undefined"))
	{
		return vbDateDiff(interval,date1,date2,firstdayofweek,1);
	}
	else
	{
		return vbDateDiff(interval,date1,date2,firstdayofweek,firstdayofyear);
	}
}

/*
返回表达式，此表达式已被格式化为日期或时间。 

	FormatDateTime(Date[, NamedFormat])

	参数
	Date

	必选项。要被格式化的日期表达式。

	NamedFormat

	可选项。指示所使用的日期/时间格式的数值，如果省略，则使用 vbGeneralDate。

*/

function FormatDateTime(expression,namedFormat)
{
	if(typeof(namedFormat) == "undefined")
	{
		return vbFormatDateTime(expression,0);
	}
	else
	{
		return vbFormatDateTime(expression,namedFormat);
	}
}
/*
	根据计算机系统设定的日期和时间返回当前的日期和时间值。
*/
function Now()
{
	return vbNow();
}
