onload = function initPage() {
     var fontMinus = document.getElementById('fontMinus');
     var fontPlus = document.getElementById('fontPlus');
     var scrhInput = document.getElementById('key');
     if (fontMinus!=null) {
	      fontMinus.onclick = function() { thisPage.changeStyles(0); };
	      fontMinus.onkeypress = function() { thisPage.changeStyles(0); };
     }
     if (fontPlus!=null) {
	      fontPlus.onclick = function() { thisPage.changeStyles(1); };
	      fontPlus.onkeypress = function() { thisPage.changeStyles(1); };
     }
     if (scrhInput!=null) {
	      scrhInput.onblur = function() { setTxtSearch('key','Palabra/s a buscar'); };
	      scrhInput.onfocus = function() { setTxtSearchBlanco('key','Palabra/s a buscar'); };
	      scrhInput.ondrop = function() { setTxtSearch('key','Palabra/s a buscar'); };
     }
     try {
     	init();
     	runcomponents();
     } catch(mErr) {
     }	
}

function trimAll(sString) {
     while (sString.substring(0,1) == ' ') {
	      sString = sString.substring(1, sString.length);
     }
     while (sString.substring(sString.length-1, sString.length) == ' ') {
	      sString = sString.substring(0,sString.length-1);
     }
     return sString;
}

function setTxtSearch(id,text) {
     if (id!=null && id!="" && text!=null && text!="") {
	      if (trimAll(document.getElementById(id).value) == "") {
		      document.getElementById(id).value = text;
	      }
     }
}

function setTxtSearchBlanco(id,text) {
     if (id!=null && id!='' && text!=null && text!='') {
	      if (trimAll(document.getElementById(id).value) == text) {
		      document.getElementById(id).value = "";
	      }
     }
}
/* Function which shows the loginForm when the user click on a link and makes
* invisible the link (last modificacion 09/07/07)
*/
function showLogin() {
   var loginform = document.getElementById('loginform');
   var linkToLogonForm = document.getElementById('registredusers');
   if (loginform != null) {
       if (loginform.className == 'invisible') {
          loginform.className = 'users';
           linkToLogonForm.className = 'invisible';
       }
   }
}

function checkUserMail(email) {
	 var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	 if (filter.test(email))
	     return true;
	 else
	     return false;
}
/*
* Function used in IE to add the string "+Enter" to the title of a  LINK and to
* give emphasis to the letter of the innerHtml which is same as the accesskey
*
* For FireFox itīs used to give emphasis to the letter of the innerHtml which
* is same as the accesskey (last modified: 09/07/07)
*/
function addIEAccessKeyText(){
   var acceskeyAtribute="";
   var title="";
   var elementId="";
   var innerContent="";
   var elements="";
 if (navigator.appVersion.match(/\bMSIE\b/)){
   elements= document.getElementsByTagName('A');
   for(i=0; i<elements.length; i++){
	  acceskeyAtribute="";
	  elementId="";
	  innerContent="";
	  elementId= elements[i].getAttribute('id');
	  acceskeyAtribute= elements[i].getAttribute('accesskey');	  
	   if (acceskeyAtribute!=""){
		 title= elements[i].getAttribute('title');			  
		 title= title.substring(0,title.length-1);
		 elements[i].setAttribute("title", title + " + Enter)");
	    }
	   if(elementId!=null){
	    if(elementId.indexOf("mainMenu")!=-1){
		 innerContent=elements[i].innerHTML;
		 innerContent= innerContent.replace(acceskeyAtribute,"<em class=\"accesskey\">"+acceskeyAtribute+"</em>");
		 elements[i].innerHTML=innerContent;
	    }
	  }
     }
     var indexLogo = document.getElementById("img-index");
     var altAtribute = indexLogo.getAttribute('alt');
     if (altAtribute.indexOf("Alt")!=-1){
	   altAtribute= altAtribute.substring(0,altAtribute.length-1);
	   altAtribute += " + Enter)";
		 indexLogo.setAttribute("title",altAtribute);
		 indexLogo.setAttribute("alt",altAtribute);
	 }
 }else{
   elements= document.getElementsByTagName('A');
   for(i=0; i<elements.length; i++){
	  acceskeyAtribute="";
	  elementId="";
	  innerContent="";
	  elementId= elements[i].getAttribute('id');
	  acceskeyAtribute= elements[i].getAttribute('accesskey');  
	   if(elementId!=null){      
	    if(elementId.indexOf("mainMenu")!=-1){
		 innerContent=elements[i].innerHTML;
		 innerContent= innerContent.replace(acceskeyAtribute,"<em class=\"accesskey\">"+acceskeyAtribute+"</em>");
		 elements[i].innerHTML=innerContent;
	    }
	   }
     }
 }
}

function changeTextInputs() {
   var inputs = document.getElementsByTagName('input');
   if (inputs != null) {
        for(i=0; i<inputs.length; i++){
	    loginform.className = 'users';
           linkToLogonForm.className = 'invisible';
       }
   }
}

