

var xmlHttp

function showHint2(query,id,type,cPath)

{if(query.length<2)

{document.getElementById(id).innerHTML="";return}

xmlHttp=GetXmlHttpObject2()

if(xmlHttp==null)

{alert("Browser does not support HTTP Request")

return}

var url="get_result.php"

query=encodeURI(query);



var params="query="+query+"&type="+type+"&cPath="+cPath+"&sid="+Math.random();



xmlHttp.onreadystatechange=function stateChanged()

{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")

{document.getElementById(id).innerHTML=xmlHttp.responseText}}

xmlHttp.open("POST",url,true)

xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlHttp.setRequestHeader("Content-length", params.length);

xmlHttp.setRequestHeader("Connection", "close");



xmlHttp.send(params)}

function GetXmlHttpObject2()

{var xmlHttp=null;try

{xmlHttp=new XMLHttpRequest();}

catch(e)

{try

{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}

catch(e)

{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}

return xmlHttp;}



function close_div(id){

 document.getElementById(id).style.visibility = 'hidden';

 document.getElementById(id).style.display = 'none';

}





function keyup2(Object)

{

	

	//Browser Detection

	var browser=navigator.appName;

	var b_version=navigator.appVersion;

	var version=parseFloat(b_version);

	if(browser=='Opera')

		return false;

	//

	textfield = Object;

	document.getElementById('content_'+Object.id).style.visibility='visible';

//Clear();

	handleKeyPress

	

	

	//alert(keycode);

	

	if(keycode=='40' || keycode=='38'||keycode=='13'||keycode=='27' ||keycode=='37' ||keycode=='39')

	{

		try{

			if(!document.getElementById('tdId_0'))

				return false;

		if(keycode=='37' || keycode=='39')

			{

				return false;

			}

			if(keycode=='27')

			{

				Clear();

				return false;

			}

			if(keycode=='13')

			{

				if(selected_no != -1)

					flag = false;

				else

				{

						var tmp_id = 'x_' + selected_id;

						var values_name_id = document.getElementById(tmp_id).value;

						if (values_name_id.indexOf('|') != -1){

							arr_name_id = values_name_id.split('|');

						}

						//alert(arr_name_id[0] + '-----------' + arr_name_id[1]);

						Object.value = arr_name_id[0];

						document.getElementById('manufacturers_id').value = arr_name_id[1];

						//alert('sfdsf1 = ' + document.getElementById('manufacturers_id').value);

						Clear();

				}

				return false;

			}

				

		if(keycode=='40')

		{

			if(selected_no != -1)

			{	

			selected_id = 'tdId_' + selected_no;

			if(document.getElementById(selected_id).style.background== "#ffd3a8" || document.getElementById(selected_id).style.background== "none repeat scroll 0% 0% rgb(255, 211, 168)")

				document.getElementById(selected_id).style.background= "";

			}

			selected_no++;

			selected_id = 'tdId_' + selected_no;

			

			if(!document.getElementById(selected_id))

				selected_no = 0;

			selected_id = 'tdId_' + selected_no;

		}

		else if(keycode=='38')

		{

			if(selected_no != -1)

			{	

			selected_id = 'tdId_' + selected_no;

			if(document.getElementById(selected_id).style.background== "#ffd3a8" || document.getElementById(selected_id).style.background== "none repeat scroll 0% 0% rgb(255, 211, 168)")

				document.getElementById(selected_id).style.background= "";

			}

			selected_no--;

			selected_id = 'tdId_' + selected_no;



			if(!document.getElementById(selected_id))

			{

				selected_no = 10;

				while(!document.getElementById(selected_id))

					selected_id = 'tdId_' + --selected_no;

			}

		}

	var tmp_id = 'x_' + selected_id;

	var values_name_id = document.getElementById(tmp_id).value;

	if (values_name_id.indexOf('|') != -1){

		arr_name_id = values_name_id.split('|');

	}

	//alert(arr_name_id[0] + '-----------' + arr_name_id[1]);

	Object.value = arr_name_id[0];

	document.getElementById('manufacturers_id').value = arr_name_id[1];

	//alert('sfdsf = ' + document.getElementById('manufacturers_id').value);

	//alert();

	//Object.value = document.getElementById(tmp_id).value;

	document.getElementById(selected_id).style.background= "#ffd3a8";

	return false;

	}catch(err){return false;}

	}

	else

	{

		try{

		clearTimeout ( timer );

		timer = setTimeout ( showHint2(Object.value,'content_'+Object.id,Object.id,''), 1000);

		}catch(err){}

	}

	return false;

}
