var banderaCRM = true;

function cambiaCRM(id) {
	if (banderaCRM) {
		$("#crm").hide();
		banderaCRM = false;
		var parametros = {};
		$.ajax({
			url: "/" + RUTA_MAESTRA + "/index.php/homeAgente/getUrl",
			type: "GET",
			data: parametros,
			dataType: "text",
			success: function (result) {
				banderaCRM = true;
				var r = JSON.parse(result);
				var url = r.url.toString().trim();
				if (url == false || url === "" || url == null || url == "false") {
					url = "caritafeliz.html"
				} else {
					url = url.replace("--dialvoxCRM--", dialvoxCRM)
					url = url.replace("--dialvoxgestor--", Usuario)
					url = url.replace("--TipoLlamadaDialvox--", tipoLlamada)

				}
				//$("#crm1" + id).attr('src', url);
				document.getElementById('crm1' + id).src = url;

			},
			error: function (data) {
				console.log(data);

				return "error";
			}
		});
	}
}
var banderaCRM2 = true;

function cambiaCRM2(id) {
	if (banderaCRM2) {
		$("#crm").hide();
		banderaCRM2 = false;
		var parametros = {};
		$.ajax({
			url: "/" + RUTA_MAESTRA + "/index.php/homeAgente/getUrl2",
			type: "POST",
			data: parametros,
			dataType: "text",
			success: function (result) {
				banderaCRM2 = true;
				var r = JSON.parse(result);
				var url = r.url.toString().trim();
				if (url == false || url === "" || url == null || url == "false") {
					$('#crm1' + id).removeClass("col-sm-6");
					$('#crm1' + id).addClass("col-sm-12");
					$('#crm2' + id).css('width', 0);
					$('#crm2' + id).css('height', 0);
				} else {
					url = url.replace("--dialvoxCRM--", dialvoxCRM)
					url = url.replace("--dialvoxgestor--", Usuario)
					url = url.replace("--TipoLlamadaDialvox--", tipoLlamada)
					document.getElementById('crm2' + id).src = url;
				}


			},
			error: function (data) {
				console.log(data);
			}
		});
	}
}

function cargaCRMS() { }
