function esvaziar_cartao() {
	ajax('esvaziar_cartao.php');
	window.parent.document.getElementById('cartao').innerHTML = "<p>0 artigos</p><p>0.00 &euro;</p>";
}
function eliminar_artigo(id) {
	ajax('eliminar_artigo.php?id=' + id);
	ajax2('actualiza_totais.php');
}
function actualizar_cartao() {
	var f = document.getElementById('form_cartao');
	f.action = "actualizar_cartao.php";
	f.submit();
}
function activa(target) {
	document.getElementById(target).disabled = false;
}
function finalizar_compra() {
	if(!document.getElementById('vazio')) {
		if(login) {
			window.parent.location = URL_DIR + 'compras/finalizar';
		} else {
			url = URL_DIR + 'includes/clientes/login.php?r=' + URL_DIR + 'compras/finalizar';
			window.parent.Shadowbox.open({player:'iframe', content:url, width:420, height:260});
		}
	}
}

var xmlhttp;
function ajax(url){xmlhttp=null;if (window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else if (window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}if (xmlhttp!=null) {xmlhttp.onreadystatechange=state_Change;xmlhttp.open("GET", url, true);  xmlhttp.send(null);}else {alert("Your browser does not support XMLHTTP.");}}
function state_Change() {if (xmlhttp.readyState==4) {if (xmlhttp.status==200) {
document.getElementById('conteudo_ajax').innerHTML = xmlhttp.responseText;
} else {alert("Problem retrieving data:" + xmlhttp.statusText);}}}

var xmlhttp2;
function ajax2(url){xmlhttp2=null;if (window.XMLHttpRequest){xmlhttp2=new XMLHttpRequest();}else if (window.ActiveXObject){xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");}if (xmlhttp2!=null) {xmlhttp2.onreadystatechange=state_Change2;xmlhttp2.open("GET", url, true);  xmlhttp2.send(null);}else {alert("Your browser does not support XMLHTTP.");}}
function state_Change2() {if (xmlhttp2.readyState==4) {if (xmlhttp2.status==200) {
window.parent.document.getElementById('cartao').innerHTML = xmlhttp2.responseText;
} else {alert("Problem retrieving data:" + xmlhttp2.statusText);}}}
