function NewWindow(mypage,myname,w,h,scroll,resize){
	var win=null;
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=0,directories=0,status=1,menubar=0,toolbar=0,resizable='+resize;
	win=window.open(mypage,myname,settings);
}
function verDetalle(id){
	NewWindow('detalle_producto.php?id='+id, 'Detalle', 460, 480, 1, 0);
}
function showID(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'inline';
	}else{
		if (document.layers){ // Netscape 4
			document.id.display = 'inline';
		}else{ // IE 4
			document.all.id.style.display = 'inline';
		}
	}
}
function hideID(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}else{
		if (document.layers){ // Netscape 4
			document.id.display = 'none';
		}else{ // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function isVisible(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		if(document.getElementById(id).style.display == 'none') return false; else return true;
	}else{
		if (document.layers){ // Netscape 4
			if(document.id.display == 'none') return false; else return true;
		}else{ // IE 4
			if(document.all.id.style.display == 'none') return false; else return true;
		}
	}
}
function agregarProd(id){
	var cant = parseInt(document.getElementById(id).value);
	if(isNaN(cant) || cant==0){
		alert("Ingrese la cantidad que desea agregar a su carrito.");
	}else{
		window.location = "micarro.php?agregar="+id+"&cantidad="+cant;

	}
}
function actCantidad(id){
	var cant = parseInt(document.getElementById(id).value);
	if(isNaN(cant) || cant==0){
		alert("Ingrese la cantidad deseada del producto. Para eliminar el producto del carro use el boton 'X'.");
	}else{
		window.location = "micarro.php?act=true&agregar="+id+"&cantidad="+cant;

	}
}
function removerProd(id){
	window.location = "micarro.php?remover="+id;
}

function checkEnter(e,id,act){
	var characterCode;
	if(e && e.which){
		characterCode = e.which;
	}else{
		characterCode = e.keyCode;
	}
	if(characterCode == 13){
		if(act==true) actCantidad(id); else agregarProd(id);
	}
	return true;
}
