﻿/*
 *Para visualizar u ocultar un div
 */
function OnToggleTOCLevel1(level2ID)
{
   var elemLevel2 = document.getElementById(level2ID);
   if (elemLevel2.style.display == 'none')
   {
      elemLevel2.style.display = 'block';
   }
   else {
      elemLevel2.style.display = 'none';
   }
}


/************************************
 * Para enmascarar campos de texto
 ***********************************/
 function checkDigit(obj, longitud)
{
var txt = "(\\d|%)+$"
var elementLong = obj.value.length
var re = new RegExp(txt); 
if (!obj.value.match(re))
    obj.value = obj.value.substring(0,obj.value.length-1);
if (elementLong > longitud)
    obj.value = obj.value.substring(0,obj.value.length-1);

}

/*********************************
 *   Fin de enmascaramiento
 ********************************/

function checkCaseLetter(obj,longitud)
{
    var txt = "[A-Z]+$";
    var elementLong = obj.value.length;
    var re = new RegExp(txt);
    if (!obj.value.match(re))
        obj.value = obj.value.substring(0,obj.value.length-1);
    if (elementLong > longitud)
        obj.value = obj.value.substring(0,obj.value.length-1);
}

/**************************************************************
Máscara de entrada. Script creado por Tunait! (21/12/2004)
Si quieres usar este script en tu sitio eres libre de hacerlo con la condición de que permanezcan intactas estas líneas, osea, los créditos.
No autorizo a distribuír el código en sitios de script sin previa autorización
Si quieres distribuírlo, por favor, contacta conmigo.
Ver condiciones de uso en http://javascript.tunait.com/
tunait@yahoo.com 
****************************************************************/
var patron = new Array(8)
var patron2 = new Array(1,3,3,3,3)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}


function changeSubjects(){

/* #######################

first we define the menus for easy reference

####################### */

aMenu=document.formTripleMenu.menuSubjects

aMenu2=document.formTripleMenu.menuFiles

aMenu3=document.formTripleMenu.menuTopics

with (aMenu3){

/* That is, with the menu that holds the Topics */

switch (selectedIndex) {

case 0:

/* this the default option, 0 that holds the starting text (Pages appear here) */

/* null off the menu that holds the subjects so previous items are removed */

nullOptions(aMenu)

/* null off the menu that holds the files so previous items are removed */

nullOptions(aMenu2)

aMenu.options[0]=

new Option("Pages appear here","none")

aMenu.options[0].selected=true;

history.go(0)

break

case 1:

//computer stuff

nullOptions(aMenu)

nullOptions(aMenu2)

aMenu2.options[0]=

new Option("Pages appear here","none")

aMenu2.options[0].selected=true;

/* We similarly deal with the next option, but this time we want it to load subjects in

the second menu. We have as many functions to do this as we have topics. So the function MyTopics1 will

handle the subjects for the first topic, and myTopics2 will handle the subjects for the second option, and so on*/

MyTopics1(aMenu)

break

case 2:

//self development

nullOptions(aMenu)

nullOptions(aMenu2)

aMenu2.options[0]=

new Option("Pages appear here","none")

aMenu2.options[0].selected=true;

MyTopics2(aMenu)

break

case 3:

//computer software

nullOptions(aMenu)

nullOptions(aMenu2)

aMenu2.options[0]=

new Option("Pages appear here","none")

aMenu2.options[0].selected=true;

MyTopics3(aMenu)

break;

}

}

}