function ObtenerDatosCboAvanzado(id, cbos, sec, nc0, nc1, nc2){
	
	if(typeof(nc0) == 'undefined'){
		
		var nc0 = "";
		
	}
	
	if(typeof(nc1) == 'undefined'){
		
		var nc1 = "";
		
	}
	
	if(typeof(nc2) == 'undefined'){
		
		var nc2 = "";
		
	}
	
	var get = "accion=ldc&id=" + id + "&sec=" + sec + "&nc0=" + nc0 + "&nc1=" + nc1 + "&nc2=" + nc2;
	
	datos = Ajax(get);

	var dc = cbos.split(',');
	
	
	for(var e = 0; e < dc.length; e++){

		LimpiarCbo(dc[e]);

	}

	if(datos != "NOK"){
		
		cbo_resultado = dc[0];
		
		var l = datos.split('|');
		
		if(l.length > 0){
			
			l.pop();
			
			for(var i = 0; i < l.length; i++){
				
				var d = l[i].split('[:?]');
				
				AgregarDatosCbo(cbo_resultado, d[1].replace(/\+/g, ' ', ' '), d[0].replace(/\+/g, ' '));
				
			}
		
		}
	}
	else{
		
	}
}

function AgregarRelacionPropiedad(campo1, campo2, campo3, hidden){
	
	if(ValidarEnvio()){
		
		var e1 = document.getElementById(campo1);
		var e2 = document.getElementById(campo2);
		var e3 = document.getElementById(campo3);
		var e4 = document.getElementById(hidden);
		
		var c1_text = e1.options[e1.selectedIndex].text;
		var c1_id = e1.options[e1.selectedIndex].value;
		var c2_text = e2.options[e2.selectedIndex].text;
		var c2_id = e2.options[e2.selectedIndex].value;
		
		if((c1_id != "") && (c2_id != "")){
	
			var id_relacion = c1_id + "-" + c2_id + "$";
			var id_relacion_div = "div_" + c1_id + "_" + c2_id;
			
			if(e4.value.indexOf(id_relacion) == -1){
	
				var div = "";
				div += "<div style='width:600px; height:20px; border:0px solid #000000; padding:2px;' id='" + id_relacion_div + "'>";
				div += "<div style='border:1px solid #666666; width:196px; height:20px; float:left;'>&nbsp;" + c1_text + "</div>";
				div += "<div style='border:1px solid #666666; width:296px; height:20px; float:left; margin-left:2px;'>&nbsp;" + c2_text + "</div>";
				div += "<div style='border:1px solid #666666; width:96px; height:20px; float:right; margin-right:2px;'>&nbsp;<a href='javascript: void(0);' onclick='return EliminarRelacionDiv(\"" + id_relacion_div + "\", \"" + id_relacion + "\", \"" + hidden + "\");'>Eliminar</a></div>";
				div += "</div>";
				
				e3.innerHTML += div;
				e4.value += id_relacion;
			
			}
			else{
			
				alert("El Propiedad seleccionada ya esta relacionado");
			
			}
		
		}
		
	}
}

function AgregarRelacionContenidos(campo1, campo2, campo3, hidden){
	
	if(ValidarEnvio()){
		
		var e1 = document.getElementById(campo1);
		var e2 = document.getElementById(campo2);
		var e3 = document.getElementById(campo3);
		var e4 = document.getElementById(hidden);
		
		var c1_text = e1.options[e1.selectedIndex].text;
		var c1_id = e1.options[e1.selectedIndex].value;
		var c2_text = e2.options[e2.selectedIndex].text;
		var c2_id = e2.options[e2.selectedIndex].value;
		
		if((c1_id != "") && (c2_id != "")){
	
			var id_relacion = c1_id + "-" + c2_id + "$";
			var id_relacion_div = "div_" + c1_id + "_" + c2_id;
			
			if(e4.value.indexOf(id_relacion) == -1){
	
				var div = "";
				div += "<div style='width:600px; height:20px; border:0px solid #000000; padding:2px;' id='" + id_relacion_div + "'>";
				div += "<div style='border:1px solid #666666; width:196px; height:20px; float:left;'>&nbsp;" + c1_text + "</div>";
				div += "<div style='border:1px solid #666666; width:296px; height:20px; float:left; margin-left:2px;'>&nbsp;" + ((c2_text.length > 35) ? c2_text.substr(0,35) : c2_text ) + "</div>";
				div += "<div style='border:1px solid #666666; width:96px; height:20px; float:right; margin-right:2px;'>&nbsp;<a href='javascript: void(0);' onclick='return EliminarRelacionDiv(\"" + id_relacion_div + "\", \"" + id_relacion + "\", \"" + hidden + "\");'>Eliminar</a></div>";
				div += "</div>";
				
				e3.innerHTML += div;
				e4.value += id_relacion;
			
			}
			else{
			
				alert("El Contenido seleccionada ya esta relacionado");
			
			}
		
		}
		
	}
}

function EliminarRelacionDiv(div, valor, campo){
	
	document.getElementById(div).style.display = 'none';
	document.getElementById(div).id = DimeTime();
	var txt = document.getElementById(campo).value.replace(valor,'');
	document.getElementById(campo).value = txt; 
	return false;
	
}


function AbrirConfirmarDireccion(ancho, alto){
	
	var d = document.getElementById('direccion').value;
	var p = document.getElementById('id_provincia').value;
	var l = document.getElementById('id_localidad').value;
	var b = document.getElementById('id_barrio').value;
	var ll = document.getElementById('posicion_ll').value;
	
	if(d != ""){
		
		var url = "?sec=propiedades&op=confirmar_ubicacion&dir=" + d + "&idp=" + p + "&idl=" + l + "&idb=" + b + "&ll=" + ll + "&TB_iframe=true&width=700&height=550";
		
		//tb_show('Confirmar Ubicacion', url, '');
		
		var n = window.open(url,'','width=' + ancho + ',height=' + alto + ', top=' + ((screen.height - alto) / 2) + ', left=' + ((screen.width - ancho) / 2) + ', scrollbars=1, resizable=1');
	
	}
	else{
		
		alert('Debe ingresar una direccion');
		
	}
}
