/******************************************************************************
 * DataManager
 ******************************************************************************/
function DataManager()
{
   this.tables = new Object();
   this.setTable = DataManager_setTable;
   this.removeTable = DataManager_removeTable;
   this.executeNamedQuery = DataManager_executeNamedQuery;
   //this.executeXPathQuery = DataManager_executeXPathQuery;

   //Named Queries
   //To get all sies with the given sitq number
   this.GET_SIE_WITH_SITQ = DataManager_GET_SIE_WITH_SITQ;
   this.GET_SIE_WITH_RELATED_SITQ_AND_SIS = DataManager_GET_SIE_WITH_RELATED_SITQ_AND_SIS;
   this.GET_SIE_MONITOR_ID = DataManager_GET_SIE_MONITOR_ID;
	 //NQ for Link portal and Diagnosis application - Check if sis exists in the manual's sis list in sis-config.xml
	 this.GET_MANUAL_SIS = DataManager_GET_MANUAL_SIS;
 
   this.GET_VEHICLE_PLATFORM_NAME = DataManager_GET_VEHICLE_PLATFORM_NAME;

   this.GET_ALL_SIE = DataManager_GET_ALL_SIE;

   this.GET_MENUITEMARRAY = DataManager_GET_MENUITEMARRAY;
   this.GET_SIE_WITH_MENUITEM = DataManager_GET_SIE_WITH_MENUITEM;
   this.GET_SIE_WITH_MENUITEM_SISNO = DataManager_GET_SIE_WITH_MENUITEM_SISNO;
   this.GET_SIE_WITH_MENUITEM_DTC = DataManager_GET_SIE_WITH_MENUITEM_DTC;
   this.GET_SIE_WITH_MENUITEM_SYMP = DataManager_GET_SIE_WITH_MENUITEM_SYMP;

   this.GET_SIE_WITH_MENUITEM_TITLE = DataManager_GET_SIE_WITH_MENUITEM_TITLE;
   this.GET_SIE_WITH_MENUITEM_SISNO_TITLE = DataManager_GET_SIE_WITH_MENUITEM_SISNO_TITLE;
   this.GET_SIE_WITH_MENUITEM_DTC_TITLE = DataManager_GET_SIE_WITH_MENUITEM_DTC_TITLE;
   this.GET_SIE_WITH_MENUITEM_SYMP_TITLE = DataManager_GET_SIE_WITH_MENUITEM_SYMP_TITLE;

   this.GET_SIE_WITH_SIS = DataManager_GET_SIE_WITH_SIS;
   this.GET_SIE_WITH_TITLE = DataManager_GET_SIE_WITH_TITLE;

   this.GET_PREV_SIE = DataManager_GET_PREV_SIE;
   this.GET_NEXT_SIE = DataManager_GET_NEXT_SIE;
   this.GET_SIE_WITH_ALPHAINDEX = DataManager_GET_SIE_WITH_ALPHAINDEX;

	 this.GET_MULTIPATH_SIE = DataManager_GET_MULTIPATH_SIE;
	 this.GET_SIE_INFO = DataManager_GET_SIE_INFO;

	 this.GET_SIE_WITH_TITLE_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_TITLE_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_SISNO_TITLE_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_SISNO_TITLE_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_DTC_TITLE_SCT_SC_CONFIG=DataManager_GET_SIE_WITH_MENUITEM_DTC_TITLE_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_SYMP_TITLE_SCT_SC_CONFIG=DataManager_GET_SIE_WITH_MENUITEM_SYMP_TITLE_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_DTC_SCT_SC_CONFIG=DataManager_GET_SIE_WITH_MENUITEM_DTC_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_SYMP_SCT_SC_CONFIG=DataManager_GET_SIE_WITH_MENUITEM_SYMP_SCT_SC_CONFIG;

	 this.GET_SIE_WITH_MENUITEM_SISNO_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_SISNO_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_DTC_SISNO_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_SYMP_SISNO_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_SCT_SC_CONFIG;
	 this.GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE_SCT_SC_CONFIG = DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE_SCT_SC_CONFIG;

 	 this.GET_SIE_WITH_MENUITEM_DTC_SISNO = DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO;
	 this.GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE = DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE;
	 this.GET_SIE_WITH_MENUITEM_SYMP_SISNO = DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO;
	 this.GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE = DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE;

	 this.GET_SIE_WITH_DTC = DataManager_GET_SIE_WITH_DTC;
	 this.GET_SIE_WITH_DTC_CONFIG = DataManager_GET_SIE_WITH_DTC_CONFIG;
	 this.GET_SIE_WITH_CONFIG_DTC = DataManager_GET_SIE_WITH_CONFIG_DTC;

	 this.GET_SIE_WITH_SIS_SIEINFOID = DataManager_GET_SIE_WITH_SIS_SIEINFOID;
	 this.GET_COMP_SIELIST = DataManager_GET_COMP_SIELIST;
	this.GET_SIE_WITH_SITQ_FOR_DM = DataManager_GET_SIE_WITH_SITQ_FOR_DM;
	this.GET_SIE_WITH_DTC_FOR_CONSULTDTC =DataManager_GET_SIE_WITH_DTC_FOR_CONSULTDTC;

	//Maintenance Change -START- for SIS button display July-27,2006
	this.GET_ALL_SIS = DataManager_GET_ALL_SIS;
	//Maintenance Change -END- for SIS button display July-27,2006

}

function DOMTable_executeXPathQuery(xpath)
{
 if (this.dom == null)
 {
   this.loadXml(this.fileName);
 }
 var condition=xpath;
 var nodeList = this.dom.documentElement.selectNodes(condition);
 if (nodeList != null && nodeList.length > 0)
 {
	 var attrs = nodeList.item(0).attributes;
	 var colNames = new Array(attrs.length);
	 for(var i=0;i<attrs.length;i++)
		{
		colNames[i] = attrs.item(i).name;
		}

	 var rows = new Array(nodeList.length);
	 for(var i=0;i<nodeList.length;i++)
	 {
			 attrs = nodeList.item(i).attributes;
	   var row = new Array(attrs.length);
	   for (var j=0;j<attrs.length;j++)
	   {
		 row[j]=attrs.item(j).text;
	   }
	   rows[i] = row;
	 }
	 return new RecordSet(colNames, rows);
 }
 else
 {
 	return new RecordSet(null, null);
 }
}

/**********************************
//PREV
**********************************/
function DataManager_GET_PREV_SIE(query)
{
	var infoid = query.params["infoid"];
	var comptype = query.params["comptype"];
	var arr = new Array();
	arr = query.params["menuitemarray"];

	var xpath="/table/row[@infoid = '" + infoid + "']";
	var rs = this.tables["SIE"].executeXPathQuery(xpath);
	var rsi = rs.iterator();
	if(rs.rowCount >0)
	{
		var rec = rsi.getNext();
		var prevsortnum = (parseInt(rec["sortno"])-1);
		if(prevsortnum != 0)
		{
			if(comptype != true)
			{
				var i =0;
				var strQuery1 = "(";
				while (i< arr.length)
				{
					/*if(i!=arr.length-1)
						strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @
serviceitem='"+arr[i]+"' or ";
					else
						strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
          */
				if(arr[i][1] == "0")
				{
					if(i!=arr.length-1)
						strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
					else
						strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
				}
				else if(arr[i][1] == "1")
				{
					if(i!=arr.length-1)
						strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
					else
						strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
				}
					i+=1;
				}
				strQuery1 = strQuery1 + ")";
				if(strQuery1 == "()")
					strQuery1 = "false";
				xpath = "/table/row[" + strQuery1 + " and ";
				
				if(rec["config"] == "")
					xpath += "number(@sortno) = '" + prevsortnum + "' and @sub_sc_id='" + rec["sub_sc_id"] + "']";
				else
					xpath += "number(@sortno) = '" + prevsortnum + "' and @config='" + rec["config"] + "']";
					
				return this.tables["SIE"].executeXPathQuery(xpath);
			}
			else
			{
				if(rec["config"] == "")
					xpath="/table/row[number(@sortno) = '" + prevsortnum + "' and @sub_sc_id='" + rec["sub_sc_id"] + "']";
				else
					xpath="/table/row[number(@sortno) = '" + prevsortnum + "' and @config='" + rec["config"] + "']";
			}
		}
		else
			xpath="/table/row[false]";
	}
	else
		xpath="/table/row[false]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/**********************************
//NEXT
**********************************/
function DataManager_GET_NEXT_SIE(query)
{
	var infoid = query.params["infoid"];
	var comptype = query.params["comptype"];
	var arr = new Array();
	arr = query.params["menuitemarray"];

	var xpath="/table/row[@infoid = '"+infoid+"']";
	var rs = this.tables["SIE"].executeXPathQuery(xpath);
	var rsi = rs.iterator();
	if(rs.rowCount >0)
	{
		var rec = rsi.getNext();
		var prevsortnum = (parseInt(rec["sortno"])+1);
		var xpath = "";
		/*if(prevsortnum != 0)
		{ */
			//var xpath="/table/row[number(@sortno) = '" + prevsortnum + "' and @config='" + rec["config"] + "']";
			if(comptype != true)
			{
				var i =0;
				var strQuery1 = "(";
				while (i< arr.length)
				{
					/*if(i!=arr.length-1)
						strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
					else
						strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
					*/
					if(arr[i][1] == "0")
					{
						if(i!=arr.length-1)
							strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
						else
							strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
					}
					else if(arr[i][1] == "1")
					{
						if(i!=arr.length-1)
							strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
						else
							strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
					}
					i+=1;
				}
				strQuery1 = strQuery1 + ")";
				if(strQuery1 == "()")
					strQuery1 = "false";
				xpath = "/table/row[" + strQuery1 + " and ";
				
				if(rec["config"] == "")
					xpath += "number(@sortno) = '" + prevsortnum + "' and @sub_sc_id='" + rec["sub_sc_id"] + "']";
				else
					xpath += "number(@sortno) = '" + prevsortnum + "' and @config='" + rec["config"] + "']";
						
				return this.tables["SIE"].executeXPathQuery(xpath);
			}
			else
			{
				if(rec["config"] == "")
					 xpath="/table/row[number(@sortno) = '" + prevsortnum + "' and @sub_sc_id='" + rec["sub_sc_id"] + "']";
				else
					 xpath="/table/row[number(@sortno) = '" + prevsortnum + "' and @config='" + rec["config"] + "']";
			}
		/*}
		else
			var xpath="/table/row[false]";
		*/
	}
	else
		var xpath="/table/row[false]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/******************************************************************************
 * Function to return all SIEs having COMP, COMP_TYPE, SIE_TITLE like title
 ******************************************************************************/
function DataManager_GET_SIE_WITH_TITLE(query)
{
	var title= query.params["title"];
	var arr = new Array();
	arr = query.params["menuitemarray"];

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";
	if(strQuery1 == "()")
		strQuery1 = "false";
	var xpath = "/table/row[" + strQuery1 + " and (contains(@searchstring,'"+title+"'))]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
// Function to get the menu item array (service item or sitq number)
function DataManager_GET_MENUITEMARRAY(query)
{
	var menuitemno = query.params["menuitemno"];
	xpath = "/table/row[@itemNo='" + menuitemno + "']";
	return this.tables["SI"].executeXPathQuery(xpath);
}

/*
* Query to fetch all the service items and sitq numbers if any for the given menu item
*/
function DataManager_GET_SIE_WITH_MENUITEM(query)
{
	var menuitem,xpath;
	var arr = new Array();
	arr = query.params["menuitemarray"];

	var i =0;
	var strQuery1 = "((";
	while (i< arr.length)
	{
    if(arr[i][1] == "0")
    {
      if(i!=arr.length-1)
        strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
      else
        strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
    }
    else if(arr[i][1] == "1")
    {
      if(i!=arr.length-1)
        strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
      else
        strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
    }
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
    */
    i+=1;
	}
	strQuery1 = strQuery1 + ")";
	if (strQuery1.indexOf("@sitqno",0) == -1)
		strQuery1 = strQuery1 + " and @first='1')";
	else
		strQuery1 = strQuery1 + ")";
	xpath = "/table/row["+strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/*
* Query to fetch all the service items and sitq numbers if any for the given menu item
and match with the configs of the supplied sis no
*/
function DataManager_GET_SIE_WITH_MENUITEM_SISNO(query)
{
	var menuitem, xpath;
	var sisno = query.params["sisno"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";

	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array();
	var strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var arr = new Array();
	arr = query.params["menuitemarray"];

	i =0;
	var strQuery1 = "((";
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";
	if (strQuery1.indexOf("@sitqno",0) == -1)
		strQuery1 = strQuery1 + " and @first='1')";
	else
		strQuery1 = strQuery1 + ")";
	if(strQuery1 =="()")
		strQuery1 = false;
	if(strQuery == "()")
		strQuery = false;
	xpath = "/table/row["+strQuery + " and " +  strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

//************************************************************************************************
// Function to return all SIEs having either of DTC ID and either of SITQ Number or service item
//************************************************************************************************
function DataManager_GET_SIE_WITH_MENUITEM_DTC(query)
{
	var menuitem,xpath, strQuery = "(", strQuery1 = "(", i=0;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
			
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	var dtcidArray = query.params["dtcid"];
	i =0;
	while (i< dtcidArray.length)
	{
		if(i!=dtcidArray.length-1)
			strQuery = strQuery + "contains(@dtcid,'"+dtcidArray[i]+"') or "
		else
			strQuery = strQuery + "contains(@dtcid,'"+dtcidArray[i]+"')"
		i+=1;
	}
	strQuery = strQuery + ")";
	if(strQuery == "()")
		strQuery = "false";
	if(strQuery1 == "()")
		strQuery1 = "false";
	var xpath = "/table/row["+ strQuery1 +" and "+strQuery +" ]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

//************************************************************************************************
// Function to return all SIEs having either of DTC ID and either of SITQ Number or service item
//************************************************************************************************
function DataManager_GET_SIE_WITH_MENUITEM_SYMP(query)
{
	var menuitem,xpath, strQuery = "(", strQuery1 = "(", i=0;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	var sympid = query.params["sympid"];
	//strQuery = "(@sympid='"+sympid+"')";
	strQuery = " contains(@sympid,'"+sympid+"')";
	if(strQuery1 != "()")
		strQuery = strQuery + " and " + strQuery1;
	xpath = "/table/row[" + strQuery + " ]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/******************************************************************************
 * Function to return All SIEs having the specified sitq no
 ******************************************************************************/
 function DataManager_GET_SIE_WITH_SITQ(query)
{
	var sieinfoid = query.params["sieinfoid"];
	var rs1 = this.tables["SIE"].executeQuery("infoid", "=", sieinfoid);
	if(rs1.rowCount > 0)
	{
		var rsi = rs1.iterator();
		var rec = rsi.getNext();
		var sitqno = rec["sitqno"];
		//sitqno = "1012";
		var rs, xpath1 = "";
		xpath1 = "/table/row[@sitqno='" + sitqno + "' and @infoid='" + sieinfoid + "']";
		rs1 = this.tables["SIE"].executeXPathQuery(xpath1);

		var rsi1 = rs1.iterator();
		var rec1 = rsi1.getNext();
		var sct,sc,config,compdesc;
		sct = rec1["sct_id"];
		sc = rec1["sc_id"];
		config = rec1["config"];
		compid = rec1["compid"];

		var flag = "0";
		var xpath = "/table/row[@from_sitq='" + sitqno + "']";
		rs = this.tables["SITQ"].executeXPathQuery(xpath);
		xpath = "";
		if(rs.rowCount > 0)
		{
			var sql = "";
			var rsi = rs.iterator();
			xpath1 = "(@sct_id='"+sct+"' and @sc_id='"+sc+"' and @config='"+config+"' and @compid='"+compid+"' and (";
			while(rsi.hasNext())
			{
				var rec = rsi.getNext();
				flag = rec["search_range_flag"];

				if(flag=="1")
				{
					xpath1 = xpath1 + "@sitqno = '" + rec["to_sitq"] + "' or "
				}
			}
			xpath1 = xpath1 + "false))"; 

			xpath2 = "(@sct_id='"+sct+"' and @sc_id='"+sc+"' and @config='"+config+"' and (";
			var rsi = rs.iterator();
			while(rsi.hasNext())
			{
				var rec = rsi.getNext();
				flag = rec["search_range_flag"];

				if(flag=="2"){
					
					xpath2 = xpath2 + "@sitqno = '" + rec["to_sitq"] + "' or "
				}
			}
			xpath2 =  xpath2 + "false))";

			sql = xpath1 + " or " + xpath2;

			xpath = "/table/row["+ sql +"]";
		}
		else
		{
			xpath = "/table/row[false]";
		}

	}
	else
	{
		xpath = "/table/row[false]";
	}
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/******************************************************************************
 * Function to return all SIEs for given CUID
 ******************************************************************************/

function DataManager_GET_SIE_MONITOR_ID(query)
{
  var cuid = query.params["cuid"];
  return this.tables["SIE"].executeXPathQuery("/table/row[@cuid='"+ cuid +"']");
}

/******************************************************************************
 * Function to return all rows for given sisnumber if available in the selected manual
 ******************************************************************************/

function DataManager_GET_MANUAL_SIS(query)
{
  var sisno = query.params["sisno"];
  return this.tables["SISCONFIG"].executeXPathQuery("/table/row[@sisno='"+ sisno +"']");
}

/******************************************************************************
 * Function to return all SIEs associated with given SITQ or SIS
 ******************************************************************************/
function DataManager_GET_SIE_WITH_RELATED_SITQ_AND_SIS(query)
{
	var sisno = query.params["sisno"];
	var sitqno = query.params["sitqno"];
	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";
	// Null pointer check to see if there are configs under the given sis or there is no record found for the given sis in the manual.
	if(strQuery =="()")
		strQuery = "false";
	return this.tables["SIE"].executeXPathQuery("/table/row[@sitqno='"+sitqno+"' and "+strQuery+"]");
}

/******************************************************************************
 * Function to return all SIES
 ******************************************************************************/
function DataManager_GET_ALL_SIE()
{
	var xpath = "/table/row";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//Maintenance Change -START- for SIS button display July-27,2006
/******************************************************************************
 * Function to return all SIS
 ******************************************************************************/
function DataManager_GET_ALL_SIS()
{
	var xpath = "/table/row[1]";
	return this.tables["SISCONFIG"].executeXPathQuery(xpath);
}
//Maintenance Change -END- for SIS button display July-27,2006

/******************************************************************************
 * Function to Return all SIEs associated with the given SISNO
 ******************************************************************************/

function DataManager_GET_SIE_WITH_SIS(query)
{
	var sisno = query.params["sisno"];
	var rs_sisno = this.tables["SISCONFIG"].executeXPathQuery("/table/row[@sisno='"+ sisno +"']");
	//var rs= new DOMElement. DOMTable;
	var strQuery ="";
	var strArray = new Array();

var rssis_i = rs_sisno.iterator();
while (rssis_i.hasNext())
  {
	var rssis_gn = rssis_i.getNext();
	//Split into Array
	  strArray=rssis_gn["config"].split(",")
}

//Making a query from the value array
	  var part_num;
	  part_num=0;
	  while (part_num< strArray.length)
	 {
			if(part_num!=strArray.length-1)
				strQuery = strQuery + "@config='"+strArray[part_num]+"' or "
			else
				strQuery = strQuery + "@config='"+strArray[part_num]+"'"

			part_num+=1;
	}
	if(strQuery == "")
		strQuery = false;
	//Return Table of Allsie records
return this.tables["SIE"].executeXPathQuery("/table/row["+strQuery+"]");
}

/******************************************************************************
 * Function to Return platform name of the SIEID
 ******************************************************************************/

function DataManager_GET_VEHICLE_PLATFORM_NAME(query)
{
  var sieid = query.params["sieid"];
  return this.tables["SIE"].executeQuery("sieid", "=", sieid);
}

function DataManager_setTable(tableName, fileName)
{
 var locator = new String(fileName);
 if (locator.indexOf(".xml") != -1)
 {
   this.tables[tableName] = new DOMTable(tableName, fileName);
 }
}

function DataManager_removeTable(tableName)
{
 this.tables[tableName] = null;
}

function DataManager_executeNamedQuery(query)
{
  return eval("this." + query.queryName + "(query)");
}

/******************************************************************************
 * Class DOMTable
 ******************************************************************************/
function DOMTable(name, fileName)
{
   this.name = name;
   this.fileName = fileName;
   this.dom = null;

   this.loadXml = DOMTable_loadXml;
   this.executeQuery =  DOMTable_executeQuery;
   this.executeXPathQuery = DOMTable_executeXPathQuery;
}

function DOMTable_loadXml()
{
	//Modified for XML version check.
  this.dom = createDOMDocument();
  this.dom.setProperty("SelectionLanguage","XPath");
  this.dom.async = false;
  this.dom.load(this.fileName);
}

function DOMTable_executeQuery(fieldName, operator, value)
{
 if (this.dom == null)
 {
   this.loadXml(this.fileName);
 }

 var condition="/table/row[@" + fieldName + operator + "'" + value + "']";
 var nodeList = this.dom.documentElement.selectNodes(condition);

 if (nodeList != null && nodeList.length > 0)
 {
 var attrs = nodeList.item(0).attributes;
 var colNames = new Array(attrs.length);
 for(var i=0;i<attrs.length;i++)
	{
    colNames[i] = attrs.item(i).name;
	}

 var rows = new Array(nodeList.length);
 for(var i=0;i<nodeList.length;i++)
 {
   attrs = nodeList.item(i).attributes;
   var row = new Array(attrs.length);
   for (var j=0;j<attrs.length;j++)
   {
     row[j]=attrs.item(j).text;
   }
   rows[i] = row;
 }
 return new RecordSet(colNames, rows);
 }
 else
 {
   return new RecordSet(null, null);
 }
}
/******************************************************************************
 * Class RecordSet
 ******************************************************************************/
function RecordSet(colNames, rows)
{
  if (rows != null)
  {
  this.rowCount = rows.length;
  }
  else
  {
  this.rowCount = 0;
  }
  this.records = rows;
  this.colNames = colNames;
  this.getRecord = RecordSet_getRecord;
  this.iterator = RecordSet_iterator;
}

function RecordSet_iterator(index)
{
  return new RecordSetIterator(this);
}

function RecordSet_getRecord(index)
{
  var row = this.records[index];
  var rec = new Object();
  for (var i=0;i<row.length;i++)
  {
    rec[this.colNames[i]] = row[i];
  }
  return rec;
}

/******************************************************************************
 * Class RecordSetIterator
 ******************************************************************************/
function RecordSetIterator(recordSet)
{
  this.recordSet = recordSet;
  this.curIndex = 0;
  this.hasNext = RecordSetIterator_hasNext;
  this.getNext = RecordSetIterator_getNext;
}

function RecordSetIterator_hasNext()
{
  return this.curIndex < this.recordSet.rowCount;
}

function RecordSetIterator_getNext()
{
  return this.recordSet.getRecord(this.curIndex++)
}
/*
* Query to fetch all the service items, Title  and sitq numbers if any for the given menu item
*/

function DataManager_GET_SIE_WITH_MENUITEM_TITLE(query)
{
	var menuitem,xpath;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	title = query.params["title"];
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";
	xpath = "/table/row[(contains(@searchstring,'"+title+"')) and "+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/*
* Query to fetch all the service items, Title  and sitq numbers if any for the given menu item
and match with the configs of the supplied sis no
*/
function DataManager_GET_SIE_WITH_MENUITEM_SISNO_TITLE(query)
{
	var menuitem, xpath;
	var sisno = query.params["sisno"];
	title = query.params["title"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";

	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array();
	var strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var arr = new Array();
	arr = query.params["menuitemarray"];

	i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
	
		i+=1;
	}
	strQuery1 = strQuery1 + ")";
	if(strQuery == "()")
		strQuery = false;
	xpath = "/table/row[(contains(@searchstring,'"+title+"')) and "+ strQuery + " and " + strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//************************************************************************************************
// Function to return all SIEs having either of DTC ID, Title  and either of SITQ Number or service item
//************************************************************************************************
function DataManager_GET_SIE_WITH_MENUITEM_DTC_TITLE(query)
{
	var menuitem,xpath, strQuery = "(", strQuery1 = "(", i=0;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	title = query.params["title"];

	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
			
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	var dtcidArray = query.params["dtcid"];
	i =0;

	if(dtcidArray[0]=="")
		var dtccodecheck = " contains(@dtcid,'" + dtcidArray[1] + "')";
	else if(dtcidArray[1]=="")
		var dtccodecheck = " contains(@dtcid,'" + dtcidArray[0] + "')";
	else
		var dtccodecheck = " contains(@dtcid,'" + dtcidArray[1] + "') or contains(@dtcid,'" + dtcidArray[0] + "')";
	strQuery = strQuery + dtccodecheck;

	strQuery = strQuery + ")";
	if(strQuery == "()")
		strQuery = "false";
	if(strQuery1 == "()")
		strQuery1 = "false";
	var xpath = "/table/row[(contains(@searchstring,'"+title+"')) and "+ strQuery1 +" and "+strQuery +" ]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

//************************************************************************************************
// Function to return all SIEs having either of DTC ID, Title and either of SITQ Number or service item
//************************************************************************************************
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_TITLE(query)
{
	var menuitem,xpath, strQuery = "(", strQuery1 = "(", i=0;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	title = query.params["title"];
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
			if(arr[i][1] == "0")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
			}
			else if(arr[i][1] == "1")
			{
				if(i!=arr.length-1)
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
				else
					strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
			}
	
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	var sympid = query.params["sympid"];
	//strQuery = "(@sympid='"+sympid+"')";
	strQuery = " contains(@sympid,'"+sympid+"')";
	if(strQuery1 == "()")
		strQuery1 = "false";
	xpath = "/table/row[(contains(@searchstring,'"+title+"')) and "+ strQuery1 +" and "+strQuery +" ]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//For the alphabetical index sub menu - Query to search within the record set specific for alpha sub page.
function DataManager_GET_SIE_WITH_ALPHAINDEX(query)
{
	var menuitem,xpath;
	var stitle = query.params["title"]
	var arr = new Array();
	arr = query.params["menuitemarray"];
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
	
		i+=1;
	}
	strQuery1 = strQuery1 + ")"
	xpath = "/table/row[(contains(@searchstring,'"+stitle+ "') and "+strQuery1+")]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//to get multiple paths through which the sie can be reached
function DataManager_GET_MULTIPATH_SIE(query)
{
	var sieinfoid = query.params["sieid"];
	var sieid = query.params["id"];
	var sis = query.params["sis"];
	var strConfigQuery ;

	if(sis!="" && sis!=null){
		strConfigQuery = "[";
		var configSearch = "/table/row[@sisno='"+sis+"']";
		var rsConfig = this.tables["SISCONFIG"].executeXPathQuery(configSearch);
		var irConfig =  rsConfig.iterator();
		while(irConfig.hasNext()){
		var strConfig = irConfig.getNext();
		var configNo = strConfig["config"].split(",");
			
		  for(var i=0;i<configNo.length;i++){
			  if(i!=configNo.length-1){
				strConfigQuery +="@config='"+configNo[i]+"' or ";
			  }
			  else{
				  strConfigQuery +="@config='"+configNo[i]+"'";
			  }
		  }
		  strConfigQuery +="]";
		  
		}
	}
	var xpath = "/table/row[@infoid='" + sieinfoid + "']";
	var xp = "/table/row[@infoid='" + sieinfoid + "']";
	var rsxp = this.tables["SIE"].executeXPathQuery(xp);
	var sub_sc_id,comptype_id,compid,config,sc_id,sct_id,sie,result; 
	var irsxp =  rsxp.iterator();
	var  searchflag= true ;
	while(irsxp.hasNext()){
		var strQ = irsxp.getNext();
		   sub_sc_id = strQ["sub_sc_id"];
		   comptype_id = strQ["comptype_id"];
		   compid = strQ["compid"];
		   config = strQ["config"];
		   sc_id = strQ["sc_id"];
		   sct_id = strQ["sct_id"];
		  }

	if(searchflag){
	var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@config='"+config+"'][@sub_sc_id='"+sub_sc_id+"'][@compid='"+compid+"'][@comptype_id='"+comptype_id+"'][@sieid='"+sieid+"']";
	if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	 }
	}
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@config='"+config+"'][@sub_sc_id='"+sub_sc_id+"'][@compid='"+compid+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@config='"+config+"'][@sub_sc_id='"+sub_sc_id+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@config='"+config+"'][@sub_sc_id='"+sub_sc_id+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@config='"+config+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sc_id='"+sc_id+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	var resc = re.iterator();
		if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	if(searchflag){
		var xpath1= "/table/row[@sct_id='"+sct_id+"'][@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	if(searchflag){
		var xpath1= "/table/row[@sieid='"+sieid+"']";
		if(sis!="" && sis!=null){
		xpath1 +=strConfigQuery;
	}
	var re = this.tables["SIE"].executeXPathQuery(xpath1);
	if(re.rowCount>0){
		searchflag= false;
		result = re;
	}
	}
	
	return result;
}
/*
* Query to fetch all the service items, Title  and sitq numbers if any for the given menu item
*/

function DataManager_GET_SIE_WITH_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	title = query.params["title"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
	
		i+=1;
	}
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'";
	xpath = "/table/row[(contains(@searchstring,'"+title+"')) and "+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/*
* Query to fetch only the config related SIEs in the SIE list.
*/
function DataManager_GET_SIE_WITH_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
    */
    if(arr[i][1] == "0")
    {
      if(i!=arr.length-1)
        strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
      else
        strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
    }
    else if(arr[i][1] == "1")
    {
      if(i!=arr.length-1)
        strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
      else
        strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
    }
		i+=1;
	}
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'";
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
/*
* Query to get all the data matching the sct,sc,config, menuitem and sisnumber
*/
function DataManager_GET_SIE_WITH_MENUITEM_SISNO_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,title,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	sisno = query.params["sisno"];
	title = query.params["title"];

	xpath = "/table/row[@sisno = '"+sisno+"']";

		var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
		var irs = rs.iterator();
		var strArray = new Array();
		var strQuery = "";
		while(irs.hasNext())
		{
			var strConfig = irs.getNext();
			strArray=strConfig["config"].split(",")
		}

		var i=0;
		strQuery = "(";
		while (i< strArray.length)
		{
			if(i!=strArray.length-1)
				strQuery = strQuery + "@config='"+strArray[i]+"' or "
			else
				strQuery = strQuery + "@config='"+strArray[i]+"'"
			i+=1;
		}
		strQuery = strQuery + ")";
	if(strQuery == "()")
		strQuery = false;
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	var titlecheck = " and contains(@searchstring,'" + title + "')";
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"' and " + strQuery + titlecheck;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"' and " + strQuery + titlecheck;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/*
* Query to fetch only the DTC_ID related SIEs in the SIE list.
*/
function DataManager_GET_SIE_WITH_MENUITEM_DTC_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,title,dtccode1,dtccode2,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	title = query.params["title"];
	dtccode1 = query.params["dtc1"] ;
	dtccode2 = query.params["dtc2"];

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	var titlecheck = " and contains(@searchstring,'" + title + "')";
	if(dtccode2=="")
		//var dtccodecheck = " and @dtcid='" + dtccode1 + "'";
		var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		//var dtccodecheck = " and @dtcid='" + dtccode2 + "'";
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		//var dtccodecheck = " and (@dtcid='" + dtccode1 + "' or @dtcid='" + dtccode2 + "')";
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";

	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'"  + titlecheck + dtccodecheck;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + titlecheck + dtccodecheck;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/*
* Query to fetch only the DTC_ID related SIEs in the SIE list without string search.
*/
function DataManager_GET_SIE_WITH_MENUITEM_DTC_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,dtccode1,dtccode2,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	dtccode1 = query.params["dtc1"] ;
	dtccode2 = query.params["dtc2"];

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	if(dtccode2=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + dtccodecheck;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + dtccodecheck;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/*
* Query to fetch only the sympid related SIEs in the SIE list.
*/
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,title,sympid,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	title = query.params["title"];
	sympid = query.params["sympid"] ;


	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	var titlecheck = " and contains(@searchstring,'" + title + "')";
	//var sympid = " and (@sympid = '" + sympid + "')";
	var sympid = " and contains(@sympid,'"+sympid+"')";
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + titlecheck + sympid;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + titlecheck + sympid;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

/*
* Query to fetch only the sympid related SIEs in the SIE list without string search.
*/
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sympid,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	configid = query.params["config"];
	sympid = query.params["sympid"] ;


	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}

	//var sympid = " and (@sympid = '" + sympid + "')";
	var sympid = " and contains(@sympid,'"+sympid+"')";
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + sympid;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + sympid;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//To get all sie related information
function DataManager_GET_SIE_INFO(query)
{
	var sieinfoid = query.params["sieinfoid"];
	var xpath = "/table/row[@infoid='" + sieinfoid + "']";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

function DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,dtccode1,dtccode2,strTemp,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	sisno = query.params["sisno"];
	dtccode1 = query.params["dtc1"] ;
	dtccode2 = query.params["dtc2"];


	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}

	if(dtccode2=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";

	strQuery1 = strQuery1 + ")" ;

	if(strQuery != "()")
	{
	 strQuery1 = strQuery1 + " and " + strQuery;
	}
	strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + dtccodecheck;
//	strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + dtccodecheck;

	strQuery1 = strQuery1 + strTemp;

	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//fucntion to get sie with dtc,sisno,title & contents tree
function DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,title,dtccode1,dtccode2,sisno,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	title = query.params["title"];
	dtccode1 = query.params["dtc1"] ;
	dtccode2 = query.params["dtc2"];
	sisno = query.params["sisno"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	var titlecheck = " and contains(@searchstring,'" + title + "')";

	if(dtccode2=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";

	strQuery1 = strQuery1 + ")" ;

	if(strQuery != "()")
	{
	 strQuery1 = strQuery1 + " and " + strQuery;
	}

	var	strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid  + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + titlecheck + dtccodecheck;
	//var	strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + titlecheck + dtccodecheck;

	strQuery1 = strQuery1 + strTemp;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,sympid,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	sisno = query.params["sisno"];
	sympid = query.params["sympid"] ;

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	//var sympid = " and (@sympid = '" + sympid + "')";
  var sympid = " and contains(@sympid,'"+sympid+"')";

	if(strQuery != "()")
	{
		strQuery1 = strQuery1 + " and " + strQuery;
	}
	var strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + sympid;
	//var strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + sympid;

	strQuery1 = strQuery1 + strTemp;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,sympid,title,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	sisno = query.params["sisno"];
	sympid = query.params["sympid"] ;
	title = query.params["title"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	//var sympid = " and (@sympid = '" + sympid + "')";
	var sympid = " and contains(@sympid,'"+sympid+"')";
	var titlecheck = " and contains(@searchstring,'" + title + "')";

	if(strQuery != "()")
	{
		strQuery1 = strQuery1 + " and " + strQuery;
	}
	var strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"'" + titlecheck + sympid;
	//var strTemp = " and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"'" + titlecheck + sympid;

	strQuery1 = strQuery1 + strTemp;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_SISNO_SCT_SC_CONFIG(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,subscid,siid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sctid = query.params["sct"];
	scid = query.params["sc"];
	configid = query.params["config"];
	subscid= query.params["subsc"];
	siid= query.params["si"];
	sisno = query.params["sisno"];

	xpath = "/table/row[@sisno = '"+sisno+"']";

		var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
		var irs = rs.iterator();
		var strArray = new Array();
		var strQuery = "";
		while(irs.hasNext())
		{
			var strConfig = irs.getNext();
			strArray=strConfig["config"].split(",")
		}

		var i=0;
		strQuery = "(";
		while (i< strArray.length)
		{
			if(i!=strArray.length-1)
				strQuery = strQuery + "@config='"+strArray[i]+"' or "
			else
				strQuery = strQuery + "@config='"+strArray[i]+"'"
			i+=1;
		}
		strQuery = strQuery + ")";
	if(strQuery == "()")
		strQuery = false;
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid  + "' and @sub_sc_id='"+ subscid +"' and @serviceitem='"+ siid +"' and " + strQuery ;
	//strQuery1 = strQuery1 + ") and @sct_id='" + sctid + "' and @sc_id='" + scid +"' and @config='"+ configid +"' and " + strQuery ;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

function DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO(query)
{
	var menuitem,xpath,sisno,dtccode1,strTemp;
	var dtccode2 = "";
	var arr = new Array();
	var dtcid = new Array();
	arr = query.params["menuitemarray"];
	sisno = query.params["sisno"];
	dtcid = query.params["dtcid"];
	if(dtcid.length==2)
	{
		dtccode1 = dtcid[0];
		dtccode2 = dtcid[1];
	}
	else if(dtcid.length==1)
	{
		dtccode1 = dtcid[0];
	}


	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";
	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}

	if(dtccode2=="")
			var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";

	strQuery1 = strQuery1 + ")" ;

	if(strQuery != "()")
	{
	 strQuery1 = strQuery1 + " and " + strQuery;
	}

	strQuery1 = strQuery1 + dtccodecheck;

	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_DTC_SISNO_TITLE(query)
{
	var menuitem,xpath,title,dtccode1,dtccode2,sisno;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	title = query.params["title"];
	var dtcid = query.params["dtcid"] ;
	if(dtcid.length > 1)
	{
		dtccode1 = dtcid[0];
		dtccode2 = dtcid[1];
	}
	else
	{
		dtccode1 = dtcid[0];
		dtccode2 = "";
	}
	sisno = query.params["sisno"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	var titlecheck = " and contains(@searchstring,'" + title + "')";

	if(dtccode2=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode1 + "')";
	else if(dtccode1=="")
		var dtccodecheck = " and contains(@dtcid,'" + dtccode2 + "')";
	else
		var dtccodecheck = " and (contains(@dtcid,'" + dtccode1 + "') or contains(@dtcid,'" + dtccode2 + "'))";

	strQuery1 = strQuery1 + ")" ;

	if(strQuery != "()")
	{
	 strQuery1 = strQuery1 + " and " + strQuery;
	}

	strQuery1 = strQuery1 + titlecheck + dtccodecheck;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,sympid;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sisno = query.params["sisno"];
	sympid = query.params["sympid"] ;

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}
		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	//var sympid = " and (@sympid = '" + sympid + "')";
  var sympid = " and contains(@sympid,'"+sympid+"')";

	if(strQuery != "()")
	{
		strQuery1 = strQuery1 + " and " + strQuery;
	}

	strQuery1 = strQuery1 + sympid;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_MENUITEM_SYMP_SISNO_TITLE(query)
{
	var menuitem,xpath,sctid,scid,configid,sisno,sympid,title;
	var arr = new Array();
	arr = query.params["menuitemarray"];
	sisno = query.params["sisno"];
	sympid = query.params["sympid"] ;
	title = query.params["title"];

	var xpath = "/table/row[@sisno = '"+sisno+"']";
	var rs = this.tables["SISCONFIG"].executeXPathQuery(xpath);
	var irs = rs.iterator();
	var strArray = new Array(),strQuery = "";
	while(irs.hasNext())
	{
		var strConfig = irs.getNext();
		strArray=strConfig["config"].split(",")
	}

	var i=0;
	var strQuery = "(";
	while (i< strArray.length)
	{
		if(i!=strArray.length-1)
			strQuery = strQuery + "@config='"+strArray[i]+"' or "
		else
			strQuery = strQuery + "@config='"+strArray[i]+"'"
		i+=1;
	}
	strQuery = strQuery + ")";

	var i =0;
	var strQuery1 = "(";
	while (i< arr.length)
	{
		/*
		if(i!=arr.length-1)
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"' or ";
		else
			strQuery1 = strQuery1 + "@sitqno='"+arr[i]+"' or @serviceitem='"+arr[i]+"'";
		*/
		if(arr[i][1] == "0")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@serviceitem='" + arr[i][0] + "'";
		}
		else if(arr[i][1] == "1")
		{
			if(i!=arr.length-1)
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "' or ";
			else
				strQuery1 = strQuery1 + "@sitqno='" + arr[i][0] + "'";
		}

		i+=1;
	}
	strQuery1 = strQuery1 + ")";

	//var sympid = " and (@sympid = '" + sympid + "')";
	var sympid = " and contains(@sympid,'"+sympid+"')";
	var titlecheck = " and contains(@searchstring,'" + title + "')";

	if(strQuery != "()")
	{
		strQuery1 = strQuery1 + " and " + strQuery;
	}

	strQuery1 = strQuery1 + titlecheck + sympid;
	xpath = "/table/row["+ strQuery1+"]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
//function to get sie list of the given dtc for special sie list page
function DataManager_GET_SIE_WITH_DTC(query)
{
	var dtcid = query.params["dtcid"];
	var xpath = "/table/row[contains(@dtcid,'" + dtcid + "')]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_DTC_CONFIG(query)
{
	var dtcid = query.params["dtcid"];
	var config = query.params["config"];
	var xpath = "/table/row[contains(@dtcid,'" + dtcid + "') and @config='"+config+"']";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

function DataManager_GET_SIE_WITH_CONFIG_DTC(query)
{
	//var dtcid = query.params["dtcid"];
	var arr = new Array();
	var canarr = new Array();
	var i = 0;

	canarr = query.params["config"];
	arr = query.params["dtcarray"];

	var xpath="/table/row[(@config='";
	while(i<canarr.length-1)
	{
		xpath +=canarr[i]+"' or @config='";
		i++;
	}
	xpath += canarr[canarr.length-1]+"') and (contains(@dtcid,',";
	i=0;
	while(i<arr.length-1)
	{
		xpath +=arr[i]+",') or contains(@dtcid,',";
		i++;
	}
	xpath +=arr[arr.length-1]+",'))]";
	return this.tables["SIE"].executeXPathQuery(xpath);
}
function DataManager_GET_SIE_WITH_SIS_SIEINFOID(query)
{
	var sisno = query.params["sisno"];
	var sieinfoid = query.params["sieinfoid"];
	var rs_sisno = this.tables["SISCONFIG"].executeXPathQuery("/table/row[@sisno='"+ sisno +"']");
	//var rs= new DOMElement. DOMTable;
	var strQuery ="";
	var strArray = new Array();

	var rssis_i = rs_sisno.iterator();
	while (rssis_i.hasNext())
		{
		var rssis_gn = rssis_i.getNext();
		//Split into Array
			strArray=rssis_gn["config"].split(",")
	}

		//Making a query from the value array
	  var part_num;
	  part_num=0;
	  while (part_num< strArray.length)
	 {
			if(part_num!=strArray.length-1)
				strQuery = strQuery + "@config='"+strArray[part_num]+"' or "
			else
				strQuery = strQuery + "@config='"+strArray[part_num]+"'"

			part_num+=1;
	}
	if(strQuery == "")
		strQuery = "false";
	//Return Table of Allsie records
return this.tables["SIE"].executeXPathQuery("/table/row[("+strQuery+") and @infoid='" + sieinfoid + "']");
}
//To get all sie related information
function DataManager_GET_COMP_SIELIST(query)
{
	/*
	var sortno = query.params["sortno"];
	sortno = sortno +1;
	*/
	//var subscid = query.params["sub_sc_id"];
	var scid = query.params["sc_id"];
	var configid = query.params["configid"];	
	/*	
	var sieinfoid = query.params["sieinfoid"];
	var xpath="/table/row[@config='" + configid + "']";	
	*/
	if(configid != "")
		var xpath="/table/row[@config='" + configid + "']";
	else
		//var xpath="/table/row[@sub_sc_id='" + subscid + "']";
		var xpath="/table/row[@sc_id='" + scid + "']";
	return this.tables["SIE"].executeXPathQuery(xpath);
}

function DataManager_GET_SIE_WITH_SITQ_FOR_DM(query)
{
var sitqno = query.params["sitqno"];
var xpath = "/table/row[@sitqno='"+sitqno+"']";
return this.tables["SIE"].executeXPathQuery(xpath);
}

function DataManager_GET_SIE_WITH_DTC_FOR_CONSULTDTC(query)
{
var dtc = query.params["dtcid"];
var dtcArr = dtc.split(" ");
var strDtc = "";
for(var i=0;i<dtcArr.length;i++){
	if(i!=dtcArr.length-1){
		strDtc +="contains(@dtcid,',"+dtcArr[i]+",') or ";
	}
	else{
		strDtc +="contains(@dtcid,',"+dtcArr[i] +",')"
	}
}
var xpath = "/table/row["+strDtc+"]";
return this.tables["SIE"].executeXPathQuery(xpath);
}
