function carga(){
	capas();
	
	//si hay listado de propiedades
	if(document.getElementById("listado_propiedades")){
		var bloque_lista=document.getElementById("listado_propiedades")
		var anchors = bloque_lista.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++){
			if(anchors[i].rel=="favoritos"){
				anchors[i].onclick = function () {iframe_pp(this.href,400,400); return false;}
			}
		}

	}
	
	//si hay iniciar sesion
	if(document.getElementById("iniciar_sesion")){
		document.getElementById("iniciar_sesion").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}
	if(document.getElementById("iniciar_sesion_alt")){
		document.getElementById("iniciar_sesion_alt").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}
	if(document.getElementById("iniciar_sesion_alt2")){
		document.getElementById("iniciar_sesion_alt2").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}
	if(document.getElementById("postulacion")){
		document.getElementById("postulacion").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}
	
}





function carga_ficha(){

	carga();

	//si hay consultar al propietario
	if(document.getElementById("enviar_consulta")){
		document.getElementById("enviar_consulta").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}
	
	if(document.getElementById("agregar_favoritos")){
		document.getElementById("agregar_favoritos").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}

	
	
	//si hay galería de fotos
	if(document.getElementById("galeria")){
		var anchors=document.getElementById("galeria").getElementsByTagName("a");
		for(var i=0;i<anchors.length;i++){
			anchors[i].onclick=function(){iframe_pp(this.href,580,350);return false;};
		}
	}
	
}


function carga_usuarios(){

	carga();

	//si hay select de tipos de propiedad
	if(document.getElementById("tipo_id")){
		document.getElementById("agregar_tipo").onclick=function(){iframe_pp(this.href,400,400);return false;}
	}	
	
	//si hay select de provincia y de localidad
	if(document.getElementById("provincia_id")&&document.getElementById("localidad_id")){
		atributos_select(1);
		document.getElementById("agregar_localidad").onclick=function(){iframe_pp(this.href+"?superior="+document.getElementById("provincia_id").value,400,400);return false;}
	}
	
	//si hay select de localidad y barrio
	if(document.getElementById("localidad_id")&&document.getElementById("barrio_id")){
		atributos_select(2);
			}

//si hay select de rubros y subrubros
	if(document.getElementById("rubro_id")&&document.getElementById("subrubro_id")){
		atributos_select_clasif();
		if(document.getElementById("rubro_id").value!="0"){	document.getElementById("agregar_subrubro").onclick=function(){iframe_pp(this.href+"?superior="+document.getElementById("rubro_id").value,400,400);return false;}
		}else{
			document.getElementById("agregar_subrubro").style.display="none";
		}
	}
	
	//si hay editores de imagen
	if(document.getElementById("muestra_img")){
		atributos_img();
	}

	//si hay lista y si hay renovar
	if(document.getElementById("listado_propiedades")){
		var anchors = document.getElementById("listado_propiedades").getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++){
			if(anchors[i].rel=="renovar"){
				//anchors[i].onclick = function () {iframe_pp(this.href,400,400); return false;}
				anchors[i].onclick = function () {renovar(this); return false;}
			}
		}
	}
}

function renovar(elemento_a){
	elemento_a.parentNode.removeChild(elemento_a);
	var elemento_faja=document.getElementById("img_"+elemento_a.id);
	elemento_faja.parentNode.removeChild(elemento_faja);
	iframe_pp(elemento_a.href,400,400); return false;
}




function atributos_select(tipo){
	if(tipo==1){var var0="provincia";var var1="localidad";}
	if(tipo==2){var var0="localidad";var var1="barrio";}
	var sel_0=document.getElementById(var0+"_id");
	//sel_0.onchange=function(){load_select(tipo,this,0);}
	if(document.getElementById(var1+"_id")){
		sel_0.onchange=function(){load_select(tipo,this,0);}
		var agregar1=document.getElementById("agregar_"+var1);
		if(sel_0.selectedIndex>0){
			agregar1.onclick = function(){iframe_pp(this.href+"?superior="+sel_0.value,400,400);return false;}
			agregar1.title="Agregar "+var1+" en "+sel_0.options[sel_0.selectedIndex].text;
			agregar1.innerHTML="Agregar "+var1+" en "+sel_0.options[sel_0.selectedIndex].text;
			agregar1.style.display="inline";
		}else{
			agregar1.style.display="none";
		}
	}
}


function atributos_select_clasif(){
	var sel_0=document.getElementById("rubro_id");
	if(document.getElementById("subrubro_id")){
		sel_0.onchange=function(){load_select_clasif(this,0);}
		var agregar1=document.getElementById("agregar_subrubro");
		if(sel_0.selectedIndex>0){
			agregar1.onclick = function(){iframe_pp(this.href+"?superior="+sel_0.value,400,400);return false;}
			agregar1.title="Agregar subrubro en "+sel_0.options[sel_0.selectedIndex].text;
			agregar1.innerHTML="Agregar subrubro en "+sel_0.options[sel_0.selectedIndex].text;
			agregar1.style.display="inline";
		}else{
			agregar1.style.display="none";
		}
	}
}


function atributos_img(){
		var oA=document.getElementById("muestra_img").getElementsByTagName("a");
		for(var i=0;i<oA.length;i++){
			oA[i].onclick=function(){iframe_pp(this.href,400,400);return false;};
		}
}



function carga_if(variables,valores){
	document.getElementById("main").style.width="auto";
	if(document.getElementById("cerrar_fpp")){
		document.getElementById("cerrar_fpp").onclick=function(){parent.fauxpopup();return false;}
	}

	if(variables=="login"){
		parent.ajaxload("sesion_info","ajax_sesion_info.php");
		//parent.fauxpopup();
		//parent.location.reload()
	}

	
	if(variables=="localidad"||variables=="barrio"){
	var id_sup=valores.split("/")[0];
	var presel=valores.split("/")[1];
	var tipo=valores.split("/")[2];
	if(tipo==1){
		if(parent.document.getElementById("barrio_box")){
			parent.document.getElementById("barrio_box").innerHTML="<select id='barrio_id' name='barrio_id'></select>";
		}
	}
	parent.ajaxload(variables+"_box","ajax_load_select.php?id_sup="+id_sup+"&presel="+presel+"&tipo="+tipo,"atributos_select("+2+");fauxpopup();");
	}

	if(variables=="tipo"){
	parent.ajaxload("tipo_box","ajax_load_select_tipo.php?presel="+valores,"fauxpopup();");
	}

	if(variables=="rubro"){
	var id_sup=valores.split("/")[0];
	var presel=valores.split("/")[1];
	parent.ajaxload("subrubro_box","ajax_load_select_clasif.php?id_sup="+id_sup+"&presel="+presel,"atributos_select_clasif();fauxpopup();");
	}

	if(variables=="imagen"){
		var id=valores.split(",")[0];
		var imagen=valores.split(",")[1];
		parent.ajaxload("imagen_"+id,"ajax_load_imagenes.php?img="+imagen+"","fauxpopup();");
	}
}

function load_select(sel_tipo,sel_id_sup,presel){
	if(sel_tipo==1){
		var sel_id="localidad_box";
		if(sel_id_sup.selectedIndex>0){
			document.getElementById("agregar_localidad").title="Agregar localidad en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
			document.getElementById("agregar_localidad").innerHTML="Agregar localidad en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
			document.getElementById("agregar_localidad").style.display="inline";
		}else{
			document.getElementById("agregar_localidad").style.display="none";
		}
		if(document.getElementById("barrio_id")){
			document.getElementById("barrio_id").innerHTML="";
			document.getElementById("agregar_barrio").style.display="none";
		}
	}
	if(sel_tipo==2){
		var sel_id="barrio_box";
		if(sel_id_sup.selectedIndex>0){
			document.getElementById("agregar_barrio").title="Agregar barrio en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
			document.getElementById("agregar_barrio").innerHTML="Agregar barrio en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
			document.getElementById("agregar_barrio").style.display="inline";
		}else{
			document.getElementById("agregar_barrio").style.display="none";
		}
	}
	ajaxload(sel_id,"ajax_load_select.php?id_sup="+sel_id_sup.value+"&presel="+presel+"&tipo="+sel_tipo,"atributos_select("+2+");");
}

function load_select_clasif(sel_id_sup,presel){
	var sel_id="subrubro_box";
	if(sel_id_sup.selectedIndex>0){
		document.getElementById("agregar_subrubro").title="Agregar subrubro en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
		document.getElementById("agregar_subrubro").innerHTML="Agregar subrubro en "+sel_id_sup.options[sel_id_sup.selectedIndex].text;
		document.getElementById("agregar_subrubro").style.display="inline";
	}else{
		document.getElementById("agregar_subrubro").style.display="none";
	}

	ajaxload(sel_id,"ajax_load_select_clasif.php?id_sup="+sel_id_sup.value+"&presel="+presel,"atributos_select_clasif();");
}



areas = new Array();
areas[0] = new Array('');
areas[1] = new Array('A - ADMINISTRATIVO','AC - ADMINISTRATIVO CONTABLE','C - CAJERO','CR - CONTADOR','LA - LICENCIADO EN ADMINISTRACION','LCE - LICENCIADO EN COMERCIO EXTERIOR','LS - LICENCIADO EN COMPUTACION / SISTEMAS','S - SECRETARIA');
areas[2] = new Array('BQ - BIOQUÍMICA ','E - ENFERMERO ','M - MEDICO','P - PSICOLOGO','R - RADIOLOGO');
areas[3] = new Array('ARQ - ARQUITECTO ','IA - ING. AGRONOMO','IAE - ING. AERONAUTICO','IC - ING. CIVIL / CONSTRUCCIONES','IE - ING. ELECTRICISTA','IET - ING. ELECTRONICO','IEM - ING. ELECTROMECANICO','II - ING. INDUSTRIAL','IL - ING. LABORAL / SEGURIDAD / HIG. M. AMBIENTE','IM - ING. MECANICO','IQ - ING. QUÍMICO','IS - ING. EN SISTEMAS / COMPUTACION','QUI - QUIMICO / LIC. QUIMICA');
areas[4] = new Array('MMO - MAESTRO MAYOR DE OBRAS','OI - OPERARIO INDUSTRIAL','OM - OPERARIO MULTIFUNCION','TC - TECNICO EN COMPUTACION / SISTEMAS','TE - TECNICO ELECTRICISTA','TEM - TECNICO ELECTROMECANICO','TET - TECNICO ELECTRONICO','TM - TECNICO MECANICO','TQ - TECNICO QUIMICO','TS - TECNICO EN SEGURIDAD');
areas[5] = new Array('M - MAESTRANZA','PRO - PROMOTORA /DEGUSTADORA (O SIMILAR)','R - REPOSITOR','VI - VENDEDOR INTANGIBLES','VM - VENDEDOR MASIVOS','VV - VENDEDOR VIAJANTE');
areas[6] = new Array('LC - LIC. EN COMUNICACION (O SIMILAR)','LRH - LIC. EN RRHH (O SIMILAR)','OTRAS NO INCLUIDAS');
function cambiar(formulario){
  var i = 0;
  var select1 = formulario['s1'];
  var select2 = formulario['actividad'];
  var vector = areas[select1.selectedIndex];
  if(vector.length)select2.length=vector.length;
  while(vector[i]){
    select2.options[i].value = vector[i];
    select2.options[i].text = vector[i];
    i++;
  }
  select2.options[0].selected = 1;
}