
/*
atributos
	- colores tabs
	- funcion cb
	- clases


*/


	function tmainclick(pid,opid) {
		//alert(pid);
		
		switch(pid) {
			case 1:
				//Inicio
				inicio();
				break;
			case 2:
			    var od = document.getElementById("divinfocurso");
			    if (od) {
				    od.innerHTML = "";
			    }
				break;
			case 3:
				apers();
				break;
			case 4:
				ait();
				break;
			case 6:
				proa();
				break;
			case 7:
				media();
				break;
		}

		var dcont = document.getElementById("txttab"+opid);
		if (dcont)
			dcont.style.display = "none";

		dcont = document.getElementById("txttab"+pid);
		if (dcont)
			dcont.style.display = "inline";

	}
	
	
	function taaclick(pid,opid) {
		//alert("aula abierta " + pid + " " + opid);
		
		var ptype;
		switch(pid) {
			case 1:
				ptype = 1;
				break;
			case 2:
				ptype = 3;
				break;
			case 3:
				ptype = 4;
				break;
			case 4:
				ptype = 5;
				break;
			case 5:
				ptype = 6;
				break;

		}

		clickTabType(getIdLng(),ptype);
	}
	
	function getdivname(pid) {
		switch(pid) {
			case 1:
				dname = "divProgama";
				break;
			case 2:
				dname = "divCondiciones";
				break;
			case 3:
				dname = "divAcredit";
				break;
			case 4:
				dname = "divAcceso";
				break;
		}
		
		return dname;
	}
	


	function tapresclick(pid,opid) {
		//alert("aula presencial " + pid + " " + opid);
		switch(pid) {
			case 2:
				//Condiciones pre-inscripción.
				condicionespre();
				break;

			case 3:
				//Cursos acreditados
				cacredit();
				break;
		}

		var dname = getdivname(opid);
		var dcont = document.getElementById(dname);
		if (dcont)
			dcont.style.display = "none";

		dname = getdivname(pid);
		dcont = document.getElementById(dname);
		if (dcont)
			dcont.style.display = "inline";

	}









	function gtab(pid) {
		this.id = pid;
	}
	
	gtab.prototype.init=function() {
		var nt = this.arrcol.length-1;
		var ot;


		for(var t=0;t<nt;t++) {
			ot = document.getElementById(this.basename+(t+1));
			if (ot) {
				if (t+1 == this.idtab) {
					ot.className = "tabsel";
				}else{
					ot.style.background = this.initcolors[t];
					ot.className = this.uselclass;
				}
			}
		}
	}
	


	gtab.prototype.GetCaptions=function() {
	    var i;
	    var t;

	    var arraycap = new Array(this.nsol);

	    for(i=1;i<=this.nsol;i++) {
	        t = document.getElementById(this.basename+i);
	        if (t) {
	            //arraycap[i-1] = t.innerText;
	            arraycap[i-1] = t.innerHTML;
	        }
	    }

	    return arraycap;
	}
	
	
	gtab.prototype.SetCaption=function(pnum,pcap) {
	    var t = document.getElementById(this.basename+pnum);

		if (t) {
		    //t.innerText = pcap;
		    //t.innerHTML = "Test<font class=tabnum> [55]</font>";
		    t.innerHTML = pcap;
		}
	}
	

	gtab.prototype.TabOver=function(pobj,pnum) {
		//alert(pnum);
		if (this.status[pnum-1] && this.idtab != pnum) {
			//alert(this.arrcol[pnum]);
			pobj.style.background = this.arrcol[pnum];
		}
	}

	gtab.prototype.TabOut=function(pobj,pnum) {
		if (this.status[pnum-1]) {
			if (this.idtab != pnum)
				//pobj.style.background = "#f3f3f3";
				pobj.style.background = this.initcolors[pnum-1];
			else
				pobj.style.background = this.arrcol[0];
		}
	}

	gtab.prototype.TabDown=function(pobj,pnum,ptype) {
		if (this.status[pnum-1]) {
			if (this.obj) {
				//this.obj.style.background = "#f3f3f3";
				this.obj.style.background = this.initcolors[this.idtab-1];
				this.obj.className = this.uselclass;
			} else {
				//alert(this.idtab-1);
			}

			this.obj = pobj;
			this.obj.className = "tabsel";
			this.obj.style.background = this.arrcol[0];
			this.callback(pnum,this.idtab);
			this.idtab = pnum;
		}
	}
	
	gtab.prototype.UpActiveTab=function() {
		if (this.obj) {
			this.obj.style.background = this.initcolors[this.idtab-1];
			this.obj.className = this.uselclass;
			
			this.idtab=0;
			this.obj = "";
		}
	}
	

	gtab.prototype.Enable=function(pnum,psts) {
	    if (this.status[pnum-1] == psts) return;

		var obj = document.getElementById(this.basename+pnum);
		if (obj) {
			if (psts) {
				obj.style.background = "#f3f3f3";
				//obj.style.background = "#e3e3e3";
				obj.className = this.uselclass;
			} else {
				obj.style.background = "LightGrey";
				obj.className = "tabdis";
			}
			this.status[pnum-1]=psts;
		}
	}

	gtab.prototype.EnableDisable=function(pnumobjs) {
	    //alert(pnumobjs);
	    var info = pnumobjs.split("-");

            if (info.length > 0) {
	        var dat = info[1].split(";");
	        if (dat.length > 0) {
	            for (var n=0;n<dat.length-1;n++) {
	                //alert(dat[n]);

	                if (dat[n] == 0) {
	                    this.Enable(n+1,false)
	                    this.status[n] = false;
                    } else {
                        this.Enable(n+1,true)
                        this.status[n] = true;
                    }

                    //Cambiar títulos de las solapas.
                    if (dat[n] != '') {
                        this.SetCaption(n+1, this.captions[n] + ' [' + dat[n] + ']');
                        //this.SetCaption(n+1, this.captions[n] + ' <font class=tabnum>[' + dat[n] + ']</font>');
                    }
	            }
	        }
	        this.SetDefault(info[0]);
	    }
	}

	gtab.prototype.SetDefault=function(pnum) {
		var obj = document.getElementById(this.basename+pnum);
		if (obj) {
			if (this.obj && this.status[this.idtab-1]) {
				this.obj.style.background = "#f3f3f3";
				this.obj.className = this.uselclass;
			}

			this.idtab = pnum;
			this.obj = obj;
			this.obj.className = "tabsel";
			this.obj.style.background = this.arrcol[0];
		}
	}

