function Show(e, id)
{
  var e=(!e)?window.event:e;//IE:Moz
  var tmpX = 0;
  var tmpY = 0;

  if(e.pageX)
  {
    tmpX = e.pageX + window.pageXOffset;
    tmpY = e.pageY + window.pageYOffset;
  } else if(e.clientX) {
			if(document.documentElement){//IE 6+ strict mode
    	tmpX = e.clientX + document.documentElement.scrollLeft;
    	tmpY = e.clientY + document.documentElement.scrollTop;
			}
			else if(document.body){//Other IE
    	tmpX = e.clientX + document.body.scrollLeft;
    	tmpY = e.clientY + document.body.scrollTop;
			}
  } else {
    return false
  }

 var el = document.getElementById(id);
     el.style.left = tmpX +'px';
     el.style.top = (tmpY + 35)+'px';
     el.style.display = "block";
}
    
function Hide(id)
{
   var el = document.getElementById(id);
       el.style.display = "none";
}

// JavaScript Document
var xmlHttp;

function ajaxElimina(pid) {};

function ajaxFunction(buida)
{
	//alert (document.myForm.presentacions.value);

	if ((document.myForm.productes.value != '0' && document.myForm.presentacions.value != '0' && document.myForm.quantitat.value != '' && document.myForm.quantitat.value != '0') || buida == 1) {
		try
		{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
		// Internet Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
		  {
		  try
			{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		  catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
		  }
		}
					
		xmlHttp.onreadystatechange=hola;
		xmlHttp.open("GET","pagines/pedidos/afegeix.php?b="+buida+"&idp="+document.myForm.productes.value+"&idpres="+document.myForm.presentacions.value+"&q="+document.myForm.quantitat.value,true);

		//resetejar el formulari per introduir un nou producte
		document.myForm.quantitat.value = '';
		document.myForm.productes.value = 0;
		document.myForm.presentacions.value = 0;
		document.myForm.presentacions.disabled = "disabled";
		//xmlHttp.overrideMimeType("text/html; charset=ISO-8859-1");
		xmlHttp.send(null);	
	}
	else alert('Debe escojer producto, presentación y cantidad para añadir un producto');
}

function hola()
{
	if(xmlHttp.readyState==4)
	{
		document.getElementById('llistat').innerHTML=xmlHttp.responseText;
	}
}

function buida() {
	alert ('Cridar funcio buidar sessió');
}

function numbersonly(e){
	//nomes deixa passar els números del 0 al 9
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
	if (unicode<48||unicode>57) //if not a number
		return false //disable key press
	}
}

function ajaxElimina(pid, ppid)
{
	/*alert("afegeix.php?del=1&idp="+pid);*/
	
		try
		{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
		// Internet Explorer
		try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		catch (e)
		  {
		  try
			{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		  catch (e)
			{
			alert("Your browser does not support AJAX!");
			return false;
			}
		  }
		}
		xmlHttp.onreadystatechange=hola;
		xmlHttp.open("GET","pagines/pedidos/afegeix.php?del=1&idp="+pid+"&idpres="+ppid,true);
		//xmlHttp.overrideMimeType("text/html; charset=ISO-8859-1");
		xmlHttp.send(null);	
}
