function noFunction(){}

function replace(cadena,que,conque)
{
cad=''+cadena;
var a=0;

   while(cad.indexOf(que)!=-1)
        {
        c=cad.indexOf(que);
        cad=cad.replace(que,conque);
        }

return cad;
}

//****************************  layers.js  ******************************************
var autoLayerCount=0;
function CreateDIV(nombre,x,y,xx,yy,classN,zIndex,clip,Contenido,Opened,Visible)
    {
	var nombre= nombre ? nombre : "AutoGeneratedLayer" + (autoLayerCount++);
	var id= 'id="' + nombre + '" ';
	var CLS=classN ? 'class="' + classN + '" ' : '';
	var visible=Visible ? 'display: none; ': '';
	var izquierda=x ? 'left: ' + x + '; ':'';
	var arriba=y ? 'top: ' + y + '; ':'';
	var ancho='width: ' + xx + '; ';
	var alto='height: ' + yy + '; ';
	//var posicion='position: ' + ((y)&&(x) ?'absolute':'relative') + '; ';
	var posicion='position: absolute; ';
	var zindex=zIndex ? 'z-index: ' + parseInt(zIndex) +'; ': '';
	var clipping=clip ? 'clip: rect(0 ' + xx + ' ' + yy + ' 0); ':'';
	if (!Contenido) Contenido="";
	if (!Opened) Contenido+="</DIV>";
	DV= "<DIV " + id + CLS + "style='"+posicion+izquierda+arriba+ancho+alto+zindex+clipping+visible+"'>" + Contenido;
	return DV;
	}

function CreateDIVNP(nombre,x,y,xx,yy,classN,zIndex,clip,Contenido,Opened,Visible)
    {
	var nombre= nombre ? nombre : "AutoGeneratedLayer" + (autoLayerCount++);
	var id= 'id="' + nombre + '" ';
	var visible=Visible ? 'display: none; ': '';
	var CLS=classN ? 'class="' + classN + '" ' : '';
	var izquierda=x ? 'left: ' + x + 'px; ':'';
	var arriba=y ? 'top: ' + y + 'px; ':'';
	var ancho='width: ' + xx + 'px; ';
	var alto='height: ' + yy + 'px; ';
	var zindex=zIndex ? 'z-index: ' + parseInt(zIndex) +'; ': '';
	var clipping=clip ? 'clip: rect(0px ' + xx + 'px ' + yy + 'px 0px)':'';
	if (!Contenido) Contenido=""
	if (!Opened) Contenido+="</DIV>"
	DV= "<DIV " + id + CLS + "style='"+izquierda+arriba+ancho+alto+zindex+clipping+visible+"'>" + Contenido;
	return DV
	}

function CreateDIVX(nombre,classN)
    {
	var nombre= nombre ? nombre : "AutoGeneratedLayer" + (autoLayerCount++);
	var id= 'id="' + nombre + '" ';
	var CLS=classN ? 'class="' + classN + '" ' : '';
	DV= "<DIV " + id + CLS + "></div>";
	write(DV)
	}

function CreateDIVR(nombre,x,y,xx,yy,classN,zIndex,clip,Contenido,Opened,Visible)
    {
	var nombre= nombre ? nombre : "AutoGeneratedLayer" + (autoLayerCount++);
	var id= 'id="' + nombre + '" ';
	var visible=Visible ? 'display: none; ': '';
	var CLS=classN ? 'class="' + classN + '" ' : '';
	var izquierda=x ? 'left: ' + x + 'px; ':'';
	var arriba=y ? 'top: ' + y + 'px; ':'';
	var ancho='width: ' + xx + 'px; ';
	var alto='height: ' + yy + 'px; ';
	var zindex=zIndex ? 'z-index: ' + parseInt(zIndex) +'; ': '';
	var clipping=clip ? 'clip: rect(0px ' + xx + 'px ' + yy + 'px 0px)':'';
	if (!Contenido) Contenido="";
	if (!Opened) Contenido+="</DIV>";
	DV= "<DIV " + id + CLS + "style='position:relative;"+izquierda+arriba+ancho+alto+zindex+clipping+visible+"'>" + Contenido;
	return DV
	}

function CreateDIVOBJ(nombre,x,y,xx,yy,classN,zIndex,clip)
    {
	var nombre= nombre ? nombre : "AutoGeneratedLayer" + (autoLayerCount++);
	CreateDIV(nombre,x,y,xx,yy,classN,zIndex,clip);
	return new Div(nombre);
	}
		  

// robado de dw4
function BuscarObj(n, d) {
  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=BuscarObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
/// fin del robado

function getLayer(id, useOpt)
	{
	try {
	if (!id)return 0;
	if (is.dom)return document.getElementById(id);
	if (document[id]) return document[id];
	    }
	catch(er) {return BuscarObj(id)}    
	if (useOpt) return BuscarObj(id);
	}
	

function DIVinvisible(obj)
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) this.obj.style.visibility="hidden";
	else if (is.ns4) this.obj.visibility="hide";
      return this;
	}
	
function DIVvisible()
	{
	if(!this.obj) return false;
	if(is.ie4||is.dom) this.obj.style.visibility="visible";
	else if(is.ns4) this.obj.visibility="show";
      return this;
	}
	
function DIVdisplay(forzar)
	{
	if (!this.obj) return this;
	if ((this.displaying)&&(!forzar)) return this;
	this.displaying=true;
	if (is.dom) this.obj.style.display='';
    return this;
	}

function DIVhide(forzar)
	{
	if (this.TRACE) alert('Existe obj?:' +  this.obj ? 'si':'no');
	if (!this.obj) return this;
	if (this.TRACE) alert(this.displaying);
    this.displaying=false;
	if (is.dom) this.obj.style.display='none';
        return this;
	}

function hideDiv(nombre)
	{
	var his=getLayer(nombre);
	if (!his) return false;
	if (is.ie4||is.dom) if (his.style.display!='none') his.style.display='none';
      return this;
	}

function DIVgetDisplay()
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) if(this.obj.style) return (this.obj.style.display=='');
	return true;
	}

function DIVMove(x,y,setnew)
	{
	if (!this.obj) return false;
	if (this.TRACE) window.status=this.nombre;
	if (is.ie4||is.dom) 
		{
		  this.obj.style.left=parseInt(x) +'px';
		  this.obj.style.top=parseInt(y) +'px';
		  if (setnew) {this.floatX=x;this.floatY=y}
		}
	if (this.TRACE) window.status="Move(" + x + "," + y + ")";
      return this;
	}

function DIVMoveX(x,rel)
	{
	if (!this.obj) return false;
	if (isNaN(x)) 
	   {
	   window.status= this.nombre + ".moveY -> x is NaN";
	   return false;
	   }
	if (is.ie4||is.dom) 
		{ 
			if (rel) x=this.x() + x;
			this.obj.style.left=parseInt(x) +'px';
		}
      return this;
	}
	
function DIVMoveY(y,rel)
	{
	if (!this.obj) return false;
	if (isNaN(y)) 
	   {
	   window.status= this.nombre + ".moveY -> y is NaN";
	   return false;
	   }
	if (is.ie4||is.dom) 
		{   
			if (rel) y=this.y() + y;
			this.obj.style.top=parseInt(y) +'px';
		}
      return this;
	}

function DIVsmoothMove(x,y)
	{
	var mx,my;
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		do
		{
		  mx=this.x();
		  my=this.y();
		  dx=Math.round((x-mx) / 5);
		  dy=Math.round((y-my) / 5);
		  if ((dx==0)&&(mx>x)) dx=-1;
		  if ((dx==0)&&(mx<x)) dx=1;
		  if ((dy==0)&&(my>y)) dy=-1;
		  if ((dy==0)&&(my<y)) dy=1;
		  this.move(mx+dx,my+dy);
		} while ((x!=mx)&&(y!=my));
      return this;
	}

function DIVSize(xx,yy, clip)
	{
	if (!this.obj) 
		{
		  return false;
		}
	if (is.ie4||is.dom) 
		{
		  if (parseInt(xx)>=0) 
			  {     this.obj.style.width=parseInt(xx) +'px';
			  }     
		  if (parseInt(yy)>=0) 
			  {     this.obj.style.height=parseInt(yy) +'px';
			  }
          if (clip) this.obj.style.clip='rect(0px ' + this.ancho() + 'px ' + this.alto() + 'px 0px)';
		}
      return this;
	}

function DIVGX()
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		{
		  t=this.obj.style.left.replace("px","");
		  if (!t) t = '0';
		  return parseInt(t);
		}
	}
function DIVGY()
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		{
		  t=this.obj.style.top.replace("px","");
		  if (!t) t = '0';
		  return parseInt(t);
		}
	}

function DIVGW()
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		{
		  if (this.obj.style) return parseInt(this.obj.style.width.replace("px",""));
		  else return this.obj.width;

		}
	}
function DIVGH()
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		{
		  var r=this.obj.height;
		  if (this.obj.style) if (parseInt(this.obj.style.height.replace("px",""))) r=parseInt(this.obj.style.height.replace("px",""));
		  if (this.TRACE) alert('H:' + r);
		  if (!r) r='0';
		  return parseInt(r);
		}
	}

function DIVRSZ()
	{
	if (!this.obj) return false;
    this.size(this.ancho(),this.alto());
      return this;
	}

function DIVSCLS(clase)
	{
	if (!this.obj) return false;
	if (is.ie4||is.dom) 
		{
		  this.obj.className=clase;
		}
      return this;
	}



function DIVTrans(opacity)
	{
	if (!this.obj) return false;
    if (is.ie) this.obj.style.filter="Alpha(opacity="+opacity+")";
    this.obj.style.MozOpacity=opacity/100;
      return this;
	}


function DIVClip()
{
	if (!this.obj) return false;
	if (!is.ie)
	  {var clipping='rect(0px ' + this.ancho() + 'px ' + this.alto() + 'px 0px); ';
       this.obj.style.clip=clipping;
      }
    else this.obj.style.clip="rect(0 auto auto 0)";
}

function DIVMacro(macro)
      {
      if (macro)
         {
	      var params=macro.split(';');
	      var a=0;
	      for (a=0;a<params.length;a++)
	          {
	          var mac=params[a];
	          if (mac)
	             {
	              if ((mac.indexOf("(")<0)&&(mac.indexOf("=")<0)) mac+="()";
	              eval('this.' + mac);
	             } 
	          }
	      }
      return this;    
      }



function DIVFloatMove()
   {
   	var vx=0;
   	var X=this.x();
   	var fX=this.floatX;
   	if (!X) X=0;
   	if (!fX) fX=0;

    newX=(navInfo.x()+fX);
    if (this.floatRight) newX=navInfo.x()+navInfo.anchoVentana()-this.ancho();

   	var vy=0;
   	var Y=this.y();
   	var fY=this.floatY;
   	if (!Y) Y=0;
   	if (!fY) fY=0;

    newY=(navInfo.y()+fY);
    if (this.floatBottom) newY=navInfo.y()+navInfo.altoVentana()-this.alto();

	if (this.smoothFloat)
	   {
	    if (newY!=Y)
	       {basey=newY-Y;
	        vy=Math.round(Math.abs(basey / this.segmento));
	        if (vy==0) vy=1;
	        if (Y>newY) vy*=-1;
	        this.moveY(vy ,1);
	       } 
	
	    if (newX!=X)
	       {basex=newX-X;
	        vx=Math.round(Math.abs(basex / this.segmento));
	        if (vx==0) vx=1;
	        if (X>newX) vx*=-1;
	        this.moveX(vx ,1);
	       } 
	   } else this.move(newX,newY);

      return this;
   }

function DIVFlotante(onOff,fx,fy)
      {
      if ((onOff)&&(!this.floatEvent))
         {
         	if (!fx) var fx=this.x();
         	if (!fy) var fx=this.y();
         	this.floatX=fx;
         	this.floatY=fy;
         	this.floatEvent=setInterval(this.DYNObj + ".floatMove()",this.floatTimer);
         }   

      if (!onOff) clearInterval(this.floatEvent);
      return this;
      }

function Div(nombre, useOpt, LayerListName, macro)
  {
  if (LayerListName) var nombre=LayerListName;
  if (DYNDIVARRAYEXIST(nombre)) return DYNDIVARRAYGETDIV(nombre,'div').macro(macro);
  this.TRACE=((useOpt&2)==2);
  useOpt=(useOpt&1);
  this.obj=BuscarObj(nombre);   //getLayer(nombre, useOpt);
  if (this.TRACE) alert(this.obj);
  this.nombre=nombre;
  this.hide=DIVhide;
  this.display=DIVdisplay;
  this.visible=DIVvisible;
  this.invisible=DIVinvisible;
  this.getDisplaying=DIVgetDisplay;
  this.displaying=this.getDisplaying();
  this.x=DIVGX;
  this.y=DIVGY;
  this.ancho=DIVGW;
  this.alto=DIVGH;
  this.size=DIVSize;
  this.move=DIVMove;
  this.moveX=DIVMoveX;
  this.moveY=DIVMoveY;
  this.smoothMove=DIVsmoothMove;
  this.estilo=DIVSCLS;
  this.del='DYNDIVARRAYDELETE("' + nombre + '")';
  this.DYNObj='DYNDIVARRAYGETDIV("' + nombre + '")';
  this.tipo='div';
  this.transparencia=DIVTrans;
  this.resize=DIVRSZ;
  this.clip=DIVClip
  this.macro=DIVMacro;

  this.floatY=0;
  this.floatX=0;
  this.flotante=DIVFlotante;
  this.floatMove=DIVFloatMove;
  this.floatEvent=0;
  this.floatTimer=20;
  this.segmento=10;
  this.smoothFloat=1;

  if (this.obj) DYNDIVARRAYADD(eval('this'));
  if (macro) this.macro(macro);
  }

var DYNDIVARRAY= new Array();
function  DYNDIVARRAYADD(dyndiv)
   {
   if (!dyndiv) return;
   if (!dyndiv.nombre) return;
   if (!DYNDIVARRAYEXIST(dyndiv.nombre))
      {
      DYNDIVARRAY[DYNDIVARRAY.length]=dyndiv;
      }
   }

function  DYNDIVARRAYEXIST(nombre)
   {
   for (a=0;a<DYNDIVARRAY.length;a++)   
      {
      if (DYNDIVARRAY[a].nombre==nombre) return true;
      }
   return false;   
   }

function  DYNDIVARRAYGETDIV(nombre,tipo)
   {
   //if (tipo) ;
   for (a=0;a<DYNDIVARRAY.length;a++)   
      {
      if (DYNDIVARRAY[a].nombre==nombre) return DYNDIVARRAY[a];
      }
   return false;   
   }

function  DYNDIVARRAYLIST()
   {
   var t="";
   for (a=0;a<DYNDIVARRAY.length;a++)   
      {
      t+=DYNDIVARRAY[a].nombre + '\n';
      }
   return t;   
   }



function DYNDIVARRAYDELETE(nombre)
{
lng=DYNDIVARRAY.length;
if (lng==0) return false;
for (a=0;a<lng;a++)   
    {
     if (DYNDIVARRAY[a].nombre==nombre);
        {
        for(b=a;b<lng;b++)
            {
            DYNDIVARRAY[b]=DYNDIVARRAY[b+1];
            }
        DYNDIVARRAY.length--;
        return true;
        }
    }
return false;
}

function fadeOUT(obj,contador)
{
if (contador>=0) 
   {
   document.getElementById(obj).style.MozOpacity=contador / 100
   document.getElementById(obj).style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=" + contador + ")"
   setTimeout("fadeOUT('" + obj + "'," + (contador -10) + ")",1)
   }
}

function fadeIN(obj,contador)
{
if (contador<=100) 
   {
   document.getElementById(obj).style.MozOpacity=contador / 100
   document.getElementById(obj).style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=" + contador + ")"
   setTimeout("fadeIN('" + obj + "'," + (contador +10) + ")",1)
   }
}

//****************************** resolucion.js  ******************************

function navInfoGetWX() 
	{ 
		var r;
		if (is.ie) r=document.body.clientWidth;
		else {
			r=window.innerWidth-1; 
		    if(this.altoDocumento() >= window.innerHeight-16) r=r-17;
		    }
 	    return r;
	}	  

function navInfoGetWY() 
	{ 
		var r;
		if (is.ie) r=document.body.clientHeight-1;
		else {
			  r=window.innerHeight-2;
			  if(this.anchoDocumento() >= window.innerWidth-16) r=r-16;
			}
 	    return r;
	}	  
function navInfoGetDX() 
	{ return (is.ie ? document.body.scrollWidth : document.documentElement.scrollWidth); }
function navInfoGetDY() 
	{ return (is.ie ? document.body.scrollHeight: document.documentElement.scrollHeight); }
function navInfoGetLeft() 
	{ return (is.ie ? document.body.scrollLeft : window.pageXOffset); }
function navInfoGetTop() 
	{ return (is.ie ? document.body.scrollTop  : window.pageYOffset); }

function NavInfo()
	{
	this.anchoVentana=navInfoGetWX;
	this.altoVentana=navInfoGetWY;
	this.anchoDocumento=navInfoGetDX;
	this.altoDocumento=navInfoGetDY;
	this.x=navInfoGetLeft;
	this.y=navInfoGetTop;
	}

var navInfo=new NavInfo();
 

function getres()
{
a=screen.width;
if (a==640) return 1;
if (a==800) return 2;
if (a==1024) return 3;
if (a==1280) return 4;
return 2;
}

//************************ Formateo de fecha ****************************

function isDate(dateStr) {
	
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
	alert("El formato de la fecha debe ser dd/mm/aaaa or dd-mm-aaaa.");
	return false;
	}
	
	month = matchArray[3]; // p@rse date into variables
	day = matchArray[1];
	year = matchArray[5];
	
	if (month < 1 || month > 12) { // check month range
	alert("El mes debe ser entre 1 y 12.");
	return false;
	}
	
	if (day < 1 || day > 31) {
	alert("El dia debe ser entre 1 y 31.");
	return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	alert(month + " no tiene 31 dias!")
	return false;
	}
	
	if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day > 29 || (day==29 && !isleap)) {
	alert("Febrero de " + year + " no tiene " + day + " dias!");
	return false;
	}
	}
	return true; // date is valid
}
