<!--
//*****************************************
// Blending Image Slide Show Script- 
//*****************************************

//specify interval between slide (in mili seconds)
var slidespeed=400

//specify images
var slideimages=new Array("images/panel02.jpg","images/panel04.jpg","images/panel06.jpg","images/panel05.jpg","images/panel07.jpg","images/panel08.jpg")

//specify corresponding links
var slidelinks=new Array("#","#","#","#")

var newwindow=1 //open links in new window? 1=yes, 0=no

var imageholder=new Array()
var ie=document.all
for (i=0;i<slideimages.length;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}

function gotoshow(){
if (newwindow)
window.open(slidelinks[whichlink])
else
window.location=slidelinks[whichlink]
}

//*****************************************
// END
//*****************************************



var colors = new Array(	"#7b7b7b", "#7b7b7b" , "#ffffff");

//	Set the basic color
var basicColor = "#7b7b7b";

//	Set the global vars to their initial state
var curColIdx = 0;
var curElem;

var	mousePosX = 0;
var mousePosY = 0;

//	Set the glow speed
var speed = 1;

//	Initialize glower scripts
function init()
{
	//	ie only :p

	if (!document.layers)
	{
		document.onmouseover = determine_tag;
		document.onmouseout = end_glow;
		check_state();
	}
}

//	Stop the glowing of a link
function end_glow()
{
	if (curElem)
	{
		//	Reset values
		curElem.style.color = basicColor;
		curColIdx = 0;
		curElem = false;
	}
}

//	Stop the glowing of a link
function start_glow(ev)
{
		// If element does not exist, return
		if (!curElem) return;
		ev = curElem;

		//	determine which color is being used
		tempCol = ev.style.color;
		if (tempCol == basicColor)
		{
			//	Reset colorindex
			curColIdx = 0;
		}
		if (!tempCol)
		{
			//	Color not yet set, set index to 0
			curColIdx = 0;
			tempCol = basicColor;
		}
		else
		{
			// 	Search current color
			itemN = colors.length;
			for (f = 0; f < itemN; f++)
			{
				if (colors[f] == tempCol)
				{
					//	Color found, update counter
					if (f >= (itemN-1))
					{
						// Jump to first color
						curColIdx = 0;
					}
					else
					{
						//	Increase color index with one
						curColIdx = f + 1;
					}

				} // end if: check for color

			}//	end if: search color

		}//	end if: initiate search

		//	set color
		ev.style.color = colors[curColIdx];

}

function determine_tag()
{
	ev = window.event.srcElement;
	mousePosX = window.event.offsetX;
	mousePosY = window.event.offsetY;

	tag = ev.tagName;

	//	Respond to anchor tags only
	if (tag == "A")
	{
		if (curElem)
		{
			curElem = false;
			return;
		}
		curElem = ev;
	}
	else
	{
		curElem = false;
	}
}

function check_state()
{
	if (curElem)
	{
		start_glow();
	}

		//	Object is selected, glow
	if (!curElem) end_glow();//	Object is not selected, do not glow


	//	Set timer
	window.setTimeout("check_state()", speed);
}














/////////////////////////////////

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




function ojo2()
{
	var a=confirm("Se borrarán todos los registro asociados a esta Lista de Casamiento.")
	if (a==1) {return true;}
	else {return false;}
}

function ojo3()
{
	var a=confirm("Se borrará la novedad.")
	if (a==1) {return true;}
	else {return false;}
}


//-------------------------------------------
// Cambia el estilo de los Links cuando se hace click

function ClickMenu(i,cont, estilo)
{
 for (n=1; n<(cont+1); n++)
 {
	 var menux = document.getElementById('menu_'+n);  
	 menux.className = estilo;
 }
 var Idmenu = document.getElementById('menu_'+i); 
 Idmenu.className = 'MenuClick'

}






//-------------------------------------------------------
// solo numeros, si no es numero devuelve false ----------

	function numero(cadena)
	{
	 var str = "1234567890";
	 for(cont = 0;cont < cadena.length;cont++)
		{
		tmp = cadena.substring(cont,cont+1);
		if (str.indexOf (tmp,0)== -1)
		return(false);
		}
	 return(true); 
	}
//---------------------------------------------------------








// FUNCION PARA EL MENU DE ACCESOS --------

	function Acceso(URL,WinName,Opciones)
	{
		if (URL != '' )		
		{	
		
			var combo = document.getElementById('ACCESOS');  
			
			window.open(URL,WinName,Opciones);			
			combo.selectedIndex = 0
			
		}
	}

//--------------------------------------------






// abre ventana nueva segun parametros recibidos--------

	function NewWin(URL,WinName,Opciones)

	{	window.open(URL,WinName,Opciones); }

//--------------------------------------------






// maximiza ventana --------------------------------

	function maxi() 
	{
	window.innerWidth = screen.width;
	window.innerHeight = screen.height;
	window.screenX = 0;
	window.screenY = 0;
	alwaysLowered = false;
	}

//--------------------------------------------





// imprimir -------------------------------------

	function WinImprime()

	{	
		window.print();
		window.close();

	}

//--------------------------------------------







//---------------------------------------------------------------


function redir(url)
{  
	if (url != '' )
	 { 	this.location.replace(url);  } 
	 
}  


//---------------------------------------------------------------





//---------------------------------------------------------------


function RedirParam(url,param)
{  
	if (param != '' )
	 { 
	 	//alert(url+param);
	 	this.location.replace(url+param);
	 } 
	 
}  



//---------------------------------------------------------------







//--------------------------------------------

function CheckMail(emailStr) 

{

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var firstChars=validChars
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom="(" + firstChars + validChars + "*" + ")"
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) return false;

	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) return false;

	var domainArray=domain.match(domainPat)

	if (domainArray==null) return false;

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length

	if (domArr[domArr.length-1].length<2 ||
			domArr[domArr.length-1].length>3) return false;

	if (domArr[domArr.length-1].length==3 && len<2) return false;

}

//--------------------------------------------







// *********** FUNCIONES DE FECHA **********************************

// año bisiesto, si es bisiesto devuelve true ----------

	function bisiesto(Vanio) 

	{
		if (Vanio % 4 == 0) 
			return true; 
		else 
			return false; 
	}

//--------------------------------------------




//cantidad de dias para cada mes---------------

	function dias_mes(vMES, vANIO) 
	
	{
	
	var vm = parseInt(vMES);
	
		switch (vm) 
		{
			case 1: 
				return 31;
				break;
			case 2: 
				return 29;
				break;
			case 3: 
				return 31;
				break;
			case 4: 
				return 30;
				break;
			case 5: 
				return 31;
				break;
			case 6: 
				return 30;
				break;
			case 7: 
				return 31;
				break;
			case 8: 
				return 31;
				break;
			case 9: 
				return 30;
				break;
			case 10: 
				return 31;
				break;
			case 11: 
				return 30;
				break;
			case 12: 
				return 31;
				break;
			default:
				return 31;
			
		}
		
	}




// valida fechas----------------------------------------

	function validafecha(REQ,dia,mes,anio) 

	{
	
		if ( (REQ==1) && ( (dia=="") || (mes=="") || (anio=="") ) )
		{ return (false);	}


		if ( dia > dias_mes(mes) )
		{	  return (false);		}


		if ((mes == 2) && ( (bisiesto(anio) == false) && (dia > 28) ) )
		{  return (false);		}

			
	}


// ******************************************************







// EXPANDE O CONTRAE OBJETOS ----------------------

function Expandir(NomObj,estilo) 
{ 
 
 var objeto = document.getElementById(NomObj);
 
 if ( objeto.className == 'contraido' ) 
 	  objeto.className = estilo ;
 else
 		objeto.className = 'contraido';
 
 
 //objeto.className = objeto.className == "contraido" ? estilo : "contraido";
 //tblDepo.className = tblDepo.className == "contraido" ? "expandido" : "contraido";


}

//-----------------------------------------------





// Confirma la eliminación de items en CheckBox ----------
function CheckBorrar(form)
{
var cant = form.contador.value;
var n=0;

	for (i=1;i<=cant;i=i+1)
	{
		var chbox = form.elements["Borrar_"+i];
		if (chbox.checked)
		{ n = (n+1); }
	}

	if (n>0)
	{ return confirm("¿ Confirma que va a ELIMINAR los Items seleccionados ?"); }

}

//-----------------------------------------------






// Valida Campos Requeridos ----------

function esVacio(FormName,campo,txtalerta)
{

	var campo = document.forms[FormName].elements[campo];
	var trimcampo = campo.value.replace(/^\s+|\s+$/g,'');

		
	if (trimcampo=='')
	{
	alert("Debe completar " + txtalerta);
	campo.focus();
	return (true);
	}

}

//-----------------------------------------------



// solo numeros, NUEVO!! ----------

	function NoEsNumero(FormName,campo,txtalerta)
	{
	 var campo = document.forms[FormName].elements[campo];
	 var cadena = campo.value;
	 var ERROR = false;
	 var str = "1234567890";
	 
	 for(cont = 0;cont < cadena.length;cont++)
		{
		tmp = cadena.substring(cont,cont+1);
		if (str.indexOf (tmp,0)== -1)
		ERROR=true;
		}	
		
		if (ERROR==true)
		{
		alert('Debe completar ' +txtalerta+ ' con Números' );
		campo.focus();
		return(true);
		}

	}
	
//---------------------------------------------------------






// valida fechas NUEVO!! -----------------------------------

	function evalFecha(REQ,FormName,DIA,MES,ANIO) 

	{

	  var ERROR = false;
	  var campo = document.forms[FormName].elements[DIA];
	  
	 	var dia = document.forms[FormName].elements[DIA].value;
	 	var mes = document.forms[FormName].elements[MES].value;
	 	var anio = document.forms[FormName].elements[ANIO].value;
	
		if ( (REQ==1) && ( (dia=='') || (mes=='') || (anio=='') ) )
		{ ERROR=true; }
		
		if ( dia > dias_mes(mes) )
		{	ERROR=true; }

		if ((mes == 2) && ( (bisiesto(anio) == false) && (dia > 28) ) )
		{ ERROR=true; }

		if (ERROR==true)
		{
		alert('La Fecha es incorrecta');
		campo.focus();
		return(true);
		}

			
	}












//-----------------------------------------------------------------
//------------------------RICARDO ---------------------------------
//-----------------------------------------------------------------

// En campos TEXTAREA PERMITE HASTA CIERTA CANTIDAD DE CARACTERES 

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}


// EMPLEOS

function CheckAll()
{
 for (var i=0;i<document.MultiOp.elements.length;i++)
 {
  var e=document.MultiOp.elements[i];
  if (e.name != 'allbox')
   e.checked=document.MultiOp.allbox.checked;
 }
}

function check()
{
var aux;
	for (var i=0; i<document.formulario.elements.length; i++)
	{
		if (document.formulario.elements[i].name.substring(0,1)=="#")
		{
			if (document.formulario.elements[i].checked==true)
			{
				aux=1;
			}
		}
	}
	if (aux!=1)
	{
		alert("Debe elegir al menos un alumno");
		return false;
	}
	else
	{
		return true;
	}
}

function CheckAll()
{
 for (var i=0;i<document.formulario.elements.length;i++)
 {
  var e=document.formulario.elements[i];
  if (e.name != 'allbox')
   e.checked=document.formulario.allbox.checked;
 }
}


function formu()
{
	if (check(document.formulario))
	{
		document.formulario.action="_SistemaBusqueda3.asp?flag=1";
		document.formulario.submit();
	}
}


//////////////////////////////////////



browserType=navigator.appName.charAt(0)+navigator.appVersion.charAt(0)




function launchWindow(myURL,myWidth,myHeight) {
        if (browserType=="N2") {

siteWindow=window.open("","","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+myWidth+",height="+myHeight);

                siteWindow.opener=self;
                siteWindow=myURL
        }
        if (browserType.charAt(0)=="M") {

siteWindow=window.open(myURL,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+myWidth+",height="+myHeight);

                siteWindow.opener=self;
        }
        else {

siteWindow=window.open(myURL,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+myWidth+",height="+myHeight);

                siteWindow.opener=self;
        }
	setTimeout("siteWindow.focus();",200);

}


/////////////

function check(formu)
{
var iano1
var eano1
var iano2
var eano2
var iano3
var eano3
var iano4
var eano4


		if (formu.elements.iano1.value > formu.elements.eano1.value) 
		{
			alert("Fecha de Egreso Erronea "+formu.elements.iano1.value + " " + formu.elements.eano1.value);
			formu.elements.iano1.focus();
			return false
		}

		if (formu.elements.iano2.value > formu.elements.eano2.value) 
		{
			alert("Fecha de Egreso Erronea "+formu.elements.iano2.value + " " + formu.elements.eano2.value);
			formu.elements.iano2.focus();
			return false
		}

		if (formu.elements.iano3.value > formu.elements.eano3.value) 
		{
			alert("Fecha de Egreso Erronea "+formu.elements.iano3.value + " " + formu.elements.eano3.value);
			formu.elements.iano3.focus();
			return false
		}

				if (formu.elements.iano4.value > formu.elements.eano4.value) 
		{
			alert("Fecha de Egreso Erronea "+formu.elements.iano4.value + " " + formu.elements.eano4.value);
			formu.elements.iano4.focus();
			return false
		}
}

//-------------------------------------------
// 


function AddText(form, Action)
{
var AddTxt="";
var txt="";
if(Action==1){
	txt=prompt("Texto para el Encabezado 1.","Texto");
	if(txt!=null)
		AddTxt="<h4>"+txt+"</h4>\r\n";
	}

if(Action==2){
	txt=prompt("Texto para el Encabezado 2.","Texto");
	if(txt!=null)
		AddTxt="<h5>"+txt+"</h5>\r\n";
	}

if(Action==3){
	txt=prompt("Texto para el Encabezado 3.","Texto");
	if(txt!=null)
		AddTxt="<h3>"+txt+"</h3>\r\n";
	}

if(Action==4){
	txt=prompt("Texto en Negrita.","Texto");
	if(txt!=null)
		AddTxt="<b>"+txt+"</b>";
	}

if(Action==5){
	txt=prompt("Texto en Cursiva","Texto");
	if(txt!=null)
		AddTxt="<i>"+txt+"</i>";
	}

if(Action==6)
	AddTxt="\r\n<p>";

if(Action==7)
	AddTxt="<br>\r\n";

if(Action==8)
	AddTxt="<hr>\r\n";

if(Action==9){
	txt=prompt("URL del Vínculo.","http://");
	if(txt!=null){
		AddTxt="<a href="+txt+">";
		txt=prompt("Texto que debe Mostrar el Vínculo","Texto");
		AddTxt+=txt+"</a>\r\n";
		}
	}

if(Action==10){
	txt=prompt("E-mail:","");
	if(txt!=null){
		AddTxt="<a href=mailto:"+txt+">";
		txt=prompt("Texto que debe Mostrar el Vínculo del e-mail","Texto");
		AddTxt+=txt+"</a>\r\n";
		}
	}

form.Descripcion.value+=AddTxt;



}

function ojo()
{
	var a=confirm("Se borrará esta Sección y todas sus Noticias asociadas")
	if (a==1) {return true;}
	else {return false;}
}

function vacio(test)
{
	if (test.ingreso.value=="")
	{alert ("Debe ingresar una Sección")
	return false;}
	else
	{return true;}
}

function check_posicion(formu)
{
	var ar = new Array();
	var igual=0;
	for (var i=0; i<formu.elements.length; i++){
		if (formu.elements[i].name.substring(0,1)=="#"){
			if (formu.elements[i].value==""){
				alert("Debe completar todas las posiciones de las secciones"); // + formu.elements[i].name.substr(1));
				formu.elements[i].focus()
				return false;
				break;
			}
			for (j=0; j<formu.elements[i].value.length; j++)
			{
				if ((formu.elements[i].value.substring(j,j+1) != "0") && (formu.elements[i].value.substring(j,j+1) != "1") && (formu.elements[i].value.substring(j,j+1) != "2") && (formu.elements[i].value.substring(j,j+1) != "3") && (formu.elements[i].value.substring(j,j+1) != "4") && (formu.elements[i].value.substring(j,j+1) != "5") && (formu.elements[i].value.substring(j,j+1) != "6") && (formu.elements[i].value.substring(j,j+1) != "7") && (formu.elements[i].value.substring(j,j+1) != "8") && (formu.elements[i].value.substring(j,j+1) != "9"))
				{
					alert("Debe completar las posiciones con un número");
					formu.elements[i].focus()
					return false;
					break;
				}
			}
			for (var j=0; j<i; j++)
			{
				if (formu.elements[i].value==ar[j])
				{
					igual=1;
				}
			}
			if (igual==1)
			{
				alert("Dos Secciones no pueden tener la misma posición");
				formu.elements[i].focus()
				return false;
				break;
			}
			else
			{
				ar[i] = formu.elements[i].value;
			}
		}
	}

}





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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



////////////////////////////////////////////////////////////////////////////////////////



function checkrequired(which) {
	var pass=true;
	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) {
				pass=false;
			break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();

if(shortFieldName=="CODNOVIOS"){
	shortFieldName= "Codigo ";
}

if(shortFieldName=="DATEBOX"){
	shortFieldName= "FECHA DEL ALTA ";
}

if(shortFieldName=="DATEBOX2"){
	shortFieldName= "FECHA DE BAJA ";
}

if(shortFieldName=="DATEBOX3"){
	shortFieldName= "FECHA DE CUMPLEAÑOS NOVIO ";
}

if(shortFieldName=="DATEBOX4"){
	shortFieldName= "FECHA DE CUMPLEAÑOS NOVIA ";
}

if(shortFieldName=="DATEBOX5"){
	shortFieldName= "FECHA DE ENLACE ";
}


if(shortFieldName=="APELLIDONOVIO"){
	shortFieldName= "APELLIDO DEL NOVIO ";
}


if(shortFieldName=="NOMBRENOVIO"){
	shortFieldName= "NOMBRE DEL NOVIO ";
}

if(shortFieldName=="APELLIDONOVIA"){
	shortFieldName= "APELLIDO DE LA NOVIA ";
}

if(shortFieldName=="NOMBRENOVIA"){
	shortFieldName= "NOMBRE DE LA NOVIA ";
}

if(shortFieldName=="EMAILNOVIO"){
	shortFieldName= "EMAIL DEL NOVIO ";
}

if(shortFieldName=="EMAILNOVIA"){
	shortFieldName= "EMAIL DE LA NOVIA ";
}

if(shortFieldName=="PASSWORDNOVIOS"){
	shortFieldName= "PASSWORD DE LOS NOVIOS ";
}

if(shortFieldName=="PASSWORDINVITADOS"){
	shortFieldName= "PASSWORD DE LOS INVITADOS ";
}



alert("Completar "+shortFieldName+".");
return false;
}
else
return true;
}



function checkrequired2(which) {
	var pass=true;
	if (document.images) {
		for (i=0;i<which.length;i++) {
			var tempobj=which.elements[i];
			if (tempobj.name.substring(0,8)=="required") {
				if (((tempobj.type=="text"||tempobj.type=="textarea")&&
				tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
				tempobj.selectedIndex==0)) {
				pass=false;
			break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();


alert("Completar "+shortFieldName+".");
return false;
}
else
return true;
}



<!-- Original:  Kedar R. Bhave (softricks@hotmail.com) -->
<!-- Web Site:  http://www.softricks.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

var weekend = [0,6];
var weekendColor = "#e0e0e0";
var fontface = "Verdana";
var fontsize = 5;

var gNow = new Date();
var ggWinCal;
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;

Calendar.Months = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
"Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];

// Non-Leap year Month days..
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Leap year Month days..
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
	if ((p_month == null) && (p_year == null))	return;

	if (p_WinCal == null)
		this.gWinCal = ggWinCal;
	else
		this.gWinCal = p_WinCal;
	
	if (p_month == null) {
		this.gMonthName = null;
		this.gMonth = null;
		this.gYearly = true;
	} else {
		this.gMonthName = Calendar.get_month(p_month);
		this.gMonth = new Number(p_month);
		this.gYearly = false;
	}

	this.gYear = p_year;
	this.gFormat = p_format;
	this.gBGColor = "white";
	this.gFGColor = "black";
	this.gTextColor = "black";
	this.gHeaderColor = "black";
	this.gReturnItem = p_item;
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;

function Calendar_get_month(monthNo) {
	return Calendar.Months[monthNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {
	/* 
	Check for leap year ..
	1.Years evenly divisible by four are normally leap years, except for... 
	2.Years also evenly divisible by 100 are not leap years, except for... 
	3.Years also evenly divisible by 400 are leap years. 
	*/
	if ((p_year % 4) == 0) {
		if ((p_year % 100) == 0 && (p_year % 400) != 0)
			return Calendar.DOMonth[monthNo];
	
		return Calendar.lDOMonth[monthNo];
	} else
		return Calendar.DOMonth[monthNo];
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	
	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

function Calendar_print() {
	ggWinCal.print();
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {
	/* 
	Will return an 1-D array with 1st element being the calculated month 
	and second being the calculated year 
	after applying the month increment/decrement as specified by 'incr' parameter.
	'incr' will normally have 1/-1 to navigate thru the months.
	*/
	var ret_arr = new Array();
	
	if (incr == -1) {
		// B A C K W A R D
		if (p_Month == 0) {
			ret_arr[0] = 11;
			ret_arr[1] = parseInt(p_Year) - 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) - 1;
			ret_arr[1] = parseInt(p_Year);
		}
	} else if (incr == 1) {
		// F O R W A R D
		if (p_Month == 11) {
			ret_arr[0] = 0;
			ret_arr[1] = parseInt(p_Year) + 1;
		}
		else {
			ret_arr[0] = parseInt(p_Month) + 1;
			ret_arr[1] = parseInt(p_Year);
		}
	}
	
	return ret_arr;
}

// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {
	var vCode = "";
	var vHeader_Code = "";
	var vData_Code = "";
	
	// Begin Table Drawing code here..
	vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
	
	vHeader_Code = this.cal_header();
	vData_Code = this.cal_data();
	vCode = vCode + vHeader_Code + vData_Code;
	
	vCode = vCode + "</TABLE>";
	
	return vCode;
}

Calendar.prototype.show = function() {
	var vCode = "";
	
	this.gWinCal.document.open();

	// Setup the page...
	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("</head>");

	this.wwrite("<body " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");
	this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
	this.wwriteA(this.gMonthName + " " + this.gYear);
	this.wwriteA("</B><BR>");

	// Show navigation buttons
	var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
	var prevMM = prevMMYYYY[0];
	var prevYYYY = prevMMYYYY[1];

	var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
	var nextMM = nextMMYYYY[0];
	var nextYYYY = nextMMYYYY[1];
	this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=''><TR><TD ALIGN=center>");
	this.wwrite("<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
		");" +
		"\"><IMG SRC=images/izquierda.gif border=0><\/A></TD><TD ALIGN=center>");
	this.wwrite("<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\"><IMG SRC=images/izq.gif border=0><\/A></TD><TD ALIGN=center>");
	this.wwrite("<A HREF=\"javascript:window.print();\"><IMG SRC=images/print.gif border=0></A></TD><TD ALIGN=center>");
	this.wwrite("<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\"><IMG SRC=images/der.gif border=0><\/A></TD><TD ALIGN=center>");
	this.wwrite("<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
		");" +
		"\"><IMG SRC=images/derecha.gif border=0><\/A></TD></TR></TABLE><BR>");

	// Get the complete calendar code for the month..
	vCode = this.getMonthlyCalendarCode();
	this.wwrite(vCode);

	this.wwrite("</font></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.showY = function() {
	var vCode = "";
	var i;
	var vr, vc, vx, vy;		// Row, Column, X-coord, Y-coord
	var vxf = 285;			// X-Factor
	var vyf = 200;			// Y-Factor
	var vxm = 10;			// X-margin
	var vym;				// Y-margin
	if (isIE)	vym = 75;
	else if (isNav)	vym = 25;
	
	this.gWinCal.document.open();

	this.wwrite("<html>");
	this.wwrite("<head><title>Calendar</title>");
	this.wwrite("<style type='text/css'>\n<!--");
	for (i=0; i<12; i++) {
		vc = i % 3;
		if (i>=0 && i<= 2)	vr = 0;
		if (i>=3 && i<= 5)	vr = 1;
		if (i>=6 && i<= 8)	vr = 2;
		if (i>=9 && i<= 11)	vr = 3;
		
		vx = parseInt(vxf * vc) + vxm;
		vy = parseInt(vyf * vr) + vym;

		this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
	}
	this.wwrite("-->\n</style>");
	this.wwrite("</head>");

	this.wwrite("<body " + 
		"link=\"" + this.gLinkColor + "\" " + 
		"vlink=\"" + this.gLinkColor + "\" " +
		"alink=\"" + this.gLinkColor + "\" " +
		"text=\"" + this.gTextColor + "\">");
	this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
	this.wwrite("Year : " + this.gYear);
	this.wwrite("</B><BR>");

	// Show navigation buttons
	var prevYYYY = parseInt(this.gYear) - 1;
	var nextYYYY = parseInt(this.gYear) + 1;
	
	this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
	this.wwrite("[<A HREF=\"" +
		"javascript:window.opener.Build(" + 
		"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
		");" +
		"\">>><\/A>]</TD></TR></TABLE><BR>");

	// Get the complete calendar code for each month..
	var j;
	for (i=11; i>=0; i--) {
		if (isIE)
			this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
		else if (isNav)
			this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

		this.gMonth = i;
		this.gMonthName = Calendar.get_month(this.gMonth);
		vCode = this.getMonthlyCalendarCode();
		this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
		this.wwrite(vCode);

		if (isIE)
			this.wwrite("</DIV>");
		else if (isNav)
			this.wwrite("</LAYER>");
	}

	this.wwrite("</font><BR></body></html>");
	this.gWinCal.document.close();
}

Calendar.prototype.wwrite = function(wtext) {
	this.gWinCal.document.writeln(wtext);
}

Calendar.prototype.wwriteA = function(wtext) {
	this.gWinCal.document.write(wtext);
}

Calendar.prototype.cal_header = function() {
	var vCode = "";
	
	vCode = vCode + "<TR>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Dom</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Lun</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mar</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mie</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Jue</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Vie</B></FONT></TD>";
	vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sab</B></FONT></TD>";
	vCode = vCode + "</TR>";
	
	return vCode;
}

Calendar.prototype.cal_data = function() {
	var vDate = new Date();
	vDate.setDate(1);
	vDate.setMonth(this.gMonth);
	vDate.setFullYear(this.gYear);

	var vFirstDay=vDate.getDay();
	var vDay=1;
	var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
	var vOnLastDay=0;
	var vCode = "";

	/*
	Get day for the 1st of the requested month/year..
	Place as many blank cells before the 1st day of the month as necessary. 
	*/

	vCode = vCode + "<TR>";
	for (i=0; i<vFirstDay; i++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
	}

	// Write rest of the 1st week
	for (j=vFirstDay; j<7; j++) {
		vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
			"<A HREF='#' " + 
				"onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
				this.format_data(vDay) + 
				"';window.close();\">" + 
				this.format_day(vDay) + 
			"</A>" + 
			"</FONT></TD>";
		vDay=vDay + 1;
	}
	vCode = vCode + "</TR>";

	// Write the rest of the weeks
	for (k=2; k<7; k++) {
		vCode = vCode + "<TR>";

		for (j=0; j<7; j++) {
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
				"<A HREF='#' " + 
					"onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
					this.format_data(vDay) + 
					"';window.close();\">" + 
				this.format_day(vDay) + 
				"</A>" + 
				"</FONT></TD>";
			vDay=vDay + 1;

			if (vDay > vLastDay) {
				vOnLastDay = 1;
				break;
			}
		}

		if (j == 6)
			vCode = vCode + "</TR>";
		if (vOnLastDay == 1)
			break;
	}
	
	// Fill up the rest of last week with proper blanks, so that we get proper square blocks
	for (m=1; m<(7-j); m++) {
		if (this.gYearly)
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
		else
			vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
			"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
	}
	
	return vCode;
}

Calendar.prototype.format_day = function(vday) {
	var vNowDay = gNow.getDate();
	var vNowMonth = gNow.getMonth();
	var vNowYear = gNow.getFullYear();

	if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
		return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
	else
		return (vday);
}

Calendar.prototype.write_weekend_string = function(vday) {
	var i;

	// Return special formatting for the weekend day.
	for (i=0; i<weekend.length; i++) {
		if (vday == weekend[i])
			return (" BGCOLOR=\"" + weekendColor + "\"");
	}
	
	return "";
}

Calendar.prototype.format_data = function(p_day) {
	var vData;
	var vMonth = 1 + this.gMonth;
	vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
	var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
	var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
	var vY4 = new String(this.gYear);
	var vY2 = new String(this.gYear.substr(2,2));
	var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

	switch (this.gFormat) {
		case "MM\/DD\/YYYY" :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
			break;
		case "MM\/DD\/YY" :
			vData = vMonth + "\/" + vDD + "\/" + vY2;
			break;
		case "MM-DD-YYYY" :
			vData = vMonth + "-" + vDD + "-" + vY4;
			break;
		case "MM-DD-YY" :
			vData = vMonth + "-" + vDD + "-" + vY2;
			break;

		case "DD\/MON\/YYYY" :
			vData = vDD + "\/" + vMon + "\/" + vY4;
			break;
		case "DD\/MON\/YY" :
			vData = vDD + "\/" + vMon + "\/" + vY2;
			break;
		case "DD-MON-YYYY" :
			vData = vDD + "-" + vMon + "-" + vY4;
			break;
		case "DD-MON-YY" :
			vData = vDD + "-" + vMon + "-" + vY2;
			break;

		case "DD\/MONTH\/YYYY" :
			vData = vDD + "\/" + vFMon + "\/" + vY4;
			break;
		case "DD\/MONTH\/YY" :
			vData = vDD + "\/" + vFMon + "\/" + vY2;
			break;
		case "DD-MONTH-YYYY" :
			vData = vDD + "-" + vFMon + "-" + vY4;
			break;
		case "DD-MONTH-YY" :
			vData = vDD + "-" + vFMon + "-" + vY2;
			break;

		case "DD\/MM\/YYYY" :
			vData = vDD + "\/" + vMonth + "\/" + vY4;
			break;
		case "DD\/MM\/YY" :
			vData = vDD + "\/" + vMonth + "\/" + vY2;
			break;
		case "DD-MM-YYYY" :
			vData = vDD + "-" + vMonth + "-" + vY4;
			break;
		case "DD-MM-YY" :
			vData = vDD + "-" + vMonth + "-" + vY2;
			break;

		default :
			vData = vMonth + "\/" + vDD + "\/" + vY4;
	}

	return vData;
}

function Build(p_item, p_month, p_year, p_format) {
	var p_WinCal = ggWinCal;
	gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);

	// Customize your Calendar here..
	gCal.gBGColor="white";
	gCal.gLinkColor="black";
	gCal.gTextColor="black";
	gCal.gHeaderColor="darkgreen";

	// Choose appropriate show function
	if (gCal.gYearly)	gCal.showY();
	else	gCal.show();
}

function show_calendar() {
	/* 
		p_month : 0-11 for Jan-Dec; 12 for All Months.
		p_year	: 4-digit year
		p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
		p_item	: Return Item.
	*/

	p_item = arguments[0];
	if (arguments[1] == null)
		p_month = new String(gNow.getMonth());
	else
		p_month = arguments[1];
	if (arguments[2] == "" || arguments[2] == null)
		p_year = new String(gNow.getFullYear().toString());
	else
		p_year = arguments[2];
	if (arguments[3] == null)
		p_format = "MM/DD/YYYY";
	else
		p_format = arguments[3];

	vWinCal = window.open("", "Calendar", 
		"width=250,height=250,status=no,resizable=no,top=200,left=200");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, p_month, p_year, p_format);
}
/*
Yearly Calendar Code Starts here
*/
function show_yearly_calendar(p_item, p_year, p_format) {
	// Load the defaults..
	if (p_year == null || p_year == "")
		p_year = new String(gNow.getFullYear().toString());
	if (p_format == null || p_format == "")
		p_format = "MM/DD/YYYY";

	var vWinCal = window.open("", "Calendar", "scrollbars=yes");
	vWinCal.opener = self;
	ggWinCal = vWinCal;

	Build(p_item, null, p_year, p_format);
}


