//reponse xml is <group><list></list><list></list></group>
function updateContent( uri,  arrayUrlLId, arrayFillId,arrayUrlName, arrayFillName,runFunction)
{
	// initiate pre define values
	if(!arrayFillId) arrayFillId = new Array();if(!arrayFillName) arrayFillName = new Array(); 
	if(!arrayUrlLId) arrayUrlLId = new Array(); if(!arrayUrlName) arrayUrlName = new Array(); 
	var arrayUrlNameList = new Array();  var tmpObject1; 
	var i = 0; var k = 0; var tmpIndex = 0; var tmpObject; 
	var livesubmitobject= new LiveSubmit();
	for(i=0; i < arrayFillId.length; i++)
	{
		arrayFillId[i] = document.getElementById(arrayFillId[i]);
	}		
	for(i=0; i < arrayFillName.length; i++)
	{
		arrayFillName[i] = document.getElementsByName(arrayFillName[i]);
	}		
	// parse arrayUrlLId out to name and value
	for(i=0; i < arrayUrlLId.length; i++)
	{
	  tmpObject =document.getElementById(arrayUrlLId[i]);
	  if(tmpObject.tagName == "SELECT")
		arrayUrlLId[i] ={id: arrayUrlLId[i], value: tmpObject.options[tmpObject.selectedIndex].value}
	 else if(tmpObject.type == "checkbox" || tmpObject.type == "radio")
	 {
		if(tmpObject.checked)
		{
			arrayUrlLId[i] ={id: arrayUrlLId[i], value: tmpObject.value}		
		}
	 }
	  else if(tmpObject.tagName == "INPUT" || tmpObject.tagName == "TEXTAREA")
		arrayUrlLId[i] = { id: arrayUrlLId[i], value: tmpObject.value}
 	  else if(tmpObject.tagName=="TD" || tmpObject.tagName=="DIV" || tmpObject.tagName=="SPAN" || tmpObject.tagName=="TR" || tmpObject.tagName=="TBODY" ||  tmpObject.tagName=="THEADER" || tmpObject.tagName=="TABLE" )
		arrayUrlLId[i] = { id: arrayUrlLId[i], value: tmpObject.innerHTML}
	}	
	// parse arrayUrlName out to name and value
	flag = 0;
	for(i=0; i < arrayUrlName.length; i++)
	{
	  tmpObject =document.getElementsByName(arrayUrlName[i]);
	  // go through array of obtained elements by name
	  for(k=0; k < tmpObject.length; k++)
	  {
		 tmpObject1 = tmpObject[k];
		 // save selection fields 
	  	 if(tmpObject1.tagName == "SELECT")
arrayUrlNameList[flag++]={ name: arrayUrlName[i], value:tmpObject1.options[tmpObject1.selectedIndex].value}   // parse input fields with different types
	 	 else if(tmpObject1.tagName == "INPUT")
	 	 {
			if(tmpObject1.type == "radio")
			{
				if(tmpObject1.checked)
				arrayUrlNameList[flag++] = { name: arrayUrlName[i], value: tmpObject1.value}
			}
			else if(tmpObject1.type == "checkbox")
			{
				if(tmpObject1.checked)
				arrayUrlNameList[flag++] = { name: arrayUrlName[i], value: tmpObject1.value}
			}			
			else if(tmpObject1.type == "text")
			{
				arrayUrlNameList[flag++] = { name: arrayUrlName[i], value: tmpObject1.value}				
			}
		 }
		 else if(tmpObject1.tagName == "TEXTAREA")
		 {
			arrayUrlNameList[flag++] = { name: arrayUrlName[i], value: tmpObject1.value}				
		 }
	  }
	}		
	// Browser Detecteting Agent
	var browserAgent = navigator.userAgent.toLowerCase(); 
	
	function isGecko()
	{
		return navigator.product == 'Gecko' ;
	}
	function submitInfo()
	{
	    var separator = "?"; 
  		if(uri.indexOf("?") >= 0)
            separator = "&"; 
	 	for(i=0; i < arrayUrlLId.length; i++)
		{
			uri += separator+arrayUrlLId[i].id+'='+encodeURI(arrayUrlLId[i].value);
			if(separator=="?") separator = "&";
		}
	 	for(i=0; i < arrayUrlNameList.length; i++)
		{
			uri += separator+arrayUrlNameList[i].name+'='+encodeURI(arrayUrlNameList[i].value);
			if(separator=="?") separator = "&";
		}		
		livesubmitobject.GET(uri,runResFunc);
	}
	function runResFunc()
	{
		 var flag = false; var resultType = "XML";
	     if (livesubmitobject.http_request.readyState == 4) 
	     {
         	if (livesubmitobject.http_request.status == 200) {
				 if(resultType == "XML")
            		livesubmitobject.result = livesubmitobject.http_request.responseXML;
				 else
           		 	livesubmitobject.result = livesubmitobject.http_request.responseText;
					flag = true;
       	    } else {
		  	 livesubmitobject.error = true;
		 	 livesubmitobject.errorMessage = "there was a problem with the request.";
			 livesubmitobject.result = "";
           }

      	 }
		if(flag)
		{
			// GET XML Data and Re populate popup layer
			// list.childNodes[0].nodeValue
			var i = 0;var list = ""; var k = 0; var h =0; var m = 0; var checkboxFound = false;
			var len = arrayFillId.length; var tmpNodeValue = ''; var listFound = false;
    	    var group = livesubmitobject.result.getElementsByTagName("group");
			if(isGecko()) livesubmitobject.result.normalize();
			
			if(group.length > 0)
				 list = group[0].getElementsByTagName("list");
			for (var i= 0; i < list.length; i++) 
			{  
			   if(!list[i].childNodes[0]) tmpNodeValue = '';
			   else  tmpNodeValue = list[i].childNodes[0].nodeValue;
			   if(len > i)
			   {
			   		tmpObject = arrayFillId[m]; 

				if(tmpObject==null){	if(len == i+1) m = 0; else m++; continue; }
 		   		if(tmpObject.tagName == "SELECT")
			   		{
						listFound = false;
					   	for(k=0; k < tmpObject.length; k++)
						{
							if(tmpObject.options[k].value == tmpNodeValue)
							{	tmpObject.selectedIndex = k; listFound= true; break;      }
							
						}
						if(!listFound) tmpObject.selectedIndex = 0;
					}
					else if(tmpObject.type == "checkbox" || tmpObject.type == "radio")
					{
						if(tmpObject.value == tmpNodeValue) tmpObject.checked = true; else tmpObject.checked = false;
					}
					else if(tmpObject.tagName == "INPUT" || tmpObject.tagName == "TEXTAREA")
						tmpObject.value= tmpNodeValue; 
	  		    	else if(tmpObject.tagName == "TD" || tmpObject.tagName == "DIV" || tmpObject.tagName == "SPAN"  ||   tmpObject.tagName=="THEADER" || tmpObject.tagName=="TABLE")
						tmpObject.innerHTML = tmpNodeValue;
					if(len == i+1) m = 0; else m++;

			   }
			   else if(arrayFillName && arrayFillName.length > 0)
			   {
				  //run through array elements from elements get by name
			   	  tmpObject =arrayFillName[m];   checkboxFound = false;    
				  for(k=0; k < tmpObject.length; k++)
				  {
					 tmpObject1 = tmpObject[k];
	 		   		 if(tmpObject1.tagName == "SELECT")
			   		 {
						listFound = false;
					   	for(h=0; h < tmpObject1.length; h++)
						{
							if(tmpObject1.options[h].value == tmpNodeValue)
							{	tmpObject1.selectedIndex = h;  listFound = true; m++; break;      }
						}
						//no selection field found default to 0
						if(!listFound) tmpObject1.selectedIndex = 0;
						m++;
					 }
					 else if(tmpObject1.tagName=="TEXTAREA" || tmpObject1.type=="INPUT")
					 {
						 tmpObject1.value = tmpNodeValue;
						 m++;
					 }
					 else if(tmpObject1.type=="radio" || tmpObject1.type=="checkbox")
					 {
						 if(tmpObject1.value ==  tmpNodeValue)
						 {
							tmpObject1.checked = true; checkboxFound = true;
							m++; break;
						 }
						 else if(tmpObject1.checked) tmpObject1.checked = false;
					 }
	  		    	else if(tmpObject.tagName == "TD" || tmpObject.tagName == "DIV" || tmpObject.tagName == "SPAN" ||  tmpObject.tagName=="THEADER" || tmpObject.tagName=="TABLE")
					{	tmpObject.innerHTML = tmpNodeValue;
						m++;
					}
				 
				  } 
				  if(!checkboxFound) m++;
			   }//end parse get elements by name
			} 
         if(runFunction) runFunction();

    	} 
		
	}
    if (window.timeout)
       window.clearTimeout(window.timeout);
	window.timeout = window.setTimeout(submitInfo, 100);   

}
