//***********definicion de variables globales************
//leer id de objetos
function porId(doc,id) {
   return doc.getElementById(id);
}

function getid(id)
{
  porId(document,id);
}

//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()")
	
	anclas=document.getElementsByTagName("area").length;
	for (i=0;i<anclas;i++)
    document.getElementsByTagName("area").item(i).onfocus=new Function("if(this.blur)this.blur()")
}
//

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//----------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// funciones de manejo del rolover de imagenes
// mediante el uso de nuevos eventos
// <input type="image" name="submitimg" src="img_1.gif" srcover="img_2.gif" srcdown="img_3.gif" border="0">
// <img src="img_1.gif" srcover="img_2.gif" srcdown="img_3.gif" width="147" height="49" alt="">
//-------------------------------------------------------------------------------------------------------
//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;
//=======================================================================================================
//=======================================================================================================
// Funciones W3C-DOM -------------//
var id_iframe;
function addStrTable(idx,str)
{
  txt = document.createTextNode(str);
  document.getElementById(idx).appendChild(txt);
}
function replaceStrTable(idx,str)
{
  txt = document.createTextNode(str);
  elem = document.getElementById(idx);
  while(elem.childNodes.length > 0) {elem.removeChild(elem.firstChild);}
  elem.appendChild(txt);
}
function clearStrTable(idx)
{
  elem = document.getElementById(idx);
  while(elem.childNodes.length > 0) {elem.removeChild(elem.firstChild);}
}
function setAttr(element,atributo,valor)
{
  if (navigator.appName == "Microsoft Internet Explorer")
  {
    att = document.createAttribute(atributo);
    att.value=valor;
	element.setAttributeNode(att);
  }else{
    element.setAttribute(atributo,valor);
  }
}
function clearTable(tbody) {
    while (tbody.rows.length > 0) {
        tbody.deleteRow(0);
    }
}
function deleteElement(idx)
{
  var elem = document.getElementById(idx);
  elem.parentNode.removeChild(elem);
}
function deleteElementId(elem)
{
  //var elem = document.getElementById(idx);
  elem.parentNode.removeChild(elem);
}
function addImagen(imagen,w,h)
{
  var element = document.createElement("img");
  element.setAttribute("src", imagen);
  element.setAttribute("height", h);
  element.setAttribute("width", w);
  return element;
}
function setPosXY(elem,x,y)
{
  with(elem.style)
  {
    position="absolute";
	top=y;
	left=x;
  }
}
function setWH(elem,w,h)
{
  with(elem.style)
  {
	width=w;
	height=h;
  }
}
function addIframe(idx,srclink,x,y,w,h,scroll)
{
  nf = document.createElement("iframe");
  if(idx!=null){ setAttr(nf,"id",idx); }
  if(srclink!=null){ setAttr(nf,"src",srclink); }
  if(scroll!=null){ setAttr(nf,"scrolling",scroll); }
  setAttr(nf,"frameborder",0);
  if((x!=null)&&(y!=null)){ setPosXY(nf,x,y); }
  if((w!=null)&&(h!=null)){ setWH(nf,w,h); }
  return nf;
}
//// --------------------------- para creacion de iframes dinamicos----------------------- ////
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while(obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while(obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
///------------jajjaaj