function cerrarMensajero(pid)
   {
      document.getElementById(pid).style.visibility = 'hidden';      
   }
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.eramirez.cl/"; 
      var titulo=":: L.E.R.O. - Website ::";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
} 
function abrirventana(nombre,ancho,alto) {
dat = 'width=' + ancho + ',height=' + alto + ',left=0,top=0,menubar=no,scrollbars=yes,resize=no';
window.open(nombre,'',dat)
}
function revisarDigito( dvr )
{	
	dv = dvr + ""	
	if ( dv != '0' && dv != '1' && dv != '2' && dv != '3' && dv != '4' && dv != '5' && dv != '6' && dv != '7' && dv != '8' && dv != '9' && dv != 'k'  && dv != 'K')	
	{		
		alert("Debe ingresar un digito verificador valido");		
	
		window.document.formlogin.rut.select();		
		return false;	
	}	
	return true;
}

function revisarDigito2( crut )
{	
	largo = crut.length;	
	if ( largo < 2 )	
	{		
		alert("Debe ingresar el rut completo")		

		window.document.formlogin.rut.select();		
		return false;	
	}	
	if ( largo > 2 )		
		rut = crut.substring(0, largo - 1);	
	else		
		rut = crut.charAt(0);	
	dv = crut.charAt(largo-1);	
	revisarDigito( dv );	

	if ( rut == null || dv == null )
		return 0	

	var dvr = '0'	
	suma = 0	
	mul  = 2	

	for (i= rut.length -1 ; i >= 0; i--)	
	{	
		suma = suma + rut.charAt(i) * mul		
		if (mul == 7)			
			mul = 2		
		else    			
			mul++	
	}	
	res = suma % 11	
	if (res==1)		
		dvr = 'k'	
	else if (res==0)		
		dvr = '0'	
	else	
	{		
		dvi = 11-res		
		dvr = dvi + ""	
	}
	if ( dvr != dv.toLowerCase() )	
	{		
		alert("EL rut es incorrecto")		
	
		window.document.formlogin.rut.select();		
		return false	
	}

	return true
}

function Rut(texto)
{	
	var tmpstr = "";	
	for ( i=0; i < texto.length ; i++ )		
		if ( texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
			tmpstr = tmpstr + texto.charAt(i);	
	texto = tmpstr;	
	largo = texto.length;	

	if ( largo < 2 )	
	{		
		alert("Debe ingresar el rut completo")		
	
		window.document.formlogin.rut.select();		
		return false;	
	}	

	for (i=0; i < largo ; i++ )	
	{			
		if ( texto.charAt(i) !="0" && texto.charAt(i) != "1" && texto.charAt(i) !="2" && texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) !="5" && texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) !="8" && texto.charAt(i) != "9" && texto.charAt(i) !="k" && texto.charAt(i) != "K" )
 		{			
			alert("El valor ingresado no corresponde a un R.U.T valido");			
			
			window.document.formlogin.rut.select();			
			return false;		
		}	
	}	

	var invertido = "";	
	for ( i=(largo-1),j=0; i>=0; i--,j++ )		
		invertido = invertido + texto.charAt(i);	
	var dtexto = "";	
	dtexto = dtexto + invertido.charAt(0);	
	dtexto = dtexto + '-';	
	cnt = 0;	

	for ( i=1,j=2; i<largo; i++,j++ )	
	{		
		//alert("i=[" + i + "] j=[" + j +"]" );		
		if ( cnt == 3 )		
		{			
			dtexto = dtexto + '.';			
			j++;			
			dtexto = dtexto + invertido.charAt(i);			
			cnt = 1;		
		}		
		else		
		{				
			dtexto = dtexto + invertido.charAt(i);			
			cnt++;		
		}	
	}	

	invertido = "";	
	for ( i=(dtexto.length-1),j=0; i>=0; i--,j++ )		
		invertido = invertido + dtexto.charAt(i);	

	window.document.formlogin.rut.value = invertido.toUpperCase()		

	if ( revisarDigito2(texto) )		
		return true;	
	return false;
}
function validar(contacto) {
  if (contacto.nombre.value.length < 4) {
    alert("Por favor ingresa más de 4 carácteres en el campo \"Nombre\".");
    contacto.nombre.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = contacto.nombre.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Escriba sólo letras en el campo \"Nombre\"."); 
    contacto.nombre.focus(); 
    return (false); 
}
  if ((contacto.email.value.indexOf ('@', 0) == -1)||(contacto.email.value.length < 5)) { 
    alert("Dirección de correo no válida. (Ej. usuario@dominio.com)."); 
    return (false); 
  }
  if (contacto.comentario.value.length < 10) { 
    alert("Ingrese más de 10 carácteres al menos."); 
    return (false); 
  }
  return (true); 
}

function validaremail(cemail) {
  if (cemail.email.value != cemail.email2.value) {
    alert("Los e-mails ingresados no coinciden.");
    cemail.email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú" + "@-_.0123456789";
  var checkStr = cemail.email.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }

  if (!allValid) { 
    alert("Su correo email no puede contener caracteres extraños ni espacios en blanco."); 
    cemail.email.focus(); 
    return (false); 
}
 if ((cemail.email.value.indexOf ('@', 0) == -1)||(cemail.email.value.length < 5)) { 
    alert("Dirección de correo no válida. (Ej. usuario@dominio.com)."); 
    return (false); 
  }
return (true); 
}

function validarfotolog(formflog) {

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "/.-_0123456789";
  var checkStr = formflog.fotolog.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }

  if (!allValid) { 
    alert("Su dirección fotolog solo puede contener números letras y rayas."); 
    formflog.fotolog.focus(); 
    return (false); 
}
 if ((formflog.fotolog.value.indexOf ('/', 0) == -1)||(formflog.fotolog.value.length < 8)||(formflog.fotolog.value.indexOf ('.', 0) == -1)) { 
    alert("Dirección de fotolog no válida. Esta debe tener al menos 8 caracteres y no debe incluir (Ej. www.fotolog.com/usuario)"); 
    return (false); 
  }
return (true); 
}

function tools(Which){ 
  document.correo.cuerpo.value = document.correo.cuerpo.value + Which; 
} 



function validarhorario(formres) {
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ" + "abcdefghijklmnñopqrstuvwxyz " + "0123456789";
  var checkStr = formres.curso.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Estimado usuario, por favor solo ingrese letras y numeros en el campo \"Otros\"."); 
    formres.curso.focus(); 
    return (false); 
}
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ" + "abcdefghijklmnñopqrstuvwxyz " + "0123456789" + ",.-_¿?!¡";
  var checkStr = formres.actividad.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (!allValid) { 
    alert("Estimado usuario, solo letras, numeros y los signos ,.-_¿?!¡ se permiten en el campo \"Actividades\"."); 
    formres.actividad.focus(); 
    return (false); 
}
  return (true); 
}


var dynamicOptionListCount=0;
var dynamicOptionListObjects = new Array();

// Init call to setup lists after page load. One call to this function sets up all lists.
function initDynamicOptionLists() {
  // init each DynamicOptionList object
  for (var i=0; i<dynamicOptionListObjects.length; i++) {
    var dol = dynamicOptionListObjects[i];

    // Find the form associated with this list
    if (dol.formName!=null) { 
      dol.form = document.forms[dol.formName];
    }
    else if (dol.formIndex!=null) {
      dol.form = document.forms[dol.formIndex];
    }
    else {
      // Form wasn't set manually, so go find it!
      // Search for the first form element name in the lists
      var name = dol.fieldNames[0][0];
      for (var f=0; f<document.forms.length; f++) {
        if (typeof(document.forms[f][name])!="undefined") {
          dol.form = document.forms[f];
          break;
        }
      }
      if (dol.form==null) {
        alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return;
      }
    }

    // Form is found, now set the onchange attributes of each dependent select box
    for (var j=0; j<dol.fieldNames.length; j++) {
      // For each set of field names...
      for (var k=0; k<dol.fieldNames[j].length-1; k++) {
        // For each field in the set...
        var selObj = dol.form[dol.fieldNames[j][k]];
        if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; }
        // Map the HTML options in the first select into the options we created
        if (k==0) {
          if (selObj.options!=null) {
            for (l=0; l<selObj.options.length; l++) {
              var sopt = selObj.options[l];
              var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);
              if (m!=null) {
                var reselectForNN6 = sopt.selected;
                var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);
                m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy
                m2.defaultSelected = sopt.defaultSelected;
                m2.DOLOption = m;
                selObj.options[l] = m2;
                selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck.
              }
            }
          }
        }
        if (selObj.onchange==null) {
          // We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source!
          selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");
        }
      }
    }
  }
  // Set the preselectd options on page load 
  resetDynamicOptionLists();
}

// This function populates lists with the preselected values. 
// It's pulled out into a separate function so it can be hooked into a 'reset' button on a form
// Optionally passed a form object which should be the only form reset
function resetDynamicOptionLists(theform) {
  // reset each DynamicOptionList object
  for (var i=0; i<dynamicOptionListObjects.length; i++) {
    var dol = dynamicOptionListObjects[i];
    if (typeof(theform)=="undefined" || theform==null || theform==dol.form) {
      for (var j=0; j<dol.fieldNames.length; j++) {
        dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values
      }
    }
  }
}

// An object to represent an Option() but just for data-holding
function DOLOption(text,value,defaultSelected,selected) {
  this.text = text;
  this.value = value;
  this.defaultSelected = defaultSelected;
  this.selected = selected;
  this.options = new Array(); // To hold sub-options
  return this;
}

// DynamicOptionList CONSTRUCTOR
function DynamicOptionList() {
  this.form = null;// The form this list belongs to
  this.options = new Array();// Holds the options of dependent lists
  this.longestString = new Array();// Longest string that is currently a potential option (for Netscape)
  this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape)
  this.currentNode = null;// The current node that has been selected with forValue() or forText()
  this.currentField = null;// The current field that is selected to be used for setValue()
  this.currentNodeDepth = 0;// How far down the tree the currentNode is
  this.fieldNames = new Array();// Lists of dependent fields which use this object
  this.formIndex = null;// The index of the form to associate with this list
  this.formName = null;// The name of the form to associate with this list
  this.fieldListIndexes = new Object();// Hold the field lists index where fields exist
  this.fieldIndexes = new Object();// Hold the index within the list where fields exist
  this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1
  this.numberOfOptions = new Array();// Store the max number of options for a given option list
  this.longestString = new Array();// Store the longest possible string 
  this.values = new Object(); // Will hold the preselected values for fields, by field name
  
  // Method mappings
  this.forValue = DOL_forValue;
  this.forText = DOL_forText;
  this.forField = DOL_forField;
  this.forX = DOL_forX;
  this.addOptions = DOL_addOptions;
  this.addOptionsTextValue = DOL_addOptionsTextValue;
  this.setDefaultOptions = DOL_setDefaultOptions;
  this.setValues = DOL_setValues;
  this.setValue = DOL_setValues;
  this.setFormIndex = DOL_setFormIndex;
  this.setFormName = DOL_setFormName;
  this.printOptions = DOL_printOptions;
  this.addDependentFields = DOL_addDependentFields;
  this.change = DOL_change;
  this.child = DOL_child;
  this.selectChildOptions = DOL_selectChildOptions;
  this.populateChild = DOL_populateChild;
  this.change = DOL_change;
  this.addNewOptionToList = DOL_addNewOptionToList;
  this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;

  // Optionally pass in the dependent field names
  if (arguments.length > 0) {
    // Process arguments and add dependency groups
    for (var i=0; i<arguments.length; i++) {
      this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
      this.fieldIndexes[arguments[i].toString()] = i;
    }
    this.fieldNames[this.fieldNames.length] = arguments;
  }
  
  // Add this object to the global array of dynamicoptionlist objects
  this.index = window.dynamicOptionListCount++;
  window["dynamicOptionListObjects"][this.index] = this;
}

// Given an array of Option objects, search for an existing option that matches value, text, or both
function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired) {
  if (a==null || typeof(a)=="undefined") { return null; }
  var value_match = null; // Whether or not a value has been matched
  var text_match = null; // Whether or not a text has been matched
  for (var i=0; i<a.length; i++) {
    var opt = a[i];
    // If both value and text match, return it right away
    if (opt.value==value && opt.text==text) { return opt; }
    if (!exactMatchRequired) {
      // If value matches, store it until we complete scanning the list
      if (value_match==null && value!=null && opt.value==value) {
        value_match = opt;
      }
      // If text matches, store it for later
      if (text_match==null && text!=null && opt.text==text) {
        text_match = opt;
      }
    }
  }
  return (value_match!=null)?value_match:text_match;
}

// Util function used by forValue and forText
function DOL_forX(s,type) {
  if (this.currentNode==null) { this.currentNodeDepth=0; }
  var useNode = (this.currentNode==null)?this:this.currentNode;
  var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);
  if (o==null) {
    o = new DOLOption(null,null,false,false);
    o[type] = s;
    useNode.options[useNode.options.length] = o;
  }
  this.currentNode = o;
  this.currentNodeDepth++;
  return this;
}

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forValue(s) { return this.forX(s,"value"); }

// Set the portion of the list structure that is to be used by a later operation like addOptions
function DOL_forText(s) { return this.forX(s,"text"); }

// Set the field to be used for setValue() calls
function DOL_forField(f) { this.currentField = f; return this; }

// Create and add an option to a list, avoiding duplicates
function DOL_addNewOptionToList(a, text, value, defaultSelected) {
  var o = new DOLOption(text,value,defaultSelected,false);
  // Add the option to the array
  if (a==null) { a = new Array(); }
  for (var i=0; i<a.length; i++) {
    if (a[i].text==o.text && a[i].value==o.value) {
      if (o.selected) { 
        a[i].selected=true;
      }
      if (o.defaultSelected) {
        a[i].defaultSelected = true;
      }
      return a;
    }
  }
  a[a.length] = o;
}

// Add sub-options to the currently-selected node, with the same text and value for each option
function DOL_addOptions() {
  if (this.currentNode==null) { this.currentNode = this; }
  if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
  for (var i=0; i<arguments.length; i++) {
    var text = arguments[i];
    this.addNewOptionToList(this.currentNode.options,text,text,false);
    if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
      this.numberOfOptions[this.currentNodeDepth]=0;
    }
    if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
      this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
    }
    if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
      this.longestString[this.currentNodeDepth] = text;
    }
  }
  this.currentNode = null;
  this.currentNodeDepth = 0;
}

// Add sub-options to the currently-selected node, specifying separate text and values for each option
function DOL_addOptionsTextValue() {
  if (this.currentNode==null) { this.currentNode = this; }
  if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); }
  for (var i=0; i<arguments.length; i++) {
    var text = arguments[i++];
    var value = arguments[i];
    this.addNewOptionToList(this.currentNode.options,text,value,false);
    if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") {
      this.numberOfOptions[this.currentNodeDepth]=0;
    }
    if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) {
      this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;
    }
    if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) {
      this.longestString[this.currentNodeDepth] = text;
    }
  }
  this.currentNode = null;
  this.currentNodeDepth = 0;
}

// Find the first dependent list of a select box
// If it's the last list in a chain, return null because there are no children
function DOL_child(obj) {
  var listIndex = this.fieldListIndexes[obj.name];
  var index = this.fieldIndexes[obj.name];
  if (index < (this.fieldNames[listIndex].length-1)) {
    return this.form[this.fieldNames[listIndex][index+1]];
  }
  return null;
}

// Set the options which should be selected by default for a certain value in the parent
function DOL_setDefaultOptions() {
  if (this.currentNode==null) { this.currentNode = this; }
  for (var i=0; i<arguments.length; i++) {
    var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);
    if (o!=null) {
      o.defaultSelected = true;
    }
  }
  this.currentNode = null;
}

// Set the options which should be selected when the page loads. This is different than the default value and ONLY applies when the page LOADS
function DOL_setValues() {
  if (this.currentField==null) { 
    alert("Can't call setValues() without using forField() first!");
    return;
  }
  if (typeof(this.values[this.currentField])=="undefined") {
    this.values[this.currentField] = new Object();
  }
  for (var i=0; i<arguments.length; i++) {
    this.values[this.currentField][arguments[i]] = true;
  }
  this.currentField = null;
}

// Manually set the form for the object using an index
function DOL_setFormIndex(i) {
  this.formIndex = i;
}

// Manually set the form for the object using a form name
function DOL_setFormName(n) {
  this.formName = n;
}

// Print blank <option> objects for Netscape4, since it refuses to grow or shrink select boxes for new options
function DOL_printOptions(name) {
  // Only need to write out "dummy" options for Netscape4
    if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){
    var index = this.fieldIndexes[name];
    var ret = "";
    if (typeof(this.numberOfOptions[index])!="undefined") {
      for (var i=0; i<this.numberOfOptions[index]; i++) { 
        ret += "<OPTION>";
      }
    }
    ret += "<OPTION>";
    if (typeof(this.longestString[index])!="undefined") {
      for (var i=0; i<this.longestString[index].length; i++) {
        ret += "_";
      }
    }
    document.writeln(ret);
  }
}

// Add a list of field names which use this option-mapping object.
// A single mapping object may be used by multiple sets of fields
function DOL_addDependentFields() {
  for (var i=0; i<arguments.length; i++) {
    this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;
    this.fieldIndexes[arguments[i].toString()] = i;
  }
  this.fieldNames[this.fieldNames.length] = arguments;
}

// Called when a parent select box is changed. It populates its direct child, then calls change on the child object to continue the population.
function DOL_change(obj, usePreselected) {
  if (usePreselected==null || typeof(usePreselected)=="undefined") { usePreselected = false; }
  var changedListIndex = this.fieldListIndexes[obj.name];
  var changedIndex = this.fieldIndexes[obj.name];
  var child = this.child(obj);
  if (child == null) { return; } // No child, no need to continue
  if (obj.type == "select-one") {
    // Treat single-select differently so we don't have to scan the entire select list, which could potentially speed things up
    if (child.options!=null) {
      child.options.length=0; // Erase all the options from the child so we can re-populate
    }
    if (obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0) {
      var o = obj.options[obj.selectedIndex];
      this.populateChild(o.DOLOption,child,usePreselected);
      this.selectChildOptions(child,usePreselected);
    }
  }
  else if (obj.type == "select-multiple") {
    // For each selected value in the parent, find the options to fill in for this list
    // Loop through the child list and keep track of options that are currently selected
    var currentlySelectedOptions = new Array();
    if (!usePreselected) {
      for (var i=0; i<child.options.length; i++) {
        var co = child.options[i];
        if (co.selected) {
          this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);
        }
      }
    }
    child.options.length=0;
    if (obj.options!=null) {
      var obj_o = obj.options;
      // For each selected option in the parent...
      for (var i=0; i<obj_o.length; i++) {
        if (obj_o[i].selected) {
          // if option is selected, add its children to the list
           this.populateChild(obj_o[i].DOLOption,child,usePreselected);
        }
      }
      // Now go through and re-select any options which were selected before
      var atLeastOneSelected = false;
      if (!usePreselected) {
        for (var i=0; i<child.options.length; i++) {
          var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);
          if (m!=null) {
            child.options[i].selected = true;
            atLeastOneSelected = true;
          }
        }
      }
      if (!atLeastOneSelected) {  
        this.selectChildOptions(child,usePreselected);
      }
    }
  }
  // Change all the way down the chain
  this.change(child,usePreselected);
}
function DOL_populateChild(dolOption,childSelectObj,usePreselected) {
  // If this opton has sub-options, populate the child list with them
  if (dolOption!=null && dolOption.options!=null) {
    for (var j=0; j<dolOption.options.length; j++) {
      var srcOpt = dolOption.options[j];
      if (childSelectObj.options==null) { childSelectObj.options = new Array(); }
      // Put option into select list
      var duplicate = false;
      var preSelectedExists = false;
      for (var k=0; k<childSelectObj.options.length; k++) {
        var csi = childSelectObj.options[k];
        if (csi.text==srcOpt.text && csi.value==srcOpt.value) {
          duplicate = true;
          break;
        }
      }
      if (!duplicate) {
        var newopt = new Option(srcOpt.text, srcOpt.value, false, false);
        newopt.selected = false; // Again, we have to do these two statements for NN4 to work
        newopt.defaultSelected = false;
        newopt.DOLOption = srcOpt;
        childSelectObj.options[childSelectObj.options.length] = newopt;
      }
    }
  }
}

// Once a child select is populated, go back over it to select options which should be selected
function DOL_selectChildOptions(obj,usePreselected) {
  // Look to see if any options are preselected=true. If so, then set then selected if usePreselected=true, otherwise set defaults
  var values = this.values[obj.name];
  var preselectedExists = false;
  if (usePreselected && values!=null && typeof(values)!="undefined") {
    for (var i=0; i<obj.options.length; i++) {
      var v = obj.options[i].value;
      if (v!=null && values[v]!=null && typeof(values[v])!="undefined") {
        preselectedExists = true;
        break;
      }
    }
  }
  // Go back over all the options to do the selection
  var atLeastOneSelected = false;
  for (var i=0; i<obj.options.length; i++) {
    var o = obj.options[i];
    if (preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined") {
      o.selected = true;
      atLeastOneSelected = true;
    }
    else if (!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected) {
      o.selected = true;
      atLeastOneSelected = true;
    }
    else {
      o.selected = false;
    }
  }
  // If nothing else was selected, select the first one by default
  if (this.selectFirstOption && !atLeastOneSelected && obj.options.length>0) {
    obj.options[0].selected = true;
  }
  else if (!atLeastOneSelected &&  obj.type=="select-one") {
    obj.selectedIndex = -1;
  }
}





if(window.addEventListener){
    window.addEventListener("load",mladdevents,false);
}
else if(window.attachEvent){
    window.attachEvent("onload",mladdevents);
}
else{
	window.onload = mladdevents;
}
function mladdevents(){
	if(!window.mlrunShim){
		window.mlrunShim = false;
	}
	if(window.mlrunShim == true){
		var Iframe = document.createElement("iframe");
		Iframe.setAttribute("src","about:blank");
		Iframe.setAttribute("scrolling","no");
		Iframe.setAttribute("frameBorder","0");
	}
	var effects_a = new Array();
	var divs = document.getElementsByTagName('div');
	for(var j=0;j<divs.length;j++){
		if(divs[j].className.indexOf('mlmenu') != -1){
			divs[j].className = divs[j].className.replace('mlmenu','mlmenujs');
			divs[j].getElementsByTagName('ul')[0].className = divs[j].className;//just for reference
			var lis = divs[j].getElementsByTagName('li');
			for(var i =0;i<lis.length;i++){
				lis[i].onmouseover = mlover;
				lis[i].onmouseout = mloutSetTimeout;
				if(window.mlrunShim == true){
					lis[i].appendChild(Iframe.cloneNode(false));
				}
				if(lis[i].parentNode.getElementsByTagName('li')[0] == lis[i]){
					lis[i].getElementsByTagName('a')[0].className += 'first';
					if(lis[i].parentNode.className.indexOf('mlmenujs') != -1){
						lis[i].className += 'pixelfix';
					}
				}
				if(lis[i] == findLast(lis[i].parentNode)){
					lis[i].className += 'last';
				}
				if(lis[i].getElementsByTagName('ul').length > 0){
					lis[i].className += ' haschild';
					if(divs[j].className.indexOf('arrow') != -1){
						if(divs[j].className.indexOf('vertical') != -1 || lis[i].parentNode.parentNode.nodeName != 'DIV'){
							lis[i].getElementsByTagName('a')[0].innerHTML += '<span class="vert">&rarr;</span>';
						}
						else{
							lis[i].getElementsByTagName('a')[0].innerHTML += '<span class="horiz">&darr;</span>';
						}
					}
					else if(divs[j].className.indexOf('plus') != -1){
						lis[i].getElementsByTagName('a')[0].innerHTML += '<span class="plus">+</span>';
					}
				}
				else{
					if(divs[j].className.indexOf('arrow') != -1){
						//This accounts for a wierd IE-specific bug in horizontal menus. CSS will set visibility: hidden;. This keeps the menu level(in IE)
						lis[i].getElementsByTagName('a')[0].innerHTML += '<span class="noshow">&darr;</span>';
					}
				}
				var uls = lis[i].getElementsByTagName('ul');
				for(var k=0;k<uls.length;k++){
					var found = 'no';
					for(var z=0;z<effects_a.length;z++){
						if(effects_a[z] == uls[k]){
							found = 'yes';
						}
					}
					if(found == 'no'){
						effects_a[effects_a.length] = uls[k];
						uls[k].style.zIndex = '100';
						mlEffectLoad(uls[k]);
					}
				}
			}
		}
	}
}
function mloutSetTimeout(e){
	if(!e){
		var the_e = window.event;
	}
	else{
		var the_e = e;
	}
	var reltg = (the_e.relatedTarget) ? the_e.relatedTarget : the_e.toElement;
	if(reltg){
		var under = ancestor(reltg,this);
		if(under === false && reltg != this){
			window.mlLast = this;
			var parent = this.parentNode;
			while(parent.parentNode && parent.className.indexOf('mlmenujs') == -1){
				parent = parent.parentNode;
			}
			if(parent.className.indexOf('delay') != -1){
				window.mlTimeout = setTimeout(function(){mlout()},1000);
			}
			else{
				mlout();
			}
		}
	}
}
function mlout(){
	if(window.mlLast==null)return false;
	var links = window.mlLast.getElementsByTagName('a');
	for(var i = 0;i<links.length;i++){
		links[i].className = links[i].className.replace('hover','');
	}
	var uls = window.mlLast.getElementsByTagName('ul');
	var sib;
	for(var i=0;i<uls.length;i++){
		mlEffectOut(uls[i]);
		window.mlLast.className += ' hide';
		window.mlLast.className = window.mlLast.className.replace('hide hide','hide');
		if(window.mlrunShim == true){
			sib = uls[i];							
			while(sib.nextSibling && sib.nodeName != 'IFRAME'){
				sib = sib.nextSibling
			}
			sib.style.display = 'none';
		}
	}
	window.lastover = null;
	return true;
}
function mlover(e){
	if(!e){
		var the_e = window.event;
	}
	else{
		var the_e = e;
	}
	the_e.cancelBubble = true;
	if(the_e.stopPropagation){
		the_e.stopPropagation();
	}
	clearTimeout(window.mlTimeout);
	if(window.mlLast && window.mlLast != this && ancestor(this,window.mlLast) === false){
		mlout();
	}
	else{
		window.mlLast = null;
	}
	var reltg = (the_e.relatedTarget) ? the_e.relatedTarget : the_e.fromElement;
	var under = ancestor(reltg,this);
	if(under == false){
		var hovered = byClass(this.parentNode,'hover','a');
		for(var i=0;i<hovered.length;i++){
			if(ancestor(this,hovered[i].parentNode) == false){
				window.mlLast = hovered[i].parentNode;
				mlout();
			}
		}
		var ob = this.getElementsByTagName('ul');
		var link = this.getElementsByTagName('a')[0];
		link.className += ' hover';
		if(ob[0]){
			if(window.lastover != ob[0]){
				if(window.mlrunShim == true){
					var sib = ob[0];
					while(sib.nextSibling && sib.nodeName != 'IFRAME'){
						sib = sib.nextSibling
					}
					ob[0].style.display = 'block';
					sib.style.top = ob[0].offsetTop+'px';
					sib.style.left = ob[0].offsetLeft-2+'px';
					sib.style.width = ob[0].offsetWidth+2+'px';
					sib.style.height = ob[0].offsetHeight-2+'px';
					sib.style.display = 'block';
				}
				this.className = this.className.replace(/hide/g,'');
				mlEffectOver(ob[0],this);
				window.lastover = ob[0];
			}
		}
	}
}
function mlSetOpacity(ob,level){
	if(ob){
		var standard = level/10;
		var ie = level*10;
		ob.style.opacity = standard;
		ob.style.filter = "alpha(opacity="+ie+")"
	}
}
function mlIncreaseOpacity(ob){
	var current = ob.style.opacity;
	current = current * 10;
	var upone = current + 1;
	mlSetOpacity(ob,upone);
}
function mlIncreaseHeight(ob){
	var current = parseInt(ob.style.height);
	if(!isNaN(current)){
		var newh = current + 1;
		ob.style.height = newh+'px';
	}
}
function mlIncreaseWidth(ob){
	var current = parseInt(ob.style.width);
	if(!isNaN(current)){
		var newh = current + 1;
		ob.style.width = newh+'px';
	}
}
function mlShake(ob){
	var newp = '5px';
	var old = '';
	if(ob.style.paddingLeft==old){
		ob.style.paddingLeft=newp;
	}
	else{
		ob.style.paddingLeft=old;
	}
}
function mlEffectOver(ob,parent){
	switch(ob.className){
	case 'fade':
		ob.style.display = 'block';
		for(var i = 1;i<=10;i++){
			window.fadeTime = setTimeout(function(){mlIncreaseOpacity(ob)},i*50);
		}
		setTimeout(function(){ob.style.filter = ''},500);
		break;
	case 'shake':
		ob.style.display = 'block';
		var shake = setInterval(function(){mlShake(ob)},50);
		setTimeout(function(){clearInterval(shake)},510);
		break;
	case 'blindv':
		ob.style.display = 'block';
		if(ob.offsetHeight){
			var height = ob.offsetHeight
			ob.style.height = '0px';
			ob.style.overflow = 'hidden';
			for(var i=0;i<height;i++){
				setTimeout(function(){mlIncreaseHeight(ob)},i*3);
			}
			setTimeout(function(){ob.style.overflow='';ob.style.height='auto'},(height-1)*3)//-1 for IE
		}
		break;
	case 'blindh':
		ob.style.display = 'block';
		if(ob.offsetWidth){
			var width = ob.offsetWidth;
			ob.style.width = '0px';
			ob.style.overflow = 'hidden';
			for(var i=0;i<width;i++){
				setTimeout(function(){mlIncreaseWidth(ob)},i*3);
			}
			setTimeout(function(){ob.style.overflow='visible';},width*3)
		}
		break;
	default:
		ob.style.display = 'block';
		break;
	}
}
function mlEffectOut(ob){
	switch(ob.className){
	case 'fade':
		clearTimeout(window.fadeTime);
		mlSetOpacity(ob,0);
		ob.style.display = 'none';
		break;
	case 'shake':
		ob.style.paddingLeft = '';
		ob.style.display = 'none';
		break;
	default:
		ob.style.display = 'none';
		break;
	}
}
function mlEffectLoad(ob){
	var parent = ob.parentNode;
	while(parent.parentNode && parent.className.indexOf('mlmenu') == -1){
		parent = parent.parentNode;
	}
	if(parent.className.indexOf('fade') != -1){
		ob.style.display = 'none';
		ob.className = 'fade';
		mlSetOpacity(ob,0);
	}
	else if(parent.className.indexOf('shake') != -1){
		ob.className = 'shake';
	}
	else if(parent.className.indexOf('blindv') != -1){
		ob.className = 'blindv';
	}
	else if(parent.className.indexOf('blindh') != -1){
		ob.className = 'blindh';
	}
	else if(parent.className.indexOf('box') != -1){
		ob.className = 'box';
	}
	ob.style.display = 'none';
}
function ancestor(child, parent){
	try{
		if(child==null)return false;//Saves checking elsewhere
		for(; child.parentNode; child = child.parentNode){
				if(child.parentNode === parent) return true;
			}
		return false;
	}
	catch(error){
		//Mozilla bug, it  must be a text control which can not be in the menu so we will foolishly assume false
		return false;
	}
}
function byClass(parent,c,tag){
	var all = parent.getElementsByTagName(tag);
	var returna = new Array();
	for(var i=0;i<all.length;i++){
		if(all[i].className.indexOf(c) != -1){
			returna[returna.length] = all[i]
		}
	}
	return returna;
}
function findLast(ob){
	if(ob.lastChild.nodeType == 1){
		return ob.lastChild
	}
	return ob.lastChild.previousSibling;
}
function movein(which,html){
which.style.background='#7a9fd4'
if (document.getElementById)
document.getElementById("boxdescription").innerHTML=html
else
boxdescription.innerHTML=html
}

function moveout(which){
which.style.background='#3365a9'
if (document.getElementById)
document.getElementById("boxdescription").innerHTML='&nbsp;'
else
boxdescription.innerHTML='&nbsp;'
}