// _lcid="1033" _version="12.0.4518"
// _localBinding
// Version: "12.0.4518"
// Copyright (c) Microsoft Corporation.  All rights reserved.
var L_GBW_CL_ToConfirm_Text="Confirm";
var L_GBW_CL_CancelConfirmation_Text="Disconfirm";
var L_GBW_CL_ViewItem_Text="View Circulation";
var L_GBW_CL_EditItem_Text="Edit Circulation";
var L_GBW_CL_DeleteItem_Text="Delete Circulation";
var g_stOfficialNoticeContentTypeId="0x01007ce30dd1206047728bafd1c39a850120";
function GBW_CL_SetMenuParam(stCTXId, stAuthor, stContentTypeId, stCmd)
{
	var aMenuParam=new Array();
	aMenuParam[0]=stAuthor;
	aMenuParam[1]=stContentTypeId;
	aMenuParam[2]=stCmd;
	g_aMenuParams[stCTXId]=aMenuParam;
}
function GBW_CL_AddListMenuItems(m, ctx)
{
	var stCTXId=ctx.ctxId+"";
	var aMenuParam=g_aMenuParams[stCTXId];
	if (aMenuParam==null)
		return;
	var stAuthor=aMenuParam[0];
	var stContentTypeId=aMenuParam[1];
	var stCmd=aMenuParam[2];
	strDisplayText=L_GBW_CL_ViewItem_Text;
	strAction="STSNavigate('"+ctx.displayFormUrl+"?ID="+currentItemID+"&Source="+GetSource()+"')";
	strImagePath="";
	CAMOpt(m, strDisplayText, strAction, strImagePath);
	{
	var stUrl=ctx.HttpRoot+"/_layouts/";
	var stListName=ctx.listName;
	var stItemId=currentItemID;
	switch (stCmd)
		{
	case "Confirm":
		strDisplayHTML=L_GBW_CL_ToConfirm_Text;
		strAction="GBW_CL_Confirm(\""+stUrl+"\",\""+stListName+"\",\""+stItemId+"\",\""+stCmd+"\");";
		strImagePath=ctx.imagesPath+"gbcnf.gif";
		CAMOpt(m, strDisplayHTML, strAction, strImagePath);
		break;
	case "Disconfirm":
		strDisplayHTML=L_GBW_CL_CancelConfirmation_Text;
		strAction="GBW_CL_Confirm(\""+stUrl+"\",\""+stListName+"\",\""+stItemId+"\",\""+stCmd+"\");";
		strImagePath=ctx.imagesPath+"gbcnfd.gif";
		CAMOpt(m, strDisplayHTML, strAction, strImagePath);
		break;
	default:
		strDisplayHTML="<span style=\"color:gray;\">"+L_GBW_CL_ToConfirm_Text+"</span>";
		strAction="";
		strImagePath=ctx.imagesPath+"gbcnfg.gif";
		GBW_CAMOpt(m, strDisplayHTML, strAction, strImagePath);
		break;
		}
	}
	var fEditable=GBW_CL_IsEditOrDeleteItemAllowed(ctx.CurrentUserId, stAuthor, stContentTypeId);
	if (fEditable)
	{
		strDisplayText=L_GBW_CL_EditItem_Text;
		strAction="STSNavigate('"+ctx.editFormUrl+"?ID="+currentItemID+"&Source="+GetSource()+"')";
		strImagePath=ctx.imagesPath+"edititem.gif";
		CAMOpt(m, strDisplayText, strAction, strImagePath);
	}
	if (fEditable)
	{
		strDisplayText=L_GBW_CL_DeleteItem_Text;
		strAction="GBW_DeleteListItem()";
		strImagePath=ctx.imagesPath+"delitem.gif";
		CAMOpt(m, strDisplayText, strAction, strImagePath);
	}
	return true;
}
function GBW_CL_TitleToMe_Renderer(stValue, stUser, stNotConfirmed, stDueDate)
{
	this.stValue=stValue;
	this.stUser=stUser;
	this.stNotConfirmed=stNotConfirmed;
	this.stDueDate=stDueDate;
	return this;
}
GBW_CL_TitleToMe_Renderer.prototype.BuildUI=GBW_CL_TitleToMe_Renderer_BuildUI;
function GBW_CL_TitleToMe_Renderer_BuildUI()
{
	var st=this.stValue;
	var fNotConfirmedContainMe;
	var fOverDueDate;
	if (this.stUser)
		{
		fNotConfirmedContainMe=0 <=this.stNotConfirmed.indexOf(";#"+this.stUser+";#");
		}
	else
		{
		fNotConfirmedContainMe=false;
		}
	var dtNow=DateOptions.ClientNow();
	var dtDueDate=DateOptions.ParseISODate(this.stDueDate);
	fOverDueDate=(dtDueDate <=dtNow);
	if (fNotConfirmedContainMe && fOverDueDate)
		{
		st="<span class=\"ms-sgs-alerttext\">"+st+"</span>";
		}
	document.write(st);
}
function GBW_CL_TitleFromMe_Renderer(stValue, stUser, stAuthor, stNotConfirmed, stDueDate)
{
	this.stValue=stValue;
	this.stUser=stUser;
	this.stAuthor=stAuthor;
	this.stNotConfirmed=stNotConfirmed;
	this.stDueDate=stDueDate;
	return this;
}
GBW_CL_TitleFromMe_Renderer.prototype.BuildUI=GBW_CL_TitleFromMe_Renderer_BuildUI;
function GBW_CL_TitleFromMe_Renderer_BuildUI()
{
	var st=this.stValue;
	var fSendFromMe;
	var fNotConfirmedIsNotEmpty;
	var fOverDueDate;
	if (this.stUser)
		{
		fSendFromMe=(this.stUser==this.stAuthor);
		}
	else
		{
		fSendFromMe=false;
		}
	fNotConfirmedIsNotEmpty=(this.stNotConfirmed !="" && this.stNotConfirmed !=";#");
	var dtNow=DateOptions.ClientNow();
	var dtDueDate=DateOptions.ParseISODate(this.stDueDate);
	fOverDueDate=(dtDueDate <=dtNow);
	if (fSendFromMe && fNotConfirmedIsNotEmpty && fOverDueDate)
		{
		st="<span class=\"ms-sgs-alerttext\">"+st+"</span>";
		}
	document.write(st);
}
function GBW_CL_ConfirmedUser_Renderer(stConfirmed, stNotConfirmed)
{
	this.stConfirmed=stConfirmed;
	this.stNotConfirmed=stNotConfirmed;
	return this;
}
GBW_CL_ConfirmedUser_Renderer.prototype.BuildUI=GBW_CL_ConfirmedUser_Renderer_BuildUI;
function GBW_CL_ConfirmedUser_Renderer_BuildUI()
{
	var st="";
	if (this.stConfirmed !="" && this.stNotConfirmed !="")
	{
		var rgConfirmed=GBW_SplitMember(this.stConfirmed);
		var rgNotConfirmed=GBW_SplitMember(this.stNotConfirmed);
		var nConfirmed=rgConfirmed.length;
		var nNotConfirmed=rgNotConfirmed.length;
		var nTotal=nConfirmed+nNotConfirmed;
		st=nConfirmed+"/"+nTotal;
	}
	document.write(st);
}
function GBW_CL_Action_Renderer(ctx, stItemId, stConfirmed, stNotConfirmed)
{
	this.ctx=ctx;
	this.stItemId=stItemId;
	this.stConfirmed=stConfirmed;
	this.stNotConfirmed=stNotConfirmed;
}
GBW_CL_Action_Renderer.prototype.BuildUI=GBW_CL_Action_Renderer_BuildUI;
function GBW_CL_Action_Renderer_BuildUI()
{
	var st="";
	var stCmd=GBW_CL_GetConfirmCmd(this.ctx.CurrentUserId, this.stConfirmed, this.stNotConfirmed);
	var stLayoutsUrl=this.ctx.HttpRoot+"/_layouts/";
	switch (stCmd)
		{
	case "Confirm":
		st+="<input type=\"button\" class=\"ms-sgs-confirm-button\" value=\""+L_GBW_CL_ToConfirm_Text+"\" onclick=\"GBW_CL_Confirm('"+stLayoutsUrl+"','"+this.ctx.listName+"','"+this.stItemId+"','"+stCmd+"');\">";
		break;
	case "Disconfirm":
		st+="<input type=\"button\" class=\"ms-sgs-confirm-button\" value=\""+L_GBW_CL_CancelConfirmation_Text+"\" onclick=\"GBW_CL_Confirm('"+stLayoutsUrl+"','"+this.ctx.listName+"','"+this.stItemId+"','"+stCmd+"');\">";
		break;
	default:
		break;
		}
	document.write(st);
}
function GBW_CL_IsEditOrDeleteItemAllowed(stUserId, stAuthor, stContentTypeId)
{
	if (stUserId==null || stAuthor==null || stContentTypeId==null)
		return true;
	if (stUserId==stAuthor)
		return true;
	var nIndex=stContentTypeId.toLowerCase().indexOf(g_stOfficialNoticeContentTypeId);
	if (nIndex < 0)
		return true;
	return false;
}
function GBW_CL_GetConfirmCmd(stUserId, stConfirmed, stNotConfirmed)
{
	if (stUserId==null || stUserId=="")
		return "";
	var nIndex;
	nIndex=stConfirmed.indexOf(";#"+stUserId+"@");
	if (nIndex >=0)
		return "Disconfirm";
	nIndex=stNotConfirmed.indexOf(";#"+stUserId+";#");
	if (nIndex >=0)
		return "Confirm";
	return "";
}
function GBW_CL_Confirm(stLayoutsUrl, stListName, stItemId, stCmd)
{
	if (stCmd !="Confirm" && stCmd !="Disconfirm")
		return;
	var stUrl=stLayoutsUrl+"gbwconfm.aspx";
	stUrl+="?";
	stUrl+="List="+stListName;
	stUrl+="&";
	stUrl+="Cmd="+stCmd;
	stUrl+="&";
	stUrl+="ID="+stItemId;
	stUrl+="&";
	stUrl+="Source="+GetSource();
	SubmitFormPost(stUrl);
}

