var ptimeout;
function viewprodsajax(val){
	if(val.length > 1){
		searchforphone(val);
	}
	else{
//		document.getElementById('usernamestatus').innerHTML = '';
	}
}


function clearplist2(){
	plist = document.getElementById("phonesearchlay");
	plist.innerHTML = "";
	plist.style.display = "none";
}

function searchforphone(txt){
	var xhr = null;
	try{
		xhr = new XMLHttpRequest(); 
	}
	catch(e){ 
		try{
			xhr = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e2){ 
			try{
				xhr = new ActiveXObject('Microsoft.XMLHTTP');
			} 
			catch (e){
			}
		}
	}
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4){
			if(xhr.status == 200){
				var psd = document.getElementById('phonesearchlay');
				psd.style.display = "inline";
				if(xhr.responseText == '0'){
					psd.innerHTML = 'No phones found';
					psd.style.padding = "15px";
					psd.style.color = 'blue';
				}
				else{
					psd.innerHTML = xhr.responseText;
					psd.style.padding = "8px";
				}
				window.clearTimeout(ptimeout);
				ptimeout = setTimeout('clearplist2()', 10000);
			}
		}
	}
	d = new Date();
	t = d.getTime();
	xhr.open('GET', '/phones/ajax_searchforphone.php?q=' + txt + '&amp;' + t + Math.random(), true);
	xhr.send(null);
}