function populateSelect(filename, selectName, optionValue, optionText, selectedValue){
	var selectObject = eval('formx.' + selectName)
	selectObject.length=0
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement
	// Getting the nodes

	nodesValue=Root.getElementsByTagName("Record")

	
	selectOption = document.createElement("<OPTION>");
	selectOption.text = "Select"
	selectOption.value = ""
	var selectObject = eval('formx.' + selectName)
	selectObject.add(selectOption);
	
	x = selectedValue.indexOf("^")
	if(x == -1)
	{
		selval = selectedValue
	}
	if(x != -1)
	{
		selval = selectedValue.substr(0,selectedValue.indexOf("^"))
	}
//alert(selval);
	for(i=0;i<nodesValue.length ; i++){
		Node = nodesValue.item(i);

		selectValue = Node.getAttribute("country_id") + '^' + Node.getAttribute("country");
		selectText = Node.getAttribute("country");
		selectOption = document.createElement("<OPTION>");
		selectOption.text = selectText
		selectOption.value = selectValue
		selectObject.add(selectOption);
		//alert(selectValue + "=" + selectedValue);
		
		if(Node.getAttribute("country") == selval)
			{
				//alert(Node.getAttribute("country") + "==" +  selval)
				selectOption.selected=true
			}
		else
			{
				//selectObject.value=selectedValue
			}
	}
	
               	
}

function filterSelect(filename, selectName, optionValue, optionText, selectedValue,filtername,filtervalue,Otherfiltername){	

//alert(filename + "," + selectName + "," + optionValue + "," + optionText + "," + selectedValue +"," + filtername + "," + filtervalue + "," + Otherfiltername);

	var selectObject = eval('formx.' + selectName)	
	selectObject.length=0
	
	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
        	
	selectOption = document.createElement("<OPTION>");
	selectOption.text = "Select"
	selectOption.value = ""
	selectObject.add(selectOption);
	selectOption = document.createElement("<OPTION>");
	selectOption.text = "None/Other"
	selectOption.value = ""
	selectObject.add(selectOption);

	p=filtervalue.substr(0,filtervalue.indexOf("^"))
	
	if(selectedValue != "")
	{
		x = selectedValue.indexOf("^")
		if(x == -1)
			{
				selval = selectedValue
			}
		if(x != -1)
			{
				selval = selectedValue.substr(0,selectedValue.indexOf("^"))
			}
	}

		nodesValue = xmlDoc.documentElement.selectNodes("Record[@"+  filtername +"='"+ p +"']")
		//str = "<select name='ar_City_ID' class='site_dropdown' onchange='change_zipcode(this.value)' ><option value=''>None"
		for (var i = 0; i<nodesValue.length; i++)
		{		
			Node = nodesValue.item(i);
			selectValue = Node.getAttribute(optionValue) + '^' + Node.getAttribute(optionText);
			selectText = Node.getAttribute(optionText);
		   	selectOption = document.createElement("<OPTION>");
			selectOption.text = selectText;
			selectOption.value = selectValue;
			selectObject.add(selectOption);		
			//alert(Node.getAttribute(optionText) + "=" + selval);
			if(Node.getAttribute(optionText) == selval)
				{
					selectOption.selected=true
				}
			else
				{
					//selectObject.value=selectedValue
					//selectObject.selectedIndex =0;
				}
		}

	//selectObject.value=selectedValue
	//selectObject.selectedIndex =0;
}


function MM_filterSelect2(filename, selectName, optionValue, optionText, selectedValue,filtername,filtervalue,Otherfiltername){

//alert(filename + "," + selectName + "," + optionValue + "," + optionText + "," + selectedValue +"," + filtername + "," + filtervalue + "," + Otherfiltername);

	var selectObject = eval('formx.' + selectName)	
	selectObject.length=0

	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	
	if (filtername=="ar_State_ID" && filtervalue=="0")
	{	
		filtervalue=eval('formx.'+Otherfiltername).value;
		//alert(filtervalue);
		//nodesFilter=Root.getElementsByTagName('ar_Country_Code')
		filtername="ar_Country_Code"
		//alert(filename);
		nodesValue = xmlDoc.documentElement.selectNodes("Record["+  filtername +"='"+ filtervalue +"']")
	}
	else
	{
		//nodesFilter=Root.getElementsByTagName(filtername)
		nodesValue = xmlDoc.documentElement.selectNodes("Record["+  filtername +"='"+ filtervalue +"']")
	}
	
	
	//alert("Record['"+  filtername +"'='"+ filtervalue +"']");
	
	selectOption = document.createElement("<OPTION>");
	selectOption.text = "None"
	selectOption.value = ""
	selectObject.add(selectOption);
	
	if(optionValue=="ar_State_ID")
	{	
		selectOption = document.createElement("<OPTION>");
		selectOption.text = "All";
		selectOption.value = "0";
		selectObject.add(selectOption);
		if (selectedValue=="0")
		{			
			selectOption.selected=true
		}
	}
	
	
	for (var item = nodesValue.nextNode(); item; item = nodesValue.nextNode())
		{
	
			//selectValue=nodesValue.item(i).firstChild.nodeValue
			//selectText=nodesText.item(i).firstChild.nodeValue
			selectValue=item.selectSingleNode(optionValue).nodeTypedValue
			selectText=item.selectSingleNode(optionText).nodeTypedValue
			//selectFilter=nodesFilter.item(i).firstChild.nodeValue
			//if (selectFilter==filtervalue)
			//{			
				selectOption = document.createElement("<OPTION>");
				selectOption.text = selectText
				selectOption.value = selectValue
				selectObject.add(selectOption);
				/*if(selectValue == selectedValue)
				{				
					selectOption.selected=true
				}*/
			//}
	}
	selectObject.value=selectedValue
}


function MM_filterSelect_Other(filename, selectName, optionValue, optionText, selectedValue,filtername,filtervalue){
	var selectObject = eval('formx.' + selectName)
	selectObject.length=0
	
	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement

	// Getting the nodes
	nodesValue=Root.getElementsByTagName(optionValue)
	nodesText=Root.getElementsByTagName(optionText)
	nodesFilter=Root.getElementsByTagName(filtername)
	selectOption = document.createElement("<OPTION>");

	selectOption.text = "None/others"
	selectOption.value = ""
	selectObject.add(selectOption);
	
	for(i=0;i<nodesValue.length ; i++){
		selectValue=nodesValue.item(i).firstChild.nodeValue
		selectText=nodesText.item(i).firstChild.nodeValue
		selectFilter=nodesFilter.item(i).firstChild.nodeValue
                if (Trim(selectFilter)==Trim(filtervalue)){
			selectOption = document.createElement("<OPTION>");
			selectOption.text = selectText
		   selectOption.value = selectValue
			selectObject.add(selectOption);
			if(selectValue == selectedValue){
				selectOption.selected=true
			}
		}
	}
}

function MM_filterText(filename,optionValue, optionText, selectedValue,filtername){

	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement

	// Getting the nodes
	nodesValue=Root.getElementsByTagName(optionValue)
	nodesText=Root.getElementsByTagName(optionText)
	nodesFilter=Root.getElementsByTagName(filtername)

	//Finding the Filtered value
	for(i=0;i<nodesValue.length ; i++){
		selectValue=nodesValue.item(i).firstChild.nodeValue
		selectText=nodesText.item(i).firstChild.nodeValue
		selectFilter=nodesFilter.item(i).firstChild.nodeValue

		if (selectValue.toString()==selectedValue.toString()){
			obj=eval("formx."+filtername)
			obj.value=selectFilter
		}
	}
}
function MM_filterText_Other(filename,optionValue, optionText, selectedValue,filtername,dispname){
	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement

	// Getting the nodes
	nodesValue=Root.getElementsByTagName(optionValue)
	nodesText=Root.getElementsByTagName(optionText)
	nodesFilter=Root.getElementsByTagName(filtername)

	//Finding the Filtered value
	for(i=0;i<nodesValue.length ; i++){
		selectValue=nodesValue.item(i).firstChild.nodeValue
		selectText=nodesText.item(i).firstChild.nodeValue
		selectFilter=nodesFilter.item(i).firstChild.nodeValue

		if (selectValue.toString()==selectedValue.toString()){
			obj=eval("formx."+dispname)
			obj.value=selectFilter
		}
	}
}


function MM_filterSelectOther(filename, selectName, optionValue, optionText, selectedValue,filtername,filtervalue,filenametosearch){
	var selectObject = eval('formx.' + selectName)
	selectObject.length=0
  str1=''

	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement
var xmlDoc1=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc1.async="false"
	xmlDoc1.load(path+'common/scripts/xml/'+filenametosearch)
	Root1 = xmlDoc1.documentElement
	nodesValue1=Root1.getElementsByTagName(filtername)
	nodesValue2=Root1.getElementsByTagName(optionValue)
for(m=0;m<nodesValue1.length ; m++){
	selectFilter=nodesValue1.item(m).firstChild.nodeValue
		if (selectFilter==filtervalue){
				str1=str1+nodesValue2.item(m).firstChild.nodeValue+","
				}
	}
	// Getting the nodes
	nodesValue=Root.getElementsByTagName(optionValue)
	nodesText=Root.getElementsByTagName(optionText)
	nodesFilter=Root.getElementsByTagName(filtername)
	selectOption = document.createElement("<OPTION>");

	selectOption.text = "None"
	selectOption.value = ""
	selectObject.add(selectOption);
str1=str1.substr(0,str1.length-1)
arr1=str1.split(",")
for(n=0;n<arr1.length;n++){
		for(i=0;i<nodesValue.length ; i++){
				selectValue=nodesValue.item(i).firstChild.nodeValue
				selectText=nodesText.item(i).firstChild.nodeValue

				if (selectValue==arr1[n]){
					selectOption = document.createElement("<OPTION>");
					selectOption.text = selectText
			  	 selectOption.value = selectValue
					selectObject.add(selectOption);
					if(selectValue == selectedValue){
						selectOption.selected=true
					}
				}
			}
		}
	}



function MM_populateSelect_filter(filename, selectName, optionValue, optionText, selectedValue,filterValue){

	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement
	// Getting the nodes

	nodesValue=Root.getElementsByTagName(optionValue)
	nodesText=Root.getElementsByTagName(optionText)
	selectOption = document.createElement("<OPTION>");

	selectOption.text = "None"
	selectOption.value = ""
	var selectObject = eval('formx.' + selectName)
	selectObject.add(selectOption);
	for(i=0;i<nodesValue.length ; i++){
		selectValue=nodesValue.item(i).firstChild.nodeValue
		selectText=nodesText.item(i).firstChild.nodeValue
		selectOption = document.createElement("<OPTION>");
	   if(selectValue!=filterValue){
		selectOption.text = selectText
		selectOption.value = selectValue
		selectObject.add(selectOption);


		if(selectValue == selectedValue){


			selectOption.selected=true
		}
         }
	}
}
function MM_filter(filename,MatchID,MatchValue,filtername){

	// Creating the dom object
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
	xmlDoc.async="false"
	xmlDoc.load(filename)
	Root = xmlDoc.documentElement

	// Getting the nodes
	nodesValue=Root.getElementsByTagName(MatchID)
//	nodesText=Root.getElementsByTagName(optionText)
	nodesFilter=Root.getElementsByTagName(filtername)

	//Finding the Filtered value
	for(i=0;i<nodesValue.length ; i++){
		selectValue=nodesValue.item(i).firstChild.nodeValue
		//selectText=nodesText.item(i).firstChild.nodeValue
		selectFilter=nodesFilter.item(i).firstChild.nodeValue
		if (selectValue.toString()==MatchValue.toString()){
			obj=eval("formx."+filtername)
			obj.value=selectFilter
		}
	}
}
