/**
 * @author 236967
 */


var lRequest1234;
var itemid;
var itemName;
var gOrgFolder;
var lXMLObject;
function addfeedback(itemTypeId,itemTypeName)
{
    var abc= "AddEdit"+itemTypeId;
	//alert(abc);
	//document.getElementById("AddEdit"+itemTypeId).style.display='block';
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	 itemid =itemTypeId;
	 itemName =itemTypeName;


	var lEntity="SCREVIEWITEM";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);

		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
//	showAddEdit(gCurrentAddEditTemplate);
	showSearch1(lSearchElement,itemTypeId);		
}
function viewFeedback(orgFolder,userid)
{
	//*added by hiren
document.getElementById('ViewProfile').className="";
document.getElementById('ProfileEdit').className="";
document.getElementById('Changepassword').className="";
document.getElementById('FeedBack').className="current"; 
//* end hiren
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	var lEntity="scratingsaverage";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	clearDIV("Search");
  clearDIV("AddEdit");
  clearDIV("Listing");
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentEntityListURL, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);

		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
//	showAddEdit(gCurrentAddEditTemplate);
  
	showListing(lRequest);	
}

function feedbackmenu(itemTypeId,itemTypeName)
{
	document.getElementById("AddEdit1123"+itemTypeId).style.display='block';
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
    var	documentElement;		
	var lEntity="scratingsaverage";

	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);

		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
//	showAddEdit(gCurrentAddEditTemplate);
	showmain(lSearchElement,itemTypeId);		
}


   function addfeedbackAdd(itemTypeId,itemTypeName)
{
    var abc= "AddEdit"+itemTypeId;
	//alert(abc);
	document.getElementById("AddEdit1"+itemTypeId).style.display='block';
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	 itemid =itemTypeId;
	 itemName =itemTypeName;


	var lEntity="scitemcategorymap";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);

		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
//	showAddEdit(gCurrentAddEditTemplate);
	showSearch11123(lSearchElement,itemTypeId);


		
}

  function addfeedback1(itemTypeId,itemTypeName)
{
    var abc= "AddEdit1"+itemTypeId;
	//alert(abc);
	//document.getElementById("AddEdit1"+itemTypeId).style.display='block';
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	 itemid =itemTypeId;
	 itemName =itemTypeName;


	var lEntity="SCRATEITEM";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
/*	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentEntityListURL+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);

		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}*/	
//	showAddEdit(gCurrentAddEditTemplate);
	//showSearch11(lSearchElement,itemTypeId);
   requestList1(itemTypeId,itemTypeName);		
}

function requestList1(itemTypeId,itemTypeName)
{	

		var lAJAXInteraction = new AJAXInteraction(gCurrentEntityListURL+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName+'&orgfolder='+gOrgFolder, null, true);
		lRequest1234 = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest1234.responseXML;
		lRoot = lXMLResponse.documentElement;
		//lSearchElement = copyNodes(lRoot);
		showListing1(lRequest1234);

	//submitForm(document.eval('LIST'+itemTypeId), gCurrentEntityListURL+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, "POST", showListing1, gLoginKey, null); 
}
function handleResult1(pResult, pFormName,openWindow)
{
	var lSuccess;
	var lStatus;
	var lMessage;
	var lParam;
	var lFocusField;
	var lCount;
	lSuccess = false;
	if (pResult.attributes != null)
	{
		lStatus = null;
		lMessage = null;
		lStatus = pResult.attributes.getNamedItem("STATUS").value;
		
		if (pResult.attributes.getNamedItem("MESSAGE") != null)
		{
			lMessage = pResult.attributes.getNamedItem("MESSAGE").value;
		}
		
		if (lStatus != null)
		{
			lSuccess = (lStatus == "0");
			if (lMessage != null)
			{				
				showMessage(lMessage);
				
			}								
		}
	}
	return lSuccess;
}

function init(pEntity)
{
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	
	gEntityConfig = eval("entityConfiguration." + pEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
}

function popUpListing()
{
	var lXMLResponse;
	var lRoot;
	var lSuccess;
	var lHeaderNodes;
	var lHeader;
	var lList;
	var lCount;
	var lRowCount;
	var lTable;
	var lTableHead;
	var lTableBody;
	var lListDiv;
	var lHasKeyValue;
	var lElement;
	//alert(itemid+'itemid');
	//alert(gOrgFolder+'gOrgFolder');
	var iswopened = false;
	lXMLResponse = lRequest1234.responseXML;
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);	    
	lDOM = new DOMforPopUp(openWindow);
	
//	 lSuccess = handleResult1(lRoot.childNodes[0], "LIST10007");
	lSuccess = handleResult1(lRoot.childNodes[0], "SEARCH");
	if (lSuccess)
	{
		if (lRoot.childNodes.length == 2)
		{
			lList = lRoot.childNodes[1];
			lHeader = gCache.get(gCurrentEntity + "HEADER");
		}
		else
		{
			lHeaderNodes = copyNodes(lRoot.childNodes[1]);
			lHeader = new Header();
			lHeader.parse(lHeaderNodes);
			//gCache.add(gCurrentEntity + "HEADER", lHeaderNodes);
			lList = lRoot.childNodes[2];
		}
		//clearDIV("Listing");
		
		lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
		lTableHead = lDOM.createNewElement("THEAD", [{name:"class", value:"tableheader"}]);
		lTable.appendChild(lTableHead);
		//check if we have a key value
		lHasKeyValue = false;
		if (lList.childNodes.length > 0)
		{
			if (lList.childNodes[0].attributes.getNamedItem("KEYVALUE"))
			{
				lHasKeyValue = true;
			}
		}
		//showHeaderforpopup(lTableHead, lHeader, lHasKeyValue,openWindow,lDOM);
		lTableBody = lDOM.createNewElement("TBODY", null);
		lTable.appendChild(lTableBody);
		for (lCount = 0, lRowCount = 0; lCount < lList.childNodes.length; lCount++)
		{
			if (!isNodeNull(lList.childNodes[lCount]))
			{
				showListItemforpopup(lTableBody, lList.childNodes[lCount], lHeader, lRowCount);
				lRowCount++;
			}
		}
		//clearDIV("Listing");
		if(lRowCount == 0)
		{
			var lMessage = "NO RECORD EXISTS";
            lListDiv = openWindow.document.getElementById("Listing");	
            //lListDiv = document.getElementById("Listing");

			lListDiv.innerHTML = "<table align=center><br><br><tr><td align=center class=tableheader><b>" + lMessage + "</b></td><td></table>";
			lListDiv.style.position = "absolute";
		}
		else
		{			
			lListDiv = openWindow.document.getElementById("Listing");

			
			//openWindow.appendChild(lTable);
			lListDiv.appendChild(lTable);
			//Append buttons for first, previous, next and last
			lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
			lListDiv.appendChild(lTable);
			lCell = lDOM.createNewElement("TR", null);
			lListDiv.appendChild(lCell);
			lCell = lDOM.createNewElement("TD", null);
			lListDiv.appendChild(lCell);
			if (lList.attributes.getNamedItem("P"))
			{
				if (lList.attributes.getNamedItem("P").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"First"},{name:"class", value:"button"},{name:"onclick", value:"pageToFirstpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Previous"},{name:"class", value:"button"},{name:"onclick", value:"pageToPreviouspopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
			
			if (lList.attributes.getNamedItem("M"))
			{
				if (lList.attributes.getNamedItem("M").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Next"},{name:"class", value:"button"},{name:"onclick", value:"pageToNextpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Last"},{name:"class", value:"button"},{name:"onclick", value:"pageToLastpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
		
			//Append Hidden Elements
			//Start Key
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"SK"}]);
			lListDiv.appendChild(lElement);
			if (lList.attributes.getNamedItem("SK"))
			{
				lElement.value = lList.attributes.getNamedItem("SK").value;
			}
			//End Key
			
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"EK"}]);
			if (lList.attributes.getNamedItem("EK"))
			{
				lElement.value = lList.attributes.getNamedItem("EK").value;
			}
			lListDiv.appendChild(lElement);
			//Start Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"FR"}]);
			if (lList.attributes.getNamedItem("FR"))
			{
				lElement.value = lList.attributes.getNamedItem("FR").value;
			}
			lListDiv.appendChild(lElement);
			//End Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"LR"}]);
			if (lList.attributes.getNamedItem("LR"))
			{
				lElement.value = lList.attributes.getNamedItem("LR").value;
			}
			lListDiv.appendChild(lElement);
			//Total Rows
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"TR"}]);
			if (lList.attributes.getNamedItem("TR"))
			{
				lElement.value = lList.attributes.getNamedItem("TR").value;
			}
			lListDiv.appendChild(lElement);
		}
	}
}
function showHeaderforpopup(pTableHead, pHeader, pHasKeyValue)
{
	var lCount;
	var lHide;
	var lElement;
	var lRow;
	var lCell;
	var lDisplay;
	var lColumnCount;
	var lAttributeCount;
	var lCellNode;
	var lColumn;
	var lAttributes;
	lAttributes = null;
	if (gEntityConfig.headerRowAdd != null)
	{
		eval("lAttributes = " + gEntityConfig.headerRowAdd + "(pHeader)");
	}
	lRow = lDOM.createNewElement("TR", lAttributes);	
	for (lCount = 0, lColumnCount = 0; lCount < pHeader.numberOfColumns; lCount++)
	{
		lAttributes = null;
		lColumn = pHeader.columns[lCount];
		if (lColumn.hide != "1")
		{
			if (gEntityConfig.headerCellAdd != null)
			{
				eval("lAttributes = " + gEntityConfig.headerCellAdd + "(pHeader, lCount)");
			}
			if (lAttributes == null)
			{
				lAttributes = new Array();
			}
			for (lAttributeCount = 0; lAttributeCount < lColumn.myattributes.length; lAttributeCount++)
			{
				lAttributes[lAttributes.length] = lColumn.myattributes[lAttributeCount];
			}
			lCell = lDOM.createNewElement("TD", lAttributes);
			lCell.appendChild(openWindow.document.createTextNode(lColumn.display));
			lRow.appendChild(lCell);
		}
		lColumnCount++;
	}
	pTableHead.appendChild(lRow);
}
function showListItemforpopup(pBody, pListItem, pHeader, pRowCount)
{
	var lRow;
	var lCell1;
	var lCell2;
	var lCell;
	var lHide;
	var lCount;
	var lCellNode;
	var lKeyValue;
	var lColumn;
	var lAttributes;
	var lElement;
	var lValue;
	var lDecodedlValue;
	lAttributes = null;
	if (gEntityConfig.rowAdd != null)
	{
		eval("lAttributes = " + gEntityConfig.rowAdd + "(pHeader, pListItem, pRowCount)");	
	}
	if (lAttributes == null)
	{
		lAttributes = new Array();
	}
	lRow = openWindow.document.createElement("TR");
	if(pRowCount % 2 == 0)
	{
		lAtt = openWindow.document.createAttribute("class");
		lAtt.nodeValue= "tablerowcolour_even";
		lRow.setAttributeNode(lAtt);
		//lRow.setAttribute("class","tablerowcolour_even");
	}
	else
	{
		lAtt = openWindow.document.createAttribute("class");
		lAtt.nodeValue= "tablerowcolour_odd";
		lRow.setAttributeNode(lAtt);
//		lRow.setAttribute("class","tablerowcolour_odd");
	}
	pBody.appendChild(lRow);
	lCell = null;

     if (pListItem.attributes.getNamedItem("KEYVALUE"))
	{
		if (pListItem.attributes.getNamedItem("KEYVALUE").value != "")
		{
			lValue = pListItem.attributes.getNamedItem("KEYVALUE").value;
			
			lCell = lDOM.createNewElement("TD",null);
			lRow.appendChild(lCell);			
		}
	}
    lCell = lDOM.createNewElement("TD",null);
   // lRow.appendChild(lCell);
	for (lCount = 0; lCount < pHeader.columns.length; lCount++)
	{
		lAttributes = new Array();
		lColumn = pHeader.columns[lCount];
		if (lColumn.hide != "1")
		{
			if (gEntityConfig.beforeCellAdd != null)
			{
				eval("lAttributes = " + gEntityConfig.cellAdd + "(pHeader, pListItem, pRowCount, lColumnCount)");
			}
			if (lAttributes == null)
			{
				lAttributes = new Array();
			}
			for (lAttributeCount = 0; lAttributeCount < lColumn.myattributes.length; lAttributeCount++)
			{
				lAttributes[lAttributes.length] = lColumn.myattributes[lAttributeCount];
			}
			//lCell = lDOM.createNewElement("TD", lAttributes);
//			lRow.appendChild(lCell);
           // lCell2 = lDOM.createNewElement("P", null);
			//lCell2.setAttribute("class","padding_viewfeedback");
			//lRow.appendChild(lCell2);
            lCell1 = lDOM.createNewElement("P", null);
			lCell1.setAttribute('class','padding_viewfeedback');
			lValue = eval("pListItem.attributes.COL" + lCount + ".value");
			lDecodedlValue = Url.decode(lValue);
			if (lColumn.type == "")
			{
				lCell1.appendChild(openWindow.document.createTextNode(Url.decode(lValue)));
			}
			else
			{
				lAttributes = new Array();
				eval("lAttributes[0] = {name:\"name\",value:\"" + lColumn.name + "\"}");								
				eval("lAttributes[1] = {name:\"value\",value:\"" +  Url.decode(lValue) + "\"}");
				eval("lAttributes[2] = {name:\"type\",value:\"" + lColumn.type + "\"}");
				lCell1.appendChild(lDOM.createNewElement("input", lAttributes));
			}
			lCell.appendChild(lCell1);
			lRow.appendChild(lCell);
		}
		else if (lColumn.type)
		{
			lValue = eval("pListItem.attributes.COL" + lCount + ".value");
			lDecodedlValue = Url.decode(lValue);
			if (lColumn.type.length > 0)
			{
				lAttributes = new Array();
				eval("lAttributes[0] = {name:\"name\",value:\"" + lColumn.name + "\"}");

				eval("lAttributes[1] = {name:\"value\",value:\"" +  Url.decode(lValue) + "\"}");
				eval("lAttributes[2] = {name:\"type\",value:\"" + lColumn.type + "\"}");
				//Assumption that the first column will never be a hidden column
				lCell.appendChild(lDOM.createNewElement("input", lAttributes));
			}
		}
	}
}
function showListItemforpopup1(pBody, pListItem, pHeader, pRowCount)
{
	var lRow;
	var lCell1;
	var lCell;
	var lHide;
	var lCount;
	var lCellNode;
	var lKeyValue;
	var lColumn;
	var lAttributes;
	var lElement;
	var lValue;
	var lDecodedlValue;
	lAttributes = null;
	if (gEntityConfig.rowAdd != null)
	{
		eval("lAttributes = " + gEntityConfig.rowAdd + "(pHeader, pListItem, pRowCount)");	
	}
	if (lAttributes == null)
	{
		lAttributes = new Array();
	}
	lRow = document.createElement("TR");
	if(pRowCount % 2 == 0)
	{
		lAtt = document.createAttribute("class");
		lAtt.nodeValue= "tablerowcolour_even";
		lRow.setAttributeNode(lAtt);
	}
	else
	{
		lAtt = document.createAttribute("class");
		lAtt.nodeValue= "tablerowcolour_odd";
		lRow.setAttributeNode(lAtt);
	}
	pBody.appendChild(lRow);
	lCell = null;

     if (pListItem.attributes.getNamedItem("KEYVALUE"))
	{
		if (pListItem.attributes.getNamedItem("KEYVALUE").value != "")
		{
			lValue = pListItem.attributes.getNamedItem("KEYVALUE").value;
			
			lCell = lDOM.createNewElement("TD",null);
			lRow.appendChild(lCell);			
		}
	}
    lCell = lDOM.createNewElement("TD",null);
   // lRow.appendChild(lCell);
	for (lCount = 0; lCount < pHeader.columns.length; lCount++)
	{
		lAttributes = new Array();
		lColumn = pHeader.columns[lCount];
		if (lColumn.hide != "1")
		{
			if (gEntityConfig.beforeCellAdd != null)
			{
				eval("lAttributes = " + gEntityConfig.cellAdd + "(pHeader, pListItem, pRowCount, lColumnCount)");
			}
			if (lAttributes == null)
			{
				lAttributes = new Array();
			}
			for (lAttributeCount = 0; lAttributeCount < lColumn.myattributes.length; lAttributeCount++)
			{
				lAttributes[lAttributes.length] = lColumn.myattributes[lAttributeCount];
			}
			//lCell = lDOM.createNewElement("TD", lAttributes);
//			lRow.appendChild(lCell);
//                   document.createElement("TR");
            lCell1 = document.createElement("P");
            if(lCount ==6)
			{
 				lAtt = document.createAttribute("class");
    		lAtt.nodeValue= "errorCodeText";
	    	lCell1.setAttributeNode(lAtt);
			//lCell1.setAttribute("class","errorCodeText");
			}
            if(lCount ==9)
			{			
                lAtt = document.createAttribute("class");
    		    lAtt.nodeValue= "textStyleRecords";
 	    	    lCell1.setAttributeNode(lAtt);
//				lCell1.setAttribute("class","textStyleRecords");
			}
			if(lCount ==10)
			{			
				lAtt = document.createAttribute("class");
    		    lAtt.nodeValue= "dark-fonts";
 	    	    lCell1.setAttributeNode(lAtt);
				
				//lCell1.setAttribute("class","dark-fonts");
			}
			if(lCount ==14)
			{    		
                lAtt = document.createAttribute("class");
    		    lAtt.nodeValue= "dark-fonts";
 	    	    lCell1.setAttributeNode(lAtt);
				//lCell1.setAttribute("class","padding_viewfeedback");
			}
			lValue = eval("pListItem.attributes.COL" + lCount + ".value");
			lDecodedlValue = Url.decode(lValue);
			if (lColumn.type == "")
			{
				lCell1.appendChild(document.createTextNode(Url.decode(lValue)));
			}
			else
			{
				lAttributes = new Array();
				eval("lAttributes[0] = {name:\"name\",value:\"" + lColumn.name + "\"}");								
				eval("lAttributes[1] = {name:\"value\",value:\"" +  Url.decode(lValue) + "\"}");
				eval("lAttributes[2] = {name:\"type\",value:\"" + lColumn.type + "\"}");
				lCell1.appendChild(lDOM.createNewElement("input", lAttributes));
			}
			lCell.appendChild(lCell1);
			lRow.appendChild(lCell);
		}
		else if (lColumn.type)
		{
			lValue = eval("pListItem.attributes.COL" + lCount + ".value");
			lDecodedlValue = Url.decode(lValue);
			if (lColumn.type.length > 0)
			{
				lAttributes = new Array();
				eval("lAttributes[0] = {name:\"name\",value:\"" + lColumn.name + "\"}");				
				eval("lAttributes[1] = {name:\"value\",value:\"" +  Url.decode(lValue) + "\"}");
				eval("lAttributes[2] = {name:\"type\",value:\"" + lColumn.type + "\"}");
				//Assumption that the first column will never be a hidden column
				lCell.appendChild(lDOM.createNewElement("input", lAttributes));
			}
		}
	}
}
function pageToFirstpopup(itemid,itemName,gOrgFolder)
{

    var lEntity='SCRATEITEM';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	init(lEntity);

	var lRequest;
	var lAJAXInteraction;

	lRequest = getRequest(document.SEARCH, "0");
	lRequest += "&PN=F";
	lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForEntityList+'?itemTypeId='+itemid+'&itemTypeName='+itemName+'&orgfolder='+gOrgFolder, null, true);
	lXMLObject = lAJAXInteraction.doPost(lRequest);
	showListing3(lXMLObject,itemid,itemName,gOrgFolder);

}
function pageToLastpopup(itemid,itemName,gOrgFolder)
{

	var lEntity='SCRATEITEM';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	init(lEntity);

	var lRequest;
	var lAJAXInteraction;

	lRequest = getRequest(document.SEARCH, "0");
	lRequest += "&PN=L";
	lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForEntityList+'?itemTypeId='+itemid+'&itemTypeName='+itemName+'&orgfolder='+gOrgFolder, null, true);
	lXMLObject = lAJAXInteraction.doPost(lRequest);
	showListing3(lXMLObject,itemid,itemName,gOrgFolder);

}
function pageToNextpopup(itemid,itemName,gOrgFolder)
{

    var lEntity='SCRATEITEM';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	init(lEntity);
	var lRequest;
	var lAJAXInteraction;

	lRequest = getRequest(document.SEARCH, "0");
    lRequest += "&PN=N&SK=" + document.LIST.SK.value + "&EK=" + document.LIST.EK.value + "&FR=" + document.LIST.FR.value + "&LR=" + document.LIST.LR.value;
	lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForEntityList+'?itemTypeId='+itemid+'&itemTypeName='+itemName+'&orgfolder='+gOrgFolder, null, true);
	lXMLObject = lAJAXInteraction.doPost(lRequest);
	showListing3(lXMLObject,itemid,itemName,gOrgFolder);
}
function pageToPreviouspopup(itemid,itemName,gOrgFolder)
{
	var lEntity='SCRATEITEM';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	init(lEntity);

	var lRequest;
	var lAJAXInteraction;

	lRequest = getRequest(document.SEARCH, "0");
	lRequest += "&PN=P&SK=" + document.LIST.SK.value + "&EK=" + document.LIST.EK.value + "&FR=" + document.LIST.FR.value + "&LR=" + document.LIST.LR.value;
	lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForEntityList+'?itemTypeId='+itemid+'&itemTypeName='+itemName+'&orgfolder='+gOrgFolder, null, true);
	lXMLObject = lAJAXInteraction.doPost(lRequest);
	showListing3(lXMLObject,itemid,itemName,gOrgFolder);
}

function showListing2(lXMLObject,itemid,itemName,gOrgFolder)
{
	var lXMLResponse;
	var lRoot;
	var lSuccess;
	var lHeaderNodes;
	var lHeader;
	var lList;
	var lCount;
	var lRowCount;
	var lTable;
	var lTableHead;
	var lTableBody;
	var lListDiv;
	var lHasKeyValue;
	var lElement;
	lDOM = new DOMforPopUp(this.window);
	lXMLResponse = lXMLObject.responseXML;
//	alert( lXMLObject.responseText);
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);
	lSuccess = handleResult(lRoot.childNodes[0], "LIST");
	if (lSuccess)
	{
		if (lRoot.childNodes.length == 2)
		{
			lList = lRoot.childNodes[1];
			lHeader = gCache.get(gCurrentEntity + "HEADER");
		}
		else
		{
			lHeaderNodes = copyNodes(lRoot.childNodes[1]);
			lHeader = new Header();
			lHeader.parse(lHeaderNodes);
			//gCache.add(gCurrentEntity + "HEADER", lHeaderNodes);
			lList = lRoot.childNodes[2];
		}
		//clearDIV("Listing");
		lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
		lTableHead = lDOM.createNewElement("THEAD", [{name:"class", value:"tableheader"}]);
		lTable.appendChild(lTableHead);
		//check if we have a key value
		lHasKeyValue = false;
		if (lList.childNodes.length > 0)
		{
			if (lList.childNodes[0].attributes.getNamedItem("KEYVALUE"))
			{
				lHasKeyValue = true;
			}
		}
		//showHeader(lTableHead, lHeader, lHasKeyValue);
		lTableBody = lDOM.createNewElement("TBODY", null);
		lTable.appendChild(lTableBody);
		for (lCount = 0, lRowCount = 0; lCount < lList.childNodes.length; lCount++)
		{
			if (!isNodeNull(lList.childNodes[lCount]))
			{
				showListItemforpopup(lTableBody, lList.childNodes[lCount], lHeader, lRowCount);
				lRowCount++;
			}
		}
		clearDIV("Listing");
		if(lRowCount == 0)
		{
			var lMessage = "NO RECORD EXISTS";
			lListDiv = document.getElementById("Listing");
			lListDiv.innerHTML = "<table align=center><br><br><tr><td align=center class=tableheader><b>" + lMessage + "</b></td><td></table>";
			lListDiv.style.position = "absolute";
		}
		else
		{
			lListDiv = document.getElementById("Listing");
			lListDiv.appendChild(lTable);
			//Append buttons for first, previous, next and last
			lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
			lListDiv.appendChild(lTable);
			lCell = lDOM.createNewElement("TR", null);
			lListDiv.appendChild(lCell);
			lCell = lDOM.createNewElement("TD", null);
			lListDiv.appendChild(lCell);
			if (lList.attributes.getNamedItem("P"))
			{
				if (lList.attributes.getNamedItem("P").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"First"},{name:"class", value:"button"},{name:"onclick", value:"pageToFirstpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Previous"},{name:"class", value:"button"},{name:"onclick", value:"pageToPreviouspopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
			
			if (lList.attributes.getNamedItem("M"))
			{
				if (lList.attributes.getNamedItem("M").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Next"},{name:"class", value:"button"},{name:"onclick", value:"pageToNextpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Last"},{name:"class", value:"button"},{name:"onclick", value:"pageToLastpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
		
			//Append Hidden Elements
			//Start Key
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"SK"}]);
			lListDiv.appendChild(lElement);
			if (lList.attributes.getNamedItem("SK"))
			{
				lElement.value = lList.attributes.getNamedItem("SK").value;
			}
			//End Key
			
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"EK"}]);
			if (lList.attributes.getNamedItem("EK"))
			{
				lElement.value = lList.attributes.getNamedItem("EK").value;
			}
			lListDiv.appendChild(lElement);
			//Start Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"FR"}]);
			if (lList.attributes.getNamedItem("FR"))
			{
				lElement.value = lList.attributes.getNamedItem("FR").value;
			}
			lListDiv.appendChild(lElement);
			//End Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"LR"}]);
			if (lList.attributes.getNamedItem("LR"))
			{
				lElement.value = lList.attributes.getNamedItem("LR").value;
			}
			lListDiv.appendChild(lElement);
			//Total Rows
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"TR"}]);
			if (lList.attributes.getNamedItem("TR"))
			{
				lElement.value = lList.attributes.getNamedItem("TR").value;
			}
			lListDiv.appendChild(lElement);
		}
	}
}

function showListing3(lXMLObject,itemid,itemName,gOrgFolder)
{
	var lXMLResponse;
	var lRoot;
	var lSuccess;
	var lHeaderNodes;
	var lHeader;
	var lList;
	var lCount;
	var lRowCount;
	var lTable;
	var lTableHead;
	var lTableBody;
	var lListDiv;
	var lHasKeyValue;
	var lElement;
	lDOM = new DOMforPopUp(this.window);
	lXMLResponse = lXMLObject.responseXML;
//	alert( lXMLObject.responseText);
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);
	lSuccess = handleResult(lRoot.childNodes[0], "LIST");
	if (lSuccess)
	{
		if (lRoot.childNodes.length == 2)
		{
			lList = lRoot.childNodes[1];
			lHeader = gCache.get(gCurrentEntity + "HEADER");
		}
		else
		{
			lHeaderNodes = copyNodes(lRoot.childNodes[1]);
			lHeader = new Header();
			lHeader.parse(lHeaderNodes);
			//gCache.add(gCurrentEntity + "HEADER", lHeaderNodes);
			lList = lRoot.childNodes[2];
		}
		//clearDIV("Listing");

		lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
		lTableHead = lDOM.createNewElement("THEAD", [{name:"class", value:"tableheader"}]);
		lTable.appendChild(lTableHead);
		//check if we have a key value
		lHasKeyValue = false;
		if (lList.childNodes.length > 0)
		{
			if (lList.childNodes[0].attributes.getNamedItem("KEYVALUE"))
			{
				lHasKeyValue = true;
			}
		}
		//showHeader(lTableHead, lHeader, lHasKeyValue);
		lTableBody = lDOM.createNewElement("TBODY", null);
		lTable.appendChild(lTableBody);
		for (lCount = 0, lRowCount = 0; lCount < lList.childNodes.length; lCount++)
		{
			if (!isNodeNull(lList.childNodes[lCount]))
			{
				showListItemforpopup1(lTableBody, lList.childNodes[lCount], lHeader, lRowCount);
				lRowCount++;
			}
		}
		clearDIV("Listing");
		if(lRowCount == 0)
		{
			var lMessage = "NO RECORD EXISTS";
			lListDiv = document.getElementById("Listing");
			lListDiv.innerHTML = "<table align=center><br><br><tr><td align=center class=tableheader><b>" + lMessage + "</b></td><td></table>";
			lListDiv.style.position = "absolute";
		}
		else
		{
			lListDiv = document.getElementById("Listing");
			lListDiv.appendChild(lTable);
			//Append buttons for first, previous, next and last
			lTable = lDOM.createNewElement("TABLE", [{name:"BORDER", value:"0"},{name:"width", value:"98%"},{name:"align", value:"center"},{name:"class", value:"border"},{name:"cellpadding", value:"0"},{name:"cellspacing", value:"0"}]);
			lListDiv.appendChild(lTable);
			lCell = lDOM.createNewElement("TR", null);
			lListDiv.appendChild(lCell);
			lCell = lDOM.createNewElement("TD", null);
			lListDiv.appendChild(lCell);
			if (lList.attributes.getNamedItem("P"))
			{
				if (lList.attributes.getNamedItem("P").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"First"},{name:"class", value:"button"},{name:"onclick", value:"pageToFirstpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Previous"},{name:"class", value:"button"},{name:"onclick", value:"pageToPreviouspopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
			
			if (lList.attributes.getNamedItem("M"))
			{
				if (lList.attributes.getNamedItem("M").value == "Y")
				{
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Next"},{name:"class", value:"button"},{name:"onclick", value:"pageToNextpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
					lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"button"},{name:"value", value:"Last"},{name:"class", value:"button"},{name:"onclick", value:"pageToLastpopup('"+itemid+"','"+itemName+"','"+gOrgFolder+"')"}]);
					lListDiv.appendChild(lElement);
				}
			}
		
			//Append Hidden Elements
			//Start Key
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"SK"}]);
			lListDiv.appendChild(lElement);
			if (lList.attributes.getNamedItem("SK"))
			{
				lElement.value = lList.attributes.getNamedItem("SK").value;
			}
			//End Key
			
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"EK"}]);
			if (lList.attributes.getNamedItem("EK"))
			{
				lElement.value = lList.attributes.getNamedItem("EK").value;
			}
			lListDiv.appendChild(lElement);
			//Start Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"FR"}]);
			if (lList.attributes.getNamedItem("FR"))
			{
				lElement.value = lList.attributes.getNamedItem("FR").value;
			}
			lListDiv.appendChild(lElement);
			//End Row
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"LR"}]);
			if (lList.attributes.getNamedItem("LR"))
			{
				lElement.value = lList.attributes.getNamedItem("LR").value;
			}
			lListDiv.appendChild(lElement);
			//Total Rows
			lElement = lDOM.createNewElement("INPUT", [{name:"type", value:"hidden"},{name:"name", value:"TR"}]);
			if (lList.attributes.getNamedItem("TR"))
			{
				lElement.value = lList.attributes.getNamedItem("TR").value;
			}
			lListDiv.appendChild(lElement);
		}
	}
}
function showListing1(lRequest1234,itemTypeID)
{
	var lXMLResponse;
	var lRoot;
	var lSuccess;
	var lHeaderNodes;
	var lHeader;
	var lList;
	var lCount;
	var lRowCount;
	var lTable;
	var lTableHead;
	var lTableBody;
	var lListDiv;
	var lHasKeyValue;
	var lElement;
	var iswopened = false;
	lXMLResponse = lRequest1234.responseXML;
	lRoot = lXMLResponse.documentElement;
	lRoot = copyNodes(lRoot);	
	//alert('pXMLObject'+lRequest1234);
	
   openWindow = window.open("/dotcom/oxford/FeedBackManagement/jsp/Noname1.html",'openWindow2',"height=300,width=700,left=100,top=200,resizable=yes,scrollbars=yes,status=yes");
//   alert(openWindow.document);
   timer = window.setTimeout('popUpListing()',300);
}

function submitForm(pForm, pURL, pMethod, pHandler, pLoginKey, pMoreParameters)
{
	var lRequest;
	var lAJAXInteraction;
	lRequest = getRequest(pForm, pLoginKey);
	if (pMoreParameters != null)
	{
		if (lRequest.length > 0)
		{
			lRequest += "&" + pMoreParameters;
		}
		else
		{
			lRequest = pMoreParameters;
		}
	}
	//alert(lRequest);
	if (pMethod == "GET" || pMethod == "get")
	{
		lAJAXInteraction = new AJAXInteraction(pURL + "?" + lRequest, pHandler);
		lAJAXInteraction.doGet();
	}
	else if (pMethod == "POST" || pMethod == "post")
	{
		lAJAXInteraction = new AJAXInteraction(pURL, pHandler);
		lAJAXInteraction.doPost(lRequest);
	}
}

function showSearch2(pSearchElement,itemTypeId)
{
	var lSearch;
	clearDIV("Search");
	clearDIV("AddEdit");
	clearDIV("Listing");
	lSearch = document.getElementById("Search");
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}
	clearForm("LIST");
	getPreEntity1(itemTypeId);
	enableDisable(document.SEARCH);
}


function showSearch1(pSearchElement,itemTypeId)
{
	var lSearch;

	clearDIV("AddEdit"+itemTypeId);
	lSearch = document.getElementById("AddEdit"+itemTypeId);
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}	
	getPreEntity1(itemTypeId);	
}

function showSearch11(pSearchElement,itemTypeId)
{
	var lSearch;

	clearDIV("AddEdit1"+itemTypeId);
	lSearch = document.getElementById("AddEdit1"+itemTypeId);
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}	
	getPreEntity1(itemTypeId);	
}

function showSearch11123(pSearchElement,itemTypeId)
{
	var lSearch;

	clearDIV("AddEdit1"+itemTypeId);
	lSearch = document.getElementById("AddEdit1"+itemTypeId);
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}	
	getPreEntity123(itemTypeId);	
}

function showmain(pSearchElement,itemTypeId)
{
	var lSearch;

	clearDIV("AddEdit1123"+itemTypeId);
	lSearch = document.getElementById("AddEdit1123"+itemTypeId);
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}	
	//getPreEntity1(itemTypeId);	
}

function getPreEntity1(itemTypeId)
{
	if (gEntityConfig.URLForPreFetch != null)
	{
		var lAJAXInteraction;
		lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForPreFetch+'?itemTypeId='+itemTypeId, null,true);
		handlePreEntity1(lAJAXInteraction.doPost('LK=' + gLoginKey),itemTypeId);
	}
}
function getPreEntity123(itemTypeId)
{
	if (gEntityConfig.URLForPreFetch != null)
	{
		var lAJAXInteraction;
		//lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForPreFetch+'?itemTypeId='+itemTypeId, null,true);
		lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForPreFetch+'?itemTypeId='+itemTypeId+"&OrgId="+gOrgID, null,true);

		handlePreEntity123(lAJAXInteraction.doPost('LK=' + gLoginKey),itemTypeId);
	}
}
function handlePreEntity123(pXMLObject,itemTypeId)
{
	var lXMLResponse;
	var lBaseEdit;
	var lEntity;
	var lData;
	var lLists;
	var lChildren;
	var lCount;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lChildren = lBaseEdit.childNodes;
		lLists = null;
		for (lCount = 1; lCount < lChildren.length; lCount++)
		{
			if (!isNodeNull(lChildren[lCount]))
			{
					if (lChildren[lCount].nodeName == "DATA")
				{
						lData = lChildren[lCount];
				}
				else if (lChildren[lCount].nodeName == "LISTS")
				{
					lLists = parseLists(lChildren[lCount]);
				}
			}
		}
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			fillView123(lData.childNodes[lCount],itemTypeId);
		}
		if (gEntityConfig.postView != null)
		{
			eval (gEntityConfig.postView + "(pXMLObject)");
		}
	}
}

function handlePreEntity1(pXMLObject,itemTypeId)
{
	var lXMLResponse;
	var lBaseEdit;
	var lEntity;
	var lData;
	var lLists;
	var lChildren;
	var lCount;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lBaseEdit = lXMLResponse.documentElement;
	lBaseEdit = copyNodes(lBaseEdit);
	lSuccess = handleResult(lBaseEdit.childNodes[0]);
	if (lSuccess)
	{
		lChildren = lBaseEdit.childNodes;
		lLists = null;
		for (lCount = 1; lCount < lChildren.length; lCount++)
		{
			if (!isNodeNull(lChildren[lCount]))
			{
					if (lChildren[lCount].nodeName == "DATA")
				{
						lData = lChildren[lCount];
				}
				else if (lChildren[lCount].nodeName == "LISTS")
				{
					lLists = parseLists(lChildren[lCount]);
				}
			}
		}
		for (lCount = 0; lCount < lData.childNodes.length; lCount++)
		{
			fillView1(lData.childNodes[lCount],itemTypeId);
		}
		if (gEntityConfig.postView != null)
		{
			eval (gEntityConfig.postView + "(pXMLObject)");
		}
	}
}
function fillView123(pEntity,itemTypeId)
{
	var lCount;
	var lSpan;
	for (lCount = 0; lCount < pEntity.attributes.length; lCount++)
	{
		lSpan = document.getElementById(pEntity.attributes[lCount].name);
		if (lSpan)
		{
			if (!!document.all)
			{
				lSpan.innerText = pEntity.attributes[lCount].value;
			}
			else
			{
				clearDIV(pEntity.attributes[lCount].name);
				lSpan.appendChild(document.createTextNode(pEntity.attributes[lCount].value));
			}
		}
	}

}

function fillView1(pEntity,itemTypeId)
{
	var lCount;
	var lSpan;
	var lCell;

	for (lCount = 0; lCount < pEntity.attributes.length; lCount++)
	{
		lSpan = document.getElementById("rate"+itemTypeId);
		if(pEntity.attributes[lCount].value=="screviewitem" )
		{		    	
			if((pEntity.attributes[lCount-1].value != "null") && (pEntity.attributes[lCount-1].value != ""))
			{				
		    lCell = gDOM.createNewElement("TD", [{name:"class", value:pEntity.attributes[lCount-1].value}]);			
			}
			else
			{    		 
		    lCell = gDOM.createNewElement("TD", [{name:"class", value:pEntity.attributes[lCount+2].value}]);			
			}
			lSpan.appendChild(lCell);
		}
		if(pEntity.attributes[lCount].value=="screviewitem")
		{
			lCell = gDOM.createNewElement("TD");
            if((pEntity.attributes[lCount-2].value != "null") && (pEntity.attributes[lCount-2].value != ""))
			{
			lCell.appendChild(document.createTextNode(pEntity.attributes[lCount-2].value));
			}
			else
			{
			lCell.appendChild(document.createTextNode(pEntity.attributes[lCount+1].value));
			}
			lSpan.appendChild(lCell);
		}

    		

		/*lSpan1 = document.getElementById('count');
		lCell1 = gDOM.createNewElement("TD", [{name:"value", value:pEntity.attributes[lCount].value}]);
		lSpan1.appendChild(lCell1);*/
		/*if (lSpan)
		{
			if (!!document.all)
			{
				lSpan.innerText = pEntity.attributes[lCount].value;
			}
			else
			{
				clearDIV(pEntity.attributes[lCount].name);
				lSpan.appendChild(document.createTextNode(pEntity.attributes[lCount].value));
			}
		}*/
	}
}


   function addfeedback10(itemTypeId,itemTypeName)
{
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	var itemid =itemTypeId;
	var itemName =itemTypeName;


	var lEntity="SCITEMTYPEMASTER";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate+'?itemTypeId='+itemTypeId+'&itemTypeName='+itemTypeName, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);
		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
	showSearch(lSearchElement);
}
  function addfeedback12345()
{
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;
	
	var lEntity="SCITEMTYPEMASTER";
	gEntityConfig = eval("entityConfiguration." + lEntity);	
	lEntityConfiguration = gEntityConfig;
	gCurrentEntity = lEntityConfiguration.entity;
	gCurrentSearchTemplate = lEntityConfiguration.searchTemplate;
	gCurrentAddEditTemplate = lEntityConfiguration.addEditTemplate;
	gCurrentListTemplate = lEntityConfiguration.listTemplate;
	gCurrentViewTemplate = lEntityConfiguration.viewTemplate;
	gCurrentEntityIdField = lEntityConfiguration.entityIdField;
	gCurrentEntityListURL = lEntityConfiguration.URLForEntityList;
	gCurrentEntityPreEditURL = lEntityConfiguration.URLForEntityPreEdit;
	gCurrentEntitySaveURL = lEntityConfiguration.URLForEntitySave;
	gCurrentEntityPreURL = lEntityConfiguration.URLForPreFetch;
	gCurrentEntityDeleteURL = lEntityConfiguration.URLForEntityDelete;
	gPostAddEdit = lEntityConfiguration.postAddEdit;
	gPostSearch = lEntityConfiguration.postSearch;
	gPostEdit = lEntityConfiguration.postEdit;
	gPostList = lEntityConfiguration.postList;
	gClearAddEdit = true;
	//Check if the search element for the entity is available in Cache.
	//lSearchElement = gCache.get(pCurrentEntity + "SEARCH");
	lSearchElement = null;
	if (lSearchElement == null)
	{
		//if it is not available then fetch the template from the server.
		var lAJAXInteraction = new AJAXInteraction(gCurrentAddEditTemplate, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);
		//Add the template received to the cache and show the search area.
		//gCache.add(gCurrentEntity + "SEARCH", lSearchElement);
	}	
	showSearch(lSearchElement);
}
