<!--

function insertar_fecha(dia, mes, anio) {
	dia = dia + "";
	mes = mes + "";
	dia = (dia.length < 2)? "0" + dia : dia;
	mes = (mes.length < 2)? "0" + mes : mes;

	document.getElementById(grupo_fecha).value  = dia + "/" + mes + "/" + anio;

	oCalendario.hideIt();
	mostrado = false;
}


function lib_bwcheck() {
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie =this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

var bw=new lib_bwcheck();
var stayFolded = false;
mainOffsetY = 0;
var px = (bw.ns4||bw.opera5)? "":"px";

function makeMenu(obj,nest){
	nest= (!nest)?"":'document.'+nest+'.';
	this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):document.getElementById(obj);
   	this.css= bw.ns4?this.el:this.el.style;
	this.ref= bw.ns4?this.el.document:document;
	this.x= (bw.ns4||bw.opera5)?this.css.left:this.el.offsetLeft;
	this.y= (bw.ns4||bw.opera5)?this.css.top:this.el.offsetTop;
	this.h= (bw.ie||bw.ns6)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.opera5?this.css.pixelHeight:0;
    this.vis= b_vis;
	this.hideIt = b_hideIt;
    this.showIt = b_showIt;
    this.moveIt = b_moveIt;
	this.fadeIt = b_fadeIt;

	return this
}

function b_showIt(){
     this.css.visibility='visible';
}

function b_hideIt(){
	this.css.visibility='hidden';
}

function b_vis(){
   if(this.css.visibility=='hidden' || this.css.visibility=='HIDDEN' || this.css.visibility=='hide')
   return true
}

function b_moveIt(x,y){
   this.x=x;
   this.y=y;
   this.css.left=this.x+px;
   this.css.top=this.y+px;
}

function b_fadeIt() {
   if(bw.ie) {
		this.css.filter="blendTrans(duration=0.05)";
		// Me aseguro que no se esté ejecutando el filtro antes de llamarlo de nuevo
		if (this.el.filters.blendTrans.status != 2) {
		   this.el.filters.blendTrans.apply();
		   this.hideIt();
		   this.el.filters.blendTrans.play();
		}

		this.css.filter="blendTrans(duration=0.3)";
		// Me aseguro que no se esté ejecutando el filtro antes de llamarlo de nuevo
		if (this.el.filters.blendTrans.status != 2) {
		   this.el.filters.blendTrans.apply();
		   this.showIt();
		   this.el.filters.blendTrans.play();
		}
	}
}

function _menu(num){
	if(bw.bw){
		if (!stayFolded){
			for (var i=0; i<oSub.length; i++){
				if (i!=num){
					oSub[i].hideIt();
				}
			}
			for(var i=1; i<oTop.length; i++){
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h)
			}
		}
		if (oSub[num].vis())  {  //si esta oculta la hago visible
			oSub[num].showIt();
			oSub[num].fadeIt();
		}
		else      			  // esta visible y la hago oculta
			oSub[num].hideIt();

		for(var i=1; i<oTop.length; i++){
			if (!oSub[i-1].vis()) oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+oSub[i-1].h+mainOffsetY)
			else oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].h+mainOffsetY)
		}
	}
}

function initFoldout(){
	oTop = new Array();
	oSub = new Array();

	for (var i=0; i<FoldNumber; i++){
		oTop[i] = new makeMenu('divTop'+i,'divCont')
		oSub[i] = new makeMenu('divSub'+i,'divCont.document.divTop'+i)
		oSub[i].hideIt()
	}

	oTop[0].moveIt(0,0)

	for (var i=1; i<oTop.length; i++){
		oTop[i].moveIt(0, oTop[i-1].y+oTop[i-1].h+mainOffsetY)
	}

	oCont = new makeMenu('divCont');
	oCont.showIt();
}

function Calendar(posX, posY) {
	
	this.arrNombreMeses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
    this.hoy         = new Date();   //Hoy
	this.primero     = new Date();   //Primer dia del mes actual
	this.mes         = new Date();   //mes actual
	this.arrDias     = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    this.dibujar     = _dibujar;
	this.obtenerHTML = _obtenerHTML;
	this.anterior    = _anterior;     //Mes anterior
	this.siguiente   = _siguiente;    //Mes siguiente
	this.anio        = this.hoy.getFullYear();  //Año actual
	this.posX        = posX;
	this.posY        = posY;

}

function _anterior() {
	if (this.hoy.getMonth() == 0) {
		this.anio--;
		this.hoy.setFullYear(this.anio, 11, 1);
	}
	else this.hoy.setMonth(this.hoy.getMonth() - 1);

	document.getElementById('divCalend').innerHTML = this.obtenerHTML();
}

function _siguiente() {
    if (this.hoy.getMonth() == 11) {
		this.anio++;
		this.hoy.setFullYear(this.anio, 0, 1);
	}
	else this.hoy.setMonth(this.hoy.getMonth() + 1);

	document.getElementById('divCalend').innerHTML = this.obtenerHTML();
}
function _obtenerHTML() {
	//Compruebo si este año es bisiesto
	if (((this.anio % 4 == 0) && (this.anio % 100 != 0)) || (this.anio % 400 == 0))
	      this.arrDias[1] = 29;

	//Obtengo el numero total de días de este mes
	var intnumerodias = this.arrDias[this.hoy.getMonth()];

	//Empiezo a dibujar el calendario
	var strCalendarHTML = "<table border='0' cellpadding='0' cellspacing='0' width='140'>";
	//compongo cabecera del calendario
    	strCalendarHTML += "<tr height='15'><td class='cab_calendario' colspan='6'>&nbsp;</td><td width='20' class='cab_calendario'><a href='javascript:cerrar_calendario();' class='cab_calendario' title='Cerrar calendario'><b>X</b></a></td></tr>";
	strCalendarHTML += "<tr height='15'><td width='20' class='cab_calendario'><a href='javascript:anterior();' class='cab_calendario'>&lt;&lt;</a></td><td width='100' colspan='5' class='cab_calendario'>";
	strCalendarHTML += this.arrNombreMeses[this.hoy.getMonth()];
	strCalendarHTML += " " + this.anio;
	strCalendarHTML += "<td width='20' class='cab_calendario'><a href='javascript:siguiente();' class='cab_calendario'>&gt;&gt;</a></td></tr>";
	strCalendarHTML +=  "<tr height='15'><td class='cab_calendario' height='15'>L<td class='cab_calendario'>M<td class='cab_calendario'>X<td class='cab_calendario'>J<td class='cab_calendario'>V<td class='cab_calendario'>S<td class='cab_calendario'>D</tr>";
        // ISRAEL
    	// strCalendarHTML +=  "<tr><td colspan='7' bgcolor='#4A4D4A'><img src='px.gif' width='140' height='1'></td></tr>";
    	strCalendarHTML +=  "<tr><td colspan='7' bgcolor='#4A4D4A'><img width='140' height='1'></td></tr>";

    //this.primero contiene el primer dia del mes 1=Lunes, 2=Martes, ...
	this.primero = this.hoy;
	this.primero.setDate(1);
	//variable de ayuda para barrer los siete dias de la semana
	var cursor = this.primero.getDay();
	if (cursor == 0) cursor = 7;

	//Filas del calendario
	strCalendarHTML += "<tr height='15'>"

	for (i=1; i<cursor; i++)   {
	  //dibujo las celdas en blanco hasta el comienzo del primer dia
	  strCalendarHTML += "<td height='15' class='dia_calendario'>&nbsp;</td>";
    }

	for (i=1; i<=intnumerodias; i++)   {
	  if (cursor < 6) strCalendarHTML += "<td height='15' class='dia_lab_calendario'>";
	  else            strCalendarHTML += "<td height='15' class='dia_fes_calendario'>";

	  strCalendarHTML += "<a href='javascript:insertar_fecha(" + i + ", " + (this.hoy.getMonth()+ 1) + ", " + this.anio + ")' class='dia_calendario'>" + i + "</a>";
	  strCalendarHTML += "</td>";
      	cursor++;

      if (cursor == 8)  {
         strCalendarHTML += "</tr><tr height='15'>";
         cursor = 1;
      }

    }

	strCalendarHTML += "</tr>";
	strCalendarHTML += "</table>";

	return strCalendarHTML;
}

function _dibujar(campoFecha) {

	//Dibujo la capa que contendrá en calendario
	//this.obtenerHTML();
	document.write("<div id='divCalend' style='position:absolute; left:" + this.posX + "px; top:" + this.posY + "px; width:142px; height:10px; z-index:2; background-color: #FFFFFF; layer-background-color: #FFFFFF; visibility: hidden; border-width:1px; border-style:ridge; border-color:#000000'>");

	//Obtengo el HTML comrrespodiente al mes de hoy
	document.write(this.obtenerHTML());
	document.write("</div>");
}

//Todo el script es para manejar el calendario
var xCal = 0;
var yCal = 0;
var ahora = new Date();

// Posicion  del calendario
objCalendar = new Calendar(xCal, yCal);
objCalendar.dibujar();


//Funciones para manejar el calendario.

function anterior() {
	objCalendar.anterior();
}

function siguiente() {
	objCalendar.siguiente();
}

function cerrar_calendario() {
	oCalendario.hideIt();
}

var mostrado = false;
var grupo_fecha = "";   //campo fecha en la que se insertará tras pulsar en el calendario.

function mostrarCalendario(grupo) {

	if (!mostrado) {
		oCalendario = new makeMenu("divCalend");
		oCalendario.showIt();
		mostrado = true;
	}
	else {
		//El Calendario esta visible y lo oculto
		oCalendario.hideIt();
		mostrado = false;
	}

	//Guardo el grupo al que apunta el calendario
	grupo_fecha = grupo;
}

function colocar(coorX,coorY){

    if (document.layers)  //NS
    {
      document.layers.divCalend.left = coorX+'px';
      document.layers.divCalend.top  = coorY+'px';     
    }
    else if (document.all)//IE
    {
      document.all.divCalend.style.left = coorX+'px';
      document.all.divCalend.style.top  = coorY+'px';
    }

}
//FIN del manejo de calendario


-->
