//Librería para Quiero
//Objeto creador. Versión 2.0. 20-09-01. Victor UVE.
function creador(){this.setDOM()}
creador.prototype.setDOM=function(){
	if(document.getElementById)creador.DOM2=true;
	else if(document.all)creador.ie=true;
	else creador.ns=true;
	if(creador.DOM2)(document.all)?creador.ie5=true:creador.ns6=true;
}
creador.prototype.crea=function(id,p,x,y,w,h,z,v,f,c){
	var objeto=new creador.instrumenta(id,p,x,y,w,h,z,v,f,c);
	eval("self."+id+"=objeto");
	return objeto;
}
creador.prototype.kill=function(){}
creador.hex=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
creador.instrumenta=function(id,padre,x,y,w,h,z,v,fondo,contenido){
	this.idObj=id;
	this.idCapa="capa"+id;
	this.args=arguments;
	this.getNodo();
	this.setCapa();
	this.setStyle();
}
creador.instrumenta.prototype.getNodo=function(){
	this.padre=this.args[1];
	var enDoc=(this.padre==null)?true:false;
	if(creador.DOM2)this.nodo=(enDoc)?document.getElementsByTagName("BODY").item(0):document.getElementById(this.padre.idCapa);
	else if(creador.ie)this.nodo=(enDoc)?document.body:document.all[this.padre.idCapa];
	else this.nodo=(enDoc)?"document.layers['"+this.idCapa+"']":this.padre.nodo+".document.layers['"+this.idCapa+"']";
}
creador.instrumenta.prototype.setCapa=function(){
	(creador.DOM2)?this.setCapaDOM2():(creador.ie)?this.setCapaIE():this.setCapaNS();
}
creador.instrumenta.prototype.setCapaDOM2=function(){
	var capa=document.createElement("DIV");
	capa.style.position="absolute";
	capa.id=this.idCapa;
	this.nodo.appendChild(capa);
	this.capa=capa;
}
creador.instrumenta.prototype.setCapaIE=function(){
	var a=this.args;
	var div='<div id='+this.idCapa+' style="position:absolute;left:'+a[2]+';top:'+a[3]+';width:'+a[4]+'"></div>';
	this.nodo.insertAdjacentHTML("BeforeEnd",div);
	this.capa=this.nodo.children[this.nodo.children.length-1];
}
creador.instrumenta.prototype.setCapaNS=function(){
	var capa;
	var w=this.args[4];
	if(this.padre==null)capa=document.layers[this.idCapa]=new Layer(w);
	else capa=eval(this.nodo+"=new Layer("+w+","+this.padre.nodo+")");
	this.capa=capa;
	this.capa.style=capa;
}
creador.instrumenta.prototype.setStyle=function(){
	var a=this.args;
	this.move(a[2],a[3]);
	if(a[5]!=null)this.resize(a[4],a[5]);
	if(a[6]!=null)this.stack(a[6]);
	(this.padre==null)?(a[7]=="show")?this.show():this.hide():this.capa.style.visibility="inherit";
	if(a[8]!=null)this.paint(a[8]);
	if(a[9]!=null&&a[9]!="")this.fill(a[9]);
}
creador.instrumenta.prototype.push=function(x,y){
	this.x+=x;
	this.y+=y;
	this.capa.style.left=this.x;
	this.capa.style.top=this.y;
}
creador.instrumenta.prototype.move=function(x,y){
	this.x=this.capa.style.left=x;
	this.y=this.capa.style.top=y;
}
creador.instrumenta.prototype.resize=function(w,h){
	this.w=this.capa.style.width=w;
	this.h=this.capa.style.height=h;
	(creador.ns)?this.capa.resizeTo(w,h):this.clip(0,w,h,0);
}
creador.instrumenta.prototype.clip=function(t,r,b,l){
	if(creador.ns){
		this.capa.clip.top=t;
		this.capa.clip.right=r;
		this.capa.clip.bottom=b;
		this.capa.clip.left=l;
	}else this.capa.style.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
	this.clip.left=l;
	this.clip.right=r;
	this.clip.top=t;
	this.clip.bottom=b;
}
creador.instrumenta.prototype.paint=function(c){
	this.color=c=this.getColor(c);
	(creador.ns)?this.capa.document.bgColor="#"+c:this.capa.style.backgroundColor="#"+c;
}
creador.instrumenta.prototype.getColor=function(c){
	return (typeof(c)=="string")?c:""+this.toHex(c[0])+this.toHex(c[1])+this.toHex(c[2]);
}
creador.instrumenta.prototype.fill=function(c){
	if(creador.ns){
		this.capa.document.open();
		this.capa.document.write(c);
		this.capa.document.close();
	}else this.capa.innerHTML=c;
}
creador.instrumenta.prototype.show=function(){
	this.capa.style.visibility=(creador.ns)?"show":"visible";
}
creador.instrumenta.prototype.hide=function(){
	this.capa.style.visibility=(creador.ns)?"hide":"hidden";
}
creador.instrumenta.prototype.stack=function(z){
	this.z=this.capa.style.zIndex=z;
}
creador.instrumenta.prototype.getDocWidth=function(){
	return (creador.ns)?this.capa.document.width:(creador.ie)?this.capa.scrollWidth:this.capa.offsetWidth;
}
creador.instrumenta.prototype.getDocHeight=function(){
	return (creador.ns)?this.capa.document.height:(creador.ie)?this.capa.scrollHeight:this.capa.offsetHeight;
}
creador.instrumenta.prototype.toHex=function(dec){
	return (dec<0)?"00":(dec>255)?"ff":creador.hex[Math.floor(dec/16)]+""+creador.hex[dec%16];
}
creador.instrumenta.prototype.captureEvent=function(evento,funcion){
	var f="function(event){"+funcion+"}";
	if(creador.ns)eval(this.nodo+".captureEvents(Event."+evento.toUpperCase()+")");
	(creador.DOM2)?(creador.ns6)?eval(this.idObj+".capa.addEventListener('"+evento+"',"+f+",false)"):eval(this.idObj+".capa.attachEvent('on"+evento+"',"+f+")"):eval(this.idObj+".capa.on"+evento+"="+f);
}
creador.instrumenta.prototype.releaseEvent=function(evento){
	if(creador.ns)eval(this.nodo+".releaseEvents(Event."+evento.toUpperCase()+")");
	//(creador.DOM2)?(creador.ns6)?this.capa.removeEventListener(evento):this.capa.detachEvent("on"+evento):eval(this.idObj+".capa.on"+evento+"=null");
	if(!creador.DOM2)eval(this.idObj+".capa.on"+evento+"=null");
}
//Subobjeto scroller. Hereda de creador. Versión 2.1. 29-Enero-2002. Victor UVE.
creador.prototype.addScroll=function(id,doc,x,y,w,h,z,v,inner,res,fl1,fl2,bg){
	var objeto=new creador.scroller(this,doc,id,x,y,w,h,z,v,inner,res,fl1,fl2,bg);
	eval("self."+id+"=objeto");
	return objeto;
}
creador.scroller=function(gestor,doc,id,x,y,w,h,z,v,inner,res,fl1,fl2,bg){
	this.gestor=gestor;
	this.doc=doc;
	this.idObj=id;
	this.ie4=(creador.ie&&navigator.appVersion.indexOf("MSIE 5.")==-1)?1:0;
	this.sto=0;
	this.x=x;
	this.y=this.y0=y;
	this.z=z;
	this.w=w;
	this.h=h;
	this.v=v;
	this.inner=inner;
	this.currentRes=this.res=res;
	this.fl1=fl1;
	this.fl2=fl2;
	this.bgcolor=bg;
	this.swap=(fl1[5]==null||fl2[5]==null)?0:1;
	this.swapped=false;
	this.flShowed=[true,true];
	this.pre=[[new Image,new Image],[new Image,new Image]];
	this.pre[0][0].src=fl1[0];
	this.pre[1][0].src=fl2[0];
	if(this.swap){
		this.pre[0][1].src=fl1[5];
		this.pre[1][1].src=fl2[5];
	}
	this.needed=this.visible=this.speeded=false;
	if(!creador.ns)document.onselectstart=function(){return false}
	this.set();
	return this;
}
creador.scroller.prototype.set=function(){
	var o=this.idObj;
	var idaux=(creador.DOM2)?"id":"name";
	var s=["<a href=javascript:void(null) onmouseover="+o+".perform(",") onmouseout="+o+".stop(",")><img "+idaux+"=imag"+o," border=0></a>",") onmousedown="+o+".speedUp(",") onmouseup="+o+".relax("];
	var f1=s[0]+1+s[4]+s[5]+s[1]+0+s[2]+0+" src="+this.fl1[0]+" width="+this.fl1[1]+" height="+this.fl1[2]+s[3];
	var f2=s[0]+0+s[4]+s[5]+s[1]+1+s[2]+1+" src="+this.fl2[0]+" width="+this.fl2[1]+" height="+this.fl2[2]+s[3];
	this.madre=this.gestor.crea(o+"madre",this.doc,this.x,this.y,this.w,this.h,this.z,null,this.bgcolor);
	this.hija=this.gestor.crea(o+"hija",this.madre,0,0,this.w,null);
	this.flUP=this.gestor.crea(o+"fl0",this.doc,this.fl1[3],this.fl1[4],this.fl1[1],this.fl1[2],this.z,null,null,f1);
	this.flDOWN=this.gestor.crea(o+"fl1",this.doc,this.fl2[3],this.fl2[4],this.fl2[1],this.fl2[2],this.z,null,null,f2);	
	if(this.swap){
		this.img=[];
		var nodoaux=[this.flUP.nodo,this.flDOWN.nodo];
		for(var i=0;i<2;i++)this.img[i]=(creador.DOM2)?document.getElementById("imag"+o+i):(creador.ie)?eval("document.all.imag"+o+i):eval(nodoaux[i]+".document.images["+0+"]");
	}
	if(this.v=="show")this.show();
	if(this.inner!=null)this.refresh(this.inner);
}
creador.scroller.prototype.refresh=function(inner,nextEv){
	var v=this.visible;
	this.nextEv=nextEv;
	this.hide();
	this.hija.fill(inner);
	this.hija.move(0,0);
	if(this.ie4)this.sto=setTimeout(this.idObj+".actualiza('"+v+"')",100);
	else this.actualiza(v);
}
creador.scroller.prototype.actualiza=function(v){
	clearTimeout(this.sto);
	var o=this.id;
	this.hija.h=this.hija.getDocHeight();
	this.needed=(this.hija.h>this.h)?1:0;
	if(this.needed){
		this.minY=0;
		this.maxY=(this.hija.h-this.h)*-1;
		this.signos=[[">","<",-1,this.flUP,this.flDOWN,this.maxY,this.minY],["<",">",1,this.flDOWN,this.flUP,this.minY,this.maxY]];
	}
	if(v)this.show();
	if(this.nextEv!=null)eval(this.nextEv);
}
creador.scroller.prototype.show=function(){
	if(!this.visible){
		this.madre.show();
		this.hija.show();
		if(this.needed){
			this.flShowed=[true,true];
			if(this.hija.y<this.minY)this.flUP.show();else this.flShowed[0]=false;
			if(this.hija.y>this.maxY)this.flDOWN.show();else this.flShowed[1]=false;
		}
		this.visible=true;
	}
}
creador.scroller.prototype.hide=function(){
	if(this.visible){
		this.madre.hide();
		this.hija.hide();
		this.flUP.hide();
		this.flDOWN.hide();
		this.visible=false;
	}
}
creador.scroller.prototype.stop=function(cual){
	clearTimeout(this.sto);
	if(this.swap&&this.swapped){
		this.img[cual].src=this.pre[cual][0].src;
		this.swapped=false;
	}
	this.currentRes=this.res;
	this.speeded=false;
}
creador.scroller.prototype.speedUp=function(){
	if(!this.speeded){
		this.currentRes*=2;
		this.speeded=true;
	}
	if(creador.ie5)window.focus();
}
creador.scroller.prototype.relax=function(){
	if(this.speeded){
		var r=Math.floor(this.currentRes/2);
		this.currentRes=(r<1)?1:r;
		this.speeded=false;
	}
}
creador.scroller.prototype.perform=function(dir){
	if(this.sto)clearTimeout(this.sto);
	var cual=(dir==0)?1:0;
	if(this.swap&&!this.swapped&&this.flShowed[cual]){
		this.img[cual].src=this.pre[cual][1].src;
		this.swapped=true;
	}
	if(eval(this.hija.y+this.signos[dir][0]+this.signos[dir][5])){
		if(!this.flShowed[dir]){
			this.signos[dir][3].show();
			this.flShowed[dir]=true;
		}
		if(eval(this.hija.y+this.signos[dir][1]+this.signos[dir][5]+this.signos[dir][2]*25))if(this.currentRes!=1)this.currentRes--;
		this.hija.push(0,this.signos[dir][2]*this.currentRes);
	}else{
		this.signos[dir][4].hide();
		this.flShowed[cual]=false;
		this.stop(cual);
	}
	this.sto=setTimeout(this.idObj+'.perform('+dir+')',50);
}
creador.scroller.prototype.getPos=function(){return -this.hija.y}
creador.scroller.prototype.move=function(y){
	y=-y;
	if(y<this.maxY)y=this.maxY;
	this.hija.move(0,y);
	if(this.needed){
		if(this.hija.y<this.minY){
			this.flShowed[0]=true;
			this.flUP.show();
		}else{
			this.flShowed[0]=false;
			this.flUP.hide();
		}
		if(this.hija.y>this.maxY){
			this.flShowed[1]=true;
			this.flDOWN.show();
		}else{
			this.flShowed[1]=false;
			this.flDOWN.hide();
		}
	}
}
creador.scroller.prototype.moveToEnd=function(){this.move(-this.maxY)}
//funciones para hacer tablas
function tablero(sp){this.sp=sp}
tablero.prototype.getTd=function(borde,bg,h,espan){
	espan=espan?" colspan="+espan:"";
	var bg=bg?" bgcolor="+bg:"";
	var clase=borde?"":" class=sp";
	h=h?" height="+h:"";
	var c=borde?"<img src="+this.sp+" width=1 height=1>":"&nbsp;";
	return "<td"+espan+h+bg+clase+">"+c+"</td>";
}
tablero.prototype.getLinea=function(espan,bg,h){
	h=h||1;
	bg=(bg==null)?"":" bgcolor="+bg;
	return "<tr><td colspan="+espan+bg+"><img src="+this.sp+" width=1 height="+h+"></td></tr>";
}
tablero.prototype.getTable=function(w,h,bg,bgTable,quesevea){
	var wt=0;
	bgTable=bgTable?" bgcolor="+bgTable:"";
	bg=bg?" bgcolor="+bg:"";
	quesevea=quesevea||0;
	for(var i=0;i<w.length;i++)wt+=w[i];
	var t="<table width="+wt+" cellpadding=0 cellspacing=0 border="+quesevea+bgTable+"><tr>";
	for(var i=0;i<w.length;i++)t+="<td width="+w[i]+bg+"><img src="+this.sp+" width="+w[i]+" height="+h+"></td>";
	return t+"</tr>";
}
//funciones para abrir ventana sin marcos
function getX(w){return window.screenLeft;}
function getY(h){return window.screenTop;}
function newWindow(url,name,w,h,x,y,scrollbar,centradoEspecial){
	scrollbar=(scrollbar==null)?"no":"yes";
	var ie=(document.all);
	if(ie){w+=2;h+=2;}
	x=x||(ie&&centradoEspecial)?getX(w):(screen.width-w)/2;
	y=y||(ie&&centradoEspecial)?getY(h):(screen.height-h)/2;
	var purl=(ie)?"":url;
	var wp=ie?"1":"0,width="+w+",height="+h+",left="+x+",top="+y;
	var miv=window.open(purl,name,"toolbar=no,location=no,directories=no,status=no,scrollbars="+scrollbar+",resizable=no");
	if(ie){
		window.focus();
		miv.moveTo(5000,0);
		miv.v1=true;
		miv.document.write(windowBorder(url,name));
		miv.document.close();
		miv.resizeTo(w,h);
		miv.moveTo(x,y);
	}
	miv.focus();
	return miv;
}
function windowBorder(p,n){
	var t='<HTML><HEAD><TITLE>Intranet</TITLE><script>\n'+
		'p=function(){v1.document.bgColor=v2.document.bgColor=v3.document.bgColor=v4.document.bgColor="#000000";}\n'+
		'b=function(){if(frames.length>3)p();else setTimeout("b()",200);}\n'+
		'b();</script></HEAD>\n'+
		'<frameset border=0 framespacing=0 frameborder=0 cols="1,100%,1">\n'+
		'<frame name=v1 src="about:blank" scrolling=no noresize>\n'+
		'<frameset border=0 framespacing=0 frameborder=0 rows="1,100%,1">\n'+
		'<frame name=v2 src="about:blank" scrolling=no noresize frameborder=0 marginheight=0 marginwidth=0>\n'+
		'<frame name=main'+n+' src="'+p+'">\n'+
		'<frame name=v3 src="about:blank" scrolling=no noresize frameborder=0 marginheight=0 marginwidth=0>\n'+
		'</frameset>\n'+
		'<frame name=v4 src="about:blank" scrolling=no noresize frameborder=0 marginheight=0 marginwidth=0>\n'+
		'</frameset>\n'+
		'</HTML>';
	return t;
}
//Hacer que una capa mueva la ventana
creador.instrumenta.prototype.setAsWindowDragger=function(){
	if(creador.ie||creador.ie5){
		var o=this.idObj;
		var m=" onmouse";
		this.wDrag=false;
		this.wXoffset=this.wYoffset=0;
		this.fill("<img style='position:absolute;left:-100px;top:-50px'"+m+"down="+o+".setWindowDrag(1)"+m+"up="+o+".setWindowDrag(0)"+m+"move="+o+".dragWindow() src='' width="+(this.w+100)+" height="+(this.h+100)+">");
		document.onmousemove=document.onselectstart=document.ondragstart=new Function(this.idObj+".dragWindow();return false");
	}
}
creador.instrumenta.prototype.setWindowDrag=function(s){
	if(s){this.wXoffset=event.x;this.wYoffset=event.y;}
	this.wDrag=s;
}
creador.instrumenta.prototype.dragWindow=function(){if(this.wDrag)top.window.moveTo(event.screenX-this.wXoffset-1,event.screenY-this.wYoffset-1);}

