﻿var IsMenuShown=false;
var itemTableDeferred=null;
var itemTable=null;
var imageCell=null;
var onKeyPress=false;
var downArrowText=null;
var currentCtx=null;
var currentEditMenu=null;
var currentItemID=null;
var currentItemAppName=null;
var currentItemProgId=null;
var currentItemIcon=null;
var currentItemOpenControl=null;
var currentItemFileUrl=null;
var currentItemFSObjType=null;
var currentItemCheckedOutUserId=null;
var currentItemCheckoutExpires=null;
var currentItemModerationStatus=null;
var currentItemUIString=null;
var currentItemCheckedoutToLocal=null;
var bIsCheckout=0;
var currentItemCanModify=null;
var currentItemPermMaskH=null;
var currentItemPermMaskL=null;
var currentItemIsEventsExcp=null;
var currentItemIsEventsDeletedExcp=null;
var UTF8_1ST_OF_2=0xc0   ;
var UTF8_1ST_OF_3=0xe0   ;
var UTF8_1ST_OF_4=0xf0   ;
var UTF8_TRAIL=0x80   ;
var HIGH_SURROGATE_BITS=0xD800 ;
var LOW_SURROGATE_BITS=0xDC00 ;
var SURROGATE_6_BIT=0xFC00 ;
var SURROGATE_ID_BITS=0xF800 ;
var SURROGATE_OFFSET=0x10000;
function escapeProperlyCoreCore(str, bAsUrl, bForFilterQuery, bForCallback)
{
	var strOut="";
	var strByte="";
	var ix=0;
	var strEscaped=" \"%<>\'&";
	if (typeof(str)=="undefined")
		return "";
	for (ix=0; ix < str.length; ix++)
	{
		var charCode=str.charCodeAt(ix);
		var curChar=str.charAt(ix);
		if(bAsUrl && (curChar=='#' || curChar=='?') )
		{
			strOut+=str.substr(ix);
			break;
		}
		if (bForFilterQuery && curChar=='&')
		{
			strOut+=curChar;
			continue;
		}
		if (charCode <=0x7f)
		{
			if (bForCallback)
			{
				strOut+=curChar;
			}
			else
			{
				if ( (charCode >=97 && charCode <=122) ||
					 (charCode >=65 && charCode <=90) ||
					 (charCode >=48 && charCode <=57) ||
					 (bAsUrl && (charCode >=32 && charCode <=95) && strEscaped.indexOf(curChar) < 0))
				{
					strOut+=curChar;
				}
				else if (charCode <=0x0f)
				{
					strOut+="%0"+charCode.toString(16).toUpperCase();
				}
				else if (charCode <=0x7f)
				{
					strOut+="%"+charCode.toString(16).toUpperCase();
				}
			}
		}
		else if (charCode <=0x07ff)
		{
			strByte=UTF8_1ST_OF_2 | (charCode >> 6);
			strOut+="%"+strByte.toString(16).toUpperCase() ;
			strByte=UTF8_TRAIL | (charCode & 0x003f);
			strOut+="%"+strByte.toString(16).toUpperCase();
		}
		else if ((charCode & SURROGATE_6_BIT) !=HIGH_SURROGATE_BITS)
		{
			strByte=UTF8_1ST_OF_3 | (charCode >> 12);
			strOut+="%"+strByte.toString(16).toUpperCase();
			strByte=UTF8_TRAIL | ((charCode & 0x0fc0) >> 6);
			strOut+="%"+strByte.toString(16).toUpperCase();
			strByte=UTF8_TRAIL | (charCode & 0x003f);
			strOut+="%"+strByte.toString(16).toUpperCase();
		}
		else if (ix < str.length - 1)
		{
			var charCode=(charCode & 0x03FF) << 10;
			ix++;
			var nextCharCode=str.charCodeAt(ix);
			charCode |=nextCharCode & 0x03FF;
			charCode+=SURROGATE_OFFSET;
			strByte=UTF8_1ST_OF_4 | (charCode >> 18);
			strOut+="%"+strByte.toString(16).toUpperCase();
			strByte=UTF8_TRAIL | ((charCode & 0x3f000) >> 12);
			strOut+="%"+strByte.toString(16).toUpperCase();
			strByte=UTF8_TRAIL | ((charCode & 0x0fc0) >> 6);
			strOut+="%"+strByte.toString(16).toUpperCase();
			strByte=UTF8_TRAIL | (charCode & 0x003f);
			strOut+="%"+strByte.toString(16).toUpperCase();
		}
	}
	return strOut;
}
function escapeProperly(str)
{
	return escapeProperlyCoreCore(str, false, false, false);
}
function escapeProperlyCore(str, bAsUrl)
{
	return escapeProperlyCoreCore(str, bAsUrl, false, false);
}
function escapeUrlForCallback(str)
{
	var iPound=str.indexOf("#");
	var iQues=str.indexOf("?");
	if ((iPound > 0) && ((iQues==-1) || (iPound < iQues)))
	{
		var strNew=str.substr(0, iPound);
		if (iQues > 0)
		{
			strNew+=str.substr(iQues);
		}
		str=strNew;
	}
	return escapeProperlyCoreCore(str, true, false, true);
}
function PageUrlValidation(url)
{
	if (url.substr(0, 4) !="http" && url.substr(0,1) !="/")
	{
		var L_InvalidPageUrl_Text="无效的网页 URL: ";
		alert(L_InvalidPageUrl_Text);
		return "";
	}
	else
		return url;
}
var g_ExpGroupWPState=new LRUCache();
function makeAbsUrl(strUrl)
{
	if (strUrl.length > 0 && "/"==strUrl.substr(0, 1))
	{
		strUrl=window.location.protocol+"//"+window.location.host+strUrl;
	}
	return strUrl;
}
function FilterNoteField(view, fieldName, fieldValue, keyCode)
{
	if (keyCode !=13) return;
	event.returnValue=false;
	var strDocUrl=window.location.href;
	pagedPart=/&Paged=TRUE&p_[^&]*&PageFirstRow=[^&]*/gi;
	strDocUrl=strDocUrl.replace(pagedPart, "");
	viewGuid=GetUrlKeyValue("View", true);
	if (viewGuid=="")
	{
		strDocUrl=StURLSetVar2(strDocUrl, "View", view);
		viewGuid=view;
	}
	if (view.toUpperCase() !=viewGuid.toUpperCase())
	{
		var encodedView=escapeProperly(view);
		if (encodedView.toUpperCase() !=viewGuid.toUpperCase())
		{
			var pattern=/\?[^?]*/i;
			var idxQuery=strDocUrl.indexOf("?");
			if (idxQuery !=-1)
			   strDocUrl=strDocUrl.replace(pattern,"?View="+view);
			else
			   strDocUrl=strDocUrl+"?View="+view;
		}
	}
	var arrayField=strDocUrl.match("FilterField([0-9]+)="+fieldName);
	if (!arrayField)
	{
		var idxQuery=strDocUrl.indexOf("?");
		if (idxQuery !=-1)
			strDocUrl=strDocUrl+"&";
		else
			strDocUrl=strDocUrl+"?";
		i=0;
		do
		{
			i++;
			FilterArray=strDocUrl.match("FilterField"+							i+"=[^&]*"+"&FilterValue"+							i+"=[^&]*");
		} while (FilterArray);
		strDocUrl=strDocUrl+"FilterField"+i+							"="+fieldName+"&FilterValue"+							i+"="+escapeProperly(fieldValue);
		strDocUrl=strDocUrl.replace("Filter=1&", "");
	}
	else
	{
		filterNo=parseInt(arrayField[1]);
		var arrayValue=strDocUrl.match("&FilterValue"+							filterNo+"=[^&]*");
		strTemp="&"+arrayField[0]+arrayValue[0];
		strNewFilter="&FilterField"+arrayField[1]+							"="+fieldName+"&FilterValue"+							arrayField[1]+"="+escapeProperly(fieldValue);
		strDocUrl=strDocUrl.replace(strTemp, strNewFilter);
		strDocUrl=strDocUrl.replace("Filter=1&", "");
	}
	window.location.href=STSPageUrlValidation(strDocUrl);
}
function SelectField(view, selectID)
{
	var strDocUrl=window.location.href;
	var strHash=window.location.hash;
	var fViewReplaced=false;
	var pattern=/\#.*/i;
	strDocUrl=strDocUrl.replace(pattern, "");
	viewGuid=GetUrlKeyValue("View", true);
	pageView=GetUrlKeyValue("PageView", true);
	if (view.toUpperCase() !=viewGuid.toUpperCase())
	{
		var encodedView=escapeProperly(view);
		if (encodedView.toUpperCase() !=viewGuid.toUpperCase())
		{
			var pattern=/\?[^?]*/i;
			var idxQuery=strDocUrl.indexOf("?");
			if (idxQuery !=-1)
				strDocUrl=strDocUrl.replace(pattern,"?View="+view);
			else
				strDocUrl=strDocUrl+"?View="+view;
			fViewReplaced=true;
		}
	}
	if (!fViewReplaced && (GetUrlKeyValue("SelectedID") !=""))
	{
		var selectIDOld=/&SelectedID=[^&]*/gi;
		strDocUrl=strDocUrl.replace(selectIDOld, "");
		selectIDOld=/\?SelectedID=[^&]*&?/;
		strDocUrl=strDocUrl.replace(selectIDOld, "?");
	}
	strDocUrl=strDocUrl+"&SelectedID=";
	strDocUrl=strDocUrl+selectID;
	if (fViewReplaced && (pageView !=""))
	{
		strDocUrl=strDocUrl+"&PageView="+pageView;
	}
	if (strHash !="")
	{
	strDocUrl=strDocUrl+strHash;
	}
	SubmitFormPost(strDocUrl);
}
function FilterField(view, fieldName, fieldValue, selOption)
{
	return FilterFieldV3(view, fieldName, fieldValue, selOption, false);
}
function FilterFieldV3(view, fieldName, fieldValue, selOption, bReturnUrl)
{
	var strDocUrl=CanonicalizeUrlEncodingCase(window.location.href);
	var arrayField=strDocUrl.match("[&\?]Paged=TRUE[^&]*");
	if (arrayField)
	{
		var pagedPart=/&p_[^&]*/gi;
		strDocUrl=strDocUrl.replace(pagedPart, "");
		pagedPart=/&PageFirstRow=[^&]*/gi;
		strDocUrl=strDocUrl.replace(pagedPart, "");
		pagedPart=/&PageLastRow=[^&]*/gi;
		strDocUrl=strDocUrl.replace(pagedPart, "");
		pagedPart=/&PagedPrev=TRUE[^&]*/i;
		strDocUrl=strDocUrl.replace(pagedPart, "");
		arrayField=strDocUrl.match("[\?]Paged=TRUE[^&]*");
		if (arrayField)
		{
			var idxQuery=strDocUrl.substr(arrayField["index"]).indexOf("&");
			if (idxQuery !=-1)
			{
				strDocUrl=strDocUrl.substr(0, arrayField["index"]+1)+					strDocUrl.substr(idxQuery+arrayField["index"]+1);
			}
			else
			{
				strDocUrl=strDocUrl.substr(0, arrayField["index"]);
			}
		}
		else
		{
			pagedPart=/&Paged=TRUE[^&]*/i;
			strDocUrl=strDocUrl.replace(pagedPart, "");
		}
	}
	viewGuid=GetUrlKeyValue("View", true);
	if (viewGuid=="")
	{
		strDocUrl=StURLSetVar2(strDocUrl, "View", view);
		viewGuid=view;
	}
	if (view.toUpperCase() !=viewGuid.toUpperCase())
	{
		var encodedView=escapeProperly(view);
		if (encodedView.toUpperCase() !=viewGuid.toUpperCase())
		{
			var pattern=/\?[^?]*/i;
			var idxQuery=strDocUrl.indexOf("?");
			if (idxQuery !=-1)
			   strDocUrl=strDocUrl.replace(pattern,"?View="+view);
			else
			   strDocUrl=strDocUrl+"?View="+view;
		}
	}
	arrayField=strDocUrl.match("FilterField([0-9]+)="+fieldName+"&");
	if (!arrayField)
	{
		if (0==selOption)
		{
			strDocUrl=strDocUrl.replace("Filter=1&", "");
			strDocUrl=strDocUrl.replace("?Filter=1", "");
		}
		else
		{
			var idxQuery=strDocUrl.indexOf("?");
			if (idxQuery !=-1)
				strDocUrl=strDocUrl+"&";
			else
				strDocUrl=strDocUrl+"?";
			i=0;
			do
			{
				i++;
				FilterArray=strDocUrl.match("FilterField"+i+"=[^&]*"+												  "&FilterValue"+i+"=[^&]*");
			} while (FilterArray);
			strDocUrl=strDocUrl+"FilterField"+i+"="+fieldName+									"&FilterValue"+i+"="+escapeProperly(fieldValue);
			strDocUrl=strDocUrl.replace("Filter=1&", "");
		}
	}
	else
	{
		filterNo=parseInt(arrayField[1]);
		var arrayValue=strDocUrl.match("FilterValue"+filterNo+"=[^&]*");
		var strTemp="&"+arrayField[0]+arrayValue[0];
		if (0==selOption)
		{
			if (strDocUrl.indexOf(strTemp)==-1)
			{
				strTemp=arrayField[0]+arrayValue[0]+"&";
			}
			strDocUrl=strDocUrl.replace(strTemp, "");
			j=filterNo+1;
			FilterArray=strDocUrl.match("FilterField"+							j+"=[^&]*"+"&FilterValue"+							j+"=[^&]*");
			for ( i=filterNo ; FilterArray; i++)
			{
				strNew="FilterField"+i;
				strOld="FilterField"+j;
				strDocUrl=strDocUrl.replace(strOld, strNew);
				strNew="FilterValue"+i;
				strOld="FilterValue"+j;
				strDocUrl=strDocUrl.replace(strOld, strNew);
				j++;
				FilterArray=strDocUrl.match("FilterField"+								j+"=[^&]*"+"&FilterValue"+								j+"=[^&]*");
			}
			strDocUrl=strDocUrl.replace("Filter=1&", "");
			strDocUrl=strDocUrl.replace("?Filter=1", "");
		}
		else
		{
			var strFirstChar;
			if (strDocUrl.indexOf(strTemp)==-1)
			{
				strTemp="?"+arrayField[0]+arrayValue[0]
				strFirstChar="?";
			}
			else
			{
				strFirstChar="&";
			}
			var strNewFilter=strFirstChar+"FilterField"+arrayField[1]+							"="+fieldName+"&FilterValue"+							arrayField[1]+"="+escapeProperly(fieldValue);
			strDocUrl=strDocUrl.replace(strTemp, strNewFilter);
			strDocUrl=strDocUrl.replace("Filter=1&", "");
		}
	}
	arrayField=strDocUrl.match("FilterField([0-9]+)=");
	if (!arrayField)
		strDocUrl=strDocUrl+"&FilterClear=1";
	else
		strDocUrl=strDocUrl.replace("&FilterClear=1", "");
	if (bReturnUrl)
		return strDocUrl;
	else
		SubmitFormPost(strDocUrl);
}
function CanonicalizeUrlEncodingCase(str)
{
	var strOut="";
	var ix;
	for (ix=0; ix < str.length; ix++)
	{
		var curChar=str.charAt(ix);
		if (curChar=='%' && (ix+2) < str.length)
		{
			strOut+=curChar;
			ix++;
			strOut+=str.charAt(ix).toString().toUpperCase();
			ix++;
			strOut+=str.charAt(ix).toString().toUpperCase();
		}
		else
		{
			strOut+=curChar;
		}
	}
	return strOut;
}
function SetControlValue(controlId, value)
{
	var control=document.getElementById(controlId);
	if (control !=null)
		 control.value=value;
}
var bValidSearchTerm=false;
function SetSearchView()
{
	if (typeof(bValidSearchTerm) !="undefined")
		bValidSearchTerm=true;
}
function SubmitFormPost(url, bForceSubmit)
{
	if (typeof(MSOWebPartPageFormName) !="undefined")
	{
		var form=document.forms[MSOWebPartPageFormName];
		if (null !=form)
		{
			if ((bForceSubmit !=undefined && bForceSubmit==true)
				|| !form.onsubmit || (form.onsubmit() !=false))
			{
				form.action=STSPageUrlValidation(url);
				form.method="POST";
				if (isPortalTemplatePage(url))
					form.target="_top";
				if (!bValidSearchTerm)
					ClearSearchTerm("");
				form.submit();
			}
		}
	}
}
var g_varSkipRefreshOnFocus=0;
function RefreshOnFocus()
{
	if (typeof(g_varSkipRefreshOnFocus)=="undefined" ||
		!g_varSkipRefreshOnFocus)
	{
		var url=window.location.href;
		var iPosition=url.indexOf("#")
		if (iPosition==-1)
			window.location.href=url;
		else
			window.location.href=url.substring(0, iPosition);
	}
}
function DisableRefreshOnFocus()
{
	g_varSkipRefreshOnFocus=1;
}
function SetWindowRefreshOnFocus()
{
	window.onbeforeunload=DisableRefreshOnFocus;
	window.onfocus=RefreshOnFocus;
}
function RemoveParametersFromUrl(url)
{
	var paramsBeginPos=url.indexOf('?');
	if (paramsBeginPos==-1)
		return url;
	else
		return url.substr(0, paramsBeginPos);
}
function GoToPageRelative(url)
{
	if (url.substr(0, 4) !="http" && url.substr(0,1) !="/")
	{
		var currentPage=RemoveParametersFromUrl(window.location.href);
		var pos=currentPage.lastIndexOf("/");
		if (pos > 0)
			url=currentPage.substring(0, pos+1)+url;
	}
	GoToPage(url);
}
function EnterFolder(url)
{
	var currentPage=RemoveParametersFromUrl(window.location.href);
	var newPage=RemoveParametersFromUrl(url);
	if (newPage.toLowerCase() !=currentPage.toLowerCase())
		STSNavigate(url);
	else
		SubmitFormPost(url);
}
function GoToDiscussion(url)
{
	var ch=url.indexOf("?") >=0 ? "&" : "?";
	var srcUrl=GetSource();
	if (srcUrl !=null && srcUrl !="")
		url+=ch+"TopicsView="+srcUrl;
	STSNavigate(url);
}
function STSNavigateWithCheckoutAlert(Url, bCheckout, bIsCheckedOutToLocal, strDocument, strhttpRoot,
			strCurrentUser, strCheckoutUser)
{
	if (typeof(strCurrentUser)=="undefined" || strCurrentUser==null || strCurrentUser=="")
		strCurrentUser=currentItemCheckedOutUserId;
	if ((typeof(strCheckoutUser)=="undefined" || strCheckoutUser==null || strCheckoutUser=="")
		  && typeof(ctx) !="undefined")
	{
		strCheckoutUser=ctx.CurrentUserId;
	}
	if (bIsCheckedOutToLocal=="1")
	{
		alert(L_CannotEditPropertyForLocalCopy_Text);
		return;
	}
	if (strCurrentUser !=null &&
		strCurrentUser !="" &&
		strCheckoutUser !=null &&
		strCurrentUser !=strCheckoutUser)
	{
		alert(L_CannotEditPropertyCheckout_Text);
		return;
	}
	if (bCheckout=="1" && browseris.ie)
	{
		if (confirm(L_ConfirmCheckout_Text))
		{
			if (strDocument.charAt(0)=="/" || strDocument.substr(0,3).toLowerCase()=="%2f")
				strDocument=document.location.protocol+"//"+document.location.host+strDocument;
			CheckoutviaXmlhttp(strhttpRoot,strDocument);
		 }
		else
			return;
	}
	STSNavigate(Url);
}
function CheckoutviaXmlhttp(strhttpRoot, strDocument)
{
	var xh=new ActiveXObject("Microsoft.XMLHTTP");
	if (xh==null)
		return false;
	xh.Open("POST", strhttpRoot+"/_vti_bin/lists.asmx", false);
	xh.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	xh.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CheckOutFile");
	var soapData='<?xml version="1.0" encoding="utf-8"?>'+		'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" '+		'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+		'<soap:Body>'+		'<CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/"><pageUrl>'+		strDocument+'</pageUrl></CheckOutFile></soap:Body></soap:Envelope>'
	xh.Send(soapData);
	if (xh.status==200 &&  xh.ResponseText.indexOf("true") !=0)
	{
		return true;
	}
	else
		return false;
}
var g_ExtensionNotSupportCheckoutToLocal=new Array("ascx","asp", "aspx", "htm", "html","master","odc", "exe", "bat","com", "cmd", "onetoc2");
var g_ExtensionDefaultForRead=new Array("jpg", "jpeg","bmp", "png", "gif","onetoc2", "one", "odc");
function FSupportCheckoutToLocal(strExtension)
{
	var fRet=true;
	if (strExtension==null || strExtension=="")
		return false;
	strExtension=strExtension.toLowerCase();
	var ix=0;
	for (ix=0; ix < g_ExtensionNotSupportCheckoutToLocal.length; ix++)
	{
		if (strExtension==g_ExtensionNotSupportCheckoutToLocal[ix])
			return false;
	}
	return true;
}
function FDefaultOpenForReadOnly(strExtension)
{
	var fRet=false;
	if (strExtension==null || strExtension=="")
		return true;
	strExtension=strExtension.toLowerCase();
	var ix=0;
	for (ix=0; ix < g_ExtensionDefaultForRead.length; ix++)
	{
		if (strExtension==g_ExtensionDefaultForRead[ix])
			return true;
	}
	return false;
}
function CheckoutDocument(strhttpRoot, strDocument, strOpenControl)
{
	var stsOpen=null;
	var fRet=true;
	var fClientCheckout=false;
	if (strDocument.charAt(0)=="/" || strDocument.substr(0,3).toLowerCase()=="%2f")
		strDocument=document.location.protocol+"//"+document.location.host+strDocument;
	var strextension=SzExtension(unescapeProperly(strDocument));
	if (FSupportCheckoutToLocal(strextension) &&
		strOpenControl=="SharePoint.OpenDocuments.3")
	{
		stsOpen=StsOpenEnsureEx(strOpenControl);
	}
	if (stsOpen !=null)
	{
		try
		{
			fRet=stsOpen.CheckoutDocumentPrompt(unescapeProperly(strDocument), false, "");
			SetWindowRefreshOnFocus();
			fClientCheckout=true;
			return;
		}
		catch (e)
		{
		}
	}
	 if (!fClientCheckout)
		NavigateToCheckinAspx(strhttpRoot, "FileName="+escapeProperly(unescapeProperly(strDocument))+"&Checkout=true");
}
function NewItem(url)
{
	GoToPage(url);
}
function EditItem(url)
{
	GoToPage(url);
}
function GoToHistoryLink(elm, strVersion)
{
	if (elm.href==null)
		return;
	var targetUrl=elm.href;
	var ch=elm.href.indexOf("?") >=0 ? "&" : "?";
	var srcUrl=ch+"VersionNo="+strVersion;
	var srcSourceUrl=GetSource();
	if (srcSourceUrl !=null && srcSourceUrl !="")
		srcSourceUrl="&"+"Source="+srcSourceUrl;
	var targetUrl=elm.href+srcUrl+srcSourceUrl;
	if (isPortalTemplatePage(targetUrl))
		window.top.location=STSPageUrlValidation(targetUrl);
	else
		window.location=STSPageUrlValidation(targetUrl);
}
function GoToLink(elm)
{
	if (elm.href==null)
		return;
	var ch=elm.href.indexOf("?") >=0 ? "&" : "?";
	var srcUrl=GetSource();
	if (srcUrl !=null && srcUrl !="")
		srcUrl=ch+"Source="+srcUrl;
	var targetUrl=elm.href+srcUrl;
	if (isPortalTemplatePage(targetUrl))
		window.top.location=STSPageUrlValidation(targetUrl);
	else
		window.location=STSPageUrlValidation(targetUrl);
}
function GoBack(defViewUrl)
{
	window.location.href=unescapeProperly(GetSource(defViewUrl));
}
function ReplyItem(url, threading, guid, subject)
{
	if(threading.length>=504)
	{
		var L_ReplyLimitMsg_Text="无法答复此线索。已达到答复限制。";
		alert(L_ReplyLimitMsg_Text);
	} else
	{
		url+="?Threading="+threading;
		url+="&Guid="+guid;
		url+="&Subject="+subject;
		GoToPage(url);
	}
}
function GoBacktoCurrentIssue(url, issueid)
{
	url+='?ID='+issueid;
	GoToPage(url);
}
function CatchCreateError(strIgnore1, strIgnore2, strIgnore3)
{
	return true;
}
function ExportToDatabase(strSiteUrl, strListID, strViewID, fUseExistingDB)
{
	var L_NoWSSClient_Text="若要导出列表，必须具有与 Windows SharePoint Services 兼容的应用程序和 Microsoft Internet Explorer 6.0 或更高版本。";
	var L_ExportDBFail_Text="导出到数据库失败。若要导出列表，必须具有与 Windows SharePoint Services 兼容的应用程序。";
	if (browseris.ie5up && browseris.win32)
	{
		try
		{
			var ExpDatabase;
			ExpDatabase=new ActiveXObject("SharePoint.ExportDatabase");
			if (!ExpDatabase)
			{
				alert(L_NoWSSClient_Text);
				return;
			}
			ExpDatabase.SiteUrl=makeAbsUrl(strSiteUrl);
			ExpDatabase.ListID=strListID;
			ExpDatabase.ViewID=strViewID;
			ExpDatabase.DoExport(fUseExistingDB);
			ExpDatabase=null;
		}
		catch(e)
		{
			alert(L_ExportDBFail_Text);
			return;
		}
	}
	else
	{
		alert(L_NoWSSClient_Text);
	}
}
function ExportList(using)
{
	var L_ExportListSpreadsheet_Text="若要导出列表，必须要有与 Windows SharePoint Services 兼容的应用程序。";
	if ((fSSImporter && SSImporterObj.IqyImportEnabled()) ||
		confirm(L_ExportListSpreadsheet_Text))
	{
		window.location.href=STSPageUrlValidation(makeAbsUrl(using));
	}
}
function ExportDiagram(weburl,listguid, listid, listname, viewname, viewguid)
{
	try
	{
		objDiagramLaunch=new ActiveXObject("DiagramLaunch.DiagramLauncher");
		var bstrTemplate="";
		var bstrURI=weburl;
		var bstrViewGUID=viewguid;
		var bstrListGUID=listguid;
		var iListID=listid;
		objDiagramLaunch.CreateDiagram(bstrTemplate, bstrURI, bstrViewGUID, bstrListGUID, listname, viewname, iListID);
	}
	catch(e)
	{
		var L_DiagramLaunchFail_Text="无法创建图表。";
		alert (L_DiagramLaunchFail_Text);
	}
	delete objDiagramLaunch;
}
var ListCtrlObj;
var fListControl=false;
var fListErrorShown=false;
var L_EditInGrid_Text="由于下列原因，列表不能在“数据表”视图中显示: \n\n- 没有安装与 Windows SharePoint Services 兼容的数据表组件。\n- 您的 Web 浏览器不支持 ActiveX 控件。\n- 对 ActiveX 控件的支持被禁用。";
function CatchListCreateError(strIgnore1, strIgnore2, strIgnore3)
{
	alert(L_EditInGrid_Text);
	fListErrorShown=true;
	return false;
}
function EnsureListControl()
{
	if (!fListControl)
	{
		fListErrorShown=false;
		if (browseris.ie5up && browseris.win32)
		{
			var functionBody=				"try"
+"{"
+"    ListCtrlObj=new ActiveXObject(\"ListNet.ListNet\");"
+"    if (ListCtrlObj)"
+"        fListControl=true;"
+"} catch (e)"
+"{"
+"    fListControl=false;"
+"};";
			var EnsureListControlInner=new Function(functionBody);
			EnsureListControlInner();
		}
		else
		{
			window.onerror=CatchListCreateError;
			ListCtrlObj=new ActiveXObject("ListNet.ListNet");
			if (ListCtrlObj)
				fListControl=true;
		}
	}
	ListCtrlObj=null;
	return fListControl;
}
var L_NoQuestion_Text="此调查没有包含问题。";
var L_NoVoteAllowed_Text="不允许再次答复此调查。";
function IsVoteOK(notAllowed)
{
	if (1==notAllowed)
		alert(L_NoQuestion_Text);
	else if (2==notAllowed)
		alert(L_NoVoteAllowed_Text);
	else
		return true;
}
function hasHighChar(str)
{
	var ix=0;
	for (ix=0; ix < str.length; ix++)
	{
		if (str.charCodeAt(ix)>127)
		return true;
	}
	return false;
}
function RemovePagingArgs(strUrl)
{
	var rePagedFlag=/&*Paged=TRUE/gi;
	strUrl=strUrl.replace(rePagedFlag, "");
	var rePagedPrevFlag=/&*PagedPrev=TRUE/gi;
	strUrl=strUrl.replace(rePagedPrevFlag, "");
	var rePagedArgs=/&p_[^&]*/gi;
	strUrl=strUrl.replace(rePagedArgs, "");
	var rePagedRow=/&PageFirstRow=[^&]*/gi;
	strUrl=strUrl.replace(rePagedRow, "");
	var rePagedLastRow=/&PageLastRow=[^&]*/gi;
	strUrl=strUrl.replace(rePagedLastRow, "");
	var reFilter1=/\?Filter=1&*/gi;
	strUrl=strUrl.replace(reFilter1, "?");
	var reFilter2=/&Filter=1/gi;
	strUrl=strUrl.replace(reFilter2, "");
	var reOrphanedQMark=/\?$/;
	strUrl=strUrl.replace(reOrphanedQMark, "");
	return strUrl;
}
function ClearSearchTerm(guidView)
{
	if (typeof(MSOWebPartPageFormName) !="undefined")
	{
		var form=document.forms[MSOWebPartPageFormName];
		if (null !=form)
		{
			if (guidView !=null)
			{
				var frmElem=form["SearchString"+guidView];
				if (frmElem !=null)
					frmElem.value="";
			}
		}
	}
	bValidSearchTerm=true;
}
function SubmitSearchRedirect(strUrl)
{
	var frm=document.forms["frmSiteSearch"];
	if (frm==null)
	{
		if (typeof(MSOWebPartPageFormName) !="undefined")
			frm=document.forms[MSOWebPartPageFormName];
	}
	if (frm !=null)
	{
		var searchText=frm.elements["SearchString"].value;
		strUrl=strUrl+"?k="+escapeProperly(searchText);
		var searchScope=frm.elements["SearchScope"];
		if (searchScope !=null)
		{
			var searchScopeUrl=searchScope.value;
			if (searchScopeUrl)
			{
				strUrl=strUrl+"&u="+escapeProperly(searchScopeUrl);
			}
		}
		frm.action=strUrl;
		frm.submit();
	}
}
function ShowGridUrlInHTML(strUrl)
{
	if (strUrl.indexOf("?") > 0)
		strUrl=strUrl+"&";
	else
		strUrl=strUrl+"?";
	strUrl=strUrl+"ShowInGrid=HTML";
	return strUrl;
}
function SubmitSearch()
{
	SubmitSearchForView("");
}
function SubmitSearchForView(ViewGuid)
{
	var frm=document.forms[0];
	var srchCtlName="SearchString"+ViewGuid;
	var searchText=frm.elements[srchCtlName].value;
	if (""==searchText)
	{
		var L_Enter_Text="请输入一个或多个要搜索的单词。";
		alert(L_Enter_Text);
		frm.elements[srchCtlName].focus();
	}
	else
	{
		var strDocUrl;
		strDocUrl=RemovePagingArgs(frm.action);
		if (typeof(bGridViewPresent) !="undefined" && bGridViewPresent)
			strDocUrl=ShowGridUrlInHTML(strDocUrl);
		frm.action=strDocUrl;
		frm.submit();
	}
}
function IsKeyDownSubmit(event)
{
	if (event !=null)
	{
		var charCode;
		var bKeyModifiers;
		if (browseris.ie)
		{
			charCode=event.keyCode;
			bKeyModifiers=event.altKey || event.ctrlKey;
		}
		else
		{
			charCode=event.which;
			bKeyModifiers=event.modifers &
						   (event.ALT_MASK | event.CONTROL_MASK);
		}
		if ((charCode==13) && !bKeyModifiers)
			return true;
	}
	return false;
}
function SearchViewKeyDown(guidView)
{
	if (IsKeyDownSubmit(event))
		SubmitSearchForView(guidView);
}
function SearchKeyDown(event, strUrl)
{
	if (IsKeyDownSubmit(event))
	{
		SubmitSearchRedirect(strUrl);
		return false;
	}
	return true;
}
function AlertAndSetFocus(msg, fieldName)
{
	fieldName.focus();
	fieldName.select();
	window.alert(msg);
}
function AlertAndSetFocusForDropdown(msg, fieldName)
{
	fieldName.focus();
	window.alert(msg);
}
function setElementValue(elemName, elemValue)
{
	var elem=document.getElementsByName(elemName).item(0);
	if (elem==null)
		return false;
	elem.value=elemValue;
	return true;
}
function GetMultipleSelectedText(frmElem) {
	if (frmElem) {
		var strret;
		strret="";
		for(var i=0; i < frmElem.options.length; i++)
			{
			if (frmElem.options[i].selected)
				strret+=","+frmElem.options[i].text;
			}
		if (strret.length > 0)
			strret=strret.substring(1);
		return strret;
	}
	else
		return "";
}
function GetCBSelectedValues(frm) {
	if (frm==null)
		return;
	var value=new Object();
	value.strList="";
	value.fAllChecked=true;
	for (var i=0;i<frm.elements.length;i++)
		{
		var e=frm.elements[i];
		if (e.type=="checkbox" && !e.disabled )
			{
			if (e.checked)
				{
				if (value.strList !="")
					value.strList+=",";
				value.strList+=e.value;
				}
			else
				value.fAllChecked=false;
			}
		}
	return value;
}
var fNewDoc=false;
var fNewDoc2=false;
var fNewDoc3=false;
var L_EditDocumentProgIDError_Text="“编辑文档”需要使用与 Windows SharePoint Services 兼容的应用程序和 Microsoft Internet Explorer 6.0 或更高版本。";
var L_EditDocumentRuntimeError_Text="无法打开文档进行编辑。找不到与 Windows SharePoint Services 兼容的应用程序来编辑该文档。";
function editDocumentWithProgID(strDocument, varProgID)
{
	if (fNewDoc)
	{
		if (strDocument.charAt(0)=="/" || strDocument.substr(0,3).toLowerCase()=="%2f")
			strDocument=document.location.protocol+"//"+document.location.host+strDocument;
		if ((!fNewDoc2) && (!fNewDoc3))
		{
			if(!EditDocumentButton.EditDocument(strDocument, varProgID))
				alert(L_EditDocumentRuntimeError_Text);
		}
		else
		{
			if(!EditDocumentButton.EditDocument2(window, strDocument, varProgID))
				alert(L_EditDocumentRuntimeError_Text);
		}
	}
	else
	{
		alert(L_EditDocumentProgIDError_Text);
	}
}
function editDocumentWithProgID2(strDocument, varProgID, varEditor, bCheckout,strhttpRoot, strCheckouttolocal)
{
	var errorCode=editDocumentWithProgIDNoUI(strDocument, varProgID, varEditor, bCheckout,strhttpRoot, strCheckouttolocal);
	if (errorCode==1)
	{
		alert(L_EditDocumentRuntimeError_Text);
		window.onfocus=RefreshOnNextFocus;
	}
	else if (errorCode==2)
		alert(L_EditDocumentProgIDError_Text);
}
function editDocumentWithProgIDNoUI(strDocument, varProgID, varEditor, bCheckout,strhttpRoot, strCheckouttolocal)
{
	var objEditor;
	var fRet;
	var fUseLocalCopy=false;
	varEditor=varEditor.replace(/(?:\.\d+)$/, '');
	if (strDocument.charAt(0)=="/" || strDocument.substr(0,3).toLowerCase()=="%2f")
		strDocument=document.location.protocol+"//"+document.location.host+strDocument;
	var strextension=SzExtension(unescapeProperly(strDocument));
	if (FSupportCheckoutToLocal(strextension))
	{
		try
		{
			objEditor=new ActiveXObject(varEditor+".3");
			if (objEditor !=null )
			{
				if (bCheckout=="1")
				{
					if (!objEditor.CheckoutDocumentPrompt(strDocument, true, varProgID))
					return 1;
				}
				else
				{
					if (strCheckouttolocal=="1")
					fUseLocalCopy=true;
					if (!objEditor.EditDocument3(window, strDocument, fUseLocalCopy, varProgID))
					return 1;
				}
				var  fRefreshOnNextFocus=false;
				fRefreshOnNextFocus=objEditor.PromptedOnLastOpen();
				if (fRefreshOnNextFocus)
				{
					window.onfocus=RefreshOnNextFocus;
				}
				else
				{
					SetWindowRefreshOnFocus();
				}
				return;
			}
		}
		catch(e)
		{
		}
	}
	if (bCheckout=="1")
	{
		if (confirm(L_ConfirmCheckout_Text))
			NavigateToCheckinAspx(strhttpRoot,"FileName="+escapeProperly(unescapeProperly(strDocument))+"&Checkout=true");
		else
			return;
	}
	try
	{
		objEditor=new ActiveXObject(varEditor+".2");
		if (!objEditor.EditDocument2(window, strDocument, varProgID))
			return 1;
		window.onfocus=RefreshOnNextFocus;
		return;
	}
	catch (e)
	{
	}
	try
	{
		objEditor=new ActiveXObject(varEditor+".1");
		window.onfocus=null;
		if (SzExtension(strDocument)=="ppt" && varProgID=="")
			varProgID="PowerPoint.Slide";
		if (!objEditor.EditDocument(strDocument, varProgID))
			return 1;
		SetWindowRefreshOnFocus();
		return;
	}
	catch (e)
	{
		return 2;
	}
}
function RefreshOnNextFocus()
{
	SetWindowRefreshOnFocus();
}
function createNewDocumentWithProgID2(strTemplate, strSaveLocation, strProgID, strProgID2, bXMLForm)
{
	if (!createNewDocumentWithProgIDCore(strTemplate, strSaveLocation, strProgID, bXMLForm, false))
	{
		createNewDocumentWithProgIDCore(strTemplate, strSaveLocation, strProgID2, bXMLForm, true);
	}
}
function createNewDocumentWithProgID(strTemplate, strSaveLocation, strProgID, bXMLForm)
{
	createNewDocumentWithProgIDCore(strTemplate, strSaveLocation, strProgID, bXMLForm, true);
}
function createNewDocumentWithProgIDCore(strTemplate, strSaveLocation, strProgID, bXMLForm, bWarning)
{
	var objEditor;
	var L_NewDocumentRuntimeError_Text;
	var L_NewDocumentError_Text;
	var fRefreshOnNextFocus=false;
	if (bXMLForm)
	{
		var L_NewDocumentRuntimeError_Text=L_NewFormLibTb1_Text;
		var L_NewDocumentError_Text=L_NewFormLibTb2_Text;
	}
	else
	{
		var L_NewDocumentRuntimeError_Text=L_NewDocLibTb1_Text;
		var L_NewDocumentError_Text=L_NewDocLibTb2_Text;
	}
	try
	{
		objEditor=new ActiveXObject(strProgID+".2");
		if (!objEditor.CreateNewDocument2(window, strTemplate, strSaveLocation))
			alert(L_NewDocumentRuntimeError_Text);
		fRefreshOnNextFocus=objEditor.PromptedOnLastOpen();
		if (fRefreshOnNextFocus)
		{
			window.onfocus=RefreshOnNextFocus;
		}
		else
		{
			SetWindowRefreshOnFocus();
		}
		return true;
	}
	catch (e)
	{
	}
	try
	{
		objEditor=new ActiveXObject(strProgID+".1");
		window.onfocus=null;
		if (!objEditor.CreateNewDocument(strTemplate, strSaveLocation))
			alert(L_NewDocumentRuntimeError_Text);
		SetWindowRefreshOnFocus();
		return true;
	}
	catch (e)
	{
		if (bWarning)
			alert(L_NewDocumentError_Text);
	}
}
function createNewDocumentWithRedirect(strTemplate, strSaveLocation, strProgID, bXMLForm, strRedirectUrl, defaultItemOpen)
{
	if (IsClientAppInstalled(strProgID) && defaultItemOpen !=1)
	{
		var strIndependentProgId=strProgID.replace(/(?:\.\d+)$/, '');
		createNewDocumentWithProgID(strTemplate, strSaveLocation, strIndependentProgId, bXMLForm);
	}
	else
	{
		STSNavigate(strRedirectUrl+			"&SaveLocation="+makeAbsUrl(escapeProperly(strSaveLocation))+			"&Source="+GetSource()+			"&DefaultItemOpen="+defaultItemOpen);
	}
}
if (typeof(ExpandBody)=="undefined")
{
	function ExpandBody(guid, anchor)
	{
		var frm=document.forms[MSOWebPartPageFormName];
		frm.CAML_Expand.value=frm.CAML_Expand.value.concat(guid);
		frm.action=frm.action.concat("#"+anchor);
		frm.submit();
		return false;
	}
}
if (typeof(CollapseBody)=="undefined")
{
	function CollapseBody(guid, anchor)
	{
		var frm=document.forms[MSOWebPartPageFormName];
		var reg=new RegExp("\{", "g");
		guid=guid.replace(reg, "\\\{");
		reg=new RegExp("\}", "g");
		guid=guid.replace(reg, "\\\}");
		reg=new RegExp(guid, "g");
		frm.CAML_Expand.value=frm.CAML_Expand.value.replace(reg, "");
		frm.CAML_ShowOriginalEmailBody.value=			frm.CAML_ShowOriginalEmailBody.value.replace(reg, "");
		frm.action=frm.action.concat("#"+anchor);
		frm.submit();
		return false;
	}
}
if (typeof(ShowQuotedText)=="undefined")
{
	function ShowQuotedText(guid, anchor)
	{
		var frm=document.forms[MSOWebPartPageFormName];
		frm.CAML_ShowOriginalEmailBody.value=			frm.CAML_ShowOriginalEmailBody.value.concat(guid);
		if (frm.action.indexOf("#") > 0)
		{
			frm.action=frm.action.substr(0, frm.action.indexOf("#"));
		}
		frm.action=frm.action.concat("#"+anchor);
		frm.submit();
		return false;
	}
}
if (typeof(HideQuotedText)=="undefined")
{
	function HideQuotedText(guid, anchor)
	{
		var frm=document.forms[MSOWebPartPageFormName];
		var reg=new RegExp("\{", "g");
		guid=guid.replace(reg, "\\\{");
		reg=new RegExp("\}", "g");
		guid=guid.replace(reg, "\\\}");
		reg=new RegExp(guid, "g");
		frm.CAML_ShowOriginalEmailBody.value=			frm.CAML_ShowOriginalEmailBody.value.replace(reg, "");
		if (frm.action.indexOf("#") > 0)
		{
			frm.action=frm.action.substr(0, frm.action.indexOf("#"));
		}
		frm.action=frm.action.concat("#"+anchor);
		frm.submit();
		return false;
	}
}
function LRUCache()
{
	this.state=new Array();
	this.ageStack=new Array();
	this.count=0;
}
function LRUCache_Add(cache, itemName)
{
	if (!cache)
	{
		return;
	}
	oldAge=cache.state[itemName];
	if (oldAge !=null)
	{
		cache.ageStack[oldAge]=null;
	}
	else
	{
		cache.count++;
	}
	age=cache.ageStack.length;
	cache.state[itemName]=age;
	cache.ageStack.push(itemName);
}
function LRUCache_Remove(cache, itemName)
{
	if (!cache)
		return;
	age=cache.state[itemName];
	if (age !=null)
	{
		cache.ageStack[age]=null;
		cache.state[itemName]=null;
		cache.count--;
	}
	else
	{
	}
}
function AddGroupToCookie(groupName)
{
	var webPartID=ExpGroupFetchWebPartID(groupName);
	if (webPartID==null)
		return;
	LRUCache_Add(g_ExpGroupWPState, webPartID);
	if (g_ExpGroupTable[webPartID]==null)
	{
		g_ExpGroupTable[webPartID]=new LRUCache();
	}
	var groupString=ExpGroupFetchGroupString(groupName);
	if (groupString==null)
		return;
	LRUCache_Add(g_ExpGroupTable[webPartID], groupString);
	ExpGroupRenderCookie();
}
function RemoveGroupFromCookie(groupName)
{
	var webPartID=ExpGroupFetchWebPartID(groupName);
	if (webPartID==null)
		return;
	if (g_ExpGroupTable[webPartID]==null)
		return;
	LRUCache_Add(g_ExpGroupWPState, webPartID);
	var groupString=ExpGroupFetchGroupString(groupName);
	if (groupString==null)
		return;
	var aGroupString;
	for (aGroupString in g_ExpGroupTable[webPartID].state)
	{
		if (g_ExpGroupTable[webPartID].state[aGroupString] !=null &&
			aGroupString.substring(0,groupString.length)==groupString)
		{
			LRUCache_Remove(g_ExpGroupTable[webPartID], aGroupString);
		}
	}
	ExpGroupRenderCookie();
}
function ExpGroupRenderCookie()
{
	if (!g_ExpGroupWPState)
		return;
	var newWPString=ExpGroupWPListName+"=";
	var numWPRendered=0;
	var ix;
	for (ix=g_ExpGroupWPState.ageStack.length - 1; ix >=0; ix--)
	{
		if (g_ExpGroupWPState.ageStack[ix] !=null)
		{
			var webPartID=g_ExpGroupWPState.ageStack[ix];
			if (numWPRendered==ExpGroupMaxWP)
			{
				DeleteCookie(ExpGroupCookiePrefix+webPartID);
				break;
			}
			else if (g_ExpGroupTable[webPartID]==null)
			{
				numWPRendered++;
				if (numWPRendered > 1)
					newWPString+=escape(ExpGroupCookieDelimiter);
				newWPString+=escape(webPartID);
			}
			else if (g_ExpGroupTable[webPartID].count==0)
			{
				DeleteCookie(ExpGroupCookiePrefix+webPartID);
			}
			else if (numWPRendered < ExpGroupMaxWP)
			{
				numWPRendered++;
				ExpGroupRenderCookieForWebPart(webPartID);
				if (numWPRendered > 1)
					newWPString+=escape(ExpGroupCookieDelimiter);
				newWPString+=escape(webPartID);
			}
		}
	}
	if (numWPRendered==0)
	{
		DeleteCookie(ExpGroupWPListName);
	}
	else
	{
		document.cookie=newWPString;
	}
}
function ExpGroupRenderCookieForWebPart(webPartID)
{
	if (!g_ExpGroupTable[webPartID].ageStack)
		return;
	var newCookieString=ExpGroupCookiePrefix+webPartID+"=";
	var bFirst=true;
	var ix;
	for (ix=g_ExpGroupTable[webPartID].ageStack.length - 1; ix >=0; ix--)
	{
		if (g_ExpGroupTable[webPartID].ageStack[ix] !=null)
		{
			var groupString=g_ExpGroupTable[webPartID].ageStack[ix];
			var newPortion="";
			if (!bFirst)
				newPortion+=escape(ExpGroupCookieDelimiter);
			newPortion+=escape(groupString);
			if (newCookieString.length+newPortion.length <=ExpGroupMaxCookieLength)
			{
				newCookieString+=newPortion;
				bFirst=false;
			}
		}
	}
	document.cookie=newCookieString+";";
}
function ExpGroupOnPageLoad()
{
	flag=document.getElementById("GroupByColFlag");
	if (flag !=null)
	{
		g_ExpGroupNeedsState=true;
		ExpGroupParseCookie();
	}
}
function ExpGroupParseCookie()
{
	var webPartListString=GetCookie(ExpGroupWPListName);
	if (webPartListString==null)
		return;
	g_ExpGroupParseStage=true;
	var webPartList=webPartListString.split(ExpGroupCookieDelimiter);
	var ix;
	for (ix=webPartList.length - 1; ix >=0; ix--)
	{
		var webPartID=webPartList[ix];
		LRUCache_Add(g_ExpGroupWPState, webPartID);
		if (g_ExpGroupTable[webPartID]==null)
		{
			if (document.getElementById("GroupByCol"+webPartID) !=null)
				ExpGroupParseCookieForWebPart(webPartID);
		}
	}
	g_ExpGroupParseStage=false;
	if (g_ExpGroupQueue.length > 0)
	{
		ExpGroupFetchData(g_ExpGroupQueue.shift());
	}
}
function ExpGroupParseCookieForWebPart(webPartID)
{
	var groupListString=GetCookie(ExpGroupCookiePrefix+webPartID);
	if (groupListString==null)
		return;
	var groupList=groupListString.split(ExpGroupCookieDelimiter);
	var ix;
	g_ExpGroupTable[webPartID]=new LRUCache();
	for (ix=groupList.length - 1; ix >=0; ix--)
	{
		var groupString=groupList[ix];
		LRUCache_Add(g_ExpGroupTable[webPartID], groupString);
	}
	var loadedGroups=new Array();
	var viewTable=document.getElementById("GroupByCol"+webPartID).parentNode;
	tbodyTags=viewTable.getElementsByTagName("TBODY");
	for (ix=0; ix < tbodyTags.length; ix++)
	{
		var groupString=tbodyTags[ix].getAttribute("groupString");
		if (groupString !=null)
		{
			var tbodyId=tbodyTags[ix].id;
			if (tbodyId==null)
				continue;
			var groupName=tbodyId.substring(4, tbodyId.length);
			if (g_ExpGroupTable[webPartID].state[groupString] !=null &&
				loadedGroups[groupName]==null)
			{
				ExpCollGroup(groupName, "img_"+groupName);
				loadedGroups[groupName]=true;
				tbody=document.getElementById("tbod"+groupName+"_");
				if (tbody !=null)
				{
					isLoaded=tbody.getAttribute("isLoaded");
					if (isLoaded=="false")
						g_ExpGroupQueue.push(groupName);
				}
			}
		}
	}
	var aGroupName;
	for (aGroupName in loadedGroups)
	{
		var index=aGroupName.indexOf("_");
		if (index !=aGroupName.length - 1 && index !=-1)
		{
			var parentName=aGroupName.substring(0, index+1);
			if (loadedGroups[parentName]==null)
			{
				var parentString=ExpGroupFetchGroupString(parentName);
				if (parentString !=null)
				{
					LRUCache_Add(g_ExpGroupState, parentString);
					ExpCollGroup(parentName, "img_"+parentName);
					loadedGroups[parentString]=true;
				}
				else
				{
				}
			}
		}
	}
}
function ExpGroupBy(formObj)
{
	if ((browseris.w3c) && (!browseris.ie)) {
		document.all=document.getElementsByTagName("*");
	}
	docElts=document.all;
	numElts=docElts.length;
	images=formObj.getElementsByTagName("IMG");
	img=images[0];
	srcPath=img.src;
	index=srcPath.lastIndexOf("/");
	imgName=srcPath.slice(index+1);
	var displayStr="auto";
	if (imgName=='plus.gif')
	{
		displayStr="";
		img.src='/_layouts/images/minus.gif';
	}
	else
	{
		displayStr="none";
		img.src='/_layouts/images/plus.gif';
	}
	oldName=img.name;
	img.name=img.alt;
	img.alt=oldName;
	spanNode=img;
	while(spanNode !=null)
	{
		spanNode=spanNode.parentNode;
		if (spanNode !=null &&
			spanNode.id !=null &&
			spanNode.id.length > 5 &&
			spanNode.id.substr(0, 5)=="group")
			break;
	}
	parentNode=spanNode;
	while(parentNode !=null)
	{
		parentNode=parentNode.parentNode;
		if (parentNode !=null &&
			parentNode.tagName=="TABLE")
			break;
	}
	lastNode=null;
	if (parentNode !=null)
	{
		lastNode=parentNode.lastChild;
		if (lastNode !=null && lastNode.tagName=="TBODY")
			lastNode=lastNode.lastChild;
		if (lastNode !=null && lastNode.tagName=="TR" && lastNode.lastChild !=null)
			lastNode=lastNode.lastChild;
	}
	for(var i=0;i<numElts;i++)
	{
		var childObj=docElts.item(i);
		if (childObj==spanNode)
			break;
	}
	ID=spanNode.id.slice(5);
	displayStyle=displayStr;
	for(var j=i+1; j<numElts; j++)
	{
		var childObj=docElts.item(j);
		if (childObj.id.length > 5 &&
			childObj.id.substr(0, 5)=="group")
		{
			curID=childObj.id.slice(5);
			if (curID <=ID)
				return;
		}
		parentNode=childObj;
		while(parentNode !=null)
		{
			parentNode=parentNode.parentNode;
			if (parentNode==spanNode)
				break;
		}
		if (parentNode==spanNode)
			continue;
		if (childObj.id !=null && childObj.id.substring(0, 5)=="group")
			displayStr=displayStyle;
		if (childObj.id !=null && childObj.id.substring(0, 8)=="footer"+ID)
			displayStr=displayStyle;
		if (displayStyle !="none" &&
			childObj !=img &&
			childObj.tagName=="IMG" &&
			childObj.src !=null)
		{
			if (childObj.src.slice(childObj.src.length - 25)=='/_layouts/images/plus.gif')
			{
				displayStr="none";
			}
			else if (childObj.src.slice(childObj.src.length - 26)=='/_layouts/images/minus.gif')
			{
				displayStr="";
			}
		}
		if (childObj.tagName==spanNode.tagName &&
			childObj.id !="footer")
		{
			childObj.style.display=displayStr;
		}
		if ((childObj.tagName=="TABLE" && lastNode==null) || childObj==lastNode)
			break;
	}
}
function SzExtension(szHref)
{
	var sz=new String(szHref);
	var re=/^.*\.([^\.]*)$/;
	return sz.replace(re, "$1").toLowerCase();
}
function SzServer(szHref)
{
	var sz=new String(szHref);
	var re=/^([^:]*):\/\/([^\/]*).*$/;
	return sz.replace(re, "$1://$2");
}
var v_stsOpenDoc=null;
var v_strStsOpenDoc=null;
function StsOpenEnsureEx(szProgId)
{
	if (v_stsOpenDoc==null || v_strStsOpenDoc !=szProgId)
	{
//@cc_on
//@if (@_jscript_version >=5)
//@            try
//@            {
//@                v_stsOpenDoc=new ActiveXObject(szProgId);
//@                v_strStsOpenDoc=szProgId;
//@            } catch(e)
//@            {
//@                v_stsOpenDoc=null;
//@                v_strStsOpenDoc=null;
//@            };
//@else
//@end
	}
	return v_stsOpenDoc;
}
function DispDocItem(ele,strProgId)
{
	return DispDocItemEx(ele,'FALSE','FALSE','FALSE',strProgId);
}
var L_OpenDocumentLocalError_Text="此文档曾经过脱机编辑，但是没有配置用于从 SharePoint 打开此文档的应用程序。只能以只读方式打开该文档。";
function DispDocItemEx(ele, fTransformServiceOn, fShouldTransformExtension, fTransformHandleUrl, strProgId)
{
	itemTable=FindSTSMenuTable(ele, "CTXName");
	if (!browseris.ie || !browseris.win32)
	{
		if (browseris.ie)
			event.cancelBubble=false;
		return true;
	}
	var stsOpen;
	var szHref;
	var szExt;
	var fRet=true;
	var szFileType=itemTable !=null ? GetAttributeFromItemTable(itemTable, "Ext", "FileType") : "";
	var szAppId="";
	var tblFileDlg=document.getElementById("FileDialogViewTable");
	if (tblFileDlg !=null)
	{
		if (browseris.ie)
		{
			event.cancelBubble=false;
			event.returnValue=false;
		}
		return true;
	}
	szHref=itemTable !=null ? GetAttributeFromItemTable(itemTable, "Url", "ServerUrl") : "";
	if (szHref==null || szHref=="")
		szHref=ele.href;
	else
		szHref=SzServer(ele.href)+szHref;
	szExt=SzExtension(szHref);
	if ((currentItemProgId==null) && (itemTable!=null))
		currentItemProgId=itemTable.getAttribute("HTMLType");
	if (currentItemProgId !=null)
		szAppId=currentItemProgId;
	if (FDefaultOpenForReadOnly(szExt))
	{
	   if (strProgId.indexOf("SharePoint.OpenDocuments") >=0)
			strProgId="SharePoint.OpenDocuments.3";
	}
	else if (!FSupportCheckoutToLocal(szExt))
	{
		strProgId="";
	}
	if ((currentItemCheckedOutUserId==null) && (itemTable!=null))
		currentItemCheckedOutUserId=itemTable.COUId;
	if ((currentItemCheckedoutToLocal==null) && (itemTable!=null))
		currentItemCheckedoutToLocal=GetAttributeFromItemTable(itemTable, "COut", "IsCheckedoutToLocal ");
	if( ((currentItemCheckedOutUserId !=null) &&
		(currentItemCheckedOutUserId !="") &&
		(currentItemCheckedOutUserId==ctx.CurrentUserId ) &&
		(strProgId==""  || ((strProgId.indexOf("SharePoint.OpenDocuments")) >=0)) &&
		FSupportCheckoutToLocal(szExt))||
		(strProgId=="SharePoint.OpenDocuments"))
	{
		strProgId="SharePoint.OpenDocuments.3";
	}
	var stsopenVersion=2;
	if(strProgId !='' && HasRights(0x10, 0x0))
	{
		if ((strProgId.indexOf(".3")) >=0)
			stsopenVersion=3;
		stsOpen=StsOpenEnsureEx(strProgId);
		if (stsOpen==null && stsopenVersion==3)
		{
			strProgId=strProgId.replace(".3",".2");
			stsOpen=StsOpenEnsureEx(strProgId);
			stsopenVersion=2;
		}
	}
	if (stsOpen !=null)
	{
		if (stsopenVersion==2 ||
			((itemTable==null) && (currentItemCheckedOutUserId==null))||
			(ctx.isVersions==1 && (itemTable==null || itemTable.isMostCur=="0")))
		{
			try
			{
				if ((currentItemCheckedOutUserId !=null) &&
					(currentItemCheckedOutUserId !="") &&
					(currentItemCheckedOutUserId==ctx.CurrentUserId ||
					ctx.CurrentUserId==null ))
				{
					if (currentItemCheckedoutToLocal=='1')
					{
						 alert(L_OpenDocumentLocalError_Text);
						 fRet=false;
					}
					else
						fRet=stsOpen.EditDocument2(window, szHref, szAppId);
				}
				else
				{
					fRet=stsOpen.ViewDocument2(window, szHref, szAppId);
				}
			}
			catch(e)
			{
				fRet=false;
			}
			if (fRet)
				window.onfocus=RefreshOnNextFocus;
		}
		else
		{
			var iOpenFlag=0;
			if (currentItemCheckedOutUserId !="")
			{
				if ((currentItemCheckedOutUserId !=ctx.CurrentUserId) && ( ctx.CurrentUserId !=null))
					iOpenFlag=1;
				else if (currentItemCheckedoutToLocal==null ||
					currentItemCheckedoutToLocal !='1')
					iOpenFlag=2;
				else
					iOpenFlag=4;
			}
			else if (!HasRights(0x0, 0x4) || FDefaultOpenForReadOnly(szExt))
				iOpenFlag=1;
			else if (ctx.isForceCheckout==true)
				iOpenFlag=3;
			try
			{
				fRet=stsOpen.ViewDocument3(window, szHref,iOpenFlag, szAppId);
			}
			catch(e)
			{
				fRet=false;
			}
			if (fRet)
			{
				var fRefreshOnNextFocus=stsOpen.PromptedOnLastOpen();
				if (fRefreshOnNextFocus)
					window.onfocus=RefreshOnNextFocus;
				else
					SetWindowRefreshOnFocus();
			}
		}
	}
	else if (currentItemCheckedoutToLocal=='1')
	{
		 alert(L_OpenDocumentLocalError_Text);
	}
	if (stsOpen==null || !fRet)
	{
		if (fTransformServiceOn=='TRUE' &&
			fShouldTransformExtension=='TRUE' &&
			fTransformHandleUrl=='TRUE')
		{
			if (itemTable==null)
				return fRet;
			if (browseris.ie)
			{
				event.cancelBubble=true;
				event.returnValue=false;
			}
			var getHttpRoot=new Function("return "+itemTable.getAttribute("CTXName")+".HttpRoot;");
			GoToPage(getHttpRoot()+"/_layouts"+				"/htmltrverify.aspx?doc="+escapeProperly(szHref));
		}
		return;
	}
	stsOpen=null;
	if (browseris.ie)
	{
		event.cancelBubble=true;
		event.returnValue=false;
	}
	return fRet;
}
function DispDocItemEx2(ele, objEvent, fTransformServiceOn, fShouldTransformExtension,
	fTransformHandleUrl, strHtmlTrProgId, iDefaultItemOpen, strProgId, strServerFileRedirect)
{
	var fRedirect=false;
	var fIsServerFile=strServerFileRedirect !=null && strServerFileRedirect !="";
	var fIsClientAppInstalled=IsClientAppInstalled(strProgId) && HasRights(0x10, 0x0);
	if (fIsServerFile)
	{
		if (iDefaultItemOpen==1 || !fIsClientAppInstalled)
		{
			STSNavigate(strServerFileRedirect+"&Source="+GetSource()+"&DefaultItemOpen="+iDefaultItemOpen);
			objEvent.cancelBubble=true;
			objEvent.returnValue=false;
			return false;
		}
		else if (fIsClientAppInstalled)
		{
			if (strProgId=="" || strProgId.indexOf("SharePoint.OpenDocuments") >=0)
			{
				return DispDocItemEx(ele, fTransformServiceOn, fShouldTransformExtension, fTransformHandleUrl, strHtmlTrProgId);
			}
			else
			{
				if (!ViewDoc(ele.href, strProgId))
				{
					var errorCode=editDocumentWithProgIDNoUI(ele.href, currentItemProgId, strProgId, false, ctx.HttpRoot, "0");
					if ((errorCode==1) || (errorCode==2))
					{
						STSNavigate(strServerFileRedirect+"&Source="+GetSource());
					}
				}
				objEvent.cancelBubble=true;
				objEvent.returnValue=false;
				return false;
			}
		}
	}
	return DispDocItemEx(ele, fTransformServiceOn, fShouldTransformExtension, fTransformHandleUrl, strProgId);
}
function DispDocItemExWithOutContext(ele, objEvent, fTransformServiceOn, fShouldTransformExtension,
	fTransformHandleUrl, strHtmlTrProgId, iDefaultItemOpen, strProgId, strHtmlType, strServerFileRedirect,
	strCheckoutUser, strCurrentUser, strRequireCheckout, strCheckedoutTolocal, strPermmask)
{
	DispEx(ele, objEvent, fTransformServiceOn, fShouldTransformExtension,
			fTransformHandleUrl, strHtmlTrProgId, iDefaultItemOpen, strProgId, strHtmlType, strServerFileRedirect,
			strCheckoutUser, strCurrentUser, strRequireCheckout, strCheckedoutTolocal, strPermmask);
}
function DispEx(ele, objEvent, fTransformServiceOn, fShouldTransformExtension,
	fTransformHandleUrl, strHtmlTrProgId, iDefaultItemOpen, strProgId, strHtmlType, strServerFileRedirect,
	strCheckoutUser, strCurrentUser, strRequireCheckout, strCheckedoutTolocal, strPermmask)
{
	var tblFileDlg=document.getElementById("FileDialogViewTable");
	if (tblFileDlg !=null)
	{
		objEvent.cancelBubble=false;
		objEvent.returnValue=false;
		return true;
	}
	if (typeof(ctx)=="undefined" || ctx==null)
		ctx=new ContextInfo();
	ctx.CurrentUserId=strCurrentUser;
	if (strRequireCheckout=='1')
		ctx.isForceCheckout=true;
	else
		ctx.isForceCheckout=false;
	currentItemCheckedOutUserId=strCheckoutUser;
	currentItemCheckedoutToLocal=strCheckedoutTolocal;
	currentItemProgId=strHtmlType;
	if (strPermmask !=null && strPermmask !='')
		SetCurrentPermMaskFromString(strPermmask, null)
	objEvent.cancelBubble=true;
	if (strServerFileRedirect !=null && strServerFileRedirect !='')
		strServerFileRedirect=strServerFileRedirect.substring(1);
	return  DispDocItemEx2(ele, objEvent, fTransformServiceOn, fShouldTransformExtension,
		fTransformHandleUrl, strHtmlTrProgId, iDefaultItemOpen, strProgId, strServerFileRedirect);
}
function IsClientAppInstalled(strProgId)
{
	var stsOpen=null;
	if(strProgId !='')
	{
		stsOpen=StsOpenEnsureEx(strProgId);
	}
	return stsOpen !=null;
}
function ViewDoc(url,strProgId)
{
	var stsOpen=StsOpenEnsureEx(strProgId);
	var fRet=false;
	if (stsOpen !=null)
	{
		try
		{
			fRet=stsOpen.ViewDocument2(window, url);
		}
		catch(e)
		{
			fRet=false;
		}
	}
	return fRet;
}
function PortalPinToMyPage(eForm, portalUrl, instanceID)
{
	eForm.action=portalUrl+'_vti_bin/portalapi.aspx?Cmd=PinToMyPage';
	eForm.ReturnUrl.value=window.location.href;
	eForm.ListViewUrl.value=MakeMtgInstanceUrl(eForm.ListViewUrl.value, instanceID);
	eForm.submit();
}
function PortalPinToMyPage(eForm, portalUrl, instanceId, listTitle, listDescription, listViewUrl, baseType, serverTemplate)
{
	eForm.action=portalUrl+'_vti_bin/portalapi.aspx?Cmd=PinToMyPage';
	SetFieldValue(eForm,"ReturnUrl",window.location.href);
	SetFieldValue(eForm,"ListViewUrl",MakeMtgInstanceUrl(listViewUrl, instanceId));
	SetFieldValue(eForm,"ListTitle",listTitle);
	SetFieldValue(eForm,"ListDescription",listDescription);
	SetFieldValue(eForm,"BaseType",baseType);
	SetFieldValue(eForm,"ServerTemplate",serverTemplate);
	eForm.submit();
}
function SetFieldValue(eForm, fieldName, value)
{
	var field=eForm[fieldName];
	if (field==null)
	{
	field=document.createElement("INPUT");
	field.setAttribute("type","hidden");
		field.setAttribute("name",fieldName);
		eForm.appendChild(field);
	}
	field.value=value;
}
function StURLSetVar2(stURL, stVar, stValue)
{
	var stNewSet=stVar+"="+stValue;
	var ichHash=stURL.indexOf("#");
	var hashParam;
	if (ichHash !=-1)
	{
		hashParam=stURL.substring(ichHash, stURL.length);
		stURL=stURL.substring(0, ichHash);
	}
	var ichQ=stURL.indexOf("?");
	if (ichQ !=-1)
	{
		var ich=stURL.indexOf("?"+stVar+"=", ichQ);
		if (ich==-1)
		{
			ich=stURL.indexOf("&"+stVar+"=", ichQ);
			if (ich !=-1)
				stNewSet="&"+stNewSet;
		}
		else
		{
			stNewSet="?"+stNewSet;
		}
		if (ich !=-1)
		{
			var re=new RegExp("[&?]"+stVar+"=[^&]*", "");
			stURL=stURL.replace(re, stNewSet);
		}
		else
		{
			stURL=stURL+"&"+stNewSet;
		}
	}
	else
	{
		stURL=stURL+"?"+stNewSet;
	}
	if (hashParam !=null && hashParam.length > 0)
		stURL=stURL+hashParam;
	return stURL;
}
function RemoveQueryParameterFromUrl(stURL, stParameterName)
{
	var re=new RegExp("[&?]"+stParameterName+"=[^&]*", "");
	stURL=stURL.replace(re, "");
	if (stURL.indexOf("?")==-1)
	{
		var ich=stURL.indexOf("&");
		if (ich !=-1)
			stURL=stURL.substring(0, ich)+"?"+stURL.substring(ich+1);
	}
	return stURL;
}
function MoveToViewDate(strdate, view_type)
{
	var wUrl=window.location.href;
	if (strdate !=null)
		wUrl=StURLSetVar2(wUrl,"CalendarDate",escapeProperly(strdate));
	if (view_type !=null)
		wUrl=StURLSetVar2(wUrl,"CalendarPeriod",view_type);
	SubmitFormPost(wUrl, true);
}
function MoveToDate(strdate)
{
	MoveToViewDate(strdate, null);
}
function MoveToToday()
{
	MoveToViewDate("", null);
}
function MoveView(viewtype)
{
	MoveToViewDate(null , viewtype);
}
function ClickDay(date)
{
	MoveToViewDate(date, null);
}
function GetMonthView(str)
{
	var wUrl=window.location.href;
	var ExpWeek=document.getElementById("ExpandedWeeksId");
	if(ExpWeek!=null)
		ExpWeek.value=str;
	else
		return ;
	SubmitFormPost(wUrl, true);
}
function NewItemDT(url,day, time)
{
	if (url==null)
		return ;
	if (time !=null)
	  url=StURLSetVar2(url,"CalendarTime",time);
	if (day !=null)
	  url=StURLSetVar2(url,"CalendarDate",day);
	NewItem(url, false);
}
function ClickTime(url, time)
{
  NewItemDT(url, null, time);
}
function NewItemDay(url, day)
{
  NewItemDT(url, day, null);
}
function HasValidUrlPrefix(url)
{
	var urlLower=url.toLowerCase();
	if (-1==urlLower.search("^http://") &&
		-1==urlLower.search("^https://"))
		return false;
	return true;
}
function ScrollToAnchorInInnerScrollPane(formName, hiddenFieldName, textInHref)
{
	if (!browseris.ie4up) return;
	try
	{
		var form=document.getElementById(formName);
		var anchor=document.getElementById(form[hiddenFieldName].value);
		if (typeof(anchor)=="undefined" || anchor==null)
			throw "";
	}
	catch(e)
	{
		var tempAnchor=null;
		for (var i=0; i < document.anchors.length; i++)
		{
			tempAnchor=document.anchors[i];
			var href=tempAnchor.href;
			if (href.search(textInHref) !=-1)
			{
				anchor=tempAnchor;
				break;
			}
		}
	}
	if (typeof(anchor) !="undefined" && anchor !=null)
	{
		var scrollTopOld=document.body.scrollTop;
		var scrollLeftOld=document.body.scrollLeft;
		anchor.scrollIntoView(false);
		document.body.scrollTop=scrollTopOld;
		document.body.scrollLeft=scrollLeftOld;
	}
}
function FilterChoice(opt, ctrl, strVal, filterVal)
{
	var i;
	var cOpt=0;
	var bSelected=false;
	var strHtml="";
	var strId=opt.id;
	var strName=opt.name;
	var strMatch="";
	var strMatchVal="";
	var strOpts=ctrl.choices;
	var rgopt=strOpts.split("|");
	var x=AbsLeft(ctrl);
	var y=AbsTop(ctrl)+ctrl.offsetHeight;
	var strHidden=ctrl.optHid;
	var iMac=rgopt.length - 1;
	var iMatch=-1;
	var unlimitedLength=false;
	var strSelectedLower="";
	if (opt !=null && opt.selectedIndex >=0)
	{
		bSelected=true;
		strSelectedLower=opt.options[opt.selectedIndex].innerText;
	}
	for (i=0; i < rgopt.length; i=i+2)
	{
		var strOpt=rgopt[i];
		while (i < iMac - 1 && rgopt[i+1].length==0)
		{
			strOpt=strOpt+"|";
			i++;
			if (i < iMac - 1)
			{
				strOpt=strOpt+rgopt[i+1];
			}
			i++;
		}
		var strValue=rgopt[i+1];
		var strLowerOpt=strOpt.toLocaleLowerCase();
		var strLowerVal=strVal.toLocaleLowerCase();
		if (filterVal.length !=0)
			bSelected=true;
		if (strLowerOpt.indexOf(strLowerVal)==0)
		{
			var strLowerFilterVal=filterVal.toLocaleLowerCase();
			if ((strLowerFilterVal.length !=0) && (strLowerOpt.indexOf(strLowerFilterVal)==0) && (strMatch.length==0))
				bSelected=false;
			if (strLowerOpt.length > 20)
			{
				unlimitedLength=true;
			}
			if (!bSelected || strLowerOpt==strSelectedLower)
			{
				strHtml+="<option selected value=\""+strValue+"\">"+STSHtmlEncode(strOpt)+"</option>";
				bSelected=true;
				strMatch=strOpt;
				strMatchVal=strValue;
				iMatch=i;
			}			
			else
			{
				strHtml+="<option value=\""+strValue+"\">"+STSHtmlEncode(strOpt)+"</option>";
			}
			cOpt++;
		}
	}
	var strHandler=" ondblclick=\"HandleOptDblClick()\" onkeydown=\"HandleOptKeyDown()\"";
	var strOptHtml="";
	if (unlimitedLength)
	{
		strOptHtml="<select tabIndex=\"-1\" ctrl=\""+ctrl.id+"\" name=\""+strName+"\" id=\""+strId+"\""+strHandler;
	}
	else
	{
		strOptHtml="<select class=\"ms-lookuptypeindropdown\" tabIndex=\"-1\" ctrl=\""+ctrl.id+"\" name=\""+strName+"\" id=\""+strId+"\""+strHandler;
	}
	if (cOpt==0)
	{
		strOptHtml+=" style=\"display:none;position:absolute;z-index:2;left:"+x+			"px;top:"+y+			"px\" onfocusout=\"OptLoseFocus(this)\"></select>";
	}
	else
	{
		strOptHtml+=" style=\"position:absolute;z-index:2;left:"+x+			"px;top:"+y+			"px\""+			" size=\""+(cOpt <=8 ? cOpt : 8)+"\""+			(cOpt==1 ? "multiple=\"true\"" : "")+			" onfocusout=\"OptLoseFocus(this)\">"+			strHtml+			"</select>";
	}
	opt.outerHTML=strOptHtml;
	var hid=document.getElementById(strHidden);
	if (iMatch !=0 || rgopt[1] !="0" )
		hid.value=strMatchVal;
	else
		hid.value="0";
	if (iMatch !=0 || rgopt[1] !="0" )
		return strMatch;
	else return "";
}
function OptLoseFocus(opt)
{
	var ctrl=document.getElementById(opt.ctrl);
	if (opt.selectedIndex >=0)
		SetCtrlFromOpt(ctrl, opt);
	opt.style.display="none";
}
function SetCtrlMatch(ctrl, opt)
{
	var hid=document.getElementById(ctrl.optHid);
	hid.value=opt.options[opt.selectedIndex].value;
	if (hid.value !=0)		
		ctrl.match=opt.options[opt.selectedIndex].innerText;
	else
		ctrl.match="";
}
function AbsLeft(obj)
{
	var x=obj.offsetLeft;
	var parent=obj.offsetParent;
	while (parent.tagName !="BODY")
	{
		x+=parent.offsetLeft;
		parent=parent.offsetParent;
	}
	x+=parent.offsetLeft;
	return x;
}
function AbsTop(obj)
{
	var y=obj.offsetTop;
	var parent=obj.offsetParent;
	while (parent.tagName !="BODY")
	{
		y+=parent.offsetTop;
		parent=parent.offsetParent;
	}
	y+=parent.offsetTop;
	return y;
}
function SetCtrlFromOpt(ctrl, opt)
{
	var hid=document.getElementById(ctrl.optHid);
	hid.value=opt.options[opt.selectedIndex].value;
	if (opt.options[opt.selectedIndex].value==0)
	{
		ctrl.value="";
		ctrl.match="";
	}
	else
	{
		ctrl.value=opt.options[opt.selectedIndex].innerText;
		ctrl.match=ctrl.value;		
	}	
}
function HandleOptDblClick()
{
	var opt=event.srcElement;
	var ctrl=document.getElementById(opt.ctrl);
	SetCtrlFromOpt(ctrl, opt);
	SetCtrlMatch(ctrl, opt);
	opt.style.display="none";
}
function HandleOptKeyDown()
{
	var opt=event.srcElement;
	var ctrl=document.getElementById(opt.ctrl);
	var key=event.keyCode;
	switch (key)
	{
	case 13:
	case 9:
		SetCtrlFromOpt(ctrl, opt)
		event.returnValue=false;
		opt.style.display="none";
		return;
	default:
		break;
	}
	return;
}
function EnsureSelectElement(ctrl, strId)
{
	var select=document.getElementById(strId);
	if (select==null)
	{
		select=document.createElement("SELECT");
		ctrl.parentNode.appendChild(select);
		select.outerHTML="<select id=\""+strId+"\" ctrl=\""+ctrl.id+"\" class=\"ms-lookuptypeindropdown\" name=\""+strId+"\" style=\"display:none\" onfocusout=\"OptLoseFocus(this)\"></select>";
		FilterChoice(select, ctrl, ctrl.value, "");
	}
	return document.getElementById(strId);;
}
function HandleKey()
{
	var key=event.keyCode;
	var ctrl=event.srcElement;
	var str=ctrl.value;
	var opt=EnsureSelectElement(ctrl, ctrl.opt);
	var bNeedMatch=false;
	var strLower;
	var strMatchLower;
	switch (key)
	{
	case 8:
		if (str.length > 0)
		{
			str=str.substr(0, str.length - 1);
		}
		bNeedMatch=true;
		break;
	case 16:
	case 17:
	case 18:
		return;
	case 9:
	case 16:
	case 17:
	case 18:
		return;
	case 13:
		strLower=ctrl.value.toLocaleLowerCase();
		strMatchLower=ctrl.match.toLocaleLowerCase();
		if (strMatchLower.indexOf(strLower) !=0)
			ctrl.match=FilterChoice(opt, ctrl, ctrl.value, "");
		if (opt.style.display !="none")
		{
			ctrl.value=ctrl.match;
			opt.style.display="none";
			event.returnValue=false;
		}
		return;
	case 27:
		opt.style.display="none";
		event.returnValue=false;
		return;
	case 38:
		if (opt.style.display !="none")
		{
			if (opt.selectedIndex > 0)
				opt.selectedIndex=opt.selectedIndex - 1;
			else
				opt.selectedIndex=opt.options.length - 1;
			SetCtrlMatch(ctrl, opt);
			event.returnValue=false;
		}
		return;		
	case 40:
		if (opt.style.display !="none" && opt.selectedIndex < opt.options.length - 1)
		{
			opt.selectedIndex=opt.selectedIndex+1;
			SetCtrlMatch(ctrl, opt);
			event.returnValue=false;
			return;
		}
		bNeedMatch=true;
		break;
	case 46:
		break;
	default:
		break;
	}
	if (bNeedMatch);
		ctrl.match=FilterChoice(opt, ctrl, str, "");
}
function ShowDropdown(textboxId)
{
	var ctrl=document.getElementById(textboxId);
	var str=ctrl.value;
	var opt=EnsureSelectElement(ctrl, ctrl.opt);
	ctrl.match=FilterChoice(opt, ctrl, "", ctrl.value);
	ctrl.focus();
}
function HandleChar()
{
	var ctrl=event.srcElement;
	var str=ctrl.value;
	var opt=document.getElementById(ctrl.opt);
	var key=event.keyCode;
	if (key==13)
		return;
	str=str+String.fromCharCode(key).toLocaleLowerCase();
	ctrl.match=FilterChoice(opt, ctrl, str, "");
}
function HandleLoseFocus()
{
	var ctrl=event.srcElement;
	var opt=document.getElementById(ctrl.opt);
	if (opt !=null && opt.style.display !="none" && document.activeElement !=opt)
		OptLoseFocus(opt);
}
function HandleChange()
{
	var ctrl=event.srcElement;
	var str=ctrl.value;
	var opt=document.getElementById(ctrl.opt);
	ctrl.match=FilterChoice(opt, ctrl, str, "");
}
function IsSafeHref(
	href)
{
	return (href.match(new RegExp("^http://", "i")) ||
			href.match(new RegExp("^https://", "i")) ||
			href.match(new RegExp("^ftp://", "i")) ||
			href.match(new RegExp("^file://", "i")) ||
			href.match(new RegExp("^mailto:", "i")) ||
			href.match(new RegExp("^news:", "i")) ||
			href.match(new RegExp("^/", "i")) ||
			href.match(new RegExp("^\\\\\\\\", "i")));
}
var L_RelativeUrlError_Text="从当前网页开始的地址可能显示不正确。必须输入完整的 URL，或者输入从当前服务器开始的地址。";
var L_UnknownProtocolUrlError_Text="超链接必须以 http://、https://、mailto:、news:、ftp://、file:// 或 \\\\ 开头。请检查该地址，然后重试。";
var L_UrlTooLongError_Text="位置的 URL 长度不能超过 256 个字符(不计查询参数)。查询参数从问号(?)处开始。"
function IsSafeHrefAlert(
	href,
	fAllowRelativeLinks)
{
	if (href.match("^[^?]{257}"))
	{
		alert(L_UrlTooLongError_Text);
		return false;
	}
	else if (IsSafeHref(href))
	{
		return true;
	}
	else
	{
		if (href.match("^[a-zA-Z]*:"))
		{
			alert(L_UnknownProtocolUrlError_Text);
			return false;
		}
		else if (true==fAllowRelativeLinks)
		{
			return true;
		}
		else
		{
			alert(L_RelativeUrlError_Text);
			return false;
		}
	}
}
function PositionMiniConsole() {
	var mc=document.getElementById("miniconsole");
	if (browseris.ie55up && browseris.win32)
		if (document.getElementById("siteactiontd")){
			mc.style.top="1";
		}
		else {
			mc.style.top="8";
		}
	else {
		mc.style.top="0";
	}
}
var deleteInstance=0;
function DeleteItemConfirmation()
{
	var message="";
	if (typeof(ItemIsCopy) !="undefined")
		if (ItemIsCopy)
			message=L_NotifyThisIsCopy_Text;
	if (recycleBinEnabled==1 &&
	deleteInstance !=1 )
		message+=L_STSRecycleConfirm_Text;
	else
		message+=L_STSDelConfirm_Text;
	return confirm(message);
}
function DeleteInstanceConfirmation()
{
	deleteInstance=1;
	return DeleteItemConfirmation()
}
function CancelMultiPageConfirmation(redirectUrl)
{
	var L_DeletePartialResponse1_text="已保存部分调查答复。单击“确定”可删除该部分调查答复。如果希望稍后继续此调查，请单击“取消”。可以在“所有答复”调查视图中找到您的部分答复。\n\n是否要将该部分答复发送到网站回收站?";
	var L_DeletePartialResponse2_text="已保存部分调查答复。单击“确定”可删除该部分调查答复。如果希望稍后继续此调查，请单击“取消”。可以在“所有答复”调查视图中找到您的部分答复。\n\n是否要删除该部分答复?";
	var message="";
	if (recycleBinEnabled==1)
		message=L_DeletePartialResponse1_text;
	else
		message=L_DeletePartialResponse2_text;
	if (confirm(message)==true)
		return true;
	else
		STSNavigate(redirectUrl);
	return false;
}
function RestoreItemVersionConfirmation()
{
	var L_Version_Restore_Confirm_Text="您将用所选版本替换当前版本。";
	var message=L_Version_Restore_Confirm_Text;
	return confirm(message);
}
function DeleteItemVersionConfirmation(bRecycleBinEnabled)
{
	var L_Version_Delete_Confirm_Text="是否确实要删除此版本?";
	var L_Version_Recycle_Confirm_Text="是否确实要将此版本发送到网站回收站?";
	if (bRecycleBinEnabled)
		return confirm(L_Version_Recycle_Confirm_Text);
	else
		return confirm(L_Version_Delete_Confirm_Text);
}
function DeleteUserInfoItemConfirmation()
{
	var L_User_Delete_Confirm_Text="您将删除此用户。";
	var message=L_User_Delete_Confirm_Text;
	return confirm(message);
}
function UnlinkCopyConfirmation(strItemUrl)
{
	return confirm(L_ConfirmUnlinkCopy_Text);
}
function Discuss(strUrl)
{
	var L_IE5upRequired_Text="“讨论”需要使用与 Windows SharePoint Services 兼容的应用程序和 Microsoft Internet Explorer 6.0 或更高版本。";
	if (browseris.ie5up && browseris.win32)
		window.parent.location.href=strUrl;
	else
		alert(L_IE5upRequired_Text);
}
function ProcessDefaultNavigateHierarchy(nodeDiv, dataSourceId, dataPath, url, listInContext, type, form, qsCore, submitPath)
{
	if (typeof(_spCustomNavigateHierarchy)=="function")
	{
		_spCustomNavigateHierarchy(nodeDiv,dataSourceId,dataPath,url,listInContext,type);
	}
	else
	{
		if (listInContext==false)
		{
			top.location=url;
		}
		else
		{
			var par=document.createElement('INPUT');
			par.type='hidden';
			par.name='_spTreeNodeClicked';
			par.value=dataPath;
			form.appendChild(par);
			var qs="?RootFolder="+escapeProperly(url)+qsCore;
			SubmitFormPost(submitPath+qs);
			return false;
		}
	}
}
function ParseMultiColumnValue(fieldValue, delimiter)
{
	var subColumnValues=new Array();
	if (delimiter==null)
		delimiter=';#';
	var lead=delimiter.charCodeAt(0);
	var trail=delimiter.charCodeAt(1);
	if (fieldValue==null || fieldValue.length==0)
		return subColumnValues;
	var strLead=delimiter.charAt(0);
	var strLeadLead=strLead+strLead;
	var escape=new RegExp(strLeadLead, "g");
	var unescape=delimiter.charAt(0);
	var start=0;
	if (fieldValue.substr(0, 2)==delimiter)
		start=2;
	var end=start;
	var bContainEscapedCharacters=false;
	var totalLength=fieldValue.length;
	while (end < totalLength)
	{
		var index=fieldValue.indexOf(strLead, end);
		if (index >=0)
		{
			end=index;
			end++;
			if (fieldValue.charCodeAt(end)==trail)
			{
				if (end - 1 > start)
				{
					var strSubColumn=fieldValue.substr(start, end - start - 1);
					if (bContainEscapedCharacters)
						strSubColumn=strSubColumn.replace(escape, unescape);
					subColumnValues.push(strSubColumn);
					bContainEscapedCharacters=false;
				}
				else
				{
					subColumnValues.push('');
				}
				end++;
				start=end;
				continue;
			}
			else if (fieldValue.charCodeAt(end)==lead)
			{
				end++;
				bContainEscapedCharacters=true;
				continue;
			}
			else
			{
				throw "ArgumentException";
			}
		}
		else
		{
			end=totalLength;
		}
	}
	if (end > start)
	{
		var strSubColumn=fieldValue.substr(start, end - start);
		if (bContainEscapedCharacters)
			strSubColumn=strSubColumn.replace(escape, unescape);
		subColumnValues.push(strSubColumn);
	}
	return subColumnValues;
}
function ConvertMultiColumnValueToString(
	subColumnValues,
	delimiter,
	bAddLeadingTailingDelimiter)
{
	if (delimiter==null)
		delimiter=";#";
	if (bAddLeadingTailingDelimiter==null)
		bAddLeadingTailingDelimiter=true;
	var strLead=delimiter.charAt(0);
	var strLeadLead=strLead+strLead;
	var escape=new RegExp(delimiter.charAt(0), "g");
	var bHasValue=false;
	var sb='';
	for (var i=0; i < subColumnValues.length; i++)
	{
		var strSubColumn=subColumnValues[i];
		if (strSubColumn !=null && strSubColumn.length > 0)
			strSubColumn=strSubColumn.replace(escape, strLeadLead);
		if (strSubColumn !=null && strSubColumn.length > 0)
			bHasValue=true;
		if (bAddLeadingTailingDelimiter || i !=0)
			sb+=delimiter;
		sb+=strSubColumn;
	}
	if (bHasValue)
	{
		if (bAddLeadingTailingDelimiter)
		{
			sb+=delimiter;
		}
		return sb;
	}
	else
		return '';
}
var httpFolderTarget=null;
var httpFolderSource=null;
var httpFolderDiv=null;
function NavigateHttpFolderCore()
{
	if (httpFolderDiv==null)
	{
		httpFolderDiv=document.createElement('DIV');
		document.body.appendChild(httpFolderDiv);
		httpFolderDiv.onreadystatechange=NavigateHttpFolderCore;
		httpFolderDiv.addBehavior('#default#httpFolder');
	}
	if (httpFolderDiv.readyState=="complete")
	{
		httpFolderDiv.onreadystatechange=null;
		try
		{
			var targetFrame=document.frames.item(httpFolderTarget);
			if (targetFrame !=null)
			{
				targetFrame.document.body.innerText=					L_WebFoldersRequired_Text;
			}
		}
		catch (e) {}
		var isOk=false;
		try
		{
			var ret="";
			ret=httpFolderDiv.navigateFrame(httpFolderSource,
				httpFolderTarget);
			if (ret=="OK")
				isOk=true;
		}
		catch (e) { }
		if (!isOk &&
			0==httpFolderSource.search("http://[a-zA-Z0-9\-\.]+(:80)?/"))
		{
			var sUrl=httpFolderSource
				.replace(/http:\/\/([a-zA-Z0-9\-\.]+)(:80)?[\/]/, "//$1/")
				.replace(/[\/]/g, "\\");
			var targetFrame=document.frames.item(httpFolderTarget);
			if (targetFrame !=null)
			{
				try
				{
						targetFrame.onload=null;
						targetFrame.document.location.href=sUrl;
						isOk=true;
				}
				catch (e) { }
			}
		}
		if (!isOk)
		{
			alert(L_WebFoldersError_Text);
		}
	}
}
function NavigateHttpFolder(urlSrc, frameTarget)
{
	if ('/'==urlSrc.charAt(0))
	{
		urlSrc=document.location.protocol+"//"+document.location.host+			urlSrc;
	}
	httpFolderSource=urlSrc;
	httpFolderTarget=frameTarget;
	NavigateHttpFolderCore();
}
function NavigateHttpFolderIfSupported(urlSrc, frameTarget)
{
	if (SupportsNavigateHttpFolder())
	{
		NavigateHttpFolder(urlSrc, frameTarget);
	}
	else
	{
		alert(L_WebFoldersError_Text);
		window.history.back();
	}
}
function SupportsNavigateHttpFolder()
{
	return (browseris.ie5up && browseris.win32);
}
function MsFloorTime(date, ms, exclusive)
{
	var time=date.getTime();
	if (exclusive)
		time=time - 1;
	time=ms * Math.floor(time / ms);
	return time;
}
function Calendar(yr, mon, dopt, stObject)
{
	if (!dopt)
		dopt=new DateOptions;
	this.dopt=dopt;
	var day=1;
	if (yr==null || mon==null)
		{
		var stCalDate=StURLGetVar("CalendarDate");
		if (stCalDate !="")
			{
			yr=stCalDate.substr(0, 4) - 0;
			var idxM2D=stCalDate.indexOf("-",5);
			if (idxM2D==-1)
				{
				mon=stCalDate.substr(5) - 1;
				}
			else
				{
				mon=stCalDate.substr(5, idxM2D-5) - 1;
				day=stCalDate.substr(idxM2D+1);
				}
			}
		if (stCalDate=="" || isNaN(dopt.DateYMD(yr, mon, 1)))
			{
			var dateToday=this.dopt.Today();
			yr=dateToday.getUTCFullYear();
			mon=dateToday.getUTCMonth();
			day=dateToday.getUTCDate();
			}
		}
	var stCalPeriod=StURLGetVar("CalendarPeriod");
	if (stCalPeriod=="week")
	{
		this.period="week";
		this.iperiod=1;
	}	
	else if (stCalPeriod=="day")
	{
		this.period="vday";
		this.iperiod=2;
	}
	else if (stCalPeriod=="vday")
	{
		this.period="vday";
		this.iperiod=2;		
	}
	else if (stCalPeriod=="month")
	{
		this.period="month";
		this.iperiod=0;		
	}
	else
	{
		this.period=dopt.CalendarPeriod;
		if (this.period=="week")
			this.iperiod=1;		
		else if (this.period=="day")
			this.iperiod=2;		
		else if (this.period=="vday")
			this.iperiod=2;		
		else
			this.iperiod=0;		
	}
	this.SetDate(yr, mon, day);
	if (this.iperiod==0 )
	{
		this.cchanMin=4;
		this.cchanMax=4;
	}
	else if (this.iperiod==1 )
	{
		this.cchanMin=20;
		this.cchanMax=20;
	}
	else
	{
		this.cchanMin=3;
		this.cchanMax=100;
	}
	this.ievtMax=0;
	this.rgEvt=new Array;
	this.fUseDHTML=(browseris.ie && browseris.verIEFull > 4.0 && browseris.win32)
					 || browseris.nav6up;
	this.fDatePicker=false;
	this.dateDP=null;
	if (!stObject)
		stObject="cal";
	this.stObject=stObject;
}
Calendar.msMinute=1000*60;
Calendar.msHour=Calendar.msMinute * 60;
Calendar.msDay=Calendar.msHour * 24;
Calendar.msWeek=Calendar.msDay * 7;
var L_rgDOW0_Text="周日";
var L_rgDOW1_Text="周一";
var L_rgDOW2_Text="周二";
var L_rgDOW3_Text="周三";
var L_rgDOW4_Text="周四";
var L_rgDOW5_Text="周五";
var L_rgDOW6_Text="周六";
Calendar.rgDOW=new Array(L_rgDOW0_Text, L_rgDOW1_Text, L_rgDOW2_Text,
						   L_rgDOW3_Text, L_rgDOW4_Text, L_rgDOW5_Text,
						   L_rgDOW6_Text);
var L_rgDOWLong0_Text="星期日";
var L_rgDOWLong1_Text="星期一";
var L_rgDOWLong2_Text="星期二";
var L_rgDOWLong3_Text="星期三";
var L_rgDOWLong4_Text="星期四";
var L_rgDOWLong5_Text="星期五";
var L_rgDOWLong6_Text="星期六";
Calendar.rgDOWLong=new Array(L_rgDOWLong0_Text, L_rgDOWLong1_Text, L_rgDOWLong2_Text,
						   L_rgDOWLong3_Text, L_rgDOWLong4_Text, L_rgDOWLong5_Text,
						   L_rgDOWLong6_Text);
var L_rgDOWDP0_Text="日";
var L_rgDOWDP1_Text="一";
var L_rgDOWDP2_Text="二";
var L_rgDOWDP3_Text="三";
var L_rgDOWDP4_Text="四";
var L_rgDOWDP5_Text="五";
var L_rgDOWDP6_Text="六";
Calendar.rgDOWDP=new Array(L_rgDOWDP0_Text, L_rgDOWDP1_Text, L_rgDOWDP2_Text,
							 L_rgDOWDP3_Text, L_rgDOWDP4_Text, L_rgDOWDP5_Text,
							 L_rgDOWDP6_Text);
var L_rgMonths0_Text="1 月";
var L_rgMonths1_Text="2 月";
var L_rgMonths2_Text="3 月";
var L_rgMonths3_Text="4 月";
var L_rgMonths4_Text="5 月";
var L_rgMonths5_Text="6 月";
var L_rgMonths6_Text="7 月";
var L_rgMonths7_Text="8 月";
var L_rgMonths8_Text="9 月";
var L_rgMonths9_Text="10 月";
var L_rgMonths10_Text="11 月";
var L_rgMonths11_Text="12 月";
Calendar.rgMonths=new Array(L_rgMonths0_Text, L_rgMonths1_Text,
							  L_rgMonths2_Text, L_rgMonths3_Text,
							  L_rgMonths4_Text, L_rgMonths5_Text,
							  L_rgMonths6_Text, L_rgMonths7_Text,
							  L_rgMonths8_Text, L_rgMonths9_Text,
							  L_rgMonths10_Text, L_rgMonths11_Text);
var L_MYDATE_Text="^2 年 ^1";
var L_YMDATE_Text="^1 年 ^2";
var L_MDYDATE_Text="^3 年 ^1 ^2 日";
var L_DMYDATE_Text="^3 年 ^1 ^2 日";
var L_YMDDATE_Text="^1 年 ^2 ^3 日";
var L_MDYDATESameYear_Text="^2 ^1 日";
var L_DMYDATESameYear_Text="^2 ^1 日";
var L_YMDDATESameYear_Text="^1 年 ^2 ^3 日";
var L_DATE1DATE2_Text="^1 - ^2";
var L_MDY_DOW_DATE_Text="^3 年 ^1 ^2 日 ^4";
var L_DMY_DOW_DATE_Text="^3 年 ^2 ^1 日 ^4";
var L_YMD_DOW_DATE_Text="^1 年 ^2 ^3 日 ^4";
Calendar.prototype.StMonthYear=CalStMonthYear;
function CalStMonthYear()
{
	var st="";
	if (this.iperiod !=0 )
		st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var stFormat="";
	var param1="";
	var param2="";
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
	case "DMY":
		param1=Calendar.rgMonths[this.mon];
		param2=this.yr;
		stFormat=L_MYDATE_Text;
		break;
	case "YMD":
		param1=this.yr;
		param2=Calendar.rgMonths[this.mon];
		stFormat=L_YMDATE_Text;
		break;
		}
	st+=StBuildParam(stFormat, param1, param2);
	if (this.iperiod !=0 )
		st+="</SPAN>";
	return st;
}
Calendar.prototype.StDaySpanMonthYear=CalDaySpanMonthYear;
function CalDaySpanMonthYear()
{
	var st="";
	var stStart="";
	var stEnd="";
	var stFormat1="";
	var stFormat2="";
	var param1="";
	var param2="";
	var param3="";
	var param4="";
	var param5="";
	var param6="";
	if (this.iperiod !=0 )
		st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var bDiffYears=this.dateStart.getUTCFullYear() !=this.dateEnd.getUTCFullYear();	
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
		param1=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param2=this.dateStart.getUTCDate();
		param3=this.dateStart.getUTCFullYear();
		if (bDiffYears)
			stFormat1=L_MDYDATE_Text;
		else
			stFormat1=L_MDYDATESameYear_Text;
		param4=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param5=this.dateEnd.getUTCDate();
		param6=this.dateEnd.getUTCFullYear();
		stFormat2=L_MDYDATE_Text;
		break;
	case "DMY":
		param1=this.dateStart.getUTCDate();
		param2=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param3=this.dateStart.getUTCFullYear();
		if (bDiffYears)
			stFormat1=L_DMYDATE_Text;
		else
			stFormat1=L_DMYDATESameYear_Text;
		param4=this.dateEnd.getUTCDate();
		param5=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param6=this.dateEnd.getUTCFullYear();
		stFormat2=L_DMYDATE_Text;
		break;
	case "YMD":
		param1=this.dateStart.getUTCFullYear();
		param2=Calendar.rgMonths[this.dateStart.getUTCMonth()];
		param3=this.dateStart.getUTCDate();
		if (bDiffYears)
			stFormat1=L_YMDDATE_Text;
		else
			stFormat1=L_YMDDATESameYear_Text;
		param4=this.dateEnd.getUTCFullYear();
		param5=Calendar.rgMonths[this.dateEnd.getUTCMonth()];
		param6=this.dateEnd.getUTCDate();
		stFormat2=L_YMDDATE_Text;
		break;
		}
	stStart=StBuildParam(stFormat1, param1, param2, param3);
	stEnd=StBuildParam(stFormat2, param4, param5, param6);
	st+=StBuildParam(L_DATE1DATE2_Text, stStart, stEnd);
	if (this.iperiod !=0 )
		st+="</SPAN>";
	return st;
}
Calendar.prototype.StDayMonthYear=CalStDayMonthYear;
function CalStDayMonthYear()
{
	var st="";
	st+='<SPAN style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+'.MoveMonth(0)')+'>';
	var stFormat="";
	var param1="";
	var param2="";
	var param3="";
	var param4=Calendar.rgDOWLong[this.dow];
	switch (this.dopt.stDateOrder)
		{
	case "MDY":
		param1=Calendar.rgMonths[this.mon];
		param2=this.day;
		param3=this.yr;
		stFormat=L_MDY_DOW_DATE_Text;
		break;
	case "DMY":
		param1=this.day;
		param2=Calendar.rgMonths[this.mon];
		param3=this.yr;
		stFormat=L_DMY_DOW_DATE_Text;
		break;
	case "YMD":
		param1=this.yr;
		param2=Calendar.rgMonths[this.mon];
		param3=this.day;
		stFormat=L_YMD_DOW_DATE_Text;
		break;
		}
	st+=StBuildParam(stFormat, param1, param2, param3, param4);
	st+="</SPAN>";
	return st;
}
function alertDate(st, date)
{
	alert(st+": yr="+date.getUTCFullYear()+" mon="+(date.getUTCMonth()+1)+" day="+date.getUTCDate());
}
Calendar.prototype.SetDate=CalSetDate;
function CalSetDate(yr, mon, day)
{
	var date=new Date(Date.UTC(yr, mon, day));
	this.dateStart=new Date(date.getTime());
	this.dateEnd=new Date(date.getTime());
	this.givenDate=new Date(date.getTime());
	if (this.iperiod==0  )
		{
		this.dateStart.setUTCDate(1);
		this.dateEnd.setTime(Date.UTC(yr, mon+1, 0));
		}
	var irw=0;
	if (this.iperiod !=2 )
		{
		this.dateStart.setUTCDate(this.dateStart.getUTCDate() - (this.dateStart.getUTCDay() -this.dopt.dow+7)%7);
		irw=this.IrwFromDate(this.dateEnd);
		this.dateEnd.setUTCDate(this.dateEnd.getUTCDate()+irw * 7 - 1);
		}
	this.irwMax=irw+1;
	if (this.iperiod==1 )
		{
		this.dateEnd.setTime(this.dateStart.getTime()+6 * Calendar.msDay);
		date=new Date(this.dateStart.getTime()+3 * Calendar.msDay);
		}
	else if (this.iperiod==2 )
		{
		this.dateTodayEnd=new Date(this.dateStart.getTime()+Calendar.msDay - 1);		
		}
	this.day=date.getUTCDate();
	this.mon=date.getUTCMonth();
	this.yr=date.getUTCFullYear();
	this.dow=date.getUTCDay();
}
Calendar.prototype.DayStyle=CalDayStyle;
function CalDayStyle(dateCur, fBottom, fTop, fWeekly)
{
	var st;
	var dateToday=this.dopt.Today();
	if (dateCur.getTime()==dateToday.getTime())
		{
			if (fBottom)
				st=' style="border-color:\'#FFD275\'; border-bottom-style:solid; border-left-style:solid; border-right-style:solid; border-bottom-width:2pt; border-left-width:2pt; border-right-width:2pt" ';
			else if (fTop)
				st=' style="border-color:\'#FFD275\'; border-top-style:solid; border-left-style:solid; border-right-style:solid; border-top-width:2pt; border-left-width:2pt; border-right-width:2pt" ';
			else
				st=' style="border-color:\'#FFD275\'; border-left-style:solid; border-right-style:solid; border-left-width:2pt; border-right-width:2pt" ';
		}
	else if (!fWeekly && dateCur.getUTCMonth() !=this.mon)
		{
			st=' BGCOLOR="#e6e6e6"';
		}
	else
		st="";
	return st;
}
Calendar.prototype.AddFullEvent=CalAddFullEvent;
function CalAddFullEvent(stDateStart, stDateEnd, stLocation, stDesc, stTitle, stURL, rgIcons)
{
	var dateStart;
	var dateEnd;
	if (stDateStart=="")
		return;
	dateStart=DateOptions.ParseISODate(stDateStart);
	if (stDateEnd=="")
		{
		dateEnd=new Date(dateStart.getTime());
		}
	else
		{
		dateEnd=DateOptions.ParseISODate(stDateEnd);
		}
	if (dateEnd < dateStart)
		dateEnd=new Date(dateStart.getTime());
	var displayDateStart=new Date(dateStart.getTime());
	var displayDateEnd=new Date(dateEnd.getTime());
	if (this.iperiod==2 )
	{
		if (dateStart > this.dateTodayEnd || dateEnd < this.dateStart)
			return;
		if (displayDateStart < this.dateStart)
			displayDateStart=this.dateStart;
		var minDisplay=Calendar.msHour/3;	
		if (dateEnd.getTime() < dateStart.getTime()+minDisplay)
			displayDateEnd=new Date(dateStart.getTime()+minDisplay);
	}
	stURL+="&Source="+escapeProperly(window.location.href);
	var evt=new CalEvent(displayDateStart, displayDateEnd, dateStart, dateEnd, stLocation, stDesc, stTitle, stURL, rgIcons);
	this.AddEvent(evt);
}
Calendar.prototype.AddEvent=CalAddEvent;
function CalAddEvent(evt)
{
	this.rgEvt[this.ievtMax++]=evt;
}
Calendar.prototype.AssignChannels=CalAssignChannels;
function CalAssignChannels()
{
	var ievt;
	this.mpSpan=new Object;
	this.mpIchan=new Object;
	this.mpEvents=new Object;
	var fAllDaySeparate=false;
	var dateTodayStart;
	var dateTodayEnd;
	if (this.iperiod==2 )
		{
		fAllDaySeparate=true;
		dateTodayStart=this.dateStart;
		dateTodayEnd=this.dateTodayEnd;
		this.mpNoTimeEvents=new Array;
		this.mpAllDayEvents=new Array;
		var dailyStart=this.dopt.WorkDayStartHour - this.dopt.DailyStartHourDelta;
		var dailyEnd=this.dopt.WorkDayEndHour+this.dopt.DailyEndHourDelta;
		if (dailyStart < 0) dailyStart=0;
		if (dailyEnd > 24) dailyEnd=24;
		this.minQuarterStart=4*dailyStart;
		this.maxQuarterEnd=4*dailyEnd-1;
		for (ievt=0; ievt < this.rgEvt.length; ievt++)
			{
			evt=this.rgEvt[ievt];
			if ((evt.actualDateStart > dateTodayEnd || (evt.actualDateEnd-1) < dateTodayStart)
				|| (evt.actualDateStart <=dateTodayStart && evt.actualDateEnd >=dateTodayEnd))
				continue;
			irwMin=this.IrwFromDate(evt.dateStart);
			if (irwMin < 0)
				irwMin=0;
			irwMax=this.IrwFromDate(evt.dateEnd);
			if (irwMax > this.irwMax)
				irwMax=this.irwMax;
			if (irwMin < this.irwMax && irwMax >=0)
				{
				for (irw=irwMin; irw <=irwMax; irw++)
					{
					var date=new Date;
					this.SetDateFromGrid(date, irw, 0);
					if (date < dateTodayStart || date >=dateTodayEnd)
						continue;
					var quarterRow=date.getTime()/(Calendar.msHour/4);
					var quarterStart=MsFloorTime(evt.dateStart, Calendar.msHour/4, 0)/(Calendar.msHour/4) - quarterRow;
					var quarterEnd=MsFloorTime(evt.dateEnd, Calendar.msHour/4, 1)/(Calendar.msHour/4) - quarterRow+1;
					if (quarterEnd < quarterStart)
						quarterEnd=quarterStart;
					if (quarterStart < this.minQuarterStart)
						this.minQuarterStart=quarterStart;
					if (quarterEnd > this.maxQuarterEnd)
						this.maxQuarterEnd=quarterEnd;
					if (quarterStart > 0 && 95 - quarterStart < 2)
						this.FVdayOverflow=true;
					}
				}
			}
			this.minQuarterStart=Math.floor(this.minQuarterStart/4)*4;
			if (this.minQuarterStart < 0)
				this.minQuarterStart=0;
			if (this.maxQuarterEnd > 95)	
				this.maxQuarterEnd=95;
			else
				this.maxQuarterEnd=4 * (Math.floor(this.maxQuarterEnd/4)+1) - 1;
		}
	if (this.iperiod <=1 )	
		this.rgEvt.sort(CalEvtSort);
	var todayMiliSec=this.dateStart;
	todayMiliSec.setUTCHours(0,0,0,0);
	todayMiliSec=todayMiliSec.getTime();
	for (ievt=0; ievt < this.rgEvt.length; ievt++)
		{
		evt=this.rgEvt[ievt];
		if (fAllDaySeparate)
		{
			if (evt.actualDateStart.getTime()==todayMiliSec
				&& evt.actualDateEnd.getTime()==todayMiliSec)
				{
					this.mpNoTimeEvents[this.mpNoTimeEvents.length]=evt;
					continue;
				}
			if (evt.actualDateStart <=dateTodayStart
				&& evt.actualDateEnd >=dateTodayEnd)
				{
					this.mpAllDayEvents[this.mpAllDayEvents.length]=evt;
					continue;
				}
		}
		irwMin=this.IrwFromDate(evt.dateStart);
		if (irwMin < 0)
			irwMin=0;
		irwMax=this.IrwFromDate(evt.dateEnd);
		if (irwMax > this.irwMax)
			irwMax=this.irwMax;
		if (irwMin < this.irwMax && irwMax >=0)
			{
			for (irw=irwMin; irw <=irwMax; irw++)
				{
				this.PlaceEventInRow(evt, irw);
				}
			}
		}
}
function CalEvtSort(e1, e2)
{
	if (e1.multiDay ^ e2.multiDay)
	{
		if (e1.multiDay)
			return -1;
		else
			return 1;
	}
	else if (e1.multiDay)
	{
		var d1=e1.dateEnd - e1.dateStart;
		var d2=e2.dateEnd - e2.dateStart;
		if (d2 < d1)
			return -1;
		else if (d2 > d1)
			return 1;
		else
			return 0;
	}
	else
	{
		if (e1.dateStart < e2.dateStart)
			return -1;
		else if (e1.dateStart > e2.dateStart)
			return 1;
		else
			return 0;
	}
}
Calendar.prototype.PlaceEventInRow=CalPlaceEventInRow;
function CalPlaceEventInRow(evt, irw)
{
	var span;
	var date=new Date;
	this.SetDateFromGrid(date, irw, 0);
	if (this.iperiod==2 )
		{
		if (irw !=0)	
			return;
		var quarterRow=date.getTime()/(Calendar.msHour/4);
		var quarterStart=MsFloorTime(evt.dateStart, Calendar.msHour/4, 0)/(Calendar.msHour/4) - quarterRow;
		var quarterEnd=MsFloorTime(evt.dateEnd, Calendar.msHour/4, 1)/(Calendar.msHour/4) - quarterRow;
		if (quarterEnd < quarterStart)
			quarterEnd=quarterStart;
		var workdayStart;
		var workdayEnd;
		if (this.iperiod==2 )
			{
			workdayStart=this.minQuarterStart;
			workdayEnd=this.maxQuarterEnd;
			}
		else
			{
			workdayStart=4*this.dopt.WorkDayStartHour;
			workdayEnd=4*this.dopt.WorkDayEndHour-1;
			}
		if (quarterEnd >=workdayStart && quarterStart <=workdayEnd)
			{
			if (this.FVdayOverflow)
				workdayEnd=99;
			quarterStart=Math.max(quarterStart, workdayStart);
			quarterEnd=Math.min(quarterEnd, workdayEnd);
			ichan=this.IchanNext(irw, quarterStart, quarterEnd);
			new Span(this, irw, quarterStart, quarterEnd, ichan, evt);
			}
		}
	else
		{
		var dayRow;
		var dayStart;
		var dayEnd;
		dayRow=date.getTime()/Calendar.msDay;
		dayStart=MsFloorTime(evt.dateStart, Calendar.msDay, 0)/Calendar.msDay - dayRow;
		dayEnd=MsFloorTime(evt.dateEnd, Calendar.msDay, 1)/Calendar.msDay - dayRow;
		if (dayEnd < dayStart
			|| (evt.actualDateEnd.getTime()-evt.actualDateStart.getTime()) < Calendar.msDay)
			{
			dayEnd=dayStart;
			}
		if (dayEnd >=0 && dayStart <=6)
			{
			dayStart=Math.max(dayStart, 0);
			dayEnd=Math.min(dayEnd, 6);
			ichan=this.IchanNext(irw, dayStart, dayEnd);
			new Span(this, irw, dayStart, dayEnd, ichan, evt);
			}
		}
}
function Span(cal, irw, start, end, ichan, evt)
{
	this.evt=evt;
	this.cbucket=end - start+1;
	if (cal.iperiod==2 )
		{
		evt.ichan=ichan;
		evt.ihour=start;
		var maxEnd=cal.maxQuarterEnd;
		if (maxEnd==95)	
			maxEnd=99;
		evt.rowspan=Math.min(this.cbucket, 1+maxEnd - start);
		}
	cal.mpSpan[irw+"."+start+"."+ichan]=this;
	for (bucket=start; bucket <=end; bucket++)
		{
		cal.mpIchan[irw+"."+bucket]=ichan+1;
		var rgevt=cal.mpEvents[irw+"."+bucket];
		if (rgevt==null)
			{
			rgevt=new Array;
			cal.mpEvents[irw+"."+bucket]=rgevt;
			}
		rgevt[rgevt.length]=evt;
		}
}
Calendar.prototype.IchanNext=CalIchanNext;
function CalIchanNext(irw, start, end)
{
	var bucket;
	var ichan=0;
	for (bucket=start; bucket <=end; bucket++)
		{
		if (this.mpIchan[irw+"."+bucket] !=null)
			ichan=Math.max(ichan, this.mpIchan[irw+"."+bucket]);
		}
	return ichan;
}
Calendar.prototype.IrwFromDate=CalIrwFromDate;
function CalIrwFromDate(date)
{
	var irw;
	irw=Math.floor((date.getTime() - this.dateStart.getTime())/Calendar.msWeek);
	return irw;
}
Calendar.prototype.BuildUI=CalBuildUI;
function CalBuildUI()
{
	var st=this.StBuild();
	document.write(st);
}
Calendar.prototype.StBuild=CalStBuild;
function CalStBuild()
{
	this.AssignChannels();
	if (this.fDatePicker)
		return this.StBuildPicker();
	if (!this.fUseDHTML)
		return this.StDownlevelBuild();
	return this.StBuildDHTML();
}
Calendar.prototype.StBuildDHTML=CalStBuildDHTML;
function CalStBuildDHTML()
{
	var st;
	var span;
	var dateCur=new Date;
	var irw;
	var iday;
	var ichan;
	var cchan;
	var ihour;
	var iHourStart;
	var iHourEnd;
	var iGrayStart;	
	var iGrayEnd;	
	iHourStart=iGrayStart=4*this.dopt.WorkDayStartHour;
	iHourEnd=4*this.dopt.WorkDayEndHour;
	iGrayEnd=iHourEnd - 1;
	if (this.iperiod==2 )
		{
		iHourStart=this.minQuarterStart;
		iHourEnd=this.maxQuarterEnd+1;
		if (iHourEnd==96 && this.FVdayOverflow)
			iHourEnd=100;
		}
	var stTDHigh='<th style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');" ';
	if (this.iperiod==2 )
		{
		cchan=this.IchanNext(0, iHourStart, iHourEnd);
		var cNoTime=this.mpNoTimeEvents.length;
		var cAllDay=this.mpAllDayEvents.length;
		cchan=Math.max(cchan, this.cchanMin);
		if (this.cchanMax > 0)
			cchan=Math.min(cchan, this.cchanMax);
		st="<table width=100% class=ms-cal cellpadding=0 cellspacing=0>";
		st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(-1)')+' class=ms-calhead style="cursor:pointer;" width=8%>&lt;</th><th width=84% class=ms-calhead nowrap>'+			this.StDayMonthYear()+			'</th>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(1)')+' class=ms-calhead style="cursor:pointer;" width=8%>&gt;</th></tr>';
		if (cNoTime > 0)
			{
			st+="</table><table width=100% class=ms-cal cellpadding=0 cellspacing=0>\r";
			st+="<tr height=0><td width="+(this.dopt.AllDayWidth+8)+"pt/><td/></tr>\r";
			st+="<tr><td class=ms-CalAllDay rowspan="+(cNoTime+1)+"></td><td width=1%/></tr>";
			for (i=0; i < cNoTime; i++)
				{
					evt=this.mpNoTimeEvents[i];
					st+="<tr><td class=ms-Vapptsingle style='border-top:1px solid black; border-left:1px solid black; border-bottom:1px solid black; border-right:1px solid black;' ";
					st+=" TITLE="+StAttrQuote(evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(evt, this.dopt, 2)+"</nobr></td></tr>\r";
				}
			}
		if (cAllDay > 0)
			{
			st+="</table><table width=100% class=ms-cal cellpadding=0 cellspacing=0>\r";
			st+="<tr height=0><td width="+(this.dopt.AllDayWidth+8)+"pt/><td/></tr>\r";
			st+="<tr><td class=ms-CalAllDay rowspan="+(cAllDay+1)+">"+this.dopt.L_AllDay_Text+"</td><td width=1%/></tr>";
			for (i=0; i < cAllDay; i++)
				{
					evt=this.mpAllDayEvents[i];
					st+="<tr><td class=ms-Vapptsingle style='border-top:1px solid black; border-left:1px solid black; border-bottom:1px solid black; border-right:1px solid black;' ";
					st+=" TITLE="+StAttrQuote(evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(evt, this.dopt, 2)+"</nobr></td></tr>\r";
				}
			}
		st+="</table><table width=100% STYLE='table-layout:fixed' class=ms-vcal cellpadding=0 cellspacing=0>\r";
		st+="<tr height=0><td width="+this.dopt.AllDayWidth+"pt/><td width=8pt/>\r";
		for (ichan=1; ichan < cchan; ichan++)
			{
				st+="<td/>\r";
			}
		st+="</tr>\r";
		var LayoutGrid=new Object;
		var HitDetect=new Array(iHourEnd);
		for (ihour=iHourStart; ihour < iHourEnd; ihour++)
			{
			HitDetect[ihour]=0;
			for (ichan=0; ichan < cchan; ichan++)
				LayoutGrid[ihour+"."+ichan]=0;
			}
		for (i=0; i < this.rgEvt.length; i++)
			{
			var evt=this.rgEvt[i];
			var ihour=evt.ihour;
			var ichan=evt.ichan;
			var rowspan=evt.rowspan;
			var max=ichan+1;
			for (irow=0; irow < rowspan; irow++)
				if (HitDetect[ihour+irow] > max)
					max=HitDetect[ihour+irow];
			for (irow=0; irow < rowspan; irow++)
				{
				HitDetect[ihour+irow]=max;
				LayoutGrid[(ihour+irow)+"."+ichan]=1;
				}
			}
		for (i=0; i < this.rgEvt.length; i++)
			{
			var width=0;
			var irow=0;
			ihour=this.rgEvt[i].ihour;
			max=HitDetect[ihour]
			rowspan=this.rgEvt[i].rowspan;
			var hit=0;
			var popMax=false;
			for (irow=1; irow < rowspan; irow++)
				{
				hit=HitDetect[ihour+irow];
				popMax |=hit !=max;
				if (hit > max)
					max=hit;
				}
			if (!popMax)
				continue;
			for (irow=0; irow < rowspan; irow++)
				HitDetect[ihour+irow]=max;
			}
		for (i=this.rgEvt.length-1; i >=0; i--)
			{
			var width=0;
			var irow=0;
			ihour=this.rgEvt[i].ihour;
			max=HitDetect[ihour]
			rowspan=this.rgEvt[i].rowspan;
			var hit=0;
			var popMax=false;
			for (irow=1; irow < rowspan; irow++)
				{
				hit=HitDetect[ihour+irow];
				popMax |=hit !=max;
				if (hit > max)
					max=hit;
				}
			if (!popMax)
				continue;
			for (irow=0; irow < rowspan; irow++)
				HitDetect[ihour+irow]=max;
			}
		for (ihour=iHourStart; ihour < iHourEnd; ihour++)
			{
			st+="<tr>\r";
			if (ihour%4==0)
				{
				var stHour=ihour/4;
				if (stHour==24)
					stHour="&nbsp;";
				else if (this.dopt.f12Hour)
					{
					stHour=((ihour/4+11)%12+1);
					if (this.dopt.TimeMarkPosn==0)
						{
						stHour+=" "+((ihour/4 < 12) ? this.dopt.stAM : this.dopt.stPM);
						}
					else
						stHour=((ihour/4 < 12) ? this.dopt.stAM : this.dopt.stPM)+" "+stHour;
					}
				var stGrayBG="";
				if ((ihour < iGrayStart || ihour > iGrayEnd))
				{
					stGrayBG=' BGCOLOR="#e6e6e6" ';
				}
				if (ihour !=iHourStart || cAllDay > 0 || cNoTime > 0)
					{
					st+="<td class=ms-CalHour rowspan=2"+stGrayBG+"><nobr>"+stHour+"</nobr></td>";
					st+="<td class=ms-calHour"+stGrayBG+">&nbsp;</td>\r";
					}
				else
					{
					st+="<td class=ms-firstCalHour rowspan=2"+stGrayBG+"><nobr>"+stHour+"</nobr></td>";
					st+="<td class=ms-firstCalHour"+stGrayBG+">&nbsp;</td>\r";
					}
				}
			else if (ihour%2==0)
				{
				st+="<td class=ms-CalHalfHour"+stGrayBG+">&nbsp;</td>\r";
				st+="<td class=ms-calHalfHour"+stGrayBG+">&nbsp;</td>\r";
				}
			else if (ihour%4==1)
				{
				st+="<td class=ms-CalQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				}
			else if (ihour%4==3)
				{
				st+="<td class=ms-CalQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				st+="<td class=ms-calQuarterHour"+stGrayBG+">&nbsp;</td>\r";
				}
			for (ichan=0; ichan < cchan; ichan++)
				{
				span=this.mpSpan[0+"."+ihour+"."+ichan];
				if (span !=null)
					{
					var stClass="ms-Vappt";
					var rowspan=span.evt.rowspan;
					var colspan=Math.floor(cchan / HitDetect[ihour]);
					if (colspan > cchan / this.cchanMin)
						colspan=Math.floor(cchan / this.cchanMin);
					var reduceby=colspan - 1;
					if (reduceby > 0)
						for (irow=0; irow < rowspan; irow++)
							{
							reduceby=colspan - 1;
							for (jchan=cchan-1; jchan > ichan && reduceby > 0; jchan--)
								{
								if (LayoutGrid[(ihour+irow)+"."+jchan]==0)
									{
										LayoutGrid[(ihour+irow)+"."+jchan]=1;
										reduceby--;
									}
								}
							}
					st+="<td class="+stClass+						" style='border-top:1px solid black; border-left:1px solid black; border-bottom:2px solid black; border-right:2px solid black;' rowspan="+span.evt.rowspan;
					if (colspan > 1)
						st+=" colspan="+colspan;
					st+=" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>"+						StRenderVDayEvt(span.evt, this.dopt, span.evt.rowspan)+"</nobr></td>\r";
					}
				else if (LayoutGrid[ihour+"."+ichan]==0)
					{
					if (ihour%4==0)
						{
						if (ihour !=iHourStart || cAllDay > 0 || cNoTime > 0)
							st+="<td class=ms-calHour"+stGrayBG+">&nbsp;</td>\r";
						else
							st+="<td class=ms-firstCalHour"+stGrayBG+">&nbsp;</td>\r";
						}
					else if (ihour%2==0)
						st+="<td class=ms-calHalfHour"+stGrayBG+">&nbsp;</td>\r";
					else
						st+="<td class=ms-calQuarterHour"+stGrayBG+">&nbsp;</td>\r";
					}
				}
			st+="</tr>\r";
			}
		st+="<tr>\r";
		for (ichan=-2; ichan < cchan; ichan++)
			{
			st+="<td class=ms-CalHour>&nbsp;</td>\r";
			}
		st+="</tr>\r";
		}
	else
		{
		var fWeekly=this.iperiod==1;
		st="<table width=100% class=ms-cal cellpadding=0 cellspacing=0>";
		st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(-1)')+' class=ms-calhead style="cursor:pointer;">&lt;</td><td class=ms-calhead colspan=5>';
		if (this.iperiod==0 )
			st+=this.StMonthYear();
		else
			st+=this.StDaySpanMonthYear();
		st+='</td>'+stTDHigh+StClickEvent(this.stObject+'.MoveDate(1)')+' class=ms-calhead style="cursor:pointer;">&gt;</td></tr>';
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			st+="<td class=ms-calDOW>"+Calendar.rgDOW[(iday+this.dopt.dow)%7]+"</td>\r";
			}
		st+="</tr>";
		for (irw=0; irw < this.irwMax; irw++)
			{
			cchan=Math.max(this.IchanNext(irw, 0, 6), this.cchanMin);
			if (this.cchanMax > 0)
				cchan=Math.min(cchan, this.cchanMax);
			st+="<tr>\r";
			for (iday=0; iday < 7; iday++)
				{
				this.SetDateFromGrid(dateCur, irw, iday);
				st+='<td class=ms-calTop'+this.DayStyle(dateCur, false, true, fWeekly)+					'>&nbsp;<span style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+".MoveToDay("+dateCur.getUTCFullYear()+","+(dateCur.getUTCMonth()+1)+","+dateCur.getUTCDate()+")")+">"+dateCur.getUTCDate()+"</span>&nbsp;</td>\r";
				}
			st+="</tr>\r";
			for (ichan=0; ichan < cchan; ichan++)
				{
				if (this.iperiod==1 )
				{	
					st+="<tr>\r";
					for (iday=0; iday < 7; iday++)
						{
						this.SetDateFromGrid(dateCur, irw, iday);
						if (ichan==cchan-1 && this.SpanCheck(irw, iday, ichan, cchan))
							{
								st+="<td class=ms-apptsingle "+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>";
							}
						else
							{
							span=this.mpSpan[irw+"."+iday+"."+ichan];
							if (span !=null
								&& !span.evt.multiDay
								&& 0 !=span.evt.actualDateStart.getTime() % Calendar.msDay
								&& 0 !=span.evt.actualDateEnd.getTime() % Calendar.msDay)
								{
								var stClass="ms-apptsingle"+this.DayStyle(dateCur, false, false, fWeekly);
								st+="<td class="+stClass+											" colspan="+span.cbucket+" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>";
								st+=StEvtTime(span.evt, this.dopt, true);
								st+="&nbsp;</nobr></td>\r";
								iday+=span.cbucket - 1;
								}
							else
								{
								st+="<td class=ms-calMid"+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>\r";
								}
							}
						}
					st+="</tr>\r";
				}
				st+="<tr>\r";
				for (iday=0; iday < 7; iday++)
					{
					this.SetDateFromGrid(dateCur, irw, iday);
					if (ichan==cchan-1 && this.SpanCheck(irw, iday, ichan, cchan))
						{
							st+="<td class=ms-apptsingle "+this.DayStyle(dateCur, false, false, fWeekly)+							'><span style="cursor:pointer;" onmouseover="HighlightText(this, \'red\');" onmouseout="HighlightText(this, \'\');"'+StClickEvent(this.stObject+".MoveToDay("+dateCur.getUTCFullYear()+","+(dateCur.getUTCMonth()+1)+","+dateCur.getUTCDate()+")")+							">"+this.dopt.L_More_Text+"</span></td>\r";
						}
					else
						{
						span=this.mpSpan[irw+"."+iday+"."+ichan];
						if (span !=null)
							{
							var stClass="ms-appt";
							if (!span.evt.multiDay)
								stClass="ms-apptsingle"+this.DayStyle(dateCur, false, false, fWeekly);
							st+="<td class="+stClass+								" colspan="+span.cbucket+" TITLE="+StAttrQuote(span.evt.StTip(this.dopt))+"><nobr>"+								StURL(span.evt.stURL, span.evt.stTitle)+"</nobr></td>\r";
							iday+=span.cbucket - 1;
							}
						else
							{
							st+="<td class=ms-calMid"+this.DayStyle(dateCur, false, false, fWeekly)+">&nbsp;</td>\r";
							}
						}
					}
				st+="</tr>\r";
				st+="<tr>\r";
				if (ichan==cchan-1)
					stClass="ms-CalBot";
				else
					stClass="ms-CalSpacer";
				for (iday=0; iday < 7; iday++)
					{
					this.SetDateFromGrid(dateCur, irw, iday);
					st+="<td class="+stClass+this.DayStyle(dateCur, ichan==cchan-1, false, fWeekly)+">&nbsp;</td>\r";
					}
				st+="</tr>\r";
				}
			}
		}
	st+="</table>";
	return st;
}
Calendar.prototype.SpanCheck=CalSpanCheck;
function CalSpanCheck(irw, iday, ichan, cchan)
{
	var span;
	var i;
	var iMax;
	if (this.IchanNext(irw, iday, iday) > cchan)
		return true;
	span=this.mpSpan[irw+"."+iday+"."+ichan];
	if (span !=null)
	{
		iMax=span.cbucket+iday;
		if (iMax > 7)
			iMax=7;
		for (i=iday+1; i<iMax; i++)
		{
			if (this.IchanNext(irw, i, i) > cchan)
				return true;
		}
	}
	return false;
}
function StRenderVDayEvt(evt, dopt, rowSpan)
{
	var st="";
	st+="<table height=12px border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse; padding-right:6px' ><tr>";
	if (evt.rgIcons && evt.rgIcons.length)
	{
		var i;
		var bAllBlank=true;
		for (i in evt.rgIcons)
			if (evt.rgIcons[i] && evt.rgIcons[i].indexOf("blank.gif") < 0)
			{
				bAllBlank=false;
				break;
			}				
		if (!bAllBlank)
		{
			st+="<td valign=top nowrap>";
			for (i in evt.rgIcons)
				if (evt.rgIcons[i] && evt.rgIcons[i].length)
					st+=evt.rgIcons[i];
			st+="</td>";
		}
	}
	st+="<td nowrap>"+StURL(evt.stURL, evt.stTitle)+"</td></tr></table>";
	if (rowSpan > 2)
		st+="<nobr>"+StEvtTime(evt, dopt, false)+"</nobr>";
	if (rowSpan > 3
		&& evt.stLocation !=null)
		st+="<br><nobr>"+STSHtmlEncode(evt.stLocation)+"</nobr>";
	return st;
}
function StEvtTime(evt, dopt, fAMPM)
{
	var st="";
	if (fAMPM)
		st+=dopt.StTime(evt.actualDateStart);
	else
		st+=dopt.StBareTime(evt.actualDateStart);
	if (evt.actualDateStart.getTime() !=evt.actualDateEnd.getTime()
		&& (MsFloorTime(evt.actualDateStart, Calendar.msDay, 0)==MsFloorTime(evt.actualDateEnd, Calendar.msDay, 0)
			|| (evt.actualDateEnd.getTime() - evt.actualDateStart.getTime()) < Calendar.msDay))
		{
		st+=" - ";
		if (fAMPM)
			st+=dopt.StTime(evt.actualDateEnd);
		else
			st+=dopt.StBareTime(evt.actualDateEnd);
		}
	return st;
}
function StClickEvent(st)
{
	return 'onclick="'+st+'" ondblclick="'+st+'"';
}
var L_TodaysDate_Text="今天是 ^1";
Calendar.prototype.StBuildPicker=CalStBuildPicker;
function CalStBuildPicker()
{
	var st;
	var dateCur=new Date;
	var dateToday=this.dopt.Today();
	var irw;
	var iday;
	var stClass;
	var ievt;
	var L_LittleRedDiamond_TXT="&loz;"; 
	st='<TABLE ONSELECTSTART="return false;" CLASS=ms-datepicker CELLPADDING="2" CELLSPACING="0" BORDER="1">\r';
	var stTDHigh='<td style="cursor:pointer;" onmouseover="Highlight(this, \'yellow\', \'black\');" onmouseout="Highlight(this, \'\', \'\');" ';
	st+='<tr>'+stTDHigh+StClickEvent(this.stObject+'.MoveMonth(-1)')+' class=ms-dpnextprev>&lt;</td><td class=ms-dphead colspan=5>'+		this.StMonthYear()+		'</td>'+stTDHigh+StClickEvent(this.stObject+'.MoveMonth(1)')+' class=ms-dpnextprev>&gt;</td></tr>';
	st+="<tr>\r";
	for (iday=0; iday < 7; iday++)
		{
		st+='<TD class=ms-dpdow HEIGHT="20" WIDTH="14%">'+			'&nbsp;'+Calendar.rgDOWDP[(iday+this.dopt.dow)%7]+'&nbsp;</TD>\r';
		}
	st+="</tr>\r";
	for (irw=0; irw < this.irwMax; irw++)
		{
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			this.SetDateFromGrid(dateCur, irw, iday);
			var rgevt=this.mpEvents[irw+"."+iday];
			var fHasEvent=(rgevt !=null);
			var yr=dateCur.getUTCFullYear();
			var mon=dateCur.getUTCMonth();
			var day=dateCur.getUTCDate();
			st+=stTDHigh+StClickEvent(this.stObject+'.ClickDay('+yr+','+mon+','+day+')');
			if (fHasEvent)
				{
				var stTips="";
				for (ievt=0; ievt < rgevt.length; ievt++)
					{
					stTips+=rgevt[ievt].StTip(this.dopt);
					if (ievt < rgevt.length-1)
						stTips+="\r";
					}
				st+=" TITLE="+StAttrQuote(stTips);
				}
			st+=' WIDTH="14%"'+				this.DPDayStyle(dateCur, fHasEvent)+'>&nbsp;'+(fHasEvent ? "<b>" : "")+				dateCur.getUTCDate()+(fHasEvent ? "</b>" : "")+				(dateCur.getTime()==dateToday.getTime() ? "<font color=red>"+L_LittleRedDiamond_TXT+"</font>" : "&nbsp;");
			st+='</TD>\r';
			}
		st+="</tr>\r";
		}
	var stTodayLink="<A HREF='javascript:"+this.stObject+".SetDate("+dateToday.getUTCFullYear()+","+		dateToday.getUTCMonth()+","+dateToday.getUTCDate()+");'>"+this.dopt.StDate(dateToday)+"</A>";
	st+="<tr><td class=ms-DPFoot colspan=7><font color=red>&loz;</font>"+		StBuildParam(L_TodaysDate_Text, stTodayLink)+"</td></tr>";
	st+="</table>";
	return st;
}
Calendar.prototype.MoveDate=CalMoveDate;
function CalMoveDate(delta)
{
	if(this.iperiod==2 )
		this.MoveVDay(delta);
	else if (this.iperiod==1 )
		this.MoveWeek(delta);
	else
		this.MoveMonth(delta);
}
Calendar.prototype.MoveMonth=CalMoveMonth;
function CalMoveMonth(dmon)
{
	var stURL;
	var mon=this.givenDate.getUTCFullYear() * 12+this.givenDate.getUTCMonth()+dmon;
	var yr=Math.floor(mon / 12);
	mon=mon % 12;
	if (dmon !=0)
		stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon+1)+"-1");
	else
		stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon+1)+"-"+(this.givenDate.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "month");
	this.Post(stURL);
}
Calendar.prototype.MoveWeek=CalMoveWeek;
function CalMoveWeek(dweek)
{
	var stURL;
	var date=this.givenDate;
	date.setUTCDate(this.givenDate.getUTCDate()+7*dweek);
	stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+(date.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "week");
	this.Post(stURL);
}
Calendar.prototype.MoveDay=CalMoveDay;
Calendar.prototype.MoveVDay=CalMoveDay;
function CalMoveDay(dday)
{
	var stURL;
	var date=this.givenDate;
	date.setUTCDate(this.givenDate.getUTCDate()+dday);
	stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+(date.getUTCDate()));
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "day");
	this.Post(stURL);
}
Calendar.prototype.MoveToDay=CalMoveToDay;
function CalMoveToDay(yr, mon, day)
{
	var stURL;
	stURL=StURLSetVar("CalendarDate", yr+"-"+St2Digits(mon)+"-"+day);
	stURL=StURLSetVar2(stURL, "CalendarPeriod", "day");
	this.Post(stURL);
}
Calendar.prototype.MoveToToday=CalMoveToToday;
function CalMoveToToday()
{
	var date=this.dopt.Today();
	var stURL=StURLSetVar("CalendarDate", date.getUTCFullYear()+"-"+St2Digits(date.getUTCMonth()+1)+"-"+date.getUTCDate());
	this.Post(stURL);
}
Calendar.prototype.Post=CalDoPost;
function CalDoPost(stURL)
{
	if (this.stViewID && this.stViewID.length)
		stURL=StURLSetVar2(stURL, "View", this.stViewID);
	SubmitFormPost(stURL);
}
function EditSeries(stEditURL)
{
	var stID="";
	if (stEditURL)
		stID=StSearchVar(stEditURL, "ID");
	else
		stID=StURLGetVar("ID");
	if (stID.length)
	{
		var iOccurDate=stID.indexOf(".0.");
		if (iOccurDate > 0)
		{
			var stURL="";
			if (stEditURL)
			{
				stURL=window.location.href;
				var ichQ=stURL.indexOf("?");
				if (ichQ > 0)
					stEditURL+=stURL.substring(ichQ, stURL.length);
				stURL=StURLSetVar2(stEditURL, "ID", stID.substr(0, iOccurDate));
			}
			else
				stURL=StURLSetVar("ID", stID.substr(0, iOccurDate));
			window.location.href=stURL;
		}
	}
}
function EditSeriesID(stMasterID, stEditURL)
{
	if (stMasterID.length)
	{
		var stURL="";
		if (stEditURL)
		{
			stURL=window.location.href;
			var ichQ=stURL.indexOf("?");
			if (ichQ > 0)
				stEditURL+=stURL.substring(ichQ, stURL.length);
			stURL=StURLSetVar2(stEditURL, "ID", stMasterID);
		}
		else
			stURL=StURLSetVar("ID", stMasterID);
		window.location.href=stURL;
	}
}
function StURLSetVar(stVar, stValue)
{
	return StURLSetVar2(window.location.href, stVar, stValue);
}
function StViewURLSetVar(viewPage, stVar, stValue)
{
	stUrl=window.location.href;
	p1=stUrl.lastIndexOf("/");
	if (p1 > 0)
		stUrl=stUrl.substring(0, p1+1)+viewPage;
	return StURLSetVar2(stUrl, stVar, stValue);
}
function StURLSetVar2(stURL, stVar, stValue)
{
	var stNewSet=stVar+"="+stValue;
	var ichQ=stURL.indexOf("?");
	if (ichQ !=-1)
		{
		var ich=stURL.indexOf("?"+stVar+"=", ichQ);
		if (ich==-1)
			{
			ich=stURL.indexOf("&"+stVar+"=", ichQ);
			if (ich !=-1)
				stNewSet="&"+stNewSet;
			}
		else
			{
			stNewSet="?"+stNewSet;
			}
		if (ich !=-1)
			{
			var re=new RegExp("[&?]"+stVar+"=[^&]*", "");
			stURL=stURL.replace(re, stNewSet);
			}
		else
			{
			stURL=stURL+"&"+stNewSet;
			}
		}
	else
		stURL=stURL+"?"+stNewSet;
	return stURL;
}
function StURLGetVar(stVar)
{
	var stURL=document.location.href;
	return StSearchVar(stURL, stVar);
}
function StSearchVar(st, stVar)
{
	var re=new RegExp("[?&]"+stVar+"=", "g");
	var ich=st.search(re);
	if (ich==-1)
		return "";
	ich+=stVar.length+2;
	var ichEnd=st.indexOf("&", ich+1);
	if (ichEnd==-1)
		ichEnd=st.length;
	var stValue=st.substring(ich, ichEnd);
	return stValue;
}
function HighlightText(elt, stText)
{
	if (stText !="")
		{
		elt.colorTextSav=elt.style.color;
		elt.style.color=stText;
		}
	else
		{
		elt.style.color=elt.colorTextSav;
		}
}
function Highlight(elt, stHighlight, stText)
{
	if (stHighlight !="")
		{
		elt.colorBackSav=elt.style.backgroundColor;
		elt.colorTextSav=elt.style.color;
		elt.style.backgroundColor=stHighlight;
		elt.style.color=stText;
		}
	else
		{
		elt.style.backgroundColor=elt.colorBackSav;
		elt.style.color=elt.colorTextSav;
		}
}
Calendar.prototype.DPDayStyle=CalDPDayStyle;
function CalDPDayStyle(dateCur, fHasEvent)
{
	var st="";
	if (dateCur.getTime()==this.dateDP.getTime())
		st+=" class=ms-dpselectedday";
	else if (dateCur.getUTCMonth() !=this.mon)
		st+=" class=ms-dpnonmonth";
	else
		st+=" class=ms-dpday";
	if (fHasEvent)
		{
		st+=' style:"font-weight: bold;"';
		}
	return st;
}
Calendar.prototype.StDownlevelBuild=CalStDownlevelBuild;
function CalStDownlevelBuild()
{
	var st;
	var dateCur=new Date;
	var irw;
	var iday;
	var stClass;
	var ievt;
	st='<TABLE CELLPADDING="2" CELLSPACING="0" WIDTH="100%" BORDER="1">\r';
	st+='<TR><TD class=ms-calhead><A class=ms-calhead TARGET=_self HREF="javascript:'+this.stObject+'.MoveDate(-1);"><B>&lt;</B></A></TD><TD class=ms-calhead colspan=5>'+		this.StMonthYear()+		'</TD><TD class=ms-calhead><A class=ms-calhead TARGET=_self HREF="javascript:'+this.stObject+'.MoveDate(1);"><B>&gt;</B></A></TD></TR>';
	st+="<tr>\r";
	for (iday=0; iday < 7; iday++)
		{
		st+='<TD class=ms-calDOWDown HEIGHT="20" WIDTH="14%">'+			'&nbsp;'+Calendar.rgDOW[(iday+this.dopt.dow)%7]+"&nbsp;</TD>\r";
		}
	st+="</tr>\r";
	for (irw=0; irw < this.irwMax; irw++)
		{
		st+="<tr>\r";
		for (iday=0; iday < 7; iday++)
			{
			this.SetDateFromGrid(dateCur, irw, iday);
			st+='<TD class=ms-calDown HEIGHT="80" WIDTH="14%"'+				this.DayStyle(dateCur)+'>&nbsp;'+dateCur.getUTCDate()+"&nbsp;<br>\r";
			var rgevt=this.mpEvents[irw+"."+iday];
			if (rgevt !=null)
				{
				for (ievt=0; ievt < rgevt.length; ievt++)
					{
					st+=StURL(rgevt[ievt].stURL, rgevt[ievt].stTitle)+'<br>\r';
					}
				}
			st+='</TD>';
			}
		st+="</tr>\r";
		}
	st+="</table>";
	return st;
}
Calendar.prototype.SetDateFromGrid=CalSetDateFromGrid;
function CalSetDateFromGrid(date, irw, iday)
{
	date.setTime(this.dateStart.getTime()+irw * Calendar.msWeek+		iday*Calendar.msDay);
}
var L_NoTitle_Text="(无标题)";
function CalEvent(dateStart, dateEnd, actualDateStart, actualDateEnd, stLocation, stDesc, stTitle, stURL, rgIcons)
{
	this.dateStart=dateStart;
	this.dateEnd=dateEnd;
	this.actualDateStart=actualDateStart;
	this.actualDateEnd=actualDateEnd;
	this.stLocation=stLocation;
	this.stDesc=stDesc;
	this.stTitle=stTitle;
	if (stTitle.length==0)
		this.stTitle=L_NoTitle_Text;
	this.stURL=stURL;
	this.rgIcons=rgIcons;
	var start;
	var end;
	var dayStart=MsFloorTime(dateStart, Calendar.msDay, 0);
	var dayEnd=MsFloorTime(dateEnd, Calendar.msDay, 1);
	if (dayStart < dayEnd
		&& (actualDateEnd.getTime() - actualDateStart.getTime()) >=Calendar.msDay)
	{
		this.multiDay=true;
	}
	else
		this.multiDay=false;
	var quarterStart=MsFloorTime(dateStart, Calendar.msHour/4, 0);
	var quarterEnd=MsFloorTime(dateEnd, Calendar.msHour/4, 1);
	if (quarterStart < quarterEnd)
		this.multiQuarter=true;
}
CalEvent.prototype.FOverlap=EvtFOverlap;
function EvtFOverlap(evt)
{
	return evt.dateStart <=this.dateEnd && evt.dateEnd >=this.dateStart;
}
var L_Tip_Text="^1: ^2";
CalEvent.prototype.StTip=EvtStTip;
function EvtStTip(dopt)
{
	var stT;
	var stTime=StEvtTime(this, dopt, true);
	if (DateOptions.FHasTime(this.actualDateStart) || DateOptions.FHasTime(this.actualDateEnd))
		stT=StBuildParam(L_Tip_Text, stTime, this.stTitle);
	else
		stT=this.stTitle;
	if (!FBlankString(this.stLocation))
		stT+="\r"+this.stLocation;
	if (!FBlankString(this.stDesc))
		stT+="\r"+this.stDesc;
	return stT;
}
cGCMinimumWidth=400;
cGCMinimumHeight=200;
cGCMaxGCResizeCount=10;
var glGCObjectHeight=0;
var glGCObjectWidth=0;
glGCResizeCounter=0;
function TestGCObject( GCObject )
{
	if (((browseris.ie55up) && (typeof(GCObject)=="undefined")) || (GCObject==null) || (GCObject.object==null))
		return false;
	return true;
}
function GCComputeSizing(GCObject)
{
	if (TestGCObject(GCObject))
	{
		var fBIDI=(document.documentElement.currentStyle.direction=="rtl");
		var lGCWindowWidth=document.documentElement.scrollWidth;
		var lGCWindowHeight=document.documentElement.scrollHeight;
		var lGCObjectOffsetLeft=0;
		var lGCObjectOffsetTop=0;
		if (fBIDI)
			{
			lGCObjectOffsetLeft=-180;
			lGCObjectOffsetTop=120;
			}
		else
			{
			lGCObjectOffsetLeft=32;
			lGCObjectOffsetTop=-2;
			}
		var lGCObjectWalker=GCObject.parentElement;
		while (lGCObjectWalker !=document.body)
		{
			lGCObjectOffsetLeft+=lGCObjectWalker.offsetLeft;
			lGCObjectOffsetTop+=lGCObjectWalker.offsetTop;
			lGCObjectWalker=lGCObjectWalker.offsetParent;
			if (fBIDI)
				if (lGCObjectWalker.offsetLeft > 0)
					break;
		}
		lGCObjectOffsetLeft+=GCObject.parentElement.offsetLeft;
		lGCObjectOffsetTop+=GCObject.parentElement.offsetTop;
		glGCObjectHeight=lGCWindowHeight - lGCObjectOffsetTop;
		if (glGCObjectHeight > lGCWindowHeight)
			glGCObjectHeight=lGCWindowHeight
		if (glGCObjectHeight < cGCMinimumHeight)
			glGCObjectHeight=cGCMinimumHeight;
		if (fBIDI)
			{
			glGCObjectWidth=lGCWindowWidth+lGCObjectOffsetLeft;
			}
		else
			glGCObjectWidth=lGCWindowWidth - lGCObjectOffsetLeft;
		if (glGCObjectWidth > lGCWindowWidth)
				glGCObjectWidth=lGCWindowWidth;
		if (glGCObjectWidth < cGCMinimumWidth)
			glGCObjectWidth=cGCMinimumWidth;
	}
}
function GCResizeGridControl(GCObject)
{
	if (TestGCObject(GCObject))
	{
		var lGCOldObjectHeight=glGCObjectHeight;
		var lGCOldglGCObjectWidth=glGCObjectWidth;
		GCComputeSizing(GCObject);
		if (lGCOldObjectHeight !=glGCObjectHeight)
			GCObject.height=glGCObjectHeight;
		if (lGCOldglGCObjectWidth !=glGCObjectWidth)
			GCObject.width=glGCObjectWidth;
	}
}
function GCWindowResize(GCObject)
{
	if (TestGCObject(GCObject))
	{
		glGCResizeCounter=0;
		GCResizeGridControl(GCObject);
	}
}
function GCOnResizeGridControl(GCObject)
{
	if (TestGCObject(GCObject))
	{
		if (glGCResizeCounter < cGCMaxGCResizeCount)
		{
			glGCResizeCounter++;
			GCResizeGridControl(GCObject);
		}
	}
}
function GCActivateAndFocus(GCObject)
{
	if (TestGCObject(GCObject))
	{
		GCObject.SetActive;
		GCObject.Focus;
 	}
}
function GCNavigateToNonGridPage()
{
	var strDocUrl=window.location.href;
	gridPart=strDocUrl.match("ShowInGrid=");
	if (gridPart)
	{
		gridSet=/ShowInGrid=\w*/;
		strDocUrl=strDocUrl.replace(gridSet, "");	
	}
   	var idxQuery=strDocUrl.indexOf("?");
	if (idxQuery !=-1)
		{
		var idxQry2=strDocUrl.indexOf("?", idxQuery+1);
		if (idxQry2 !=-1)
			strDocUrl=strDocUrl.slice(0, idxQry2);
		strDocUrl=strDocUrl+"&";
		}
	else
		strDocUrl=strDocUrl+"?";
	strDocUrl=strDocUrl+"ShowInGrid=False";
	document.location.replace(STSPageUrlValidation(strDocUrl));
}
function GCAddNewColumn(GCObject,path)
{
	if (TestGCObject(GCObject))
	{
	  var source=window.location.href;
	  var listName=GCObject.Name;
	  var colName=GCObject.SelectedColumnUniqueName;
	  var ltr=GCObject.RightToLeft;
	  var viewGUID=GCObject.ViewGUID;
	  var page="FldNew.aspx";
	  var listServerTemplate=GCObject.ServerTemplate;
	  if (listServerTemplate=="102" )
	  {
	    page="QstNew.aspx";
	  }
	  path=path+"/_layouts/"+page+"?List="+listName+"&View="+viewGUID+"&Source="+source+"&RelativeToField="+colName+"&LTR="+ltr;
	  window.location=path
	}
}
function GCEditDeleteColumn(GCObject,path)
{
	if (TestGCObject(GCObject))
	{
		  var source=window.location.href;
		  var colName=GCObject.SelectedColumnUniqueName;
		  var listName=GCObject.Name;
		  var page="FldEdit.aspx";
		  var listServerTemplate=GCObject.ServerTemplate;
		  if (listServerTemplate=="102" )
		  {
		    page="QstEdit.aspx";
		  }
		  path=path+"/_layouts/"+page+"?List="+listName+"&Field="+colName+"&Source="+source;
		  window.location=path
	}
}
function GCShowHideTaskPane(GCObject)
{
	if (TestGCObject(GCObject))
	{
		var state=GCObject.DisplayTaskPane;
		GCObject.DisplayTaskPane=!state;
	}
}
function GCShowHideTotalsRow(GCObject)
{
	if (TestGCObject(GCObject))
	{
		var state=GCObject.DisplaySheetTotals;
		GCObject.DisplaySheetTotals=!state;
	}
}
function GCGridNewRow(GCObject)
{
	if (TestGCObject(GCObject))
	{
		GCObject.SelectNewRow();
	}
}
function GCRefresh(GCObject)
{
	if (TestGCObject(GCObject))
	{
		GCObject.Refresh();
	}
}
function GCNewFolder(GCObject)
{
	if (TestGCObject(GCObject))
	{
		GCObject.NewFolder();
	}
}
var L_Edit_Text="编辑";
var L_ViewItem_Text="查看项目";
var L_EditItem_Text="编辑项目";
var L_EditSeriesItem_Text="编辑序列";
var L_DeleteItem_Text="删除项目";
var L_DeleteDocItem_Text="删除";
var L_ViewProperties_Text="查看属性";
var L_EditProperties_Text="编辑属性";
var L_ViewResponse_Text="查看答复";
var L_EditResponse_Text="编辑答复";
var L_DeleteResponse_Text="删除答复";
var L_Subscribe_Text="通知我";
var L_CustomizeNewButton_Text="更改“新建”按钮的顺序";
var L_Review_Text="请求审阅";
var L_EditIn_Text="在 ^1 中编辑";
var L_EditInApplication_Text="编辑文档"
var L_Checkin_Text="签入";
var L_Checkout_Text="签出";
var L_DiscardCheckou_Text="放弃签出";
var L_CreateDWS_Text="创建文档工作区";
var L_PublishBack_Text="发布到源位置";
var L_Versions_Text="版本历史记录";
var L_WorkOffline_Text="连接到客户端";
var L_Reply_Text="答复";
var L_ExportContact_Text="导出联系人";
var L_ExportEvent_Text="导出事件";
var L_Reschedule_Text="重新计划选项";
var L_Move_Text="移动";
var L_Keep_Text="保留";
var L_Delete_Text="删除";
var L_Open_Text="打开";
var L_SiteSettings_Text="更改网站设置";
var L_ManageUsers_Text="管理用户";
var L_DeleteSite_Text="删除网站";
var L_SiteStorage_Text="管理网站存储";
var L_MngPerms_Text="管理权限";
var L_Settings_Text="设置";
var L_Remove_Text="从此列表中删除";
var L_ModerateItem_Text="批准/拒绝";
var L_PublishItem_Text="发布主要版本";
var L_CancelPublish_Text="取消审批";
var L_UnPublishItem_Text="取消发布此版本";
var L_DownloadOriginal_Text="下载图片";
var L_EditVersion_Text="编辑";
var L_EditInOIS_Text="编辑图片";
var L_Workflows_Text="工作流";
var L_Send_Text="发送到";
var L_ExistingCopies_Text="现有副本";
var L_OtherLocation_Text="其他位置";
var L_GoToSourceItem_Text="转到源项目";
var L_NotifyThisIsCopy_Text="此项目从其他位置复制而来，并可从该位置接收更新。应确保该源停止发送更新，否则会重新创建该项目。\n\n";
var L_SendToEmail_Text="通过电子邮件发送链接";
var L_DownloadACopy_Text="下载副本";
var L_DocTran_Text="转换文档";
var L_AddToMyLinks_Text="添加到“我的链接”";
var L_AddToCategory_Text="提交到门户区域";
var L_VS_DownArrow_Text="选择视图";
var L_ModifyView="修改此视图";
var L_CreateView="新建视图";
function resetExecutionState()
{
	IsMenuShown=false;
	itemTable=null;
	EndDeferItem();
	imageCell=null;
	onKeyPress=false;
	currentCtx=null;
	currentEditMenu=null;
	currentItemID=null;
	downArrowText=null;
	currentItemAppName=null;
	currentItemProgId=null;
	currentItemIcon=null;
	currentItemOpenControl=null;
	currentItemModerationStatus=null;
	currentItemUIString=null;
	currentItemCheckedoutToLocal=null;
	currentItemCanModify=null;
	currentItemFileUrl=null;
	currentItemFSObjType=null;
	currentItemCheckedOutUserId=null;
	currentItemCheckoutExpires=null;
	currentItemPermMaskH=null;
	currentItemPermMaskL=null;
	currentItemIsEventsExcp=null;
	currentItemIsEventsDeletedExcp=null;
}
function IsMenuEnabled()
{
	return (browseris.ie55up || browseris.nav6up || browseris.safari125up);
}
function GetSelectedElement(elem, tagName)
{
	while(elem !=null && elem.tagName !=tagName)
		elem=elem.parentNode;
	return elem;
}
function setupMenuContext(ctx)
{
	currentCtx=ctx;
}
function FindSTSMenuTable(elm, strSearch)
{
	var str=elm.getAttribute(strSearch);
	while (elm !=null && (str==null ||str==""))
	{
		elm=GetSelectedElement(elm.parentNode, "TABLE");
		if (elm !=null)
			str=elm.getAttribute(strSearch);
	}
	return elm;
}
function OnLinkDeferCall(elm)
{
	if (!IsMenuEnabled())
		return false;
	elm.onblur=OutItem;
	elm.onkeydown=PopMenu;
	var elmTmp=FindSTSMenuTable(elm, "CTXName");
	if (elmTmp==null)
		return false;
	OnItem(elmTmp);
	return false;
}
function StartDeferItem(elm)
{
	if (elm !=itemTable)
	{
		itemTableDeferred=elm;
		elm.onmouseout=EndDeferItem;
		elm.onclick=DeferredOnItem;
		elm.oncontextmenu=DeferredOnItem;
	}
}
function DeferredOnItem(e)
{
	var elm=itemTableDeferred;
	if (elm !=null)
	{
		MenuHtc_hide();
		OnItem(elm);
		CreateMenu(e);
		return false;
	}
}
function EndDeferItem()
{
	var elm=itemTableDeferred;
	if (elm !=null)
	{
		itemTableDeferred=null;
		elm.onmouseout=null;
		elm.onclick=null;
		elm.oncontextmenu=null;
	}
}
function GetFirstChildElement(e)
{
	for (var i=0; i < e.childNodes.length; i++)
	{
		if (e.childNodes[i].nodeType==1)
			return e.childNodes[i];
	}
	return null;
}
function GetLastChildElement(e)
{
	for (var i=e.childNodes.length-1; i >=0; i--)
	{
		if (e.childNodes[i].nodeType==1)
			return e.childNodes[i];
	}
	return null;
}
function OnItemDeferCall(elm)
{
	if (!IsMenuEnabled())
		return false;
	if (IsMenuOn())
	{
		StartDeferItem(elm);
		return false;
	}
	if (itemTable !=null)
		OutItem();
	itemTable=elm;
	currentItemID=GetAttributeFromItemTable(itemTable, "ItemId", "Id");
	var createCtx=new Function("setupMenuContext("+itemTable.getAttribute("CTXName")+");");
	createCtx();
	var ctx=currentCtx;
	if (browseris.nav6up)
		itemTable.className="ms-selectedtitlealternative";
	else
		itemTable.className="ms-selectedtitle";
	if (browseris.ie5up && !browseris.ie55up)
	{
		itemTable.onclick=EditMenuDefaultForOnclick;
		itemTable.oncontextmenu=EditMenuDefaultForOnclick;
	}
	else
	{
		itemTable.onclick=CreateMenu;
		itemTable.oncontextmenu=CreateMenu;
	}
	itemTable.onmouseout=OutItem;
	var titleRow;
	titleRow=GetFirstChildElement(GetFirstChildElement(itemTable));
	if (titleRow !=null)
	{
		imageCell=GetLastChildElement(titleRow);
	}
	if (ctx.listTemplate==200)
	{
		if (itemTable.getAttribute("menuType")=="Orphaned")
			downArrowText=L_Reschedule_Text;
	}
	else
		downArrowText=L_Edit_Text;
	var imageTag=GetFirstChildElement(imageCell);
	imageTag.src=ctx.imagesPath+"menudark.gif";
	imageTag.alt=downArrowText;
	imageTag.style.visibility="visible";
	imageCell.className="ms-menuimagecell";
	return false;
}
function OutItem()
{
	if (!IsMenuOn() && itemTable !=null)
	{
		itemTable.className="ms-unselectedtitle";
		itemTable.onclick=null;
		itemTable.oncontextmenu=null;
		itemTable.onmouseout=null;
		if (imageCell !=null)
		{
			GetFirstChildElement(imageCell).style.visibility="hidden";
			imageCell.className="";
		}
		resetExecutionState();
	}
}
function IsMenuOn()
{
	if (!IsMenuShown)
		return false;
	var fIsOpen=false;
	fIsOpen=MenuHtc_isOpen(currentEditMenu);
	if (!fIsOpen)
		IsMenuShown=false;
	return fIsOpen;
}
function PopMenu(e)
{
	if (!IsMenuEnabled())
		return true;
	if (e==null)
		e=window.event;
	var nKeyCode;
	if (browseris.nav6up)
		nKeyCode=e.which;
	else
		nKeyCode=e.keyCode;
	if (!IsMenuOn() && ((e.shiftKey && nKeyCode==13) || (e.altKey && nKeyCode==40)))
	{
		onKeyPress=true;
		CreateMenu(e);
		onKeyPress=false;
		return false;
	}
	else
		return true;
}
function CreateMenuEx(ctx, container, e)
{
	if (container==null)
		return;
	IsMenuShown=true;
	document.body.onclick="";
	var m;
	m=CMenu(currentItemID+"_menu");
	if (!m)
		return;
	else if (ctx.isVersions)
		AddVersionMenuItems(m, ctx);
	else if (ctx.listBaseType==1)
		AddDocLibMenuItems(m, ctx);
	else if (ctx.listTemplate==200)
		AddMeetingMenuItems(m, ctx);
	else
		AddListMenuItems(m, ctx);
	InsertFeatureMenuItems(m, ctx);
	currentEditMenu=m;
	container.onmouseout=null;
	OMenu(m, container, null, null, -1);
	itemTable=GetSelectedElement(container, "TABLE");
	m._onDestroy=OutItem;
	e.cancelBubble=true;
	return false;
}
function CreateMenu(e)
{
	if (!IsContextSet())
		return;
	var ctx=currentCtx;
	if (e==null)
		e=window.event;
	var srcElement=e.srcElement ? e.srcElement : e.target;
	if (itemTable==null || imageCell==null ||
		(onKeyPress==false &&
		 (srcElement.tagName=="A" ||
		  srcElement.parentNode.tagName=="A")))
		return;
	return CreateMenuEx(ctx, itemTable, e);
}
function AddSendSubMenu(m,ctx)
{
	strDisplayText=L_Send_Text;
	var currentItemUrl=GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
	var currentItemEscapedFileUrl;
	var currentItenUnescapedUrl;
	var strExtension;
	if (currentItemFileUrl !=null)
   {
	currentItenUnescapedUrl=unescapeProperly(currentItemFileUrl);
	currentItemEscapedFileUrl=escapeProperly(currentItenUnescapedUrl);
	strExtension=SzExtension(currentItenUnescapedUrl);
	if (strExtension !=null && strExtension !="")
   		strExtension=strExtension.toLowerCase();
	}
	var sm=CASubM(m,strDisplayText,"","",400);
	sm.id="ID_Send";
	var menuOption;
	var serverFileRedirect=itemTable.getAttribute("SRed");
	if (currentItemProgId !="SharePoint.WebPartPage.Document" &&
		(serverFileRedirect==null || serverFileRedirect=="" || HasRights(0x0, 0x20)) && strExtension !="aspx")
	{
		if (typeof(ctx.SendToLocationName) !="undefined" &&
			ctx.SendToLocationName !=null &&
			ctx.SendToLocationName !="" &&
			typeof(ctx.SendToLocationUrl) !="undefined" &&
			ctx.SendToLocationUrl !=null &&
			ctx.SendToLocationUrl !="")
		{
			strAction="STSNavigate('"+				ctx.HttpRoot+				"/_layouts/copy.aspx?"+				"SourceUrl="+				currentItemEscapedFileUrl+				"&Source="+				GetSource()+"&FldUrl="+				escapeProperly(ctx.SendToLocationUrl)+"')";
			menuOption=CAMOpt(sm,
								ctx.SendToLocationName,
								strAction,
								"");
		}
		if (typeof(itemTable.getAttribute("HCD")) !="undefined" && itemTable.getAttribute("HCD")=="1")
		{
			strDisplayText=L_ExistingCopies_Text;
			strAction="STSNavigate('"+ctx.HttpRoot+				"/_layouts/updatecopies.aspx?"+				"SourceUrl="+				currentItemEscapedFileUrl+				"&Source="+				GetSource()+"')";
			strImagePath=ctx.imagesPath+"existingLocations.gif";
			menuOption=CAMOpt(sm, strDisplayText, strAction, strImagePath);
			menuOption.id="ID_ExistingCopies";
		}
		strDisplayText=L_OtherLocation_Text;
		strAction="STSNavigate('"+			ctx.HttpRoot+			"/_layouts/copy.aspx?"+			"SourceUrl="+			currentItemEscapedFileUrl+			"&Source="+			GetSource()+"')";
		strImagePath=ctx.imagesPath+"sendOtherLoc.gif";
		menuOption=CAMOpt(sm, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_OtherLocation";
		if (ctx.OfficialFileName !=null && ctx.OfficialFileName !="")
		{
			strDisplayText=ctx.OfficialFileName;
			strAction="STSNavigate('"+				ctx.HttpRoot+				"/_layouts/SendToOfficialFile.aspx?"+				"SourceUrl="+				currentItemEscapedFileUrl+				"&Source="+				GetSource()+"')";
			strImagePath="";
			CAMOpt(sm, strDisplayText, strAction, strImagePath);
		}
		CAMSep(sm);
	}
	if(HasRights(0x10, 0x0))
	{
		strDisplayText=L_SendToEmail_Text;
		var currentItemUrl=GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
		var httpRootWithSlash=ctx.HttpRoot.substr(0);
		if (httpRootWithSlash[httpRootWithSlash.length-1] !='/')
			httpRootWithSlash+='/';
		var slashLoc=-1;
		var fileUrl="";
		slashLoc=httpRootWithSlash.substring(8).indexOf('/')+8;
		fileUrl=httpRootWithSlash.substr(0, slashLoc)+			escapeProperlyCore(unescapeProperly(currentItemUrl), true);
		var serverFileRedir=itemTable.getAttribute("SRed");
		if ((serverFileRedir !=null) &&
			(serverFileRedir !="") &&
			(serverFileRedir !="1"))
		{
			if (serverFileRedir.substring(0,1) !="1")
			{
				fileUrl=serverFileRedir;
			}
			else
			{
				fileUrl=serverFileRedir.substring(1);
			}
		}
		strAction="javascript:navigateMailToLinkNew('"+fileUrl+"')";
		strImagePath=ctx.imagesPath+"gmailnew.gif";
		menuOption=CAMOpt(sm, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_SendToEmail";
	}
	var serverFileRedirect=itemTable.getAttribute("SRed");
	if (currentItemFSObjType !=1 &&
		ctx.listBaseType==1 &&
		(serverFileRedirect==null || serverFileRedirect==""
		   || HasRights(0x0, 0x20)))
	{
		if (ctx.listTemplate !=109 &&
			ctx.listTemplate !=119)
			AddWorkspaceMenuItem(sm, ctx);
		strAction="STSNavigate('"+			ctx.HttpRoot+			"/_layouts/download.aspx?"+			"SourceUrl="+			currentItemEscapedFileUrl+			"&Source="+			GetSource()+"&FldUrl="+			escapeProperly(ctx.SendToLocationUrl)+"')";;
		menuOption=CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
		menuOption.id="ID_DownloadACopy";
	}
}
function AddDocTransformSubMenu(m, ctx)
{
	if (typeof(rgDocTransformers)=="undefined" ||
		rgDocTransformers==null)
	{
		return;
	}
	var sm=null;
	var currentItemUrl=GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
	var currentItemEscapedFileUrl;
	if (currentItemFileUrl !=null)
		currentItemEscapedFileUrl=escapeProperly(
		unescapeProperly(currentItemFileUrl));
	var iDot=currentItemUrl.lastIndexOf(".");
	if (iDot > 0)
	{
		var strExtension=currentItemUrl.substring(iDot+1, currentItemUrl.length).toLowerCase();
		var iTransformer;
		var fAddedTransformer=false;
		for (iTransformer=0; iTransformer < rgDocTransformers.length; iTransformer++)
		{
			if (rgDocTransformers[iTransformer].ConvertFrom==strExtension)
			{
				var ctid=GetAttributeFromItemTable(itemTable, "CId", "ContentTypeId");
				var re=new RegExp("/\|"+ctid+"\|/");
				if (ctid && !re.test(rgDocTransformers[iTransformer].ExcludedContentTypes))
				{
					if (!fAddedTransformer)
					{
						sm=CASubM(m, L_DocTran_Text, ctx.imagesPath+"ConvertDocument.gif", L_DocTran_Text, 500);
						sm.Id="ID_ConvertDocument";
						fAddedTransformer=true;
					}
					strAction="STSNavigate('"+ctx.HttpRoot+											"/_layouts/"+escapeProperlyCore(rgDocTransformers[iTransformer].TransformUIPage, true)+"?"+											"FileName="+currentItemEscapedFileUrl+											"&TID="+rgDocTransformers[iTransformer].Id+											"&Source="+GetSource()+											"')";
					var tm;
					tm=CAMOpt(sm, rgDocTransformers[iTransformer].Name, strAction, "");
					tm.Id="ID_Transform"+rgDocTransformers[iTransformer].Id;
				}
			}
		}
	}
}
function AddMeetingMenuItems(m, ctx)
{
	if (itemTable.getAttribute("menuType")=="Orphaned")
	{
		var menuOption;
		var currentInstanceId=GetAttributeFromItemTable(itemTable, "ItemId", "Id");
		strDisplayText=L_Move_Text;
		strAction="GoToMtgMove('"+ctx.listUrlDir+"',"+currentInstanceId+",'"+itemTable.getAttribute("DateTime")+"','"+itemTable.getAttribute("DateTimeISO")+"')";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_Move";
		strDisplayText=L_Keep_Text;
		strAction="MtgKeep('"+ctx.HttpPath+"','"+ctx.listName+"',"+currentInstanceId+")";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_Keep";
		strDisplayText=L_Delete_Text;
		strAction="MtgDelete('"+ctx.HttpPath+"','"+ctx.listName+"',"+currentInstanceId+")";
		strImagePath=ctx.imagesPath+"delitem.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_Delete";
	}
}
function AddListMenuItems(m, ctx)
{
	if (typeof(Custom_AddListMenuItems) !="undefined")
	{
		if (Custom_AddListMenuItems(m, ctx))
			return;
	}
	if (currentItemFileUrl==null)
		currentItemFileUrl=GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
	var currentItemEscapedFileUrl;
	if (currentItemFileUrl !=null)
		currentItemEscapedFileUrl=escapeProperly(unescapeProperly(currentItemFileUrl));
	if (currentItemIsEventsExcp==null)
	{
		currentItemIsEventsExcp=false;
		currentItemIsEventsDeletedExcp=false;
		currentItemEvtType=itemTable.getAttribute("EventType");
		if(currentItemEvtType !=null &&
			 (currentItemEvtType==2 || currentItemEvtType==3 || currentItemEvtType==4))
		{
			currentItemIsEventsExcp=true;
			if (currentItemEvtType==3)
	            currentItemIsEventsDeletedExcp=true;
		}
	}
	var menuOption;
	if (ctx.listBaseType==3 && ctx.listTemplate==108)
	{
		strDisplayText=L_Reply_Text;
		if(itemTable.getAttribute("Ordering").length>=504)
		{
			var L_ReplyLimitMsg_Text="无法答复此线索。已达到答复限制。";
			strAction="alert('"+L_ReplyLimitMsg_Text+"')";
		}
		else
		{
			strAction="STSNavigate('"+ctx.newFormUrl
+"?Threading="+escapeProperly(itemTable.getAttribute("Ordering"))
+"&Guid="+escapeProperly(itemTable.getAttribute("ThreadID"))
+"&Subject="+escapeProperly(itemTable.getAttribute("Subject"))
+"&Source="+GetSource()+"')";
		}
		strImagePath=ctx.imagesPath+"reply.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 100);
		menuOption.id="ID_Reply";
	}
	AddSharedNamespaceMenuItems(m, ctx);
	if (currentItemID.indexOf(".0.") < 0 && HasRights(0x0, 0x8)
		  && !currentItemIsEventsExcp)
	{
		if (ctx.listBaseType==4)
			strDisplayText=L_DeleteResponse_Text;
		else
			strDisplayText=L_DeleteItem_Text;
		strAction="DeleteListItem()";
		strImagePath=ctx.imagesPath+"delitem.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 300);
		menuOption.id="ID_DeleteItem";
	}
	var contentTypeId=itemTable.getAttribute("CId");
	if (contentTypeId !=null && contentTypeId.indexOf("0x0106")==0
			&& HasRights(0x10, 0x0))
	{
		strDisplayText=L_ExportContact_Text;
		strAction="STSNavigate('"+ctx.HttpPath+"&Cmd=Display&CacheControl=1&List="+ctx.listName+"&ID="+currentItemID+"&Using="+escapeProperly(ctx.listUrlDir)+"/vcard.vcf"+"')";
		strImagePath=ctx.imagesPath+"exptitem.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 350);
		menuOption.id="ID_ExportContact";
	}
	CAMSep(m);
	if (ctx.verEnabled==1)
	{
		AddVersionsMenuItem(m, ctx, currentItemEscapedFileUrl);
	}
	AddWorkflowsMenuItem(m, ctx);
	CAMSep(m);
	if ((currentItemID.indexOf(".0.") < 0)
		  && HasRights(0x80, 0x0))
	{
		strDisplayText=L_Subscribe_Text;
		strAction="NavigateToSubNewAspx('"+ctx.HttpRoot+"', 'List="+ctx.listName+"&ID="+currentItemID+"')";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1100);
		menuOption.id="ID_Subscribe";
	}
	if (ctx.isModerated==true &&
		  HasRights(0x0, 0x10) && HasRights(0x0, 0x4)
			&& HasRights(0x0, 0x21000) && ctx.listBaseType !=4)
	{
		strDisplayText=L_ModerateItem_Text;
		strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/approve.aspx?List="+ctx.listName
+"&ID="+currentItemID+"&Source="+GetSource()+"')";
		strImagePath=ctx.imagesPath+"apprj.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1150);
		menuOption.id="ID_ModerateItem";
	}
	if (currentItemFSObjType==1 &&
		ctx.ContentTypesEnabled &&
		ctx.listTemplate !=108)
	{
		strDisplayText=L_CustomizeNewButton_Text;
		strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/ChangeContentTypeOrder.aspx?List="+ctx.listName+"&RootFolder="+currentItemEscapedFileUrl+"&Source="+GetSource()+"')";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1170);
		menuOption.id="ID_CustomizeNewButton";
	}
}
function ReplaceUrlTokens(urlWithTokens, ctx)
{
	if (currentItemID !=null)
		urlWithTokens=urlWithTokens.replace("{ItemId}", currentItemID);
	if (currentItemFileUrl !=null)
		urlWithTokens=urlWithTokens.replace("{ItemUrl}", currentItemFileUrl);
	if (ctx.HttpRoot !=null)
		urlWithTokens=urlWithTokens.replace("{SiteUrl}", ctx.HttpRoot);
	if (ctx.listName !=null)
		urlWithTokens=urlWithTokens.replace("{ListId}", ctx.listName);
	return urlWithTokens;
}
function InsertFeatureMenuItems(m, ctx)
{
	CAMSep(m);
	var fileType=GetAttributeFromItemTable(itemTable, "Ext", "FileType");
	var progId=GetAttributeFromItemTable(itemTable, "Type", "HTMLType");
	var contentTypeId=GetAttributeFromItemTable(itemTable, "CId", "ContentTypeId");
	var listTemplateId=null;
	if (ctx !=null)
		listTemplateId=ctx.listTemplate;
	if (fileType) fileType=fileType.toLowerCase();
	if (progId) progId=progId.toLowerCase();
	if (contentTypeId) contentTypeId=contentTypeId.toLowerCase();
	var menuOption;
	var elemTable=document.getElementById("ECBItems");
	if (elemTable !=null)
	{
		var elemTBody=elemTable.childNodes[0];
		for (var iMenuItem=0; iMenuItem < elemTBody.childNodes.length; iMenuItem++)
		{
			var elemTR=elemTBody.childNodes[iMenuItem];
			var elemTDRightsH=parseInt(GetInnerText(elemTR.childNodes[3]));
			var elemTDRightsL=parseInt(GetInnerText(elemTR.childNodes[4]));
			var regType=GetInnerText(elemTR.childNodes[5]);
			var regId=GetInnerText(elemTR.childNodes[6]);
			var fInsertMenuItem=false;
			if (regId)
			{
				regId=regId.toLowerCase();
				if (regType=="FileType")
				{
					fInsertMenuItem=						(fileType==regId.toLowerCase());
				}
				else if (regType=="ProgId")
				{
					fInsertMenuItem=						(progId==regId.toLowerCase());
				}
				else if (regType=="ContentType")
				{
					fInsertMenuItem=						(contentTypeId &&
						 contentTypeId.indexOf(regId.toLowerCase())==0);
				}
				else if (regType=="List")
				{
					fInsertMenuItem=						(listTemplateId &&
						 listTemplateId==regId);
				}
			}
			if (fInsertMenuItem &&
				HasRights(elemTDRightsH, elemTDRightsL))
			{
				var elemTDTitle=elemTR.childNodes[0];
				var elemTDImageUrl=elemTR.childNodes[1];
				var elemTDAction=elemTR.childNodes[2];
				var iSequence=parseInt(GetInnerText(elemTR.childNodes[7]));
				var strDisplayText=GetInnerText(elemTDTitle);
				var tdAction=ReplaceUrlTokens(GetInnerText(elemTDAction), ctx);
				var strAction;
				if (tdAction.substr(0,11)=="javascript:")
					strAction=tdAction;
				else
					strAction="STSNavigate('"+STSScriptEncode(tdAction)+"')";
				var strImagePath=ReplaceUrlTokens(GetInnerText(elemTDImageUrl), ctx);
				menuOption=CIMOpt(m, strDisplayText, strAction, strImagePath, null, iSequence);
			}
		}
	}
}
function GetRootFolder(ctx)
{
	var RootFolder=GetUrlKeyValue("RootFolder", true);
	if (RootFolder=="" || bValidSearchTerm)
	{
		var FileDirRef;
		if (itemTable)
			FileDirRef=GetAttributeFromItemTable(itemTable, "DRef", "FileDirRef");
		if (FileDirRef !=null)
			RootFolder="/"+FileDirRef;
		else
			RootFolder=ctx.listUrlDir;
		RootFolder=escapeProperly(RootFolder);
	}
	return "&RootFolder="+RootFolder;
}
function HasRights(requiredH, requiredL)
{
	if(currentItemPermMaskH==null)
	{
		if (itemTable==null) return true;
		var pmStr=GetAttributeFromItemTable(itemTable, "Perm", "PermMask");
		if(pmStr==null) return true;
		var currentItemAuthor=itemTable.getAttribute("Author");
		SetCurrentPermMaskFromString(pmStr, currentItemAuthor);
	}
	if(!currentItemCanModify
		&& (EqualRights(requiredH, requiredL, 0x0, 0x4)
		|| EqualRights(requiredH, requiredL, 0x0, 0x8)
		|| EqualRights(requiredH, requiredL, 0x40000000, 0x0)))
	{
		return false;
	}
	return (((requiredL & currentItemPermMaskL)==requiredL)
	&& ((requiredH & currentItemPermMaskH)==requiredH));
}
function EqualRights(rightsH1, rightsL1, rightsH2, rightsL2)
{
	return ((rightsH1==rightsH2) && (rightsL2==rightsL2));
}
function SetCurrentPermMaskFromString(pmStr, currentItemAuthor)
{
	var pmLen=pmStr.length;
	if(pmLen <=10 )
	{
		currentItemPermMaskH=0;
		currentItemPermMaskL=parseInt(pmStr);
	}
	else
	{
		currentItemPermMaskH=parseInt(pmStr.substring(2, pmLen - 8), 16);
		currentItemPermMaskL=parseInt(pmStr.substring(pmLen - 8, pmLen), 16);
	}
	currentItemCanModify=true;
	  currentItemCanModify=(currentItemAuthor==null)
							  || HasRights(0x0, 0x800)
							  || (ctx.CurrentUserId==currentItemAuthor)
							  || (ctx.CurrentUserId==null)
							  || (ctx.WriteSecurity==1);
}
function AddSharedNamespaceMenuItems(m, ctx)
{
	var RootFolder=GetRootFolder(ctx);
	setupMenuContext(ctx);
	if (currentItemFileUrl==null)
		currentItemFileUrl=GetAttributeFromItemTable(itemTable, "Url", "ServerUrl");
	if (currentItemFSObjType==null)
		currentItemFSObjType=GetAttributeFromItemTable(itemTable, "OType", "FSObjType");
	if (currentItemModerationStatus==null)
		currentItemModerationStatus=GetAttributeFromItemTable(itemTable, "MS", "MStatus");
	if (currentItemCheckedOutUserId==null)
		currentItemCheckedOutUserId=itemTable.getAttribute("COUId");
	if (currentItemCheckedoutToLocal==null)
		currentItemCheckedoutToLocal=GetAttributeFromItemTable(itemTable, "COut", "IsCheckedoutToLocal ");
	if (currentItemCheckedoutToLocal !=1)
		currentItemCheckedoutToLocal=0;
	bIsCheckout=0;
	if (ctx.isForceCheckout==true &&  currentItemCheckedOutUserId=="" &&
		currentItemFSObjType !=1)
	{
		bIsCheckout=1;
	}
	var currentItemEscapedFileUrl;
	if (currentItemFileUrl !=null)
		currentItemEscapedFileUrl=escapeProperly(
		unescapeProperly(currentItemFileUrl));
	var menuOption;
	if (ctx.listBaseType==1)
		strDisplayText=L_ViewProperties_Text;
	else if (ctx.listBaseType==4)
		strDisplayText=L_ViewResponse_Text;
	else
		strDisplayText=L_ViewItem_Text;
	strAction="STSNavigate('"+ctx.displayFormUrl+"?ID="+currentItemID+				"&Source="+GetSource()+RootFolder+"')";
	strImagePath="";
	menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 200);
	if (ctx.listBaseType==1)
		menuOption.id="ID_ViewProperties";
	else
		menuOption.id="ID_ViewItem";
	if (HasRights(0x0, 0x4) &&
	      !currentItemIsEventsDeletedExcp)
	{
		if (ctx.listBaseType==1)
			strDisplayText=L_EditProperties_Text;
		else if (ctx.listBaseType==4)
			strDisplayText=L_EditResponse_Text;
		else
			strDisplayText=L_EditItem_Text;
	   if (ctx.listBaseType==1)
	   {
		   strAction="STSNavigateWithCheckoutAlert('"+ctx.editFormUrl+"?ID="+currentItemID+					   "&Source="+GetSource()+RootFolder+"',"+bIsCheckout+",'"
+currentItemCheckedoutToLocal+"','"+STSScriptEncode(currentItemFileUrl)+"','"+ctx.HttpRoot+"')";
	   }
	   else
	   {
		   strAction="STSNavigate('"+ctx.editFormUrl+"?ID="+currentItemID+"&Source="+GetSource()+"')";
	   }
		strImagePath=ctx.imagesPath+"edititem.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 220);
		if (ctx.listBaseType==1)
			menuOption.id="ID_EditProperties";
		else
			menuOption.id="ID_EditItem";
		if (ctx.listTemplate==106 &&
			currentItemID.indexOf(".0.") > 0)
		{
			var SeriesIdEnd=currentItemID.indexOf(".0.");
			var itemSeriesID=currentItemID.substr(0, SeriesIdEnd);
			strDisplayText=L_EditSeriesItem_Text;
			strAction="STSNavigate('"+ctx.editFormUrl+"?ID="+itemSeriesID+"&Source="+					   GetSource()+"')";
			strImagePath=ctx.imagesPath+"recurrence.gif";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 230);
			menuOption.id="ID_EditSeriesItem";
		}
	}
	AddManagePermsMenuItem(m, ctx, ctx.listName, currentItemID);
}
function AddDocLibMenuItems(m, ctx)
{
	if (typeof(Custom_AddDocLibMenuItems) !="undefined")
	{
		if (Custom_AddDocLibMenuItems(m, ctx))
			return;
	}
	var RootFolder=GetRootFolder(ctx);
	var menuOption;
	AddSharedNamespaceMenuItems(m, ctx);
	var currentItemEscapedFileUrl;
	if (currentItemFileUrl !=null)
		currentItemEscapedFileUrl=escapeProperly(unescapeProperly(currentItemFileUrl));
	var serverFileRedirect=itemTable.getAttribute("SRed");
	if (HasRights(0x0, 0x4) && HasRights(0x10, 0x0)
		  && currentItemFSObjType !=1
		  && (serverFileRedirect==null || serverFileRedirect=="" || HasRights(0x0, 0x20))
		  )
	{
		if (ctx.isWebEditorPreview==0 && ctx.listBaseType==1)
		{
			if (ctx.listTemplate==109 && itemTable.getAttribute("IsImage")=="1")
			{
				strDisplayText=L_EditInOIS_Text;
				strAction="EditSingleImage('"+currentItemID+"')";
				strImagePath=ctx.imagesPath+"oisweb.gif";
				menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 240);
				menuOption.id="ID_EditInOIS";
			}
			else
			{
				setDocType();
				if (currentItemAppName !="" && currentItemOpenControl !="")
				{
		      strDisplayText="";	
		      if (currentItemAppName !=" ")
						strDisplayText=StBuildParam(L_EditIn_Text, currentItemAppName);
					else
			{			
			      var	objEditor=StsOpenEnsureEx(currentItemOpenControl+".3");
	        	      if (objEditor !=null )	
					strDisplayText=L_EditInApplication_Text;
						}
			if (strDisplayText !="")
			{
				strAction="editDocumentWithProgID2('"+currentItemFileUrl+"', '"+currentItemProgId+"', '"
+currentItemOpenControl+"', '"+bIsCheckout+"', '"+ctx.HttpRoot+"', '"+currentItemCheckedoutToLocal+"')";
	                    	strImagePath=ctx.imagesPath+currentItemIcon;
	                    	menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 240);
	                    	menuOption.id="ID_EditIn_"+currentItemAppName;
			}
				}
			}
		}
	}
	if (HasRights(0x0, 0x8))
	{
		strDisplayText=L_DeleteDocItem_Text;
		var isCopy="false";
		if (typeof(itemTable.getAttribute("CSrc")) !="undefined" &&
			itemTable.getAttribute("CSrc") !=null &&
			itemTable.getAttribute("CSrc") !="")
		{
			isCopy="true";
		}
		strAction="DeleteDocLibItem('"+				ctx.HttpPath+"&Cmd=Delete&List="+ctx.listName+				"&ID="+currentItemID+"&owsfileref="+				currentItemEscapedFileUrl+"&NextUsing="+GetSource()+"',"+				isCopy+")";
		strImagePath=ctx.imagesPath+"delitem.gif";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 310);
		menuOption.id="ID_DeleteDocItem";
	}
	AddGotoSourceItemMenuItem(m, ctx, itemTable, currentItemFSObjType);
	if (currentItemFSObjType !=1)
	{
		AddSendSubMenu(m,ctx);
		AddDocTransformSubMenu(m,ctx);
	}
	if (currentItemFSObjType !=1 &&
	   ctx.listTemplate==109 &&
	   typeof(DownloadOriginalImage)=="function")
	{
		strAction="DownloadOriginalImage("+currentItemID+")";
		strImagePath=ctx.imagesPath+"download.gif";
		strDisplayText=L_DownloadOriginal_Text;
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 550);
		menuOption.id="ID_DownloadOriginal";
	}
	if (HasRights(0x0, 0x4))
	{
		if ((ctx.isModerated==true) && (((currentItemModerationStatus==2) ||
				!ctx.EnableMinorVersions) && currentItemCheckedOutUserId=="" ||currentItemFSObjType==1))
		{
			strDisplayText=L_ModerateItem_Text;
			strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/approve.aspx?List="+ctx.listName
+"&ID="+currentItemID+"&Source="+GetSource()+GetRootFolder(ctx)+"')";
			strImagePath=ctx.imagesPath+"apprj.gif";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1150);
			menuOption.id="ID_ModerateItem";
		}
		if (currentItemFSObjType !=1)
		{
			if (ctx.listBaseType==1)
			{
				CAMSep(m);
				AddCheckinCheckoutMenuItem(m, ctx, currentItemEscapedFileUrl);
			}
		}
	}
	if (ctx.verEnabled==1 || ctx.isModerated)
		AddVersionsMenuItem(m, ctx, currentItemEscapedFileUrl);
	if (currentItemFSObjType !=1)
	{
		AddWorkflowsMenuItem(m, ctx);
		CAMSep(m);
		if (ctx.PortalUrl !=null)
		{
			strDisplayText=L_AddToMyLinks_Text;
			strAction="Portal_Tasks('PinToMyPage')"; ;
			strImagePath="";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1000);
			menuOption.id="ID_AddToMyLinks";
			CAMSep(m);
		}
	}
	else if (ctx.listBaseType==1
		  && HasRights(0x10, 0x0))
	{
		AddWorkOfflineMenuItem(m, ctx, currentItemFileUrl);
	}
	if (HasRights(0x80, 0x0))
	{
		strDisplayText=L_Subscribe_Text;
		strAction="NavigateToSubNewAspx('"+ctx.HttpRoot+"', 'List="+ctx.listName+"&ID="+currentItemID+"')";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1100);
		menuOption.id="ID_Subscribe";
	}
	if (currentItemFSObjType==1 &&
		ctx.ContentTypesEnabled &&
		ctx.listTemplate !=108)
	{
		strDisplayText=L_CustomizeNewButton_Text;
		strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/ChangeContentTypeOrder.aspx?List="+ctx.listName+"&RootFolder="+currentItemEscapedFileUrl+"&Source="+GetSource()+"')";
		strImagePath="";
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 1170);
		menuOption.id="ID_CustomizeNewButton";
	}
}
function AddManagePermsMenuItem(m, ctx, listId, url)
{
	if(!HasRights(0x40000000, 0x0) || currentItemIsEventsExcp)
		return;
	strDisplayText=L_MngPerms_Text;
	strAction="NavigateToManagePermsPage('"+ctx.HttpRoot+"', '"+listId+"','"+url+"')";
	strImagePath=ctx.imagesPath+"manageperm.gif";
	var menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 250);
	menuOption.id="ID_MngPerms";
}
function AddGotoSourceItemMenuItem(m, ctx, itemTable, objtype)
{
	if (objtype !=1 &&
		typeof(itemTable.getAttribute("CSrc")) !="undefined" &&
		itemTable.getAttribute("CSrc") !=null &&
		itemTable.getAttribute("CSrc") !="")
	{
		strDisplayText=L_GoToSourceItem_Text;
		strAction="NavigateToSourceItem('"+itemTable.getAttribute("CSrc")+"')";
		strImagePath=ctx.imagesPath+"goToOriginal.gif";
		var menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 340);
		menuOption.id="ID_GoToSourceItem";
	}
}
function AddCheckinCheckoutMenuItem(m, ctx, url)
{
	var menuOption;
	if(!HasRights(0x0, 0x4))
		return;
	if (currentItemCheckedOutUserId==null)
		currentItemCheckedOutUserId=itemTable.getAttribute("COUId");
	if (currentItemCheckedOutUserId !="")
	{
		if(currentItemCheckedOutUserId==ctx.CurrentUserId
	     || ctx.CurrentUserId==null
			|| HasRights(0x0, 0x100))
		{
			strDisplayText=L_Checkin_Text;
			strAction="NavigateToCheckinAspx('"+ctx.HttpRoot+"', 'List="+ctx.listName+"&FileName="+url+"')";
			strImagePath=ctx.imagesPath+"checkin.gif";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 700);
			menuOption.id="ID_Checkin";
			strDisplayText=L_DiscardCheckou_Text;
			strAction="UnDoCheckOut('"+ctx.HttpRoot+"', '"+url+"')";
			strImagePath=ctx.imagesPath+"unchkout.gif";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 710);
			menuOption.id="ID_DiscardCheckou";
		}
	}
	else
	{
		strDisplayText=L_Checkout_Text;
		if (currentItemOpenControl=="")
			setDocType();
		var opencontrol="";
		if (ctx.listTemplate !=109)
			opencontrol=currentItemOpenControl+".3";
		var serverFileRedirect=itemTable.getAttribute("SRed");
		if(serverFileRedirect==null || serverFileRedirect=="" || HasRights(0x0, 0x20))
		{
			strAction="CheckoutDocument('"+ctx.HttpRoot+"', '"+url+"', '"+opencontrol+"')";
			strImagePath=ctx.imagesPath+"checkout.gif";
			menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 700);
			menuOption.id="ID_Checkout";
		}
		if (currentItemModerationStatus==null)
			currentItemModerationStatus=GetAttributeFromItemTable(itemTable, "MS", "MStatus");
		if (ctx.EnableMinorVersions)
		{
			if (currentItemUIString==null)
				currentItemUIString=GetAttributeFromItemTable(itemTable, "UIS", "UIString");
			var minorversion=currentItemUIString%512;
			if ((((currentItemModerationStatus==1) ||
				(currentItemModerationStatus==3)) &&
				ctx.isModerated) ||
				(!ctx.isModerated  && minorversion !=0))
			{
				strDisplayText=L_PublishItem_Text;
				strAction="NavigateToCheckinAspx('"+ctx.HttpRoot+"', 'List="+ctx.listName+"&FileName="+url+"&Publish=true')";
				strImagePath=ctx.imagesPath+"pubmajor.gif";
				menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 720);
				menuOption.id="ID_PublishItem";
			}
			else
			{
				var strMenuOptionId;
				var  bCancelApproval=false;
				if ((!ctx.isModerated) || (currentItemModerationStatus==0))
				{
					strDisplayText=L_UnPublishItem_Text;
					strMenuOptionId="ID_UnPublishItem";
					strImagePath=ctx.imagesPath+"unpub.gif";
				}
				else
				{
					strDisplayText=L_CancelPublish_Text;
					strMenuOptionId="ID_CancelPublish";
					strImagePath=ctx.imagesPath+"unapprv.gif";
					bCancelApproval=true;
				}
				strAction="UnPublish('"+ctx.HttpRoot+"', 'FileName="+url+"&UnPublish=true',"+bCancelApproval+")";	
				menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 730);
				menuOption.id=strMenuOptionId;
			}
		}
	}
}
function AddWorkflowsMenuItem(m, ctx)
{
	if (ctx.WorkflowsAssociated && HasRights(0x0, 0x4))
	{
		var strCTID=GetAttributeFromItemTable(itemTable, "CId", "ContentTypeId");
		if (strCTID==null || strCTID.substr(0,8) !="0x010801")
		{
			var strImagePath=ctx.imagesPath+"workflows.gif";
			var itemID;
			var SeriesIdEnd=currentItemID.indexOf(".0.");
			if (SeriesIdEnd > 0)
				itemID=currentItemID.substr(0, SeriesIdEnd);
			else
				itemID=currentItemID;
			var strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/Workflow.aspx?ID="+itemID+"&List="+ctx.listName+"&Source="+GetSource()+"')";
			var menuOption=CAMOpt(m, L_Workflows_Text, strAction, strImagePath, null, 900);
			menuOption.id="ID_Workflows";
		}
	}
}
function AddWorkspaceMenuItem(m, ctx)
{
	var menuOption;
	var strSourceUrl=GetAttributeFromItemTable(itemTable, "SUrl", "SourceUrl");
	if ( strSourceUrl !=null && strSourceUrl !="" && strSourceUrl !="%20")
	{
		if (HasRights(0x0, 0x21000))
		{
			strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/publishback.aspx?list="+ctx.listName+"&item="+currentItemID+GetRootFolder(ctx)+"')";
			menuOption=CAMOpt(m, L_PublishBack_Text, strAction, "", null, 1140);
			menuOption.id="ID_PublishBack";
		}
	}
	else
	{
		if (HasRights(0x0, 0x800000) && HasRights(0x0, 0x21000) && HasRights(0x0, 0x4000000))
		{
			strAction="STSNavigate('"+ctx.HttpRoot+"/_layouts/createws.aspx?list="+ctx.listName+"&item="+currentItemID+GetRootFolder(ctx)+"')";
			menuOption=CAMOpt(m, L_CreateDWS_Text, strAction, "", null, 1140);
			menuOption.id="ID_CreateDWS";
		}
	}
}
function AddVersionsMenuItem(m, ctx, url)
{
	if (currentItemID !=null)
	{
	   var strCurrentItemID=currentItemID.toString();
	   if (strCurrentItemID.indexOf(".0.") >=0 )
	   return;
	}
	if (!HasRights(0x0, 0x40))
	  return;
	strDisplayText=L_Versions_Text;
	strAction="NavigateToVersionsAspx('"+ctx.HttpRoot+"', 'list="+ctx.listName+"&ID="+currentItemID+"&FileName="+url+"')";
	strImagePath=ctx.imagesPath+"versions.gif";
	var menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 800);
	menuOption.id="ID_Versions";
}
function AddWorkOfflineMenuItem(m, ctx, url)
{
	strDisplayText=GetStssyncAppNameForType("documents",L_WorkOffline_Text,strImagePath);
	if (strDisplayText)
	{
		strAction="javascript:ExportHailStorm('documents','"+ctx.HttpRoot+"','"+			ctx.listName+"','"+STSScriptEncode(ctx.SiteTitle)+			"','"+ctx.ListTitle+"','"+			STSScriptEncode(ctx.listUrlDir)+"','','"+STSScriptEncode(unescapeProperly(ctx.listUrlDir))+"'";
		strAction+=",'"+STSScriptEncode(unescapeProperly(url))+"','"+currentItemID+"')";
		strImagePath=GetStssyncIconPath(ctx.imagesPath+"tbsprsht.gif", ctx.imagesPath);
		menuOption=CAMOpt(m, strDisplayText, strAction, strImagePath);
		menuOption.id="ID_WorkOffline";
	}
}
function AddVersionMenuItems(m, ctx)
{
	if (typeof(AddVersionMenuItemsCore)=="function")
	{
		AddVersionMenuItemsCore(m, ctx);
	}
}
function NavigateToSubNewAspx(strHttpRoot, strArgs)
{
	STSNavigate(strHttpRoot+"/_layouts/SubNew.aspx?"+strArgs+"&Source="+GetSource());
}
function NavigateToVersionsAspx(strHttpRoot, strArgs)
{
	STSNavigate(strHttpRoot+"/_layouts/Versions.aspx?"+strArgs+"&Source="+GetSource());
}
var L_UndoCheckoutWarning_Text="如果放弃签出，则会丢失对文档所做的所有更改。是否确实要放弃签出?";
var L_UnPublishWarning_Text=" 是否确实要取消发布此版本的文档?";
var L_CancleApproval_TEXT=" 是否确实要取消审批此文档?";
function UnDoCheckOut(strHttpRoot, strUrl)
{
	try
	{
		var stsOpen=null;
		var strextension=SzExtension(unescapeProperly(strUrl));
   	 if (FSupportCheckoutToLocal(strextension) )
	 	stsOpen=StsOpenEnsureEx("SharePoint.OpenDocuments.3");
		if (stsOpen !=null)
		{
			var strDocument=currentItemFileUrl;
			if (strDocument.charAt(0)=="/" || strDocument.substr(0,3).toLowerCase()=="%2f")
				 strDocument=document.location.protocol+"//"+document.location.host+strDocument;
			stsOpen.DiscardLocalCheckout(strDocument);
			SetWindowRefreshOnFocus();
			return;
		 }
	else
	{
		if (!confirm(L_UndoCheckoutWarning_Text))
			{
			return;
			}
	}
	}
	catch (e)
	{
	}
	NavigateToCheckinAspx(strHttpRoot, "FileName="+strUrl+"&DiscardCheckout=true");
}
function UnPublish(strHttpRoot, strArgs, bCancelApproval)
{
	var strAlert=L_UnPublishWarning_Text;
	if (bCancelApproval)
	strAlert=L_CancleApproval_TEXT;	
	if (!confirm(strAlert))
		return;
   NavigateToCheckinAspx(strHttpRoot, strArgs)
}
function NavigateToCheckinAspx(strHttpRoot, strArgs)
{
	SubmitFormPost(strHttpRoot+"/_layouts"+		"/Checkin.aspx?"+strArgs+"&Source="+GetSource());
}
function NavigateToManagePermsPage(strHttpRoot, strListId, strFileRef)
{
	var strObjType=",LISTITEM";
	STSNavigate(strHttpRoot+		"/_layouts/User.aspx?obj="+strListId+","+strFileRef+strObjType+		"&List="+strListId+		"&Source="+GetSource());
}
function NavigateToSourceItem(url)
{
	var match=url.match(/[^\/]*\/\/[^\/]*/g);
	var serverUrl=match[0];
	url=escapeProperly(url);
	STSNavigate(serverUrl+"/_layouts/copyutil.aspx?GoToDispForm=1&Use=url&ItemUrl="+url);
}
function setDocType()
{
	var strArray;
	strArray=GetAttributeFromItemTable(itemTable, "Icon", "DocIcon").split("|");
	currentItemIcon=strArray[0];
	currentItemAppName=strArray[1];
	currentItemOpenControl=strArray[2];
	currentItemProgId=GetAttributeFromItemTable(itemTable, "Type", "HTMLType");
}
function DeleteListItem()
{
	if (! IsContextSet())
		return;
	var ctx=currentCtx;
	var ciid=currentItemID;
	if (confirm(ctx.RecycleBinEnabled ? L_STSRecycleConfirm_Text : L_STSDelConfirm_Text))
	{
		SubmitFormPost(ctx.HttpPath+"&Cmd=Delete&List="+ctx.listName+					"&ID="+ciid+"&NextUsing="+GetSource());
	}
}
function DeleteDocLibItem(delUrl, isCopy)
{
	if (! IsContextSet())
		return;
	var strConfirm=(currentItemFSObjType==1)  ?
		(ctx.RecycleBinEnabled ? L_STSRecycleConfirm1_Text : L_STSDelConfirm1_Text) :
		(ctx.RecycleBinEnabled ? L_STSRecycleConfirm_Text : L_STSDelConfirm_Text);
	if (isCopy && currentItemFSObjType !=1)
		strConfirm=L_NotifyThisIsCopy_Text+strConfirm;
	if (confirm(strConfirm))
		SubmitFormPost(delUrl);
}
function EditMenuDefaultForOnclick()
{
	if (! IsContextSet())
		return;
	var ctx=currentCtx;
	if (ctx.isVersions)
	{
		STSNavigate(itemTable.getAttribute("verUrl"));
	}
	else if (ctx.listTemplate==200)
	{
		var currentInstanceID=currentItemID;
		MtgNavigate(currentInstanceID);
	}
	else
	{
		EditListItem();
	}
}
function EditListItem()
{
	if (event.srcElement.tagName=="A" ||
		event.srcElement.parentNode.tagName=="A")
		return;
	if (! IsContextSet())
		return;
	var ctx=currentCtx;
	var editFormUrl=ctx.editFormUrl+"?ID="+currentItemID+					   "&Source="+GetSource()
	if (ctx.listBaseType==1)
		editFormUrl=editFormUrl+GetRootFolder(ctx)
	STSNavigate(editFormUrl);
}
function DoNavigateToTemplateGallery(strSaveLocUrl, strTGUrl)
{
	document.cookie="MSOffice_AWS_DefSaveLoc="+strSaveLocUrl;
	STSNavigate(strTGUrl);
}
function Portal_Tasks(cmd)
{
	if (! IsContextSet())
		return;
	var ctx=currentCtx;
	var fileRef=unescapeProperly(currentItemFileUrl);
	var idx1=0, idx2=0;
	idx1=fileRef.lastIndexOf("/")
	idx2=fileRef.lastIndexOf(".")
	if (idx1 < 0 || idx2 < 0 || idx1 > idx2)
		return;
	var fileName=fileRef.substr(idx1+1, idx2-idx1-1);
	var serverUrl="";
	idx1=ctx.HttpRoot.indexOf("://");
	if (idx1 > 0)
	{
		idx2=ctx.HttpRoot.indexOf("/", idx1+3);
		if (idx2 > 0)
			serverUrl=ctx.HttpRoot.substring(0, idx2);
		else
			serverUrl=ctx.HttpRoot;
	}
	var currentItemFileFullUrl="";
	if (currentItemFileUrl.charAt(0)=="/"
		|| currentItemFileUrl.substr(0,3).toLowerCase()=="%2f")
	{
		currentItemFileFullUrl=serverUrl+currentItemFileUrl;
	}
	else
	{
		currentItemFileFullUrl=currentItemFileUrl;
	}
	var strParams="";
	if (false==setElementValue("ListViewURL", currentItemFileFullUrl))
	{
		strParams=strParams+"&ListViewURL="+escapeProperly(currentItemFileFullUrl);
	}
	if (false==setElementValue("ListTitle", fileName))
	{
		strParams=strParams+"&ListTitle="+escapeProperly(fileName);
	}
	if (false==setElementValue("ListDescription", ""))
	{
		strParams=strParams+"&ListDescription=";
	}
	if (false==setElementValue("ReturnUrl", window.location.href))
	{
		strParams=strParams+"&ReturnUrl="+escapeProperly(window.location.href);
	}
	if (ctx.PortalUrl.substr(0, 4) !="http")
	{
		ctx.PortalUrl=serverUrl+ctx.PortalUrl;
	}
	var url=ctx.PortalUrl+"_vti_bin/portalapi.aspx?cmd="+cmd;
	url=url+"&IconUrl="+ctx.imagesPath+currentItemIcon+strParams;
	SubmitFormPost(url);
}
function IsContextSet()
{
	if (currentCtx==null)
		return false;
	else if (currentCtx.isExplictLogin)
		return true;
	else if (currentCtx.HttpPath==null || currentItemID==null)
		return false;
	return true;
}
function ChangeContentType(id)
{
	var obj=document.getElementById(id);
	var strUrl=window.location.href;
	var idxQuery=strUrl.indexOf("?");
	if (strUrl.indexOf("?") <=0)
	{
		strUrl=strUrl+"?ContentTypeId="+obj.value;
	}
	else if (strUrl.indexOf("&ContentTypeId=") <=0)
	{
		strUrl=strUrl+"&ContentTypeId="+obj.value;
	}
	else
	{
		var pattern=/&ContentTypeId=[^&]*/i;
		strUrl=strUrl.replace(pattern,"&ContentTypeId="+obj.value);
	}
	STSNavigate(strUrl);
}
var IMNControlObj=null;
var bIMNControlInited=false;
var IMNDictionaryObj=null;
var bIMNSorted=false;
var bIMNOnloadAttached=false;
var IMNOrigScrollFunc=null;
var bIMNInScrollFunc=false;
var IMNSortableObj=null;
var IMNHeaderObj=null;
var IMNNameDictionaryObj=null;
var IMNShowOfflineObj=null;
function EnsureIMNControl()
{
	if (!bIMNControlInited)
	{
		if (browseris.ie5up && browseris.win32)
		{
//@cc_on
//@if (@_jscript_version >=5)
//@            try
//@            {
//@                IMNControlObj=new ActiveXObject("Name.NameCtrl.1");
//@            } catch(e)
//@            {
//@
//@            };
//@else
//@end
		}
		bIMNControlInited=true;
		if (IMNControlObj)
		{
			IMNControlObj.OnStatusChange=IMNOnStatusChange;
		}
	}
	return IMNControlObj;
}
function IMNImageInfo()
{
	this.img=null;
	this.alt='';
}
var L_IMNOnline_Text="空闲";
var L_IMNOffline_Text="脱机";
var L_IMNAway_Text="离开";
var L_IMNBusy_Text="忙碌";
var L_IMNDoNotDisturb_Text="请勿打扰";
var L_IMNIdle_Text="可能已离开";
var L_IMNBlocked_Text="阻止";
var L_IMNOnline_OOF_Text="空闲(OOF)";
var L_IMNOffline_OOF_Text="脱机(OOF)";
var L_IMNAway_OOF_Text="离开(OOF)";
var L_IMNBusy_OOF_Text="忙碌(OOF)";
var L_IMNDoNotDisturb_OOF_Text="请勿打扰(OOF)";
var L_IMNIdle_OOF_Text="可能已离开(OOF)";
function IMNGetStatusImage(state, showoffline)
{
	var img="blank.gif";
	var alt="";
	switch (state)
	{
		case 0:
			img="imnon.png";
			alt=L_IMNOnline_Text;
		break;
		case 11:
			img="imnonoof.png";
			alt=L_IMNOnline_OOF_Text;
		break;
		case 1:
			if (showoffline)
			{
				img="imnoff.png";
				alt=L_IMNOffline_Text;
			}
			else
			{
				img="blank.gif";
				alt="";
			}
		break;
		case 12:
			if (showoffline)
			{
				img="imnoffoof.png";
				alt=L_IMNOffline_OOF_Text;
			}
			else
			{
				img="blank.gif";
				alt="";
			}
		break;
		case 2:
			img="imnaway.png";
			alt=L_IMNAway_Text;
		break;
		case 13:
			img="imnawayoof.png";
			alt=L_IMNAway_OOF_Text;
		break;
		case 3:
			img="imnbusy.png";
			alt=L_IMNBusy_Text;
		break;
		case 14:
			img="imnbusyoof.png";
			alt=L_IMNBusy_OOF_Text;
		break;
		case 4:
			img="imnaway.png";
			alt=L_IMNAway_Text;
		break;
		case 5:
			img="imnbusy.png";
			alt=L_IMNBusy_Text;
		break;
		case 6:
			img="imnaway.png";
			alt=L_IMNAway_Text;
		break;
		case 7:
			img="imnbusy.png";
			alt=L_IMNBusy_Text;
		break;
		case 8:
			img="imnaway.png";
			alt=L_IMNAway_Text;
		break;
		case 9:
			img="imndnd.png";
			alt=L_IMNDoNotDisturb_Text;
		break;
		case 15:
			img="imndndoof.png";
			alt=L_IMNDoNotDisturb_OOF_Text;
		break;
		case 10:
			img="imnbusy.png";
			alt=L_IMNBusy_Text;
		break;
		case 16:
			img="imnidle.png";
			alt=L_IMNIdle_Text;
		break;
		case 17:
			img="imnidleoof.png";
			alt=L_IMNIdle_OOF_Text;
		break;
		case 18:
			img="imnblocked.png";
			alt=L_IMNBlocked_Text;
		break;
		case 19:
			img="imnidlebusy.png";
			alt=L_IMNBusy_Text;
		break;
		case 20:
			img="imnidlebusyoof.png";
			alt=L_IMNBusy_OOF_Text;
		break;
	}
	var imnInfo=new IMNImageInfo();
	imnInfo.img=img;
	imnInfo.alt=alt;
	return imnInfo;
}
function IMNGetHeaderImage()
{
	var imnInfo=new IMNImageInfo();
	imnInfo.img="imnhdr.gif";;
	imnInfo.alt="";
	return imnInfo;
}
function IMNIsOnlineState(state)
{
	if (state==1)
	{
			return false;
	}
	return true;
}
function IMNSortList(j, oldState, state)
{
	var objTable=null;
	var objRow=null;
	if (IMNSortableObj && IMNSortableObj[j])
	{
		objRow=document.getElementById(j);
		while (objRow && !(objRow.tagName=="TR" &&
			   typeof(objRow.Sortable) !="undefined"))
		{
			objRow=objRow.parentNode;
		}
		objTable=objRow;
		while (objTable && objTable.tagName !="TABLE")
		{
			objTable=objTable.parentNode;
		}
		if (objTable !=null && objRow !=null)
		{
			if (objTable.rows[1].style.display=="none")
			{
				for (i=1; i<4; i++)
				{
					objTable.rows[i].style.display="block";
				}
			}
			if (!IMNIsOnlineState(oldState) && IMNIsOnlineState(state))
			{
				objTable.rows[2].style.display="none";
				i=3;
				while (objTable.rows[i].id !="Offline" && objTable.rows[i].innerText < objRow.innerText)
					i++;
				objTable.moveRow(objRow.rowIndex, i);
				if (    objTable.rows[objTable.rows.length - 3].id=="Offline")
				{
					objTable.rows[objTable.rows.length - 2].style.display="block";
				}
			}
			else if (IMNIsOnlineState(oldState) && !IMNIsOnlineState(state))
			{
				if (objRow.rowIndex==3 &&
					objTable.rows[objRow.rowIndex+1].id=="Offline")
				{
					objTable.rows[2].style.display="block";
				}
				if (objTable.rows[objTable.rows.length - 3].id=="Offline")
				{
					objTable.rows[objTable.rows.length - 2].style.display="none";
				}
				i=objTable.rows.length - 2;
				while (objTable.rows[i - 1].id !="Offline" && objTable.rows[i].innerText > objRow.innerText)
					i--;
				objTable.moveRow(objRow.rowIndex, i);
			}
		}
	}
}
function IMNOnStatusChange(name, state, id)
{
	if (IMNDictionaryObj)
	{
		var img=IMNGetStatusImage(state, IMNSortableObj[id] ||
									IMNShowOfflineObj[id]);
		if (IMNDictionaryObj[id] !=state)
		{
			if (bIMNSorted)
				IMNSortList(id, IMNDictionaryObj[id], state);
			IMNUpdateImage(id, img);
			IMNDictionaryObj[id]=state;
		}
	}
}
function IMNUpdateImage(id, imgInfo)
{
	var obj=document.images(id);
	if (obj)
	{
		var img=imgInfo.img;
		var alt=imgInfo.alt;
		var oldImg=obj.src;
		var index=oldImg.lastIndexOf("/");
		var newImg=oldImg.slice(0, index+1);
		newImg+=img;
		if (oldImg==newImg && img !='blank.gif')
			return;
		if (obj.altbase)
		{
			obj.alt=obj.altbase;
		}
		else
		{
			obj.alt=alt;
		}
		var useFilter=browseris.ie &&
					browseris.ie55up &&
					browseris.verIEFull < 7.0;
		var isPng=(newImg.toLowerCase().indexOf(".png") > 0);
		if (useFilter)
		{
			if (isPng)
			{
				obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+newImg+"),sizingMethod=scale,enabled=true);";
				obj.src="/_layouts/images/blank.gif";
			}
			else
			{
				obj.style.filter="";
				obj.src=newImg;
			}
		}
		else
		{
			obj.src=newImg;
		}
	}
}
function IMNHandleAccelerator()
{
	if (IMNControlObj)
	{
	   if (event.altKey && event.shiftKey &&
			event.keyCode==121)
		{
		   IMNControlObj.DoAccelerator();
		}
	}
}
function IMNImageOnClick()
{
	if (IMNControlObj)
	{
		IMNShowOOUIKyb();
		IMNControlObj.DoAccelerator();
	}
}
function IMNGetOOUILocation(obj)
{
	var objRet=new Object;
	var objSpan=obj;
	var objOOUI=obj;
	var oouiX=0, oouiY=0, objDX=0;
	var fRtl=document.dir=="rtl";
	while (objSpan && objSpan.tagName !="SPAN" && objSpan.tagName !="TABLE")
	{
		objSpan=objSpan.parentNode;
	}
	if (objSpan)
	{
		var collNodes=objSpan.tagName=="TABLE" ?
			objSpan.rows(0).cells(0).childNodes :
			objSpan.childNodes;
		var i;
		for (i=0; i < collNodes.length;++i)
		{
			if (collNodes.item(i).tagName=="IMG" && collNodes.item(i).id)
			{
				objOOUI=collNodes.item(i);
				break;
			}
			if (collNodes.item(i).tagName=="A" &&
				collNodes.item(i).childNodes.length > 0 &&
				collNodes.item(i).childNodes.item(0).tagName=="IMG" &&
				collNodes.item(i).childNodes.item(0).id)
			{
				objOOUI=collNodes.item(i).childNodes.item(0);
				break;
			}
		}
	}
	obj=objOOUI;
	while (obj)
	{
		if (fRtl)
		{
			if (obj.scrollWidth >=obj.clientWidth+obj.scrollLeft)
				objDX=obj.scrollWidth - obj.clientWidth - obj.scrollLeft;
			else
				objDX=obj.clientWidth+obj.scrollLeft - obj.scrollWidth;
			oouiX+=obj.offsetLeft+objDX;
		}
		else
			oouiX+=obj.offsetLeft - obj.scrollLeft;
		oouiY+=obj.offsetTop - obj.scrollTop;
		obj=obj.offsetParent;
	}
	try
	{
		obj=window.frameElement;
		while (obj)
		{
			if (fRtl)
			{
				if (obj.scrollWidth >=obj.clientWidth+obj.scrollLeft)
					objDX=obj.scrollWidth - obj.clientWidth - obj.scrollLeft;
				else
					objDX=obj.clientWidth+obj.scrollLeft - obj.scrollWidth;
				oouiX+=obj.offsetLeft+objDX;
			}
			else
				oouiX+=obj.offsetLeft - obj.scrollLeft;
			oouiY+=obj.offsetTop - obj.scrollTop;
			obj=obj.offsetParent;
		}
	} catch(e)
	{
	};
	objRet.objSpan=objSpan;
	objRet.objOOUI=objOOUI;
	objRet.oouiX=oouiX;
	objRet.oouiY=oouiY;
	if (fRtl)
		objRet.oouiX+=objOOUI.offsetWidth;
	return objRet;
}
function IMNShowOOUIMouse()
{
	IMNShowOOUI(0);
}
function IMNShowOOUIKyb()
{
	IMNShowOOUI(1);
}
function IMNShowOOUI(inputType)
{
	if (browseris.ie5up && browseris.win32)
	{
		var obj=window.event.srcElement;
		var objSpan=obj;
		var objOOUI=obj;
		var oouiX=0, oouiY=0;
		if (EnsureIMNControl() && IMNNameDictionaryObj)
		{
			var objRet=IMNGetOOUILocation(obj);
			objSpan=objRet.objSpan;
			objOOUI=objRet.objOOUI;
			oouiX=objRet.oouiX;
			oouiY=objRet.oouiY;
			var name=IMNNameDictionaryObj[objOOUI.id];
			if (objSpan)
				objSpan.onkeydown=IMNHandleAccelerator;
			IMNControlObj.ShowOOUI(name, inputType, oouiX, oouiY);
		}
	}
}
function IMNHideOOUI()
{
	if (IMNControlObj)
	{
		IMNControlObj.HideOOUI();
		return false;
	}
	return true;
}
function IMNScroll()
{
	if (!bIMNInScrollFunc)
	{
		bIMNInScrollFunc=true;
		IMNHideOOUI();
	}
	bIMNInScrollFunc=false;
	if(IMNOrigScrollFunc==IMNScroll)
		return true;
	return IMNOrigScrollFunc ? IMNOrigScrollFunc() : true;
}
var imnCount=0;
var imnElems;
var imnElemsCount=0;
var imnMarkerBatchSize=4;
var imnMarkerBatchDelay=40;
function ProcessImn()
{
	if (EnsureIMNControl() && IMNControlObj.PresenceEnabled)
	{
		imnElems=document.getElementsByName("imnmark");
		imnElemsCount=imnElems.length;
		ProcessImnMarkers();
	}
}
function ProcessImnMarkers()
{
	for (i=0;i<imnMarkerBatchSize;++i)
	{
		if (imnCount==imnElemsCount)
			return;
		IMNRC(imnElems[imnCount].sip,imnElems[imnCount]);
		imnCount++;
	}
	setTimeout("ProcessImnMarkers()",imnMarkerBatchDelay);
}
function IMNRC(name, elem)
{
	if (name==null || name=='')
		return;
	if (browseris.ie5up && browseris.win32)
	{
		var obj=(elem) ? elem : window.event.srcElement;
		var objSpan=obj;
		var id=obj.id;
		var fFirst=false;
		if (!IMNDictionaryObj)
		{
			IMNDictionaryObj=new Object();
			IMNNameDictionaryObj=new Object();
			IMNSortableObj=new Object();
			IMNShowOfflineObj=new Object();
			if (!IMNOrigScrollFunc)
			{
				IMNOrigScrollFunc=window.onscroll;
				window.onscroll=IMNScroll;
			}
		}
		if (IMNDictionaryObj)
		{
			if (!IMNNameDictionaryObj[id])
			{
				IMNNameDictionaryObj[id]=name;
				fFirst=true;
			}
			if (typeof(IMNDictionaryObj[id])=="undefined")
			{
				IMNDictionaryObj[id]=1;
			}
			if (!IMNSortableObj[id] &&
				(typeof(obj.Sortable) !="undefined"))
			{
				IMNSortableObj[id]=obj.Sortable;
				if (!bIMNOnloadAttached)
				{
					if (EnsureIMNControl() && IMNControlObj.PresenceEnabled)
						window.attachEvent("onload", IMNSortTable);
					bIMNOnloadAttached=true;
				}
			}
			if (!IMNShowOfflineObj[id] &&
				(typeof(obj.ShowOfflinePawn) !="undefined"))
			{
				IMNShowOfflineObj[id]=obj.ShowOfflinePawn;
			}
			if (fFirst && EnsureIMNControl() && IMNControlObj.PresenceEnabled)
			{
				var state=1, img;
				state=IMNControlObj.GetStatus(name, id);
				if (IMNIsOnlineState(state) || IMNSortableObj[id] ||
					IMNShowOfflineObj[id])
				{
					img=IMNGetStatusImage(state, IMNSortableObj[id] ||
											IMNShowOfflineObj[id]);
					IMNUpdateImage(id, img);
					IMNDictionaryObj[id]=state;
				}
			}
		}
		if (fFirst)
		{
			var objRet=IMNGetOOUILocation(obj);
			objSpan=objRet.objSpan;
			if (objSpan)
			{
				objSpan.onmouseover=IMNShowOOUIMouse;
				objSpan.onfocusin=IMNShowOOUIKyb;
				objSpan.onmouseout=IMNHideOOUI;
				objSpan.onfocusout=IMNHideOOUI;
			}
		}
	}
}
function IMNSortTable()
{
	var id;
	for (id in IMNDictionaryObj)
	{
		IMNSortList(id, 1, IMNDictionaryObj[id]);
	}
	bIMNSorted=true;
}
function IMNRegisterHeader()
{
	if (browseris.ie5up && browseris.win32)
	{
		var obj=window.event.srcElement;
		if (!IMNHeaderObj)
		{
			IMNHeaderObj=new Object();
		}
		if (IMNHeaderObj)
		{
			var id=obj.id;
			if (!IMNHeaderObj[id])
			{
				IMNHeaderObj[id]=id;
				var img;
				img=IMNGetHeaderImage();
				IMNUpdateImage(id, img);
			}
		}
	}
}
function TopHelpButtonClick(strParam)
{
	if(typeof(navBarHelpOverrideKey) !="undefined")
	   return HelpWindowKey(navBarHelpOverrideKey);
	if (strParam !=null)
		HelpWindowKey(strParam);
	else
		HelpWindowKey('NavBarHelpHome');
}
function HelpWindowHelper(strParam)
{
	var strHelpUrl;
	if (typeof(strParam)=="undefined")
		{strHelpUrl="/_layouts/help.aspx?Lcid="+L_Language_Text;}
	else
		{strHelpUrl="/_layouts/help.aspx?Lcid="+L_Language_Text+strParam;}
	var wndHelp=window.open(strHelpUrl, "STSHELP",
		"height=500,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=475"
		);
	wndHelp.focus();
}
function HelpWindowKey(strKey)
{
	HelpWindowHelper("&Key="+strKey);
}
function HelpWindowUrl(strUrl)
{
	HelpWindowHelper("&Url="+strUrl);
}
function HelpWindow()
{
	HelpWindowKey("helphome");
}
function HelpBack()
{
	history.back();
}
function HelpForward()
{
	history.forward();
}
function HelpPrint()
{
	window.print();
}
function HelpSearch(strStringToSearchFor)
{
	var nMaxLengthSearchString=256;
	var strLocationHref="";
	if (typeof(glob_strLocaleNumId)=="undefined")
	{
		return true;
	}
	if (typeof(glob_strCollectionIds)=="undefined")
	{
		return true;
	}
	if (glob_strCollectionIds.length <=0)
	{
		return true;
	}
	if (typeof(strStringToSearchFor)=="undefined")
	{
		return true;
	}
	if (strStringToSearchFor.length <=0)
	{
		return true;
	}
	strStringToSearchFor=TrimWhiteSpaces(strStringToSearchFor);
	if (strStringToSearchFor.length==0)
	{
		return true;
	}
	strStringToSearchFor=strStringToSearchFor.substr(0,nMaxLengthSearchString);
	strStringToSearchFor=encodeURIComponent(strStringToSearchFor);
	strLocationHref="/_layouts/HelpSearch.aspx?lcid="
+escapeProperlyCore(glob_strLocaleNumId, true);
	for (var i=0; i < glob_strCollectionIds.length ;i++)
		{
		strLocationHref=strLocationHref
+"&cid"
+i
+"="
+escapeProperlyCore(glob_strCollectionIds[i], true);
		}
	strLocationHref=strLocationHref
+"&sq="
+strStringToSearchFor
		;
	window.location.href=strLocationHref;
}
var L_EmptySlideShow_Text="该库中找不到任何图片。请添加图片并重试。";
var L_NotOurView_Text="该操作不能在当前视图中完成。请选择其他视图并重试。";
function IsImgLibJssLoaded()
{
	if (typeof(fImglibJssLoaded) !="undefined")
		return fImglibJssLoaded;
	return false;
}
function EditSelectedImages()
{
	if (!IsImgLibJssLoaded())
	{
		alert(L_NotOurView_Text);
		return;
	}
	_EditSelectedImages();
}
function DeleteImages()
{
	if (!IsImgLibJssLoaded())
	{
		alert(L_NotOurView_Text);
		return;
	}
	_DeleteImages();
}
function SendImages()
{
	if (!IsImgLibJssLoaded())
	{
		alert(L_NotOurView_Text);
		return;
	}
	_SendImages();
}
function DownloadImages()
{
	if (!IsImgLibJssLoaded())
	{
		alert(L_NotOurView_Text);
		return;
	}
	_DownloadImages();
}
function MtgToggleTimeZone()
{
	var timezoneElem=document.getElementById("TimeZoneSection");
	var timezoneLinkElem=document.getElementById("TimeZoneLink");
	var L_ShowTZ_Text="显示时区";
	var L_HideTZ_Text="隐藏时区";
	if ( timezoneElem.style.display=="none" )
	{
		timezoneElem.style.display="";
		timezoneLinkElem.innerHTML="&lt;&lt;"
		timezoneLinkElem.title=L_HideTZ_Text;
		SetCookie("MtgTimeZone", "1", "");	
	}
	else
	{
		timezoneElem.style.display="none";
		timezoneLinkElem.innerHTML="&gt;&gt;"
		timezoneLinkElem.title=L_ShowTZ_Text;
		SetCookie("MtgTimeZone", "0", "");		
	}
}
function GetPageUrl(fHomePage)
{
	return unescapeProperly(fHomePage ? g_webUrl : g_pageUrl);
}
function MtgNavigate(instanceId)
{
	if (instanceId==g_instanceId)
		return;
	var fHomePage=!g_fPageGlobal;
	window.location.href=GetPageUrl(fHomePage)+'?InstanceID='+instanceId+'&'+g_thispagedata;
}
function GoToMtgMove(listUrlDir, instanceId, instanceDateTime, instanceDateTimeISO)
{
	window.location.href=listUrlDir+'/movetodt.aspx'
+'?FromInstanceID='+instanceId
+'&FromInstanceDate='+escapeProperly(instanceDateTime)
+'&FromInstanceDateISO='+escapeProperly(instanceDateTimeISO)
+'&Source='+escapeProperly(window.location.href);
}
function MtgKeep(httpPath, listId, instanceId)
{
	var L_MtgKeepConfirm_Text="此会议日期信息与您日历和计划程序中的信息不匹配。如果保留此会议日期，则日期将继续出现在工作区的“会议序列”列表中。";
	if (confirm(L_MtgKeepConfirm_Text))
		SubmitFormPost( httpPath
+'&Cmd=MtgKeep&List='+escapeProperly(listId)
+'&EditInstanceID='+instanceId
+'&NextUsing='+escapeProperly(window.location.href) );
}
function MtgDelete(httpPath, listId, instanceId)
{
	var L_MtgDeleteConfirm_Text="此会议日期和与之关联的内容将从此工作区删除。";
	if (confirm(L_MtgDeleteConfirm_Text))
	{
		var fHomePage=(instanceId==g_instanceId);
		SubmitFormPost( httpPath
+'&Cmd=MtgMove&List='+escapeProperly(listId)
+'&FromInstanceID='+instanceId+'&ToInstanceID=-3'
+'&NextUsing='+escapeProperly(fHomePage ? GetPageUrl(true) : window.location.href) );
	}
}
function SetCookie(name, value, path)
{
	document.cookie=name+"="+value+";path="+path;
}
function SetAsLastTabVisited()
{
	if (typeof(g_pageUrl) !="undefined" && typeof(g_webUrl) !="undefined")
		SetCookie("MtgLastTabVisited",
			escapeProperly(unescapeProperly(g_pageUrl)),
			escapeProperlyCore(unescapeProperly(g_webUrl),  true));
}
function MtgDeletePageConfirm()
{
	var L_DeleteGlobalConfirm_Text="此网页将从与此工作区关联的所有会议中删除。";
	var L_DeleteConfirm_Text="是否确实要删除此网页?";
	var text;
	if (document.getElementById("MtgTlPart_PageType").value=='MtgTlPart_LocalPage')
		text=L_DeleteConfirm_Text;
	else
		text=L_DeleteGlobalConfirm_Text+L_DeleteConfirm_Text;
	return confirm(text);
}
function MtgRedirect()
{
	var strServerRelative=GetCookie("MtgLastTabVisited");
	if (strServerRelative==null)
	{
		if (typeof(g_webUrl) !="undefined")
			strServerRelative=g_webUrl;
		else
			strServerRelative="../../";
	}
	else
		strServerRelative=escapeProperlyCore(strServerRelative, true);
	window.location.href=strServerRelative;
}
function MakeMtgInstanceUrl(strUrl, instanceID)
{
	if (instanceID !="undefined" && instanceID !='')
	{
		var iQueryString=strUrl.indexOf('?');
		if (iQueryString==-1 || strUrl.indexOf('InstanceID=', iQueryString)==-1)
			strUrl=strUrl+(iQueryString==-1 ? '?' : '&')+'InstanceID='+instanceID;
	}
	return strUrl;
}
function commonShowModalDialog(url, features, callback, args)
{
	if (document.getElementById("__spPickerHasReturnValue") !=null)
		document.getElementById("__spPickerHasReturnValue").value="";
	if (document.getElementById("__spPickerReturnValueHolder") !=null)
		document.getElementById("__spPickerReturnValueHolder").value="";
	commonModalDialogReturnValue.clear();
	var rv;
	if (window.showModalDialog)
	{
		rv=window.showModalDialog(url, args, features);
		onDialogClose(callback, null, rv);
	}
	else
	{
		var defaultWidth=500, defaultHeight=550, defaultScrollbars="yes";
		if(!features) features="width="+defaultWidth+",height="+defaultHeight;
		else
		{
			function assocArray() { return new Array(); }
			function assocArray_add(array, key, value)
			{
				array.push(key);
				array[key]=value;
			}
			function assocArray_keys(array)
			{
				var keys=new Array();
				for(var i=0; i<array.length; i++) keys.push(array[i]);
				return keys;
			}
			var feats=assocArray(), fre, split;
			if(features.search(/^(\s*\w+\s*:\s*.+?\s*)(;\s*\s*\w+\s*:\s*.+?\s*)*(;\s*)?$/) !=-1)
			{
				fre=/^\s*(\w+)\s*:\s*(.+?)\s*$/;
				split=features.split(/\s*;\s*/);
			}
			else
			{
				fre=/^\s*(\w+)\s*=\s*(.+?)\s*$/;
				split=features.split(/\s*,\s*/);
			}
			for(var feat in split)
			{
				var kv=fre.exec(split[feat]);
				if(kv && kv.length==3) assocArray_add(feats, kv[1].toLowerCase(), kv[2]);
			}
			if(!feats["width"]) assocArray_add(feats, "width", feats["dialogwidth"] || defaultWidth);
			if(!feats["height"]) assocArray_add(feats, "height", feats["dialogheight"] || defaultHeight);
			if(!feats["scrollbars"]) assocArray_add(feats, "scrollbars", feats["scroll"] || defaultScrollbars);
			features='';
			var keys=assocArray_keys(feats);
			for(var i in keys)
			{
				if(features) features+=",";
				features+=keys[i]+"="+feats[keys[i]];
			}
		}
		var modalDialog=window.open(url, '_blank', features+',modal=yes,dialog=yes');
		modalDialog.dialogArguments=args;
		window.onfocus=function() {
			var bHasReturnValue
=((document.getElementById("__spPickerHasReturnValue") !=null) &&
					 (document.getElementById("__spPickerHasReturnValue").value=="1"))
				  || commonModalDialogReturnValue.isSet();
			if (modalDialog && !modalDialog.closed && !bHasReturnValue)
			{
				modalDialog.focus();
			}
			else
			{
				window.onfocus=null;
				onDialogClose(callback, modalDialog, null);
			}
		}
	}
}
function onDialogClose(callback, modalDialog, rv)
{
	if(callback)
	{
		if(typeof(rv) !="undefined"
		   && rv !=null)
		{
			callback(rv);
		}
		else if (typeof(modalDialog) !="undefined"
		   && modalDialog !=null
		   && typeof(modalDialog.returnValue) !="undefined")
		{
			rv=modalDialog.returnValue;
			callback(rv);
		}
		else if (typeof(commonModalDialogReturnValue) !="undefined"
				 && commonModalDialogReturnValue !=null
				 && commonModalDialogReturnValue.isSet())
		{
			rv=commonModalDialogReturnValue.get();
			callback(rv);
			commonModalDialogReturnValue.clear();
		}
		else if (document.getElementById("__spPickerHasReturnValue") !=null &&
			document.getElementById("__spPickerHasReturnValue").value=="1" &&
			document.getElementById("__spPickerReturnValueHolder") !=null)
		{
			rv=document.getElementById("__spPickerReturnValueHolder").value;
			callback(rv);
		}
	}
}
function setModalDialogReturnValue(wnd, returnValue)
{
	if (wnd.opener !=null &&
		typeof(returnValue)=='string' &&
		wnd.opener.document.getElementById('__spPickerHasReturnValue') !=null &&
		wnd.opener.document.getElementById('__spPickerReturnValueHolder') !=null)
	{
		wnd.opener.document.getElementById('__spPickerHasReturnValue').value='1';
		wnd.opener.document.getElementById('__spPickerReturnValueHolder').value=returnValue;
	}
	else
	{
	   setModalDialogObjectReturnValue(wnd, returnValue);
	}
}
function setModalDialogObjectReturnValue(wnd, returnValue)
{
	if (wnd.showModalDialog)
	{
		wnd.returnValue=returnValue;
	}
	if(wnd.opener !=null)
	{
		wnd.opener.commonModalDialogReturnValue.set(returnValue);
	}
}
commonModalDialogReturnValue={
	 hasRetval: false,
	 retVal: null,
	 set: function (obj) {
			if(typeof(obj) !="undefined")
			{
				this.retVal=obj;
				this.hasRetval=true;
			}
		},
	 isSet: function() { return this.hasRetval;},
	 get: function() { if(this.hasRetval) return this.retVal; },
	 clear: function() { this.hasRetval=false; this.retVal=null; }
}
var filterTable=null;
var bIsFilterMenuShown=false;
var bIsFilterDataLoaded=false;
var filterImageCell=null;
var currentFilterMenu=null;
var loadingFilterMenu=null;
var ctxFilter=null;
var bIsFilterKeyPress=false;
var filterStr=null;
var strFieldName="";
var bMenuLoadInProgress=false;
var strFilteredValue=null;
var L_NotSortable_Text="无法对此栏类型排序";
var L_NotFilterable_Text="无法筛选此栏类型";
var L_AOnTop_Text="升序";
var L_ZOnTop_Text="降序";
var L_SmallestOnTop_Text="由小到大";
var L_LargestOnTop_Text="由大到小";
var L_OldestOnTop_Text="由旧到新";
var L_NewestOnTop_Text="由新到旧";
var L_AttachmentsOnTop_Text="带附件的项目在上";
var L_BlanksOnTop_Text="不带附件的项目在上";
var L_Ascending_Text="升序";
var L_Descending_Text="降序";
var L_DontFilterBy_Text="清除对“^1”的筛选";
var L_Loading_Text="正在加载....";
var L_FilterMode_Text="显示筛选选项";
var L_OpenMenu_Text="打开菜单";
function resetFilterMenuState()
{
	if (bMenuLoadInProgress)
		return;
	bIsFilterMenuShown=false;
	bIsFilterDataLoaded=false;
	filterTable=null;
	filterImageCell=null;
	currentFilterMenu=null;
	loadingFilterMenu=null;
	ctxFilter=null;
	bIsFilterKeyPress=false;
}
function setupFilterMenuContext(ctx)
{
	ctxFilter=ctx;
}
function IsFilterMenuOn()
{
	if (!bIsFilterMenuShown)
		return false;
	var bIsOpen=false;
	bIsOpen=MenuHtc_isOpen(currentFilterMenu) || MenuHtc_isOpen(loadingFilterMenu);
	if (!bIsOpen)
		bIsFilterMenuShown=false;
	return bIsOpen;
}
function IsFilterMenuEnabled()
{
	return true;
}
function OnMouseOverFilterDeferCall(elm)
{
	if (!IsFilterMenuEnabled())
		return false;
	if (IsFilterMenuOn())
		return false;
	if (window.location.href.search("[?&]Filter=1") !=-1)
		return false;
	if (elm.FilterDisable=="TRUE")
		return false;
	if (filterTable !=null)
		OnMouseOutFilter();
	filterTable=elm;
	var createCtx=new Function("setupFilterMenuContext(ctx"+filterTable.getAttribute('CtxNum')+");");
	createCtx();
	filterTable.className="ms-selectedtitle";
	filterTable.onclick=CreateFilterMenu;
	filterTable.oncontextmenu=CreateFilterMenu;
	filterTable.onmouseout=OnMouseOutFilter;
	var titleRow=filterTable.childNodes[0].childNodes[0];
	filterImageCell=titleRow.childNodes[titleRow.childNodes.length - 1];
	var filterArrow=filterImageCell.childNodes[0];
	filterArrow.src=ctxFilter.imagesPath+"menudark.gif";
	filterArrow.alt=L_OpenMenu_Text;
	filterArrow.style.visibility="visible";
	if (IsElementRtl(filterTable))
	{
		filterImageCell.style.right=null;
		filterImageCell.style.left="1px";
	}
	else
	{
		filterImageCell.style.left=null;
		filterImageCell.style.right="1px";
	}
	filterImageCell.className="ms-menuimagecell";
	return true;
}
function OnMouseOutFilter()
{
	if (!IsFilterMenuOn() && filterTable !=null)
	{
		filterTable.className="ms-unselectedtitle";
		filterTable.onclick="";
		filterTable.oncontextmenu="";
		filterTable.onmouseout="";
		if (filterImageCell !=null)
		{
			filterImageCell.childNodes[0].style.visibility="hidden";
			filterImageCell.className="";
		}
		resetFilterMenuState();
	}
}
function OnFocusFilter(elm)
{
	if (window.location.href.search("[?&]Filter=1") !=-1)
		return false;
	if (!IsFilterMenuEnabled())
		return false;
	elm.onblur=OnMouseOutFilter;
	elm.onkeydown=PopFilterMenu;
	var elmTmp=FindSTSMenuTable(elm, "CTXNum");
	if (elmTmp==null)
		return false;
	OnMouseOverFilter(elmTmp);
	return false;
}
function PopFilterMenu(e)
{
	if (!IsFilterMenuEnabled())
		return true;
	if (e==null)
		e=window.event;
	var nKeyCode;
	if (browseris.nav6up)
		nKeyCode=e.which;
	else
		nKeyCode=e.keyCode;
	if (!IsFilterMenuOn() && ((e.shiftKey && nKeyCode==13) || (e.altKey && nKeyCode==40)))
	{
		CreateFilterMenu(e);
		return false;
	}
	else
		return true;
}
function CreateFilterMenu(e)
{
	if (filterTable==null || filterImageCell==null)
		return true;
	if (e==null)
		e=window.event;
	bIsFilterMenuShown=true;
	window.document.body.onclick="";
	currentFilterMenu=CMenu("filter_menu");
	loadingFilterMenu=CMenu("filter_menu_loading");
	currentFilterMenu.setAttribute("CompactMode", "true");
	addSortMenuItems(currentFilterMenu, loadingFilterMenu);
	if (filterStr==null)
		addFilterMenuItems(currentFilterMenu, loadingFilterMenu);
	else
		addAdHocFilterMenuItems(currentFilterMenu, loadingFilterMenu);
	e.cancelBubble=true;
	return false;
}
function GetUrlWithNoSortParameters(strSortFields)
{
	var url=window.location.href;
	var strT;
	var ichStart=0;
	var ichEqual;
	var ichAmp;
	do
	{
		ichEqual=strSortFields.indexOf("=", ichStart);
		if (ichEqual==-1)
			return url;
		strT=strSortFields.substring(ichStart, ichEqual);
		if (strT !="");
			url=RemoveQueryParameterFromUrl(url, strT);
		ichAmp=strSortFields.indexOf("&", ichEqual+1);
		if (ichAmp==-1)
			return url;
		ichStart=ichAmp+1;
	} while (strT !="");
	return url;
}
function addSortMenuItems(menu, menuLoading)
{
	if (filterTable.getAttribute('Sortable')=="FALSE" || filterTable.getAttribute('SortDisable')=="TRUE" ||
		filterTable.getAttribute('FieldType')=="MultiChoice")
	{
		CAMOptFilter(menu, menuLoading, L_NotSortable_Text, "", "", false, "fmi_ns");
		CAMSep(menu);
		CAMSep(menuLoading);
		return;
	}
	var strSortAsc="";
	var strSortDesc="";
	var strFieldType="";
	var strImageAZ="/_layouts/"+L_Language_Text+"/images/SORTAZLang.gif";
	var strImageZA="/_layouts/"+L_Language_Text+"/images/SORTZALang.gif";
	if (filterStr==null)
	{
		var str=filterTable.getAttribute('SortFields');
		var ichSort=str.indexOf("&SortDir");
		if (ichSort==-1)
		{
			CAMOptFilter(menu, menuLoading, L_NotSortable_Text, "", "", false, "fmi_ns");
			CAMSep(menu);
			CAMSep(menuLoading);
			return;
		}
		var ichSortMac=str.indexOf("&", ichSort+1);
		var url=GetUrlWithNoSortParameters(str);
		url=RemovePagingArgs(url);
		if (url.indexOf("?") < 0)
			url+="?";
		else
			url+="&";
		strSortAsc="SubmitFormPost('"+STSScriptEncode(url)+STSScriptEncode(str.substr(0, ichSort)+"&SortDir=Asc"+str.substr(ichSortMac))+"');";
		strSortDesc="SubmitFormPost('"+STSScriptEncode(url)+STSScriptEncode(str.substr(0, ichSort)+"&SortDir=Desc"+str.substr(ichSortMac))+"');";
		var strFieldType=filterTable.getAttribute('FieldType');
		strFieldName=filterTable.getAttribute('Name');
	}
	else
	{
		var separator=' ';
		var index=filterStr.lastIndexOf(separator);
		strFieldType=filterStr.substring(index+1);
		if (strFieldType.substring(0, 2)=="x:")
			strFieldType=strFieldType.substring(2);
		var curStr=filterStr.substring(0, index);
		index=curStr.lastIndexOf(separator);
		strFieldName=curStr.substring(index+1);
		if(strFieldName.substring(0, 1)=='@')
			strFieldName=strFieldName.substring(1);
		curStr=filterStr.substring(0, index);
		index=curStr.lastIndexOf(separator);
		if (index > 0)
		{
			strFieldName=curStr.substring(0, index);
		}
		var titleRow=filterTable.childNodes[0].childNodes[0];
		var filterATag=titleRow.childNodes[0].childNodes[0];
		var strSort=filterATag.href;
		strSort=strSort.replace(/%20/g, " ");
		if (strSort.indexOf("'ascending'") > 0)
		{
			strSortAsc=strSort;
			strSortDesc=strSort.replace("'ascending'", "'descending'");
		}
		else
		{
			strSortDesc=strSort;
			strSortAsc=strSort.replace("'descending'", "'ascending'");
		}
	}
	strFieldType=strFieldType.toLowerCase();
	if (strFieldType=="dateTime")
	{
		CAMOptFilter(menu, menuLoading, L_OldestOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
		CAMOptFilter(menu, menuLoading, L_NewestOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
	}
	else if (strFieldType=="integer" || strFieldType=="number" || strFieldType=="currency")
	{
		CAMOptFilter(menu, menuLoading, L_SmallestOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
		CAMOptFilter(menu, menuLoading, L_LargestOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
	}
	else if (strFieldType=="text" || strFieldType=="user" || strFieldType=="string")
	{
		CAMOptFilter(menu, menuLoading, L_AOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
		CAMOptFilter(menu, menuLoading, L_ZOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
	}
	else if (strFieldType=="calculated")
	{
		var strResultType=filterTable.getAttribute('ResultType');
		if (strResultType=="Number" || strResultType=="Currency")
		{
			CAMOptFilter(menu, menuLoading, L_SmallestOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_LargestOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
		else if (strResultType=="dateTime")
		{
			CAMOptFilter(menu, menuLoading, L_OldestOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_NewestOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
		else if (strResultType=="boolean")
		{
			CAMOptFilter(menu, menuLoading, L_Ascending_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_Descending_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
		else
		{
			CAMOptFilter(menu, menuLoading, L_AOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_ZOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
	}
	else if (strFieldType=="attachments")
	{
		CAMOptFilter(menu, menuLoading, L_BlanksOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
		CAMOptFilter(menu, menuLoading, L_AttachmentsOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
	}
	else if (strFieldType=="lookup")
	{
		var curFieldName=filterTable.getAttribute('Name');
		if (curFieldName=="Last_x0020_Modified" || curFieldName=="Created_x0020_Date")
		{
			CAMOptFilter(menu, menuLoading, L_OldestOnTop_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_NewestOnTop_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
		else
		{
			CAMOptFilter(menu, menuLoading, L_Ascending_Text, strSortAsc, strImageAZ, true, "fmi_asc");
			CAMOptFilter(menu, menuLoading, L_Descending_Text, strSortDesc, strImageZA, true, "fmi_desc");
		}
	}
	else
	{
		CAMOptFilter(menu, menuLoading, L_Ascending_Text, strSortAsc, strImageAZ, true, "fmi_asc");
		CAMOptFilter(menu, menuLoading, L_Descending_Text, strSortDesc, strImageZA, true, "fmi_desc");
	}
	CAMSep(menu);
	CAMSep(menuLoading);
}
function CAMOptFilter(menu, menuLoading, wzText, wzAct, wzImage, bEnabled, strId)
{
	var mi;
	mi=CAMOpt(menu, wzText, wzAct, wzImage);
	mi.id=strId;
	if (!bEnabled)
		mi.setAttribute("enabled", "false");
	mi=CAMOpt(menuLoading, wzText, wzAct, wzImage);
	mi.id=strId+"_p";
	if (!bEnabled)
		mi.setAttribute("enabled", "false");
}
function ShowFilterLoadingMenu()
{
	if (!bIsFilterDataLoaded)
		OMenu(loadingFilterMenu, filterTable, null, null, -1);
}
function addFilterMenuItems(menu, menuLoading)
{
	var mi;
	if (filterTable.getAttribute('Filterable')=="FALSE"
		|| filterTable.getAttribute('FieldType ')=="Note"
		|| filterTable.getAttribute('FieldType ')=="URL")
	{
		mi=CAMOpt(menu, L_NotFilterable_Text, "");
		mi.setAttribute("enabled", "false");
		OMenu(menu, filterTable, null, null, -1);
		menu._onDestroy=OnMouseOutFilter;
		return;
	}
	var iframe=document.getElementById("FilterIframe"+filterTable.getAttribute('CtxNum'));
	if (iframe==null)
		return;
	var strDocUrl=iframe.getAttribute('FilterLink');
	var strFilterField=escapeProperly(filterTable.getAttribute('Name'));
	strFilteredValue=null;
	var strFilterQuery="";
	var i=0;
	var arrayField;
	do
	{
		i++;
		arrayField=strDocUrl.match("FilterField"+i+"=[^&]*"+			"&FilterValue"+i+"=[^&]*");
		if (arrayField !=null)
		{
			if (strFilteredValue==null)
				strFilteredValue=getFilterValueFromUrl(arrayField.toString(), strFilterField);
			strFilterQuery=strFilterQuery+"&"+arrayField;
		}
	} while (arrayField);
	var bFiltered=(strFilteredValue !=null);
	strDisplayText=StBuildParam(L_DontFilterBy_Text, filterTable.getAttribute('DisplayName'));
	var strFilterUrl="javascript:SubmitFormPost('"+		STSScriptEncode(FilterFieldV3(ctxFilter.view, strFilterField, "", 0, true))+"')";
	var strImageUrl;
	if (bFiltered)
		strImageUrl=ctxFilter.imagesPath+"FILTEROFF.gif";
	else
		strImageUrl=ctxFilter.imagesPath+"FILTEROFFDISABLED.gif";
	CAMOptFilter(menu, menuLoading, strDisplayText, strFilterUrl, strImageUrl, bFiltered, "fmi_clr");
	mi=CAMOpt(menuLoading, L_Loading_Text, "");
	mi.setAttribute("enabled", "false");
	setTimeout("ShowFilterLoadingMenu()", 500);
	menuLoading._onDestroy=OnMouseOutFilter;
	arrayField=strDocUrl.match("MembershipGroupId=[^&]*");
	if (arrayField !=null)
	{
		strFilterQuery=strFilterQuery+"&"+arrayField;
	}
	arrayField=strDocUrl.match("InstanceID=[^&]*");
	if (arrayField !=null)
	{
		strFilterQuery=strFilterQuery+"&"+arrayField;
	}
	var strRootFolder="";
	arrayField=strDocUrl.match("RootFolder=[^&]*");
	if (arrayField !=null)
		strRootFolder="&"+arrayField;
	if (browseris.safari)
	{
		iframe.src="/_layouts/blank.htm";
		iframe.style.offsetLeft="-550px";
		iframe.style.offsetTop="-550px";
		iframe.style.display="block";
	}
	iframe.src=ctxFilter.HttpRoot+"/_layouts/filter.aspx?ListId="+ctxFilter.listName+		strRootFolder+		"&FieldInternalName="+strFilterField+		"&ViewId="+ctxFilter.view+"&FilterOnly=1&Filter=1"+strFilterQuery;
	bMenuLoadInProgress=true;
}
function getFilterValueFromUrl(strUrl, strFilterField)
{
	var ichStart, ichEnd;
	var strFilterFieldUrl;
	ichStart=strUrl.indexOf("=");
	if (ichStart==-1)
		return;
	ichEnd=strUrl.indexOf("&");
	if (ichEnd==-1)
		return;
	if (ichEnd < ichStart)
		return;
	strUrl=CanonicalizeUrlEncodingCase(strUrl);
	strFilterFieldUrl=strUrl.substring(ichStart+1, ichEnd);
	if (strFilterFieldUrl==strFilterField)
	{
		var strUnescaped;
		ichStart=strUrl.indexOf("=", ichEnd+1);
		if (ichStart==-1)
			return;
		strUnescaped=strUrl.substr(ichStart+1);
		strUnescaped=unescapeProperly(strUnescaped);
		return strUnescaped;
	}
	return null;
}
function OnIframeLoad()
{
	bMenuLoadInProgress=false;
	if (filterTable !=null && filterTable.getAttribute('Name') !=null)
	{
		var iframe=window.frames["FilterIframe"+filterTable.getAttribute('CtxNum')];
		if (iframe !=null)
		{
			var strFieldName=filterTable.getAttribute('Name');
			var select=iframe.document.getElementById("diidFilter"+strFieldName);
			strFieldName=escapeProperly(strFieldName);
			if (select !=null)
			{
				var c=select.childNodes.length;
				if (c > 500)
				{
					addFilterOptionMenuItem();
				}
				else
				{
					var rgChoices=select.childNodes;
					for (var i=1; i < c; i++)
					{
						var strMenuText;
						if (rgChoices[i].innerText)
							strMenuText=rgChoices[i].innerText;
						else if (rgChoices[i].textContent)
							strMenuText=rgChoices[i].textContent;
						else
							strMenuText=rgChoices[i].innerHTML;
						var strFilterUrl="javascript:SubmitFormPost('"+							STSScriptEncode(FilterFieldV3(ctxFilter.view, strFieldName, rgChoices[i].value, i, true))+"')";
						var mi=CAMOpt(currentFilterMenu, strMenuText, strFilterUrl);
						if (strFilteredValue !=null && strFilteredValue==rgChoices[i].value)
							mi.setAttribute("checked", "true");
					}
				}
			}
			else
			{
			   addFilterOptionMenuItem();
			}
			bIsFilterDataLoaded=true;
			if (loadingFilterMenu !=null)
				loadingFilterMenu._onDestroy=null;
			if (currentFilterMenu !=null)
			{
				currentFilterMenu._onDestroy=OnMouseOutFilter;
				OMenu(currentFilterMenu, filterTable, null, null, -1);
			}
		}
	}
}
function addFilterOptionMenuItem()
{
	var strUrl=window.location.href;
	strUrl=StURLSetVar2(strUrl, "Filter", "1");
	strUrl=StURLSetVar2(strUrl, "View", ctxFilter.view);
	strUrl="javascript:SubmitFormPost('"+strUrl+"')";
	CAMOpt(currentFilterMenu, L_FilterMode_Text, strUrl);
}
function OnMouseOverAdHocFilterDeferCall(elm, fieldStr)
{
	filterStr=fieldStr;
	if (!browseris.ie55up || !browseris.win32)
		return false;
	if (IsFilterMenuOn())
		return false;
	if (filterTable !=null)
		OnMouseOutFilter();
	filterTable=elm;
	filterTable.className="ms-selectedtitle";
	filterTable.onclick=CreateFilterMenu;
	filterTable.oncontextmenu=CreateFilterMenu;
	filterTable.onmouseout=OnMouseOutFilter;
	var titleRow=filterTable.children[0].children[0];
	filterImageCell=titleRow.children[titleRow.children.length - 1];
	filterImageCell.children[0].src="/_layouts/images/menudark.gif";
	filterImageCell.children[0].style.visibility="visible";
	filterImageCell.style.visibility="visible";
	filterImageCell.className="ms-menuimagecell";
	return true;
}
function addAdHocFilterMenuItems(menu, menuLoading)
{
	var mi=CAMOpt(menuLoading, L_Loading_Text, "");
	mi.setAttribute("enabled", "false");
	OMenu(menuLoading, filterTable, null, null, -1);
	menuLoading._onDestroy=OnMouseOutFilter;
	DoCallBack("__filter={"+filterStr+"}");
}
function UpdateFilterCallback(filterHTML, foo)
{
	var select="</OPTION>";
	var i=-1;
	i=filterHTML.indexOf(select, i+1);
	var j=filterHTML.lastIndexOf('>', i);
	var strDisplayText=StBuildParam(L_DontFilterBy_Text, strFieldName);
	var strImageUrl;
	var strFilterUrl="";
	if (j < i - 1)
	{
		var index=filterHTML.lastIndexOf('\"', i);
		if (index > 0)
		{
			var index2=filterHTML.lastIndexOf('\"', index - 1);
			if (index2 > 0)
			{
				strFilterUrl=filterHTML.substring(index2+1, index);
			}
		}
	}
	if (j==i - 1)
		strImageUrl="/_layouts/images/FILTEROFFDISABLED.gif";
	else
		strImageUrl="/_layouts/images/FILTEROFF.gif";
	if (i > 0)
	{
	    var mi=CAMOpt(currentFilterMenu, strDisplayText, strFilterUrl, strImageUrl);
		mi.setAttribute("enabled", j==i - 1 ? "false" : "true");
		var index=i;
		var optionStart="<OPTION href=\"";
		i=filterHTML.indexOf(select, i+8);
		while ( i > 0)
		{
			j=filterHTML.indexOf(optionStart, index+8);
			j=filterHTML.indexOf('\"', j+20);
			if (j > 0 && j < i)
			{
				var strMenuText=filterHTML.substring(j+2, i);
				var strFilterUrl='';
				index=filterHTML.lastIndexOf('\"', j);
				if (index > 0)
				{
					var index2=filterHTML.lastIndexOf('\"', index - 1);
					if (index2 > 0)
					{
						strFilterUrl=filterHTML.substring(index2+1, index);
						strFilterUrl=strFilterUrl.replace(/&amp;/g, "&");
					}
				}
				if (strMenuText.length > 40)
					strMenuText=strMenuText.substring(0, 40)+"...";
				if (strMenuText.length > 0)
					CAMOpt(currentFilterMenu, strMenuText, strFilterUrl);
			}
			index=i;
			i=filterHTML.indexOf(select, i+8);
		}
	}
	else
	{
		var mi=CAMOpt(currentFilterMenu, L_NotFilterable_Text, "");
		mi.setAttribute("enabled", "false");
		OMenu(currentFilterMenu, filterTable, null, null, -1);
		return;
	}
	loadingFilterMenu._onDestroy=null;
	OMenu(currentFilterMenu, filterTable, null, null, -1);
	currentFilterMenu._onDestroy=OnMouseOutFilter;
}
function OnClickFilter(obj, e)
{
	var o=FindSTSMenuTable(obj, "CTXNum");
	if (o !=null && o.getAttribute("SortFields") !=null)
	{
		var strSortFields=o.getAttribute("SortFields");
		var url=GetUrlWithNoSortParameters(strSortFields);
		url=RemovePagingArgs(url);
		if (url.indexOf("?") < 0)
			url+="?";
		else
			url+="&";
		SubmitFormPost(url+strSortFields);
	}
	if (!bIsFileDialogView)
		e.cancelBubble=true;
	return false;
}
var _spBodyOnLoadFunctionNames;
if (_spBodyOnLoadFunctionNames==null)
{
	_spBodyOnLoadFunctionNames=new Array();
	_spBodyOnLoadFunctionNames.push("_spBodyOnLoad");
	_spBodyOnLoadFunctionNames.push("_spRestoreScrollForDiv_rscr");
}
var _spOriginalFormAction;
var _spEscapedFormAction;
var _spFormOnSubmitCalled=false;
var _spBodyOnPageShowRegistered=false;
function _spBodyOnPageShow(evt)
{
	_spFormOnSubmitCalled=false;
}
function _spResetFormOnSubmitCalledFlag( sender,  e)
{
	_spFormOnSubmitCalled=false;
}
function _spBodyOnLoadWrapper()
{
	if (!_spBodyOnPageShowRegistered &&
		typeof(browseris) !="undefined" &&
		!browseris.ie &&
		typeof(window.addEventListener)=='function')
	{
		window.addEventListener('pageshow', _spBodyOnPageShow, false);
		_spBodyOnPageShowRegistered=true;
	}
	if (_spOriginalFormAction==null)
	{
		if (document.forms.length > 0)
		{
			_spOriginalFormAction=document.forms[0].action;
			var url=window.location.href;
			var index=url.indexOf("://");
			if (index >=0)
			{
				var temp=url.substring(index+3);
				index=temp.indexOf("/");
				if (index >=0)
					url=temp.substring(index);
			}
			_spEscapedFormAction=escapeUrlForCallback(url);
			document.forms[0].action=_spEscapedFormAction;
		}
	}
	_spFormOnSubmitCalled=false;
	if (typeof(Sys) !="undefined" &&
		typeof(Sys.Net) !="undefined" &&
		typeof(Sys.Net.WebRequestManager) !="undefined")
	{
		Sys.Net.WebRequestManager.add_invokingRequest(_spResetFormOnSubmitCalledFlag);
	}
	ProcessDefaultOnLoad(_spBodyOnLoadFunctionNames);
}
var _spSuppressFormOnSubmitWrapper=false;
function _spFormOnSubmitWrapper()
{
	if (_spSuppressFormOnSubmitWrapper)
	{
		return true;
	}
	if (_spFormOnSubmitCalled)
	{
		return false;
	}
	if (typeof(_spFormOnSubmit)=="function")
	{
		var retval=_spFormOnSubmit();
		var testval=false;
		if (typeof(retval)==typeof(testval) && retval==testval)
		{
			return false;
		}
	}
	RestoreToOriginalFormAction();
	_spFormOnSubmitCalled=true;
	return true;
}
function RestoreToOriginalFormAction()
{
	if (_spOriginalFormAction !=null)
	{
		if (_spEscapedFormAction==document.forms[0].action)
		{
			document.forms[0].action=_spOriginalFormAction;
		}
		_spOriginalFormAction=null;
		_spEscapedFormAction=null;
	}
}
function DefaultFocus()
{
	if (typeof(_spUseDefaultFocus)!="undefined")
	{
		var elements=document.getElementsByName("_spFocusHere");
		var elem=null;
		if (elements==null || elements.length <=0)
		{
			elem=document.getElementById("_spFocusHere");
		}
		else if (elements !=null && elements.length > 0)
		{
			elem=elements[0];
		}
		if (elem !=null)
		{
			var aLinks=elem.getElementsByTagName("a");
			if (aLinks !=null && aLinks.length > 0)
			{
				try{aLinks[0].focus();}catch(e){}
			}
		}
	}
}
function ProcessDefaultOnLoad(onLoadFunctionNames)
{
	ProcessPNGImages();
	UpdateAccessibilityUI();
	ProcessImn();
	for (var i=0; i < onLoadFunctionNames.length; i++)
	{
		var expr="if(typeof("+onLoadFunctionNames[i]+")=='function'){"+onLoadFunctionNames[i]+"();}";
		eval(expr);
	}
	if (typeof(_spUseDefaultFocus)!="undefined")
		DefaultFocus();
}


