	function ajaxFunction()
	{
		var ret;
		try
		{  
			// Firefox, Opera 8.0+, Safari  
			ret=new XMLHttpRequest();  
		}
		catch (e)
		{  
			// Internet Explorer  
			try
			{    
			ret=new ActiveXObject("Msxml2.XMLHTTP");    
			}
			catch (e)
			{    	
				try
				{      		
					ret=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
				{      
					alert("Your must use a web broswer that supports AJAX!"); 
					return false;      
				}    
			}  
		}
		return ret;
	}	
	
	
	
	
	function retrievePhones(brandId,formname,valueToSelect,appId)
	{

		var phoneSelect = document.forms[formname].phoneId;
		phoneSelect.options.length = 0;
		
		if ( brandId == ' ' )
			return;
	

		phoneSelect.options[phoneSelect.options.length] = new Option('Loading phones...',' ');
	
		var xmlHttp = ajaxFunction()

		
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				var xmlDoc=xmlHttp.responseXML.documentElement;
				
				var phones =xmlDoc.getElementsByTagName("p");
				
				phoneSelect.options.length = 0;
	
				
				for (i=0;i<phones.length;i++)
				{ 
					phoneSelect.options[phoneSelect.options.length] = new Option(phones[i].getElementsByTagName("m")[0].childNodes[0].nodeValue,phones[i].getElementsByTagName("i")[0].childNodes[0].nodeValue);
				}
				
				phoneSelect.focus();
				
				if ( formname=='phoneChooseForm' )
				{
					document.getElementById('pfd').style.display = '';
				}
				if ( valueToSelect )
				{
					var indexToSelect = 0;
					for (i=0;i<phoneSelect.options.length;i++)
					{ 
						if (phoneSelect.options[i].value == valueToSelect )
							indexToSelect = phoneSelect.options[i].index;
					}
					phoneSelect.selectedIndex = indexToSelect;
				}
				
				
			}
		}
		
		var url = "/phone.action?phones&brandId="+brandId;
		if ( typeof(appId) != 'undefined' )
		{
			url = url +	"&appId="+appId;
		}
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);  
	}