var guarda;
function cambiax(opc)
	{
		if (opc==1)	///Opcion para Imprimir y mandar mail 
		{
		var opcradio;
		if (document.frmelige.cambia[0].checked)
		{opcradio=1;}else{
		if (document.frmelige.cambia[1].checked)
		{
		opcradio=2;
		}
		}
		var menuinfHTTP=makeRequestSync("cargamenu.m3?idopcion=5&eligeradio="+opcradio+"&seleccionados=" + guarda + "&pasa="+pasa);
		document.getElementById("ContTabul").innerHTML=menuinfHTTP;
		}
	}
	
function ObtenerDatos(ver)
{
	//CollectaGuarda();
	var myString = String(guarda);
	var mySplitResult = myString.split(",");
	cta=0;
	for (i = 0; i < mySplitResult.length; i++)
		{
		if ((mySplitResult[i]=="") || (mySplitResult[i]=="undefined")){}else{cta++;}
		}
if (ver==2 || ver==4 || ver==5 || ver==7 )
{

	if (cta>=1)
	{
		if (ver==2 && cta>20)
			{
				alert ("Esta permitido 20 propiedades para elaborar el ACM, gracias . .");
			}else{
				mm=jj;
				mm.idopcion=ver;
				mm.seleccionados=guarda;
				mm.pasa=pasa;
				$.get('/cargamenu.m3',mm,function(data){
					$('#ContTabul').html(data);
					scroll(0,0);
				});
				//var menuinfHTTP=makeRequestSync("?idopcion=" + ver + "&seleccionados=" + guarda + "&pasa="+pasa);
				//document.getElementById("ContTabul").innerHTML=menuinfHTTP;
				
			}
	}else{
	alert ("Favor de seleccionar por lo menos un inmueble, gracias");
	}	   
}else{
	var menuinfHTTP=makeRequestSync("cargamenu.m3?idopcion=" + ver + "&seleccionados=" + guarda + "&pasa="+pasa);
	if(document.getElementById("ContTabul") != null)
		document.getElementById("ContTabul").innerHTML=menuinfHTTP;
	scroll(0,0);
}

}

function ObtenerDatos2(pag, val)
	{

			var myString = String(guarda);
			var mySplitResult = myString.split(",");
			cta=0;

			for (i = 0; i < mySplitResult.length; i++)
			{
				if ((mySplitResult[i]=="") || (mySplitResult[i]=="undefined")){}else{cta++;}
			}
				
			if ((cta>0) && (cta<=30))
			{
				if (val==1)
				{
				var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=700, height=500, top=85, left=140";
				window.open(pag+"?seleccionados="+guarda+"&sta="+$('#idbase').val()+"&op="+jj.idoperacion,"",opciones);
				}else{
				window.open(pag+"?seleccionados="+guarda+"&sta="+$('#idbase').val()+"&op="+jj.idoperacion)
				}
				
			}
			if (cta>30){alert ("Usted seleccionó " + cta + " inmuebles, solo esta permitido 30, gracias");}
	}

function ObtenerDatos3(ver, idcli){sel1="";if (ver>0){
	var ObtenerDatos3HTTP=makeRequestSync("clientes/cargamenu.m3?idopcion=" + ver + "&idcli=" + idcli);
	document.getElementById("ContTabul").innerHTML=ObtenerDatos3HTTP;
	}}
	
function ObtenerDatos4(ver, idinm)
{
if (ver>=0){
	if (ver==5)
	{
		makeRequest("cargamenudetalle.m3?idopcion=" + ver + "&seleccionado=" + idinm, modulo5);
	}else{
		guarda = [];
		guarda[0] = idinm;
		makeRequest("cargamenudetalle.m3?idopcion=" + ver + "&seleccionado=" + idinm, modulo5);
	}
}


}



function ObtenerDatos5(pag, val){var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=700, height=500, top=85, left=140";window.open(pag+"?seleccionados="+val,"",opciones);}


function ObtenerDatos6(ver)
{
	if (ver==1 || ver==2)
		{
			//if (ver>0){makeRequest("directorio/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value+ "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value, modulo6);}
			  if (ver>0){makeRequest("directorio/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value, modulo6);}
		if (ver==1)
			{
			document.getElementById("empresa").innerHTML='<a href=javascript:ObtenerDatos6("2");CambiarEstilo2("bt2");><img src=images/tab_empresa.jpg border=0></a>';
			document.getElementById("usuario").innerHTML='<a href=javascript:ObtenerDatos6("2");CambiarEstilo2("bt2");><img src=images/tab_agentes.jpg border=0></a>';
			
			}else{
		if (ver==2)	
			{
			document.getElementById("usuario").innerHTML='<a href=javascript:ObtenerDatos6("1");CambiarEstilo2("bt1"); OnMouseDown=cambiacolor(1)><img src=images/tab_agentes2.jpg border=0></a>';
			document.getElementById("empresa").innerHTML='<a href=javascript:ObtenerDatos6("1");CambiarEstilo2("bt1"); OnMouseDown=cambiacolor(1)><img src=images/tab_empresas.jpg border=0></a>';
			}
			}
		
		
		}
		else
		{
			//if (ver==3){if (ver>0){makeRequest("directorio/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value+ "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value, modulo6);}}
			  if (ver==3){if (ver>0){makeRequest("directorio/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value, modulo6);}}
		}

	
}



function ObtenerDatos6_2(ver,idusu)
{
	if (ver==6)
	{
	makeRequest("directorio/cargamenu2.m3?idopcion=" + ver + "&idusu="+idusu, modulo6_2);
	}

}



function ObtenerDatos6btf(ver, idusu){

		
		if (ver==3 || ver==4)
		{
		//alert ("directorio/cargamenu.m3?idopcion=" + val + "&buscan=" + document.frmdirectorio.buscaae.value);
		if (ver>0){makeRequest("perfil/cargamenu.m3?idopcion=" + ver +"&idusu="+idusu, modulo6jrg);}
		}else{
		if (ver==4)
		{
		if (ver>0){makeRequest("perfil/cargamenu.m3?idopcion=" + ver +"&idusu="+idusu, modulo6jrg);
		}}}
}


function ObtenerDatos6jrg(ver, idusu){
	if (ver==3 || ver==4)
	{
	//alert ("directorio/cargamenu.m3?idopcion=" + val + "&buscan=" + document.frmdirectorio.buscaae.value);
		if (ver>0){makeRequest("perfil/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value+ "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value+"&idusu="+idusu, modulo6jrg);}
		}
		else
		{
		if (ver==4)
		{
		if (ver>0){makeRequest("perfil/cargamenu.m3?idopcion=" + ver + "&buscan=" + document.frmdirectorio.buscaae.value+ "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value+"&idusu="+idusu, modulo6jrg);}
		}
	}
}



function busca(val)
	{
	if (val==1)
		{
		//alert ("directorio/cargamenu.m3?idopcion=" + val + "&buscan=" + document.frmdirectorio.buscaae.value);
		if (val>0){makeRequest("directorio/cargamenu.m3?idopcion=" + val + "&buscan=" + document.frmdirectorio.buscaae.value, modulo6);}
		}else{
	if (val==2)
		{
		//alert("directorio/cargamenu.m3?idopcion=1&buscan=" + document.frmdirectorio.buscaae.value + "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value);
		//if (val>0){makeRequest("directorio/cargamenu.m3?idopcion=1&buscan=" + document.frmdirectorio.buscaae.value + "&edo="+ document.frmdirectorio.idestado.value + "&mun="+document.frmdirectorio.idmunicipio.value, modulo6);
		if (val>0){makeRequest("directorio/cargamenu.m3?idopcion=1&buscan=" + document.frmdirectorio.buscaae.value, modulo6);
		}}}
	}

function modulo5(){if (http_request.readyState==4){document.getElementById("ContTabul5").innerHTML=http_request.responseText;}}
function modulo6(){document.getElementById('show_load').style.display="block";if (http_request.readyState==4){document.getElementById('show_load').style.display="none";document.getElementById("ContTabul").innerHTML=http_request.responseText;}}
function modulo6crm(){if (http_request.readyState==4){document.getElementById("ContTabulcrm").innerHTML=http_request.responseText;}}
function modulo6_2(){if (http_request.readyState==4){document.getElementById("ContTabul").innerHTML=http_request.responseText;}}
function modulo6jrg(){if (http_request.readyState==4){document.getElementById("ContTabul21").innerHTML=http_request.responseText;}}

function CambiarEstilo(id) {
	var elementosMenu = getElementsByClassName(document, "li", "activo");
	for (k = 0; k< elementosMenu.length; k++) {
	elementosMenu[k].className = "inactivo";}
	var identity=document.getElementById(id);
	identity.className="activo";
}

function CambiarEstilo2(id) { 
	var elementosMenu = getElementsByClassName(document, "li", "activo2"); 
	for (k = 0; k< elementosMenu.length; k++) { 
	elementosMenu[k].className = "inactivo2"; 
	} 
	var identity=document.getElementById(id); 
	identity.className="activo2"; 
} 

function CambiarEstilo2(id) { 
	var elementosMenu = getElementsByClassName(document, "li", "activo3"); 
	for (k = 0; k< elementosMenu.length; k++) { 
	elementosMenu[k].className = "inactivo3"; 
	} 
	var identity=document.getElementById(id); 
	identity.className="activo3"; 
} 

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

function getElementsByClassName2(oElm, strTagName, strClassName){ 
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-"); 
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); 
    var oElement; 
    for(var i=0; i<arrElements.length; i++){ 
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){ 
            arrReturnElements.push(oElement); 
        }    
    } 
    return (arrReturnElements) 
}

function cambiacolor(){


bt1.style.color ="red";

}


