function addproduct(pid,count)
{
	var pname = document.getElementById('hname'+pid).value;

	var pprice = document.getElementById('hprice'+pid).value;
	var pqtyleft = document.getElementById('hqty'+pid).value;
	var taxid = document.getElementById('tax'+pid).value;
	var attributeid = '';
	var attribute = '';
	if(count != 0){
	try{
		for(var i=count-1;i>=0;i--)
		{
			var w = document.getElementById('att-'+i+'-'+pid).selectedIndex;
			attribute = attribute +' : '+document.getElementById('att-'+i+'-'+pid).options[w].text;
			var temp = document.getElementById('att-'+i+'-'+pid).value.substring(0,document.getElementById('att-'+i+'-'+pid).value.indexOf(";"));
			attributeid = attributeid+','+temp;
		}
		attributeid = attributeid.substring(1);
		attribute = attribute.substring(2);
	}catch(err){
		attributeid = '[NA]';
		attribute = '-';
	}
	}else {
		attributeid = '[NA]';
		attribute = '-';
	}
	//alert(attributeid);
	parent.additem(pid,pname,pprice,attribute,attributeid,pqtyleft,taxid);
	
}

function changeqty(pid,count,branch)
{

	var stock_att_id = '';
	var stock_att_price = document.getElementById('horgprice'+pid).value;

	for(var i=count-1;i>=0;i--)
	{
		stock_att_id = stock_att_id +','+document.getElementById('att-'+i+'-'+pid).value.substring(0,document.getElementById('att-'+i+'-'+pid).value.indexOf(";"));
		stock_att_price = eval(stock_att_price) + eval(document.getElementById('att-'+i+'-'+pid).value.substring(document.getElementById('att-'+i+'-'+pid).value.indexOf(";")+1));
	}

	document.getElementById('hprice'+pid).value = stock_att_price.toFixed(2);
	document.getElementById('price'+pid).innerHTML = stock_att_price.toFixed(2);

	//Ajax
	if (window.ActiveXObject) 
      httpObject =  new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) 
      httpObject =  new XMLHttpRequest();
   else {
      httpObject = null;
   }
   if (httpObject != null) {
		httpObject.open("GET", "pos_attribute_qty.php?pid="+pid+"&stock_attribute="+stock_att_id.substring(1)+"&branch="+branch, true);

      httpObject.send(null);

      httpObject.onreadystatechange = function (){
		if(httpObject.readyState == 4){
				document.getElementById('product'+pid).innerHTML = httpObject.responseText;
				document.getElementById('hqty'+pid).value = httpObject.responseText;

		}
	  }
   }
}
