var m_oAssMgr=new g_VNLibs.VNAssetMgr();

function WriteSidePanel()
{
	var strHTML='';
	
	strHTML+=m_objMqButton.GetTextButtonHTML("Reassign", g_MqRef.RESX['BTN_REASSIGN_ASSETS'], "m_oAssMgr.ReassignSelected(mDataGrid,document)", "", 65, "", "", 150);

	strHTML+=m_objMqButton.GetTextButtonHTML("ScrapAssets", g_MqRef.RESX['BTN_SCRAP_ASSETS'], "ScrapAssets()", "", 65, "", "", 150);

	strHTML+=m_objMqButton.GetTextButtonHTML("LostAssets", g_MqRef.RESX['BTN_MARK_ASSETS_LOST'], "MarkAssetsAsLost()", "", 65, "", "", 150);

	strHTML+=m_objMqButton.GetTextButtonHTML("RequestStatus", g_MqRef.RESX['BTN_REQUEST_ASSET_STATUS'], "RequestAssetStatus()", "", 65, "padding-bottom:50px;", "", 150);
	
	document.write(strHTML);
}

function EditResInfo(lngID)
{
	parent.LoadRecord(lngID, -1, false);
}

function MarkAssetsAsLost()
{
	if(GetSelectedRows()){
		var strCols=m_arrCheckedCols.join("");
		
		var strMsg = g_MqRef.RESX["MSG_CONFIRM_MARK_LOST"] + "<br \><br \>" + strCols;
		
		g_MqRef.ConfirmBox.show(g_MqRef.RESX["MSG_TITLE_LOST_ASSET"], strMsg).then(function(res)
		{
			if(res)
			{
				if (parent){
					var strIDs=m_arrCheckedIDs.join(";");
					var co = parent.objRequest.Get(parent.mstrCurrentLocation + "../ASP/SetLost.asp?IDs=" + strIDs);
					if (co!=""){
						if(parent.ToolBar){
							parent.ToolBar.submitinfo(null,true);
						}
					}
				}
			}
		});
	}
}

function ScrapAssets()
{
	if(GetSelectedRows()){
		var strCols=m_arrCheckedCols.join("");
		
		var strMsg = g_MqRef.RESX["MSG_CONFIRM_SCRAP_ASSETS1"] + "<br \><br \>" + strCols + "<br \><br \>" + g_MqRef.RESX["MSG_CONFIRM_SCRAP_ASSETS2"];
		
		g_MqRef.ConfirmBox.show(g_MqRef.RESX["MSG_TITLE_SCRAP_ASSET"], strMsg).then(function(res)
		{
			if(res)
			{
				if (parent){
					var strIDs=m_arrCheckedIDs.join(";");
					var co = parent.objRequest.Get(parent.mstrCurrentLocation + "../ASP/SetScrapped.asp?IDs=" + strIDs);
					if (co!=""){
						if(parent.ToolBar){
							parent.ToolBar.submitinfo(null,true);
						}
					}
				}
			}
		});	
	}
}

function RequestAssetStatus()
{
	if(GetSelectedRows()){
		var strCols=m_arrCheckedCols.join("");
		
		var strMsg = g_MqRef.RESX["MSG_CONFIRM_REQUEST_STATUS"] + "<br \><br \>" + strCols;
		
		g_MqRef.ConfirmBox.show(g_MqRef.RESX["MSG_TITLE_REQUEST_ASSET_STATUS"], strMsg).then(function(res)
		{
			if(res)
			{
				if (parent){
					var strIDs=m_arrCheckedIDs.join(";");
					var co = parent.objRequest.Get(parent.mstrCurrentLocation + "../ASP/SetStatusRequested.asp?IDs=" + strIDs);
					if (co!=""){
						if(parent.ToolBar){
							parent.ToolBar.submitinfo(null,true);
						}
					}
				}
			}
		});	
	}	
}

function GetGridValue(strTag, lngID)
{
	var strValue="";
	var objCell=document.getElementById(strTag+lngID);
	if(objCell){
		strValue=objCell.innerHTML;
	}
	return strValue;
}

var m_arrCheckedIDs = [];
var m_arrCheckedCols = [];


function GetSelectedRows()
{
	m_arrCheckedIDs.length=0;
	m_arrCheckedCols.length=0;
	
	if(mDataGrid){
		var lngLastCol=mDataGrid.getColumnsNum()-1;
		if(mDataGrid.getColType(lngLastCol)=="ch"){
			
			m_arrCheckedCols.push("<table style=\"color:#727272;width:100%;\">");
			mDataGrid.forEachRow(function(id){
				if (mDataGrid.cells(id,lngLastCol).getValue()=="0"){
				}else{
					m_arrCheckedIDs.push(id);
					var col1 = mDataGrid.cells(id,1).getValue().replace(/<(?:.|\n)*?>/gm,"");
					var col2 = mDataGrid.cells(id,2).getValue().replace(/<(?:.|\n)*?>/gm,"");
					var col3 = mDataGrid.cells(id,3).getValue().replace(/<(?:.|\n)*?>/gm,"");
					m_arrCheckedCols.push("<tr><td style=\"font-weight:bold;padding-right:5px;\">" + col1 + "</td><td style=\"padding-left:5px;padding-right:5px;\">" + col2 + "</td><td style=\"padding-left:5px\">" + col3 + "</td></tr>");
				}
			});
			m_arrCheckedCols.push("</table>");
		}
	}	
	return true;
}