//**quita el recuadro punteado de los links activos**
function quitacuadro() {
    anclas=document.getElementsByTagName("a").length;
    for (i=0;i<anclas;i++)
	{
     document.getElementsByTagName("a").item(i).onfocus=new Function("if(this.blur)this.blur()");
	}
	anclas2=document.getElementsByTagName("area").length;
    for (i=0;i<anclas2;i++)
	{
     document.getElementsByTagName("area").item(i).onfocus=new Function("if(this.blur)this.blur()");
	}
}

//**deshabilita el boton derecho del raton sin votar mensaje de advertencia**

IE4plus = (document.all) ? true : false;
NS4 = (document.layers) ? true : false;

function clickIE()
{
    return false;
}

function clickNS(e)
{
	if (e.which==2 || e.which==3) 
     {
       return false;
     }
}
if (!IE4plus) 
{
   document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
   document.onmousedown=clickNS;
   document.onmouseup= clickNS;
   document.oncontextmenu=clickIE; // For NS 6+
} 
else 
{
   document.onmouseup= clickIE;
   document.oncontextmenu=clickIE;
}

//**leer id de objetos**
function porId(doc, id) {
   return doc.getElementById(id);
}

//**para abrir un form**
function fAbreForm(tid,docu,ancho,Hh,modo)
{
	var ind = porId(document,"sFiles").selectedIndex;
	if (modo == 'O') { 
		var datid = porId(document,"sFiles").options[ind].value;
	} else if(modo == 'N') {
		var datid = 0;
	}
	with(porId(top.document,"launchtool").style){visibility = "hidden";}
	var Ww = ancho+140;
	var formlink = 'formtools/formularios.php?tid='+tid+'&docu='+docu+'&datid='+datid;
	var iz = (screen.width-Ww) / 2;
	var html = '<iframe src="' + formlink + '" scrolling="No" width="' + Ww + '" height="' + Hh + '" frameborder="0"></iframe>';
	var myLayer = top.document.getElementById('aiPopupTool');
	myLayer.innerHTML = html;
	myLayer.style.left = iz + "px";
	myLayer.style.top = "30px";
	myLayer.style.display = "block";
}

//**para abrir un pdf**
function fAbrePdf(pdfname)
{ 
	with(porId(top.document,"launchtool").style){visibility = "hidden";}
	var pdflink = 'pdftools/'+pdfname;//nota que el archivo pdf debe estar ubicado en la carpeta "pdftools"
	var iz=(screen.width-760) / 2;
	var de=(screen.height-500) / 2;
	var data2 ="top="+de+",left="+iz+",width=760,height=500,resizable=yes,scrollbars=no,toolbar=no,directories=no,menubar=no,status=no";
	var wPdf = window.open(pdflink,"pdf_visor",data2);
}

//**para descargar un pdf**
function fBajaPdf(pdfname)
{
 with(porId(top.document,"launchtool").style){visibility = "hidden";}
 document.location.href = 'download_pdf.php?pdffile='+pdfname; 
}

var iframeid = new Array("capaF","launchtool");
function fverIframe(n)
{
 if(porId(top.document,iframeid[n-1]).style.visibility == "hidden")
 {
  with(porId(top.document,iframeid[n-1]).style){visibility = "visible";}
 }
 else if(porId(top.document,iframeid[n-1]).style.visibility == "visible")
 {
  with(porId(top.document,iframeid[n-1]).style){visibility = "hidden";}
 }
}

//**Abrir el mini popup de apertura de los TOOLS**
herramienta = 0;//se inicializa la variable en cero

function fsuIdTool(n)//favoritetools.php
{ 
 with(porId(top.document,"capaF").style)
 {
  visibility = "hidden";
 }
 herramienta = n;
 fLaunchT();
}

function fLaunchT()//intro.php y estapas.php
{
 if(porId(top.document,"launchtool").style.visibility == "hidden")
 {
  if(herramienta!=0)
  {
   top.launchtool.location.href = "lanzapdf.php?toolid="+herramienta;
  }
 }
}

//**para borrar las letras decorativas cuando se pulse en el boton de 'home'
function fborraLetra()
{
 dat = '';
 top.num2.document.getElementById("xx3").innerHTML=dat;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
function hTabPanel(prf, w, h, panStls, strFunc)
{
	function onClick() {
		paint(this);
		return false;
	}
	function onFocus() {
		paint(this);
	}
	function onOver() {
		if (selectedIndex != this.xTabIndex) {
			this.src = this.srcHover;
		}
	}
	function onOut() {
		if (selectedIndex != this.xTabIndex) {
			this.src = this.srcOut;
		}
	}
	function paint(tab)	{
		tab.className = "tabClick";
		tab.src = tab.srcClick;
		xZIndex(tab, highZ++);
		xDisplay(panels[tab.xTabIndex], 'block');
		if (selectedIndex != tab.xTabIndex) {
			xDisplay(panels[selectedIndex], 'none');
			tabs[selectedIndex].className = "tabNormal";
			tabs[selectedIndex].src = tabs[selectedIndex].srcOut;
			selectedIndex = tab.xTabIndex;
		}
		panelGrp.className = panelGrpStyle+" tabBgBody"+tab.styleNum;
		if (strFunc) { strFunc(tab.xTabIndex); }
	}
	function gotoTab(n) {
		if (n && n > 0) {
			tabs[n-1].onclick();
		}
	}
	var tabGrp = xGetElementById(prf+"_tabs");
	if (!tabGrp) { return null; }
	var tabs = xGetElementsByClassName("tabNormal", tabGrp);
	var panelGrp = xGetElementById(prf+"_panels");
	var panelGrpStyle = panelGrp.className;
	if (!panelGrp) { return null; }
	var panels = new Array();
	var plist = xGetElementsByClassName("panDef", panelGrp, "div");
	var i, a, re = new RegExp(prf+'_', 'i');
    for (i = 0; i < plist.length; ++i) {
	    a = plist[i].getAttribute("id");
	    if (!a) {a = plist[i]["id"];}
	    if (typeof(a)=='string' && a.search(re) != -1) {
	      panels[panels.length] = plist[i];
		}
    }
	if (!tabs || !panels || tabs.length != panels.length) { return null; }
	var selectedIndex = 0, highZ, str, k;
	xResizeTo(panelGrp, w, h);
	for (i = 0; i < tabs.length; ++i)
	{
		tabs[i].xTabIndex = i;
		tabs[i].srcOut = tabs[i].src;
		str = tabs[i].srcOut.split(".");
		k = str.length;
		tabs[i].srcHover = (str[k-2].substring(str[k-2].indexOf("/images")+1, str[k-2].lastIndexOf("_0")+1)+"1")+"."+str[k-1];
		tabs[i].srcClick = (str[k-2].substring(str[k-2].indexOf("/images")+1, str[k-2].lastIndexOf("_0")+1)+"2")+"."+str[k-1];
		tabs[i].onmouseover = onOver;
		tabs[i].onmouseout = onOut;
		tabs[i].onclick = onClick;
		tabs[i].onfocus = onFocus;
		xDisplay(panels[i], 'none');
		xResizeTo(panels[i], w-6, h-6);
		xMoveTo(panels[i], 3, 3);
		if(panStls) {
			tabs[i].styleNum = panStls[i];
		}
	}
	// propiedades y elementos
	this.tg = tabGrp;
	this.pg = panelGrp;
	// metodos publicos
	this.gotoTab = gotoTab;
	highZ = i;
	tabs[0].onclick();
}
//DOM Image Rollover II- Available at Dynamic Drive (http://www.dynamicdrive.com)

	// Make Variables----------------------
	var imgMouseOverHolder = new Array();
	var imgMouseDownHolder = new Array();
	//-------------------------------------

function preloader(imgTags){

	// Create Variables------------------
	var newmouseover, newmouseout, newmouseup, newmousedown, oldmouseover, oldmouseout, oldmouseup, oldmousedown
	//-----------------------------------
	
	// Get array length--------------
	var AL = imgMouseOverHolder.length + 1;
	//-------------------------------

	for (var i = 0; i < imgTags.length; i++) {

		if (imgTags[i].getAttribute('srcdown')||imgTags[i].getAttribute('srcover')) {
	
		newmouseover = null; newmouseout = null; newmouseup = null;	newmousedown = null; oldmouseover = null; oldmouseout = null; oldmouseup = null; oldmousedown = null

			// Store src Images------------------
			if (imgTags[i].getAttribute('srcover')) {imgMouseOverHolder[AL] = new Image(); imgMouseOverHolder[AL].src = imgTags[i].getAttribute('srcover');}
			if (imgTags[i].getAttribute('srcdown')) {imgMouseDownHolder[AL] = new Image(); imgMouseDownHolder[AL].src = imgTags[i].getAttribute('srcdown');}
			//-----------------------------------
			
			// Make backups----------------------
			if (imgTags[i].src) {imgTags[i].setAttribute("oldsrc", imgTags[i].src);}
			//-----------------------------------
				
			if (imgTags[i].getAttribute('srcover')) {
			
				// Make Mouse over--------------------
				if (imgTags[i].onmouseover) {imgTags[i].oldmouseover = imgTags[i].onmouseover; newmouseover = function (){this.src=this.getAttribute("srcover"); this.oldmouseover();}}
				else {newmouseover = function (){this.src=this.getAttribute("srcover");}}
				imgTags[i].onmouseover = newmouseover;
				//------------------------------------
			
				// Make Mouse out--------------------
				if (imgTags[i].onmouseout){imgTags[i].oldmouseout = imgTags[i].onmouseout; newmouseout = function (){this.src=this.getAttribute("oldsrc"); this.oldmouseout();}}
				else {newmouseout = function (){this.src=this.getAttribute("oldsrc");}}
				imgTags[i].onmouseout = newmouseout;
				//-----------------------------------
			}
			
			if (imgTags[i].getAttribute('srcdown')) {	
			
			// Make Mouse Down---------------------
			if (imgTags[i].onmousedown) {imgTags[i].oldmousedown = imgTags[i].onmousedown; newmousedown = function (){this.src=this.getAttribute("srcdown"); this.oldmousedown();}}
			else {newmousedown = function (){this.src=this.getAttribute("srcdown");}}
			imgTags[i].onmousedown = newmousedown;
			//-------------------------------------
			
				if (imgTags[i].getAttribute('srcover')) {
						
					// Make Mouse up-----------------------
					if (imgTags[i].onmouseup) {imgTags[i].oldmouseup = imgTags[i].onmouseup; newmouseup = function (){this.src=this.getAttribute("srcover"); this.oldmouseup();}}
					else {newmouseup = function (){this.src=this.getAttribute("srcover");}}
					imgTags[i].onmouseup = newmouseup;
					//-------------------------------------
				
				} else {
								
					//Make Mouse up-------------------------
					if (imgTags[i].onmouseup) {imgTags[i].oldmouseup = imgTags[i].onmouseup; newmouseup = function (){this.src=this.getAttribute("oldsrc"); this.oldmouseup();}}
					else {newmouseup = function (){this.src=this.getAttribute("oldsrc");}}
					imgTags[i].onmouseup = newmouseup;
					//-------------------------------------
					
					// Make Mouse out--------------------
					if (imgTags[i].onmouseout) {imgTags[i].oldmouseout = imgTags[i].onmouseout; newmouseout = function (){this.src=this.getAttribute("oldsrc"); this.oldmouseout();}}
					else {newmouseout = function (){this.src=this.getAttribute("oldsrc");}}
					imgTags[i].onmouseout = newmouseout;
					//-----------------------------------
				
				}
				
			}
		}
	}
}
function preloadimgsrc() {

	// Check to see if document element----
	if (!document.getElementById) return;
	//-------------------------------------
	
	// Declare variables--------------------
	var imgTags = document.getElementsByTagName('IMG'); 
	var imgTags2 = document.getElementsByTagName('INPUT');   // For image type submit buttons 
	//--------------------------------------
	
	// Preload Images-----------------------
	preloader(imgTags);
	preloader(imgTags2);  // For image type submit buttons 
	//--------------------------------------
}

if (window.addEventListener)
window.addEventListener("load", preloadimgsrc, false)
else if (window.attachEvent)
window.attachEvent("onload", preloadimgsrc)
else if (document.getElementById)
window.onload=preloadimgsrc;

