function addSupplier(id,bottonImg)
{
	var xhr = newXhr();	//建立XHR物件
	xhr.onreadystatechange = getData;
	xhr.open("GET",'../supplier/action.php?action=addSupplier&id='+id,true);	//true設定為非同步處理
	xhr.send(null); //傳遞GET參數*/
	function getData()
	{
		if(xhr.readyState == 1)	//已送出send的時候
		{
			//document.getElementById('searchbar').innerHTML = "Loading...";			
		}
		if(xhr.readyState == 4)	//收到全部資料的時候
		{
			if(xhr.status == 200) //代表接收正常 如果為404為找不到網頁
			{
				if(xhr.responseText==1)
				{
					alert('收藏成功');
					var imgurl=bottonImg.src.split(/[a-zA-Z0-9_.]{1,50}$/);
					bottonImg.src=imgurl+'collected.gif';
					bottonImg.style.cursor='default';
					bottonImg.onclick=function(){return false;}
				}
				else
				{
					alert('收藏失敗');
				}
			}
			else
			{
				alert('收藏失敗');
			}
		}
	}
}
function addProduct(id,no,bottonImg)
{
	var xhr = newXhr();	//建立XHR物件
	xhr.onreadystatechange = getData;
	xhr.open("GET",'../supplier/action.php?action=addProduct&id='+id+'&no='+no,true);	//true設定為非同步處理
	xhr.send(null); //傳遞GET參數*/
	function getData()
	{
		if(xhr.readyState == 1)	//已送出send的時候
		{
			//document.getElementById('searchbar').innerHTML = "Loading...";			
		}
		if(xhr.readyState == 4)	//收到全部資料的時候
		{
			if(xhr.status == 200) //代表接收正常 如果為404為找不到網頁
			{
				if(xhr.responseText==1)
				{
					alert('收藏成功');
					var imgurl=bottonImg.src.split(/[a-zA-Z0-9_.]{1,50}$/);
					bottonImg.src=imgurl+'CollectedBtn.gif';
					bottonImg.style.cursor='default';
					bottonImg.onclick=function(){return false;}
				}
				else
				{
					alert('收藏失敗');
				}
			}
			else
			{
				alert('收藏失敗');
			}
		}
	}
}

