function alacesta(idp,ruta){
	if(idp){
		cantidad=document.getElementById("cantidad"+idp).value;
		document.getElementById("producto_id").value=idp;
		document.getElementById("cantidad").value=cantidad;
		document.getElementById("form_addcesta").action = ruta+'proceso-compra/procesa-articulo.php';
		/*alert(document.getElementById("producto_id").value);
		alert(document.getElementById("cantidad").value);*/
		document.getElementById("form_addcesta").submit();
	}
}

function regaloalacesta(idp,puntos,ruta){
	if(idp){
		var puntos_user = document.getElementById("puntos_user").value;
		document.getElementById("producto_id").value=idp;
		document.getElementById("puntos").value=puntos;
		document.getElementById("form_addcesta").action = ruta+'proceso-compra/procesa-regalo.php';
		//alert(puntos + " / "+puntos_user);
		if(puntos>(puntos_user-1)){
			alert("No dispone de puntos suficientes para solicitar este regalo.");
		}else{
			document.getElementById("form_addcesta").submit();
		}
	}
}

function actualizarUnidades(linea,units){
	document.getElementById("linea").value = linea;
	document.getElementById("unidades").value = units.value;
	document.getElementById("form-cesta").action = "proceso-compra/actualizar-cesta.php";
	document.getElementById("form-cesta").submit();
}

function winScroll(url,ancho,alto,nombre){
	var posx = (screen.width-ancho)/2;
	var posy = (screen.height-alto)/2;
	window.open(url,nombre,'toolbar=0, resizable=0, location=0,status=0,directories=0,menubar=0,scrollbars=1,width='+ancho+',height='+alto+',left='+posx+',top='+posy);	
}

function verPedido(id){
	winScroll('ver-pedido.php?id='+id,950,520,'VERPEDIDO');
}

function verAfiliado(id){
	if(id!=""){
		document.location.href = 'index.php?seccion=micuenta&afil='+id+'#afiliados';
	}
}