

									//--  ************  Funzione per FOCUS INPUT, TEXT, SELECT
window.onload = function(){
  /*applico l'highlight a tutti i campi di input*/
  var inputFields = document.getElementsByTagName("INPUT");
  for(i=0; i<inputFields.length; i++){
	var field = inputFields.item(i);
	if ( field != undefined){
	  if ( field.type=="text" || field.type=="password" ){
		/*onfocus cambio la classe corrente con quella focus*/
	field.onfocus = function(){this.className="focus";}
		/*onblur ripristino la classe di default*/
	field.onblur = function(){this.className="";}
	  }
	}
  }
  /*stesso vale per le textarea*/
  var textareas = document.getElementsByTagName("TEXTAREA");
  for(i=0; i<textareas.length; i++){
	var textarea = textareas.item(i);
	textarea.onfocus = function(){this.className="focus";}
	textarea.onblur = function(){this.className="";}
  }

  /*stesso vale per le select*/
  var selects = document.getElementsByTagName("SELECT");
  for(i=0; i<selects.length; i++){
	var select = selects.item(i);
	select.onfocus = function(){this.className="focus";}
	select.onblur = function(){this.className="";}
  }
}							
	
	function openoverlay() { document.getElementById('Layer1').style.display = 'block'; }
function closeoverlay() { document.getElementById('Layer1').style.display = 'none'; }
  								
									//--  ************  Funzione per l'HELP
function addHelp()
{
  var strID, objHelp;

  // Check we're working with a DOM compliant browser
  if (document.getElementById && document.appendChild && document.removeChild)
  {
    var objHelpform = document.getElementById('transfer');
    
    var objAnchors = objHelpform.getElementsByTagName('a');
    
    // Iterate through all anchors in the form
    for (var iCounter=0; iCounter<objAnchors.length; iCounter++)
    {
      if (objAnchors[iCounter].className != 'leave')
      {
        // Locate the associated help text's container,
        // and hide it
        strID = getIDFromHref(objAnchors[iCounter].href);
        objHelp = document.getElementById(strID);
        objHelp.style.display = 'none';

        // Add events to reveal/hide
        objAnchors[iCounter].onclick = function(event){return expandHelp(this, event);}
        objAnchors[iCounter].onkeypress = function(event){return expandHelp(this, event);}

        // Move beneath current form field
        objAnchors[iCounter].parentNode.appendChild(objHelp);
      }
    }
    
    // Remove the remainder of the old help section
    var objOldnode = document.getElementById('helpcontainer');
    
    objOldnode.parentNode.removeChild(objOldnode);

    // Release memory to prevent IE memory leak
    // Thanks to Mark Wubben <http://novemberborn.net/>
    // for highlightint the issue
    objHelpform = null;
    objHelp = null;
    objAnchors = null;
  }
}

// Return the ID of the element from the "href" attribute
function getIDFromHref(strHref)
{
  var iOffset = strHref.indexOf('#') + 1;
  var iEnd = strHref.length;

  return strHref.substring(iOffset, iEnd);
}

function expandHelp(objAnchor, objEvent)
{
  var iKeyCode;

  // If from the keyboard, check the user is
  // activating it rather than tabbing through
  if (objEvent && objEvent.type == 'keypress')
  {
    if (objEvent.keyCode)
      iKeyCode = objEvent.keyCode;
    else if (objEvent.which)
      iKeyCode = objEvent.which;
    
    if (iKeyCode != 13 && iKeyCode != 32)
      return true;
  }

  strID = getIDFromHref(objAnchor.href);
  objHelp = document.getElementById(strID);

  // Toggle on and off
  if (objHelp.style.display == 'none')
    objHelp.style.display = 'block';
  else
    objHelp.style.display = 'none';

  return false;
}




