

entityConfiguration.dcendusers = {
	entity:"dcendusers",
	applicationId : "AppId4",
	searchTemplate: "/dotcom/"+gOrgFolder+"/ProfileManagement/jsp/profilemanagement/ForgotPassword.jsp",
	addEditTemplate: "/dotcom/"+gOrgFolder+"/ProfileManagement/jsp/profilemanagement/SignUp.jsp",
	listTemplate: "",
	viewTemplate: "",
	entityIdField: "euid_eudatacenterid",
	URLForEntityList:"/dotcom/"+gOrgFolder+"/SearchUsersList.kar",
	URLForEntityPreEdit:"",
	URLForEntitySave:"/dotcom/"+gOrgFolder+"/ProfileSave.kar?orgfolder="+gOrgFolder,
	URLForPreFetch:"/dotcom/"+gOrgFolder+"/ForgotPrefetch.kar?OrgFolder="+gOrgFolder,
	URLForEntityDelete:"",
	URLForEntityView:"",
	URLForEntitySubmit:"/dotcom/"+gOrgFolder+"/ForgotPassword.kar",
	postAddEdit: "",
	postSearch:null,
	postEdit:"",
	postList:null,
	saveValidate:null,
	beforeRowAdd:null,
	beforeCellAdd:null,
	beforeHeaderRowAdd:null,
	afterHeaderRowAdd:null,
	afterRowAdd:null,
	postViewTemplate:"",
	postView:"",
	imageURL:""
};

entityConfiguration.MENU= {
	entity:"MENU",
	applicationId : "AppId4",
	searchTemplate: "/dotcom/gOrgFolder/ProfileManagement/jsp/profilemanagement/UserMenuDisplay.jsp",
	addEditTemplate: "",
	listTemplate: "",
	viewTemplate: "",
	entityIdField: "",
	URLForEntityList:"",
	URLForEntityPreEdit:"",
	URLForEntitySave:"/dotcom/"+gOrgFolder+"/ModuleController.kar",
	URLForPreFetch:"/dotcom/"+gOrgFolder+"/UserMenuDisplay.kar",
	postAddEdit: "",
	postSearch:null,
	postEdit:"",
	postList:null,
	saveValidate:null,
	beforeRowAdd:null,
	beforeCellAdd:null,
	beforeHeaderRowAdd:null,
	afterHeaderRowAdd:null,
	imageURL:""
};


entityConfiguration.sccouriermaster= {
	entity:"sccouriermaster",
	applicationId : "AppId4",
	searchTemplate: "",
	addEditTemplate: "",
	listTemplate: "",
	viewTemplate: "",
	entityIdField: "couriermstrid_couriermstrdcnid",
	URLForEntityList:"/dotcom/"+gOrgFolder+"/CourierListing.kar",
	URLForEntityPreEdit:"",
	URLForEntitySave:"",
	URLForPreFetch:"/dotcom/"+gOrgFolder+"/ZonePrefetch.kar",
	postAddEdit: "",
	postSearch:null,
	postEdit:"",
	postList:null,
	saveValidate:null,
	beforeRowAdd:null,
	beforeCellAdd:null,
	beforeHeaderRowAdd:null,
	afterHeaderRowAdd:null,
	imageURL:""
};

var USERFIELDS = new Object();

USERFIELDS.LoginId = "cusloginid";
USERFIELDS.Password = "cuspassword";
USERFIELDS.Salutation = "salid";
USERFIELDS.FirstName = "eufirstname";
USERFIELDS.MiddleName = "eumiddlename";
USERFIELDS.LastName = "eulastname";
USERFIELDS.DisplayName = "cusdisplayname";
USERFIELDS.ContactNo = "eucontactno";
USERFIELDS.AddLine1 = "euaddline1";
USERFIELDS.AddLine2 = "euaddline2";
USERFIELDS.City= "euaddcity";
USERFIELDS.State = "euaddstate";
USERFIELDS.Country = "countrymastid";
USERFIELDS.ZipCode = "euaddzipcode";
USERFIELDS.EmailId = "euemailid";
USERFIELDS.DoB = "eudob";
USERFIELDS.QuestionId = "favid";
USERFIELDS.Answer = "eusecretanswer";
USERFIELDS.OldPassword = "OldPassword";
USERFIELDS.NewPassword = "newpassword";
USERFIELDS.ConfirmNewPassword = "ConfirmNewPassword";
USERFIELDS.SalutationEdit = "salid";
USERFIELDS.QuestionIdEdit = "favid";
USERFIELDS.Interest = "euinterest";
USERFIELDS.Status = "usid";


function showForgotPassword(pOrgFolder)
{

	var lEntity='dcendusers';
	var	lEntityConfig = eval("entityConfiguration." + lEntity);	
	showOnlyEntity(lEntity);
	gCurrentEntitySaveURL = gEntityConfig.URLForEntitySubmit;
	submitForm(document.SEARCH ,gCurrentEntitySaveURL, "POST", handleRedirectSave, gLoginKey, null);
}

function signUp(pOFolder)
{
	var lSearchElement;
	var lSearch;
	var lEntityConfiguration;
	var lRequest;
	var lXMLResponse;
	var lRoot;

	var lEntity="dcendusers";
	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;
	lSearchElement = null;
	if (lSearchElement == null)
	{
		var lSignUpTemplate="/dotcom/"+pOFolder+"/ProfileManagement/jsp/profilemanagement/SignUp.jsp?OrgFolder="+pOFolder;
		var lAJAXInteraction = new AJAXInteraction(lSignUpTemplate, null, true);
		lRequest = lAJAXInteraction.doPost('LK=' + gLoginKey);
		lXMLResponse = lRequest.responseXML;
		lRoot = lXMLResponse.documentElement;
		lSearchElement = copyNodes(lRoot);
		var lSearch = document.getElementById("Search");
		lSearch.appendChild(lSearchElement);
	}
	showSearch(lSearchElement);
	//if (gEntityConfig.URLForPreFetch != null)
	//{
	//	var lAJAXInteraction;
	//	lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForPreFetch, null,true);
		//fillCheckbox(lAJAXInteraction.doPost('LK=' + gLoginKey));
	//}
}

function fillCheckbox(pXMLObject)
{
	var lXMLResponse;
	var lRoot;
	var lLists;
	var lCount;
	var lElementCount;
	var lOptionCount;
	var lForm;
	var lOptions;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lRoot = lXMLResponse.documentElement;
	lSuccess = handleResult(lRoot.childNodes[0], null);
	if (lSuccess)
	{
		var lCheck=lRoot.childNodes[1].childNodes[3];
		for(lCount=0; lCount<lCheck.childNodes.length; lCount++)
		{
			fillInterest(lCheck.childNodes[lCount],lCount);
		}
	}
}

function fillInterest(pInterest,pCount)
{
	for ( var i=0; i<pInterest.attributes.length; i++)
	{
		if(pInterest.attributes[i].nodeName=="DISPLAY") 
		{
			var lInterest=pInterest.attributes[i].value;
			break;
		}
		if(pInterest.attributes[i].nodeName=="ID") 
		{
			var lID=pInterest.attributes[i].value;
		}
	}
	var lElement;
	var lIntDiv=document.getElementById("Interest");	
	lElement = gDOM.createNewElement("INPUT", [{name:"type", value:"checkbox"},{name:"value", value:lID},{name:"name", value:"userInterest"+pCount}]);
	if (pCount%3=='0')
	{
		var lRow = gDOM.createNewElement("TR", [{name:"id", value:"RowID"+pCount}]);
		var lTempRow=lRow;
		lIntDiv.appendChild(lRow);
		lRow.appendChild(lElement);
	}
	lIntDiv.appendChild(lElement);

	var lOption= document.createTextNode(lInterest);
	lIntDiv.appendChild(lOption);
}

function showSearchSignUp(pSearchElement)
{
	var lSearch;
	lSearch = document.getElementById("Search");
	lSearch.appendChild(pSearchElement);
	if (gPostSearch != null)
	{
		eval(gPostSearch);
	}
	clearForm("LIST");
	getPreEntitySignUp();
}

function getPreEntitySignUp()
{
	if (gEntityConfig.URLForPreFetch != null)
	{
		var lAJAXInteraction;
		lAJAXInteraction = new AJAXInteraction(gEntityConfig.URLForPreFetch, handlePreEntitySignUp);
		lAJAXInteraction.doPost('LK=' + gLoginKey);
	}
}

function  handlePreEntitySignUp(pXMLObject)
{
	var lXMLResponse;
	var lBaseEdit;
	var lEntity;
	var lData;
	var lLists;
	var lChildren;
	var lCount;
	var lSuccess;
	var lModules;
	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 == "LISTS")
				{
					lLists = parseLists(lChildren[lCount]);
				}
			}
		}
		if (lLists != null)
		{
			fillSelectsInForm(document.AddEdit, lLists);
		}
		
		if (gEntityConfig.postAddEdit!= null)
		{
			eval (gPostEdit + "(pXMLObject)");
		}
	}

}

function redirectFunction()
{
	var lRedirectPath="/dotcom/"+gOrgFolder+"/ProfileManagement/redirectToHome.html";
	gotoPage(lRedirectPath, null, null);
}

function fillCheckbox1(pXMLObject)
{
	var lXMLResponse;
	var lRoot;
	var lLists;
	var lCount;
	var lElementCount;
	var lOptionCount;
	var lForm;
	var lOptions;
	var lSuccess;
	lXMLResponse = pXMLObject.responseXML;
	lRoot = lXMLResponse.documentElement;
	lSuccess = handleResult(lRoot.childNodes[0], null);
	if (lSuccess)
	{
		var lCheck=lRoot.childNodes[1].childNodes[3];
		for(lCount=0; lCount<lCheck.childNodes.length; lCount++)
		{
			fillInterest1(lCheck.childNodes[lCount],lCount);
		}
	}
}

function fillInterest1(pInterest,pCount)
{
	for ( var i=0; i<pInterest.attributes.length; i++)
	{
		if(pInterest.attributes[i].nodeName=="DISPLAY") 
		{
			var lInterest=pInterest.attributes[i].value;
			break;
		}
		if(pInterest.attributes[i].nodeName=="ID") 
		{
			var lID=pInterest.attributes[i].value;
		}
	}
	var lElement;
	var lIntDiv=document.getElementById("Interest");	
	lElement = gDOM.createNewElement("INPUT", [{name:"type", value:"checkbox"},{name:"value", value:lID},{name:"name", value:"userInterest"+pCount}]);
	if (pCount%3=='0')
	{
		var lRow = gDOM.createNewElement("TR", [{name:"id", value:"RowID"+pCount}]);
		var lTempRow=lRow;
		lIntDiv.appendChild(lRow);
		lRow.appendChild(lElement);
	}
	lIntDiv.appendChild(lElement);

	var lOption= document.createTextNode(lInterest);
	lIntDiv.appendChild(lOption);
}

/*function showProfileEdit(pXMLObject)
{
	//alert(pXMLObject.responseText);
	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]);
				}
			}
		}
		gCurrentEntityIdForEdit = "";
		if (lLists != null)
		{
			fillSelectsInForm(document.AddEdit, lLists);
		}
			//var lName=lData.childNodes[1];
			//var lInterest=lName.getAttribute("euinterest");
			//var selectedInterest=lInterest.split("-");
			//for(var c=0;c<selectedInterest.length;c++)
			//{
			//	var a=selectedInterest[c];
			//	a=a-1;
			//	var b="userInterest"+a;
			//	var lFinal=eval("document.AddEdit."+b);
			//	lFinal.checked=true;
			//}
						
			for (lCount = 0; lCount < lData.childNodes.length; lCount++)
			{
				fillForm("AddEdit", lData.childNodes[lCount]);
			}
		if (gEntityConfig.postAddEdit!= null)
		{
			eval (gPostEdit + "(pXMLObject)");
		}
	}
}*/