	var nPagina=1;
	var IdCat = -1;
	var IdItemCat = -1;
	var lstIdCat = -1;
	var nNivel = 0;
	var IdCatParent = 0;
	var IdOperacion=-1;
	var sFiltroFormatos = "11111";
	var TreeItems;
	var IdTypeObj=1;


	var wiax;
	var wiaxaaap;
	var ottabmain;
	var ottab;	//Solapas principales aaap.
	var ottab2;  //Solapas programa.
	var tf;     //Overlay
	var oquest;	//Question object

	//var gaurl = "http://esbar925/institutoalcon/";
	//var gaurl = "http://" + window.location.host + "/institutoalcon/";
	var gaurl = "http://www.institutoalcon.com/";


	var iactrl;
	function IAControl() {
		this.nPagina=1;
		this.mx=0;
		this.my=0;
		this.Body = document.getElementsByTagName("body").item(0);
		this.form = document.getElementsByTagName("form").item(0);
		this.dmsg = document.createElement("div");
		this.dmsg.setAttribute('id','dmsg');
		this.dmsg.style.display = 'none';
		//this.dmsg.className = "hlp";
		this.dmsg.style.position = 'absolute';
		this.dmsg.style.width = '350px';
		//this.dmsg.className="hlp";
		this.dmsg.style.background = "gold";
		this.Body.appendChild(this.dmsg);


		/*
		this.txtiaxpos = document.createElement("input");
		this.txtiaxpos.type='text'; 
		this.txtiaxpos.name="txtiaxpos"; 
		this.txtiaxpos.id="txtiaxpos";
		this.txtiaxpos.style.width="100px"
		this.form.appendChild(this.txtiaxpos);
		//this.objxx = document.getElementById("txtiaxpos");
		*/




		this.init = function() {
			//alert("empezando ...");
			//this.addMouseMoveEvent();
			
			this.addClickEventHandler (this.DocumentOnClickHandler);
			this.addMouseMoveEventHandler (this.DocumentOnMouseMoveHandler);
		}

		this.addMouseMoveEvent = function() {
			//document.getElementById("testImage").onmousemove = this.TrackCoordinates;
			if (document.all) {
				document.onmousemove = this.TrackCoordinates;
			} else {
				document.captureEvents(Event.MOUSEMOVE);
				document.onmousemove = this.TrackCoordinates;
			}

			document.onclick = this.MouseClick;
		}

		this.TrackCoordinates = function(evt) {
			this.mx = (evt) ? evt.pageX : document.body.scrollLeft+event.clientX;
			this.my = (evt) ? evt.pageY : document.body.scrollTop+event.clientY;

			//if (this.txtiaxpos)
			//	this.txtiaxpos.value = mx;
			/*objxx = document.getElementById("txtiaxpos");
			if (objxx)
				objxx.value = this.mx;
			else
				window.status="err ..";
			*/

			if (iactrl) {
				iactrl.mx = this.mx;
				iactrl.my = this.my;
			}

			window.status="x: " + this.mx + " my: " + this.my;
		}
		
		this.MouseClick = function(evt) {
			//alert("doc click.");
			var dmsg = document.getElementById("dmsg");
			if (dmsg) {
				dmsg.style.display = 'none';
			}

		}

		this.getX = function() {
			return this.mx;
		}




		this.addClickEventHandler = function(func) {
			var previous_handler = document.onclick;

			if(typeof document.onclick != "function") document.onclick = func; 
			else document.onclick = function(e)  {             
				previous_handler (e);             
				func(e);
			}
		}

		this.DocumentOnClickHandler = function (evt){
			var dmsg = document.getElementById("dmsg");
			if (dmsg) {
				dmsg.style.display = 'none';
			}
		}

		this.addMouseMoveEventHandler = function(func) {
			if (!document.all)
				document.captureEvents(Event.MOUSEMOVE);

			var previous_handler = document.onmousemove;

			if(typeof document.onmousemove != "function") document.onmousemove = func; 
			else document.onmousemove = function(e)  {             
				previous_handler (e);             
				func(e);
			}
		}

		this.DocumentOnMouseMoveHandler = function (evt){
			this.mx = (evt) ? evt.pageX : document.body.scrollLeft+event.clientX;
			this.my = (evt) ? evt.pageY : document.body.scrollTop+event.clientY;

			if (iactrl) {
				iactrl.mx = this.mx;
				iactrl.my = this.my;
			}

			//window.status="x: " + this.mx + " my: " + this.my;
		}
	}


	function InitTreeArray() {
		var otxtItemNum = document.getElementById("txttreeparents");

		if (otxtItemNum) {
			TreeItems = new Array();

			var nmax = otxtItemNum.value * 1;
			var ni;

			for (ni=0;ni<nmax;ni++) {
				TreeItems[ni] = -1;
			}
		}
	}


	function restoretreestatus() {
		var otxtItemNum = document.getElementById("txttreeparents");

		if (otxtItemNum) {
			var nmax = otxtItemNum.value * 1;
			var ni;

			for (ni=0;ni<nmax;ni++) {
				if (TreeItems[ni] > -1) {
					verocultar(TreeItems[ni],ni) ;
				}
			}
		}
	}


	function colexp(iddiv,pnum) {
		verocultar(iddiv,pnum);
	}


	function verocultar(iddiv,pnum) {
		var obj = document.getElementById("div" + iddiv);
		var img = document.getElementById("timg_" + iddiv);

		if (obj) {
			if (obj.style.display == "none") {
				obj.style.display = "inline";
				img.src = "imagesIA/menos.jpg";
			//	TreeItems[pnum] = iddiv;
			} else {
				obj.style.display = "none";
				img.src = "imagesIA/mas.jpg";
			//	TreeItems[pnum] = -1;
			}
		}
	}


	//clickitem(pidlng, idc,pg,ptype)
	function ver2(idlng, idc, idcp, lvl) {
		if (IdItemCat == idc) return;

		var obj = document.getElementById("divi" + idc);

		//SelItem(idc);


		nNivel = lvl;		//Nivel de anidación.
		IdCat = idc;		//Categoría.
		IdItemCat = idc;		//Categoría.
		IdCatParent = idcp;	//Categoría padre.
		nPagina=1;
		lstIdCat = -1;

		var param = "?OP=1&IDC=" + idc + "&IDCP=" + idcp + "&LVL=" + lvl + "&FIL=" + sFiltroFormatos + "&IDLNG=" + idlng;
		httpcall(param,1);
	}


	function SelItem(idc) {
		var img;

		if (IdItemCat>-1) {
			img = document.getElementById("timg_" + IdItemCat);

			if (img) {
				img.src = "images/box.jpg";
			}
		}

		img = document.getElementById("timg_" + idc);
		if (img) {
			img.src = "images/fbox.jpg";
		}
	}


	function SelSubItem(idc) {
		var tdobj = document.getElementById("ttd" + idc);
		if (tdobj) {
			tdobj.style.backgroundColor="#dbdbdb";
		}
	}


	function UnSelSubItem(idc) {
		var tdobj = document.getElementById("ttd" + idc);
		if (tdobj) {
			tdobj.style.backgroundColor="#f3f3f3";
		}
	}


	function clickitem(pidlng, idc, pg, ptype) {
		IdOperacion=1;

		var cobj = document.getElementById("divContenidos");
		if (cobj) {
			cobj.innerHTML = "<table width=100% height=100% border=0><tr><td align=center><img src=images/loading-spiral.gif></td></tr></table>";
		}

		vercont(pidlng, idc, pg, ptype);
	}


	function vercont(pidlng, idc, pg, ptype) {
		if (lstIdCat > -1) {
			UnSelSubItem(lstIdCat);
		}

		lstIdCat = idc;
		IdCat = idc;
		IdTypeObj = ptype;

		SelSubItem(idc);


		//IdOperacion=1;

		var param = "?OP=5&IDC=" + idc + "&FIL=" + sFiltroFormatos + "&PG=" + pg + "&LVL=" + nNivel + "&IDLNG=" + pidlng + "&TYPE=" + ptype;
		wiaxaaap.call(Contenidos,param);
	}


	function clickTabType(pidlng,ptype) {
		if (IdOperacion == 1) {
			vercont(pidlng, IdCat,1,ptype);
		} else {
			buscar(1,ptype);
		}
	}

	function clickTabProgram(pidlng,plstnum,pnum) {
		alert(plstnum + " "+ pnum);
		switch (pnum) {
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
		}
	}


/*
	function cpath(plvl) {
		var param = "?OP=1&IDC=" + ArrayIDs[plvl] + "&IDCP=-1&LVL=" + plvl + "&FIL=" + sFiltroFormatos + "&IDLNG=1";
		httpcall(param,1);
	}
*/


	function go(npag) {
		nPagina = npag;

		if (IdOperacion==1) {
			//var idlng = getIdLng();
			vercont(getIdLng(),IdCat,nPagina,IdTypeObj);
		}else if (IdOperacion==2) {
			//Buscar
			buscar(npag,IdTypeObj);
		}
	}

/*
	function aplicarfiltro() {
		var strFormat = "";

		strFormat = abin("chkIMG");
		strFormat += abin("chkANI");
		strFormat += abin("chkSIM");
		strFormat += abin("chkECU");
		strFormat += abin("chkAPR");
		sFiltroFormatos = strFormat;

		var txtIdlng = document.getElementById("txtIdLng");

		if (txtIdlng) {
			if (txtIdlng.value != '') {
				if (IdOperacion==2) {
					//Buscar & filtrar árbol.
					var param = "?OP=130&IDC=" + IdCat + "&IDCP=" + IdCatParent + "&LVL=" + nNivel + "&FIL=" + sFiltroFormatos + "&IDLNG="+txtIdlng.value + "&QRY=" + escape(document.frmia.txtbuscar.value) + "&LNG=" + document.frmia.txtLng.value;
					httpcall(param,130);
				} else {
					var param = "?OP=2&IDC=" + IdCat + "&IDCP=" + IdCatParent + "&LVL=" + nNivel + "&FIL=" + sFiltroFormatos + "&IDLNG="+txtIdlng.value;
					httpcall(param,2);
				}
			}
		}
	}
*/

	function abin(pchk) {
		if (document.getElementById(pchk).checked){
			return "1";
		} else {
			return "0";
		}
	}

	function ait() {
		//var param = "?OP=100&IDLNG=1";
		//wiax.call(GetAIT,param);
		var slng = getLng();
		var liax  = new iajax(gaurl + "ait" + slng + ".htm");
		liax.call(GetAIT,"");
	}

	/*function aitPerlas() {
		var slng = getLng();
		var liax  = new iajax("http://esbar925/institutoalcon/aitPerlas" + slng + ".htm");
		liax.call(GetAIT,"");
	}

	function aitRetinaResidentes() {
		var slng = getLng(); 
		var liax  = new iajax("http://esbar925/institutoalcon/aitRetinaResidentes" + slng + ".htm");
		liax.call(GetAIT,"");
	}*/
	
	function aitLink(psbasename) {
		var slng = getLng(); 
		var liax  = new iajax(gaurl + psbasename + slng + ".htm");
		liax.call(GetAIT,"");
	
	}




	function proa() {
		//var param = "?OP=101&IDLNG=1";
		//wiax.call(GetPROA,param);
		var liax  = new iajax(gaurl + "proaESP.htm");
		liax.call(GetPROA,"");
	}

	function proaLink(psbasename) {
		var slng = getLng(); 
		var liax  = new iajax(gaurl + psbasename + slng + ".htm");
		liax.call(GetPROA,"");
	
	}


	function media() {
		document.getElementById("divmedia").innerHTML = "<img src='images/cargando.gif'>"
		var mediaiax = new iajax("http://www.institutoalcon.com/Mediateca/media" + getLng() + ".aspx");
		mediaiax.call(GetMedia,"");
		/*document.getElementById("divmedia").innerHTML = "<img src='images/cargando.gif'>"
		var mediaiax = new iajax(gaurl + "Mediateca2/media.aspx?LNG=" + getLng());
		mediaiax.call(GetMedia,"");*/
	}

	function mp() {
		var param = "?OP=103&LNG="+ getLng() + "&IDLNG="+getIdLng();
		//httpcall(param,103);
		wiax.call(GetMP,param);
	}


	function inicio(){
		/*
		var slng;
		//var txtlng = document.getElementById("txtLng");
		//slng = txtlng.value;
		slng ="ESP";

		var param = "?OP=150&LNG="+getLng();
		//httpcall(param,150);
		//alert(wiax.requestURL+param);
		'wiax.call(AHome,param);
		*/
		var slng = getLng();
		var liax  = new iajax(gaurl + "home" + slng + ".aspx");
		liax.call(AHome,"");
	}
	
	function apers(spage) {
		var slng = getLng();
		var liax  = new iajax(gaurl + "aper" + slng + ".htm");
		liax.call(AAPer,"");
	}





	function condicionespre() {
		var liax  = new iajax(gaurl + "condicionesESP.htm");
		liax.call(ACondiciones,"");
	}


	function cacredit() {
		var liax  = new iajax(gaurl + "acreditadosESP.htm");
		liax.call(AAcreditados,"");
	}









	function buscarclick(pg) {
		IdTypeObj = 1;
		buscar(pg,1);
	}
	
	function buscarkp(e) {
	
		var charCode = (e.which) ? e.which : e.keyCode
		if (charCode == 13) {
			buscarclick(1);
			return false;
		}
			
	}

	function buscar(pg, ptype) {
		//if (document.frmia.txtbuscar.value != "") {
		if (document.forms[0].txtbuscar.value != "") {
			IdOperacion=2;

			IdTypeObj = ptype;
			
			var aut = '';//escape(document.frmia.cmbAutores.value);
			var param = "?OP=110&QRY=" + escape(document.forms[0].txtbuscar.value) + "&IDLNG=" + getIdLng() + "&PG=" + pg + "&FIL=" + sFiltroFormatos + "&LNG=" + document.forms[0].txtLng.value + "&AUT=" + aut + "&TYPE=" + ptype;


			var cobj = document.getElementById("divContenidos");
			if (cobj) {
				cobj.innerHTML = "<table width=100% height=100% border=0><tr><td align=center><img src=images/loading-spiral.gif></td></tr></table>";
			}
			
			//alert(param);



			wiax.call(ABuscar,param);
		}
	}


	function __cidioma(pslng) {
		document.frmia.target = "";
		document.frmia.txtLng.value = pslng;
		document.frmia.submit();
	}


 	function VerSObj(uid,tipo) {
		/*
		document.frmIAVisor.txtSI.value = "";
		document.frmIAVisor.txtUI.value = uid;
		document.frmIAVisor.txtTYP.value = tipo;
		document.frmIAVisor.action = "nvisor.asp";
		document.frmIAVisor.target = "top";
		document.frmIAVisor.submit();
		*/

		//uid = Request.Form("txtUI")
		//lng = Request.Form("txtLng")


		var h = screen.availHeight;
		var w = screen.availWidth;

		window.open ("nvisor.asp?LNG=" + getLng() + "&UID=" +uid +"&TYPE="+tipo,222,"top=0,left=0,height="+h+",width="+w+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}



	//Función de inicio.
	function carga(idtab) {
		var ntab = "tab"+idtab
		var tab = document.getElementById(ntab);
		if (tab) {
		    setActiveTab(tab);
		}



		InitTreeArray();





		//wiax = new iajax("http://esbar919/institutoalcon/arbol_ajax2.asp");
		wiax = new iajax(gaurl + "arbol_ajax2.asp");
		wiaxaaap = new iajax(gaurl + "ContenidosAAAP.asp");

		inicio();
	
	//return;
	
		ottabmain = new gtab(3);
		ottabmain.basename="tm";
		ottabmain.idtab = 1;
		ottabmain.obj = document.getElementById(ottabmain.basename+ottabmain.idtab);
		ottabmain.arrcol= new Array("white","black","#79b4ca","#406f84","#7dbb70","black","black","black");
		ottabmain.idlng = getIdLng();
		ottabmain.nsol=6;
		ottabmain.status= new Array(true,true,true,true,true,true,true);
		ottabmain.initcolors = new Array("black","#417ca0","#16375a","#619f38","#d58a31","#757983","#725f27");
		ottabmain.uselclass = "tabunsel2";
		ottabmain.callback = tmainclick;
		ottabmain.init();


		ottab = new gtab(1);
		ottab.basename="tt";
		ottab.idtab = 1;
		ottab.obj = document.getElementById(ottab.basename+ottab.idtab);
		ottab.arrcol= new Array("white","#ffdf79","#b9cb99","#fea2a2","#e3e3b0","#d2e8f0");
		ottab.idlng = getIdLng();
		ottab.nsol=5;
		ottab.status= new Array(true,true,true,true,true);
		ottab.captions = ottab.GetCaptions();
		ottab.initcolors = new Array("white","white","white","white","white");
		ottab.uselclass = "tabunsel";
		ottab.callback = taaclick;
		ottab.init();
		ottab.EnableDisable('0-;;;;;');


		ottab2 = new gtab(2);
		ottab2.basename="tp";
		ottab2.idtab = 1;
		ottab2.obj = document.getElementById(ottab2.basename+ottab2.idtab);
		ottab2.arrcol= new Array("white","white","white","white","white");
		ottab2.idlng = getIdLng();
		ottab2.nsol=4;
		ottab2.status= new Array(true,true,true,true);
		ottab2.captions = ottab2.GetCaptions();
		ottab2.initcolors = new Array("#d2e8f0","#d2e8f0","#d2e8f0","#d2e8f0");
		ottab2.uselclass = "tabunsel3";
		ottab2.callback = tapresclick;
		ottab2.init();





		//oquest = new QuestionObj();

		iactrl = new IAControl();
		iactrl.init();


		//alert("carga IA");
	}


	function calendar() {
		var dcont = document.getElementById("txttab"+ottabmain.idtab);
		if (dcont)
			dcont.style.display = "none";
		ottabmain.UpActiveTab();

		//return;
		//resetActiveTab();

		var calobj = document.getElementById("divcal");
		if (calobj) {
			calobj.style.display = "inline";

			var param = "?OP=120&IDLNG=1";;
			//httpcall(param,120);
			wiax.call(GetCal,param);
		}
	}


	function Pregunta(){
		var w,h;
		var t,l;

		var txtlng = document.getElementById("txtLng");

		if (txtlng) {
			if (txtlng.value != '') {
				h = screen.availHeight;
				w = screen.availWidth;
				t = (h/2) - 220;
				l = (w/2) - 300;
				window.open ("question.asp?LNG="+txtlng.value,114,"top=" + t + ",left=" + l + ",height=440,width=600,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");	
			}
		}
	}


	function ReloadContens() {
		if (IdOperacion == 1)
			vercont(getIdLng(), IdCat,1,IdTypeObj);
		else
			buscar(1,IdTypeObj);
	}


	function VerCOL(id) {
		//document.frmIAVisor.action = "/Cursos/Curso.asp";
		document.frmIAVisor.action = "http://www.institutoalcon.com/Cursos/Curso.asp";
		document.frmIAVisor.txtCI.value=id;
		document.frmIAVisor.txtUSR.value="";
		document.frmIAVisor.target = "top";
		document.frmIAVisor.submit();
	}


	function VerPDFCOL(psPDF) {
		window.open('/Cursos/PDF/' + psPDF, 'COLPDF', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes')
	}


	function evento(d,m,y) {
		/*var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 210;
		l = (w/2) - 315;

		window.open ("eventos.asp?D="+d+"&M="+m+"&Y="+y,2,"top=" + t + ",left=" + l + ",height=420,width=630,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
		*/


		//alert(iactrl.getX());

		var dmsg = document.getElementById("dmsg");
		if (dmsg) {
			dmsg.innerHTML= "<p>cargando ...</p>";
			dmsg.style.top = iactrl.my;
			dmsg.style.left = iactrl.mx;
			dmsg.style.display = "inline";

			var param = "?OP=600&IDLNG=1&DIA="+d+"&MES="+m+"&AN="+y;
			wiax.call(GetEvents,param);
		}

	}


	function DisableTab(evt) {
		kc = (evt) ?  evt.which: event.keyCode; 

		if(kc == 9) {
			return false;
		}
	}

	function dt() {
		document.onkeydown = DisableTab;
	}

	function et() {
		document.onkeydown = '';
	}

	function alt(pta) {
		var txtb = document.getElementById("txtbuscar");
		if (txtb) {
			txtb.value = pta;
			buscar(1,1);
		}
	}

	function switcharea(psname) {
		switch (psname ) {
			case 'tblsearch':
				stsarea("tbltree",false);
				var box = document.getElementById("txtbuscar");
				if (box) {
					box.focus();
				}
				break;
			case "tbltree":
				stsarea("tblsearch",false);
				break;
		}
		stsarea(psname,true);
	}

	function stsarea(psname,psts) {
		var tbl = document.getElementById(psname);
		var color;
		var bimg;

		if (psts==true) {
			//color = "#dbebf4";
			color = "#70c6ff";
			bimg = "tce";
		}else{
			color = "#e9e9e9";
			bimg = "tc";
		}

		if (tbl) {
			tbl.style.backgroundColor = color;

			for (var i=1;i<5;i++) {
				var img = document.getElementById("img"+psname+ i);
				if (img) {
					img.src = "images/"+bimg+i+".jpg";
				}
			}
		}
	}


	function logon() {
		var tl = document.getElementById("txtLogin");
		var tp = document.getElementById("txtPass");

		if (tl && tp) {
			if (tl.value != '' && tp.value !='') {
				var param = "?OP=500&uid=" + tl.value + "&pass=" + tp.value;
				//httpcall(param,500);


				/*var w,h;
				var t,l;

				h = screen.availHeight;
				w = screen.availWidth;
				t = (h/2) - 275;
				l = (w/2) - 375;*/

				//window.open ("http://www.institutoalcon.com/npreinscripcion.asp",1,"top=0,left=0,height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");		
				//window.open ("http://www.institutoalcon.com/frmServerLogon.asp"+param,1,"top=0,left=0,height=500,width=100,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no");		

				/*
				var ifrm = document.getElementById("ifrmlogon");
				if (ifrm) {
					//ifrm.src = "http://www.institutoalcon.com/frmServerLogon.asp"+param;
					ifrm.src = "http://esbar902/institutoalcon/next/frmServerLogon.asp"+param;
				}
				*/


				//frames['ifrmlogon'].location = "http://esbar902/institutoalcon/next/frmServerLogon.asp"+param;
				//frames['ifrmlogon'].location = "http://www.institutoalcon.com/frmServerLogon.asp"+param;


				var df = document.getElementById("divif");
				if (df) {
					var ifrm = document.createElement("IFRAME"); 
					//ifrm.setAttribute("src", "http://www.institutoalcon.com/frmServerLogon.asp"+param); 
					//ifrm.setAttribute("src", "http://esbar919/institutoalcon/next/frmServerLogon.asp"+param); 
					ifrm.setAttribute("src", "http://www.institutoalcon.com/Fototeca/next/frmServerLogon.asp"+param); 
					ifrm.setAttribute("id", "ifrmlogon"); 
					ifrm.setAttribute("name", "ifrmlogon"); 
					ifrm.style.width = 100+"px"; 
					ifrm.style.height = 100+"px"; 
					df.appendChild(ifrm); 

					alert(param);
				}

			}
		}
	}
	
	function getlogon(str) {
		var htmarr = str.split("<br>");
		var sts = htmarr[0]*1;
		var dir = htmarr[1];

		//alert(str);

		stslogon(sts,dir);

		var df = document.getElementById("divif");
		if (df) {
			var ifrm = document.getElementById('ifrmlogon');
			if (ifrm) {
				df.removeChild(ifrm);
			}
		}
	}
	
	function getmail(str) {
		var htmarr = str.split("<br>");
		var sts = htmarr[0]*1;
		var dir = htmarr[1];

		stslogon(sts,dir);

		var df = document.getElementById("divif");
		if (df) {
			var ifrm = document.getElementById('ifrmlogon');
			if (ifrm) {
				df.removeChild(ifrm);
			}
		}
	}
	
	
	
	function logoff() {
		var param = "?OP=501";
		httpcall(param,501);

		var tl = document.getElementById("txtLogin");
		var tp = document.getElementById("txtPass");

		if (tl) tl.value = "";
		if (tp) tp.value = "";
	}

	function stslogon(psts,pusr) {
		var tbl = document.getElementById("tbllogon");
		var color;
		var bimg;

		switch(psts) {
			case -1:
				//Logoff
				//color = "#0080ff";
				color = "#c8c8c8";
				bimg = "";
				break;
			case 0:
				//No logon
				color = "red";
				bimg = "of";
				break;
			case 1:
				//logon ok
				color = "green";
				ReloadContens();
				condpreins();
				bimg = "on";
				break;
			case 2:
				//No mail
				color = "orange";
				datprof();
				bimg = "sb";
				break;
		}


		//Asignar color al marco.
		if (tbl) {
			tbl.style.backgroundColor = color;

			for (var i=1;i<5;i++) {
				var img = document.getElementById("imgtbllogon"+ i);
				if (img) {
					img.src = "images/tcl"+bimg+i+".jpg";
				}
			}
		}

		//Asignar color a la etiqueta con los datos del usuario.
		var dinfo = document.getElementById("dusrinf");
		if (dinfo) {
			dinfo.innerHTML= pusr;
			if (psts == 0) {
				dinfo.className = "denied";
			} else
				dinfo.className = "cuser";
		}

		//Visuarlizar o no los enlaces del login.
		var dloged = document.getElementById("dloged");
		if (dloged) {
			if (psts == 1)
				dloged.style.display = "inline";
			else
				dloged.style.display = "none";
		}

		//Habilitar el boton de logoff.
		var blogoff = document.getElementById("cmdSalir");
		if (blogoff) {
			if (psts == 1)
				blogoff.disabled= false;
			else
				blogoff.disabled= true;
		}
	}
	
	
	function datprof() {
		tf = new tframe();
		tf.lng = getLng();
		//alert(tf.lng);
		tf.addmsg(700,400,2);
		tf.show();
	}

	/*function condpreins() {
		tf = new tframe();
		tf.addmsg(600,600,1);
		tf.show();
	}

	function preins() {
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 275;
		l = (w/2) - 375;

		//window.open ("http://www.institutoalcon.com/npreinscripcion.asp",1,"top=0,left=0,height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
		window.open ("PreInsBridgeLocal.asp?op=1",1,"top=0,left=0,height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
		tf .hide();
	}*/

	function setmailprof() {
		var otm = document.getElementById("txtMail");

		if (otm) {
			if (otm.value != "") {
				tf.hide();

				/*
				var w,h;
				var t,l;

				h = screen.availHeight;//100;
				w = screen.availWidth;//300;
				t = (h/2) - 150;
				l = (w/2) - 50;

				window.open ("PreInsBridgeLocal.asp?op=2&email=" + escape(otm.value),1,"top=" + t + ",left=" + l + ",height=100,width=300,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
				*/


				var df = document.getElementById("divif");
				if (df) {
					//df.style.display = "inline";
					var ifrm = document.createElement("IFRAME"); 
					
					//ifrm.setAttribute("src", "http://esbar902/institutoalcon/next/frmServerLogon.asp"+param); 
					ifrm.setAttribute("src", "PreInsBridgeLocal.asp?op=2&email=" + escape(otm.value)); 
					ifrm.setAttribute("id", "ifrmsetmail"); 
					ifrm.setAttribute("name", "ifrmsetmail"); 
					ifrm.style.width = 100+"px"; 
					ifrm.style.height = 100+"px"; 
					df.appendChild(ifrm); 
				}

				//var param = "?OP=530&MAIL="+otm.value;
				//httpcall(param,530);
			}
		}
	}



	function resetoverlay(dover,dcondit) {
		if (dover) {
			dover.style.display="none";
		}

		if (dcondit) {
			dcondit.style.display = "none";
		}

		window.onresize = "";
	}









	function cambio() {
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 75;
		l = (w/2) - 250;

		window.open ("cambio.asp",null,"top=" + t + ",left=" + l + ",height=150,width=500,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");
	}


	function getIdLng() {
		var idlng;
		var tidlng = document.getElementById("txtIdLng");
		idlng = tidlng.value;

		//idlng = 1;
		return idlng;
	}


	function getLng() {
		var slng;
		var tslng = document.getElementById("txtLng");
		slng = tslng.value;

		//slng = "ESP";
		return slng;
	}


	function load(id) {
		var osrc = document.getElementById("tab"+id);

		if (osrc) {
			osrc.className = "tab-button2";
			TabDown(osrc,id);
			TabUp(osrc) ;
		}
	}


	function closeover() {
		tf.hide();
	}


	function info(op,sw,sh,lng){
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;

		t = (h/2) - (sh/2);
		l = (w/2) - (sw/2);

		window.open ("Info.asp?OP="+op+"&LNG="+lng,null,"top=" + t + ",left=" + l + ",height="+sh+",width="+sw+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}


	function xinfo(op,sw,sh,lng){
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;

		t = (h/2) - (sh/2);
		l = (w/2) - (sw/2);

		window.open ("XInfo.asp?OP="+op+"&lng="+lng,op,"top=" + t + ",left=" + l + ",height="+sh+",width="+sw+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}


	function enlaces() {
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 200;
		l = (w/2) - 200;
		
		window.open ("enlaces.asp",3,"top=" + t + ",left=" + l + ",height=400,width=400,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}


	function recover(){
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 100;
		l = (w/2) - 300;

		window.open ("recover.asp?",null,"top=" + t + ",left=" + l + ",height=200,width=600,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");
	}



	function bloc(){
		var w,h;
		var t,l;
		var idlng = getIdLng();

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 200;
		l = (w/2) - 320;
		window.open ("bloc.asp?idlng="+idlng,184,"top=" + t + ",left=" + l + ",height=400,width=640,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no");	
	}



	function Descargar(idh,f){
		var w,h;
		var t,l;
		var lng = "ESP"

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 200;
		l = (w/2) - 300;
		window.open ("descarga.asp?LNG="+lng+"&IDA="+idh+"&FN="+escape(f),114,"top=" + t + ",left=" + l + ",height=400,width=600,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");	
	}


	function VerPDFCOL(psPDF) {
		window.open('/Cursos/PDF/' + psPDF, 'COLPDF', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes')
	}

	function donde(p) {
		var w,h;
		var t,l;
		var sh,sw;
			
		sh = 600;
		sw = 750;

		h = screen.availHeight;
		w = screen.availWidth;

		t = (h/2) - (sh/2);
		l = (w/2) - (sw/2);

		window.open("http://www.institutoalcon.com/Donde"+p+".asp?DOM="+document.location.hostname,"donde","top=" + t + ",left=" + l + ",height="+sh+",width="+sw+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}
	
	
	
	function quest() {
		tf = new tframe();
		tf.lng = getLng();
		//alert(tf.lng);
		tf.addmsg(600,600,10);
		tf.show();
	}

	
	
	function answer() {
		vercont(1, IdCat, nPagina, IdTypeObj);
		//vercont(1, IdCat, 2, IdTypeObj);
	}
	
	
	function testprograma() {
		resetActiveTab();

		var calobj = document.getElementById("txttab6");
		if (calobj) {
			calobj.style.display = "inline";

			//var mediaiax = new iajax("http://esbar925/InstitutoAlcon/Preinscripciones/programa.aspx");
			//mediaiax.call(GetPrograma,"");

		}	
	}
	
	

		function infocurso(idi,tipo, mode,pslng) {
			var param = "?TYP="+tipo+"&IDC="+idi+"&MODE="+mode+"&SLNG="+pslng;
			
			var ajurl = gaurl + "Preinscripciones/Controles/Programa/Programa.aspx";
			var iax  = new iajax(ajurl);
	    		iax.call(CBVerInfoCurso,param);
		}
	
	
	
	
	function _misdatos(pscod) {
	    var lnk = "run/completar.aspx?tmpusrid=" + pscod;
		var w,h;
		var sw,sh;
		var t,l;

		sw = 600;
		sh = 500;

		h = screen.availHeight;
		w = screen.availWidth;

		t = (h/2) - (sh/2);
		l = (w/2) - (sw/2);

		window.open (lnk,null,"top=" + t + ",left=" + l + ",height="+sh+",width="+sw+",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=yes");
	}
	
	
	function gotoprofzone() {
		var tdtab = document.getElementById("tp4");
		if (tdtab) {
			ottab2.TabDown(tdtab,4,4);
		}
	}

	function gotoprofzonemsg() {
		var tdmtab = document.getElementById("tm2");
		if (tdmtab) {
			ottabmain.TabDown(tdmtab,2,2);
		}

		var tdtab = document.getElementById("tp4");
		if (tdtab) {
			ottab2.TabDown(tdtab,4,4);
		}

		tf.hide();

		/*var dmsg = document.getElementById("dmsg");
		if (dmsg) {
			dmsg.style.display = 'none';
		}*/
	}

	function gotomainzone(pid) {
		var tdtab = document.getElementById("tm"+pid);
		if (tdtab) {
			ottabmain.TabDown(tdtab,pid,pid);
		}
	}


	function cursoantibiotic() {
		tf = new tframe();
		tf.addmsg(800,350,20);
		tf.show();
	}


	
	// ********************************
	//Callback IA functions
	// ********************************
	
		function AHome(str) {
			//alert(str);
				var htmarr = str.split("\r\r"); 
				//alert(htmarr.length);
				//alert(str);

				document.getElementById("divHomeLinks").innerHTML = htmarr[0];
				//document.getElementById("divHomeNews").innerHTML = htmarr[1];
				//document.getElementById("divHomeIMG").innerHTML ="<img src='imagesIA/art/cuadro1.jpg'/>";

		}
		
		function AAPer(pstr) {
			document.getElementById("divaper").innerHTML = pstr;
		}

		function GetMP(str) {
			//if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
			//	var str = xmlHttp.responseText;
				//alert(str);
				document.getElementById("divmp").innerHTML = str;
			//}
		}

		//callback function
		function GetAIT(str) {
			//if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
			//	var str = xmlHttp.responseText;
				//alert(str);
				document.getElementById("divait").innerHTML = str;
			//}
		}

		//callback function
		function GetPROA(str) {
			//if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
			//	var str = xmlHttp.responseText;
				//alert(str);
				document.getElementById("divproa").innerHTML = str;
			//}
		}

		//callback function
		function GetMedia(str) {
			document.getElementById("divmedia").innerHTML = str;
		}


		//callback function
		function Contenidos(str) {
		
				var htmarr = str.split("<br>");
				document.getElementById("divContenidos").innerHTML = htmarr[0];
				//document.getElementById("divctrls").innerHTML = htmarr[1];
				document.getElementById("divctrls").innerHTML = htmarr[2];
				//alert("n tipo obj. " + htmarr[1]);

				ottab.EnableDisable(htmarr[1]);

				SelSubItem(lstIdCat);
		}



		//callback function
		function GetCal(str) {
			document.getElementById("divcal").innerHTML = str;
		}

		//callback function
		function ABuscar(str) {
			//alert(str);
			var htmarr = str.split("<br>");
			//alert(htmarr.length);

			if (htmarr.length > 1) {
				document.getElementById("divContenidos").innerHTML = htmarr[0];
				//alert(htmarr[1]);
				ottab.EnableDisable(htmarr[1]);
			}
			
			//alert("IdTypeObj " + IdTypeObj);
		}

		//callback function
		function FBuscar(str) {
			document.getElementById("divbuscar").innerHTML = str;
		}

		//callback function
		function CBQuestion(pstr) {
			if (tf) {
				if (tf.msgid == 10) {
					tf.dmsg.innerHTML = pstr;

					//Asociar el evento de mousemove a la imagen de la pregunta.
					//addImageEvent();


					oquest = new QuestionObj();
					oquest.init();

				}
			}		
		}
		
		function GetPrograma(pstr) {
			var calobj = document.getElementById("divprograma");
			calobj.innerHTML = pstr;
		}


		function CBVerInfoCurso(pstr) {
			var od = document.getElementById("divinfocurso");
			if (od) {
				od.innerHTML = pstr;
			}
		}
		
		function GetEvents(pstr) {
			//alert(pstr);
			var dmsg = document.getElementById("dmsg");
			if (dmsg) {
				dmsg.innerHTML= pstr;
			}
		}
		
		
		function ACondiciones(pstr) {
			var dcont = document.getElementById("divCondiciones");
			if (dcont) {
				dcont.innerHTML= pstr;
			}
		}
		
		function AAcreditados(pstr) {
			var dcont = document.getElementById("divAcredit");
			if (dcont) {
				dcont.innerHTML= pstr;
			}
		}
		
		
		function menuPrograma() {
			
		}
		
		
	function agracede(plng) {
		var w,h;
		var t,l;

		h = screen.availHeight;
		w = screen.availWidth;
		t = (h/2) - 350;
		l = (w/2) - 250;

		if (plng == 'ESP')
			window.open ("agradeceESP.htm",null,"top=" + t + ",left=" + l + ",height=700,width=500,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes");
		else
			window.open ("agradecePOR.htm",null,"top=" + t + ",left=" + l + ",height=700,width=500,status=no,toolbar=no,menubar=no,resizable=no,scrollbars=yes");
	}
	
	
	function CBcursoantibiotic(pstr) {
			if (tf) {
					if (tf.msgid == 20) {
					tf.dmsg.innerHTML = pstr;
				}
			}
	}
