//fpv=6
function mw_colecciondedatos_alternar_subdatos_onchange_select(selectelem,datosalternoskey){
	if(	selectelem["_mw_colecciondedatos_alternar_subdatos"]){
		return	selectelem["_mw_colecciondedatos_alternar_subdatos"].onselectchange();
	}
	var man=new mw_colecciondedatos_alternar_subdatos(datosalternoskey);
	man.set_select_elem(selectelem);
	return	selectelem["_mw_colecciondedatos_alternar_subdatos"].onselectchange();
}
function mw_colecciondedatos_alternar_subdatos(datosalternoskey){
	this.datosalternoskey=datosalternoskey;
	this.onselectchange=function(){
		this.ocultarsubdatos();
		if(this.select_elem){
			var cod=	this.select_elem.value;
			var e=this.get_subdatoelem(cod);
			if(e){
				e.mostrar();	
			}
		}
	}
	this.ocultarsubdatos=function(){
		if(!this.set_subdatoselems()){
			return false;	
		}
		for (var c in this.subdatoselems){
			this.subdatoselems[c].ocultar();	
		}
	}
	this.get_subdatoelem=function(cod){
		if(!cod){
			return false;	
		}
		if(!this.set_subdatoselems()){
			return false;	
		}
		if(this.subdatoselems[cod]){
			return 	this.subdatoselems[cod];
		}

	}
	this.set_select_elem=function(elem){
		this.select_elem=elem;
		this.select_elem._mw_colecciondedatos_alternar_subdatos=this;
	}
	this.set_subdatoselems=function(){
		if(this.subdatoselems){
			return true;	
		}
		return this.set_subdatos_elems_by_select();
	}
	this.set_subdatos_elems_by_select=function(){
		if(!this.select_elem){
			return false;	
		}
		var sdelems=new Object;
		var c;
		var ok=false;
		for(var i=0;i<this.select_elem.options.length;i++){
			c=this.select_elem.options[i].value;
			if(c){
				ok=true;
				sdelems[c]=new mw_colecciondedatos_alternar_subdatos_elem(c,this);
			}
		}
		if(ok){
			this.subdatoselems=	sdelems;
			return true;
		}
			
	}
}
function mw_colecciondedatos_alternar_subdatos_elem(cod,man){
	this.man=man;
	this.cod=cod;
	this.ocultar=function(v){
		return this.set_visible(false);
	}
	this.set_visible=function(v){
		if(!v){
			v=false;	
		}
		if(!this.set_elems()){
			return false;	
		}
		for (var i=0; i<this.elems.length;i++){
			if(v){
				fp_show_obj(this.elems[i]);	
			}else{
				fp_hide_obj(this.elems[i]);	
			}
		}
		
	}
	this.mostrar=function(){
		return this.set_visible(true);
	}
	this.set_elems=function(){
		if(this.elems){
			return true;	
		}
		var pelem=this.man.datosalternoskey;
		if(!pelem){
			return false;
		}
		this.elems=new Array();
		var nombredecampo=pelem+"[valor]["+this.cod+"]";
		var eid="fptr_"+nombredecampo;
		var e;
		if(e=fp_get_element_by_id(eid)){
			this.elems.push(e);	
		}
		eid="fptbody_"+nombredecampo;
		if(e=fp_get_element_by_id(eid)){
			this.elems.push(e);	
		}
		eid="fptrtitulo_"+nombredecampo;
		if(e=fp_get_element_by_id(eid)){
			this.elems.push(e);	
		}
		return true;
	}
}
function mw_colecciondedatos_actinputafterfilequickupload(inputobj,valor,inputselector) {
	if (inputselector){
		fp_hide_obj(inputselector);
	}
	inputobj.value=valor;
	fp_show_obj(inputobj);
}
function mw_colecciondedatos_act_imgsizefromselect(imgselectobj,hinput,winput,urlimg) {
	if (val=fp_input_get_val_inputorselect(imgselectobj)){
		var imgurl=urlimg+"/"+val;
		return mw_colecciondedatos_act_size(imgurl,hinput,winput);
	}
}
var http_request = false;

function mw_colecciondedatos_act_size(urlimg,hinput,winput,modofkeditor) {
	if (!urlimg){
		return false;	
	}
	var url=fp_url_get()+"output/imginfo.php?href="+urlimg;
	var fp_ajax;
	if (fp_ajax=fp_ajax_crear_Request()){
		fp_ajax.onreadystatechange = function (){
			var data;
			if(data=fp_ajax_xml2obj(fp_ajax)){
				if (modofkeditor){
					hinput.setValue(data.height);
					winput.setValue(data.width);
				}else{
					hinput.value=data.height;
					winput.value=data.width;
				}
			}
			
		}
		fp_ajax.open("GET", url, true);
		fp_ajax.send(null);	
	}
}
function mw_colecciondedatos_act_largocss(id_val,id_largo,id_dim) {
	var vallargo=fp_get_valor_input(id_largo)
	var dim=fp_get_valor_select(id_dim)
	if (!isNaN(parseInt(vallargo))){
		fp_setvalue(id_val,parseInt(vallargo)+dim)
		fp_setvalue(id_largo,parseInt(vallargo))
	}else if(dim=="auto"){
		fp_setvalue(id_val,'auto')
		fp_setvalue(id_largo,'')
	}else{
		fp_setvalue(id_val,'')
		fp_setvalue(id_largo,'')
	}
}

function  mw_colecciondedatos_resaltarbgcolor(id,color){
	fp_cambiar_style(id,'backgroundColor',color);
}

function mw_colecciondedatos_color_get_selector(elemcrt,estilo,usarcoloresperfil,parenttagname){
	if (usarcoloresperfil){
		usarcoloresperfil="true";	
	}else{
		usarcoloresperfil="false";		
	}
	if (!parenttagname){
		parenttagname="TD";	
	}
	
	url=fp_url_get()+"output/selectcolor.php?estilo="+estilo+"&usarcoloresperfil="+usarcoloresperfil;
	url=url+"&parenttagname="+parenttagname;
	contenedorcrt=elemcrt.parentNode;
	if (elemtd=mw_dom_get_parent_by_tagname(contenedorcrt,parenttagname)){
		if (inputs=elemtd.getElementsByTagName("INPUT")){
			input=inputs[0];
			url=url+"&valor="+input.value;
		}
	}
	fp_ajax_cargaURL_onelem(url,contenedorcrt,false);
}
function mw_colecciondedatos_color_selectoronch(sel,parenttagname){
	if (elemtd=mw_dom_get_parent_by_tagname(sel,parenttagname)){
		if (inputs=elemtd.getElementsByTagName("INPUT")){
			input=inputs[0];
			input.value=sel.options[sel.selectedIndex].value;
			mw_colecciondedatos_color_inputonch(input,parenttagname);
		}
	}
}
function mw_colecciondedatos_color_inputonch(input,parenttagname){
	if (!parenttagname){
		parenttagname="TD";	
	}
	if (elemtd=mw_dom_get_parent_by_tagname(input,parenttagname)){
		if (muestras=elemtd.getElementsByTagName("SPAN")){
			muestras[0].style.backgroundColor=input.value;
		}
	}
}



