	var defaultEmptyOK = false;
	var daysInMonth = new Array();
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;   // must programmatically check this
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;

	function doSubmit(doLogin){
	  var objForm = document.getElementById("frmTransaction");
	  if(doLogin){
	   	var objUserText = document.getElementById("id_user");
	   	var objUserPwd = document.getElementById("id_pwd");
	   	if(objUserText.value=='' || objUserText.value=='username'){
	   		alert("Inserire lo username");
	   		return false;
	   	}
	   	if(objUserPwd.value=='' || objUserPwd.value=='password'){
	   		alert("Inserire la password");
	   		return false;
	   	}
	   	objForm.fUsername.value = objUserText.value;
	   	objForm.fPassword.value = objUserPwd.value;
	  }
	  else{
	  	objForm.doLogin.value="0";
	  }
	 	objForm.submit();
	 }
 
	function isValidDate (year, month, day) {   // catch invalid years (not 2- or 4-digit) and invalid months and days.
		if (year!="" || month!="0" || day!="0") {	//Date is a field optional    
			if ((! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) 
				|| year<1900) {
				return false;
			}
		    // Explicitly change type to integer to make code work in both
		    // JavaScript 1.1 and JavaScript 1.2.
		    var intYear = parseInt(year);
		    var intMonth = parseInt(month);
		    var intDay = parseInt(day);
		
		    // catch invalid days, except for February
		    if (intDay > daysInMonth[intMonth]) {
				return false; 
			}
			
		    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) {
				return false;
			}
		    return true;
		}
		else {
			return true; //Date is a field optional, so continue normally;
		}
	}
	
	function isNotABirthDay(birthYear) {
		var now = new Date(); 
		var year = now.getYear();
		if ((year - birthYear) <= 0) {
			return true;
		} 
		else {
			return false;
		}
	}
	
	function daysInFebruary (year)
	{   // February has 29 days in any year evenly divisible by four,
    	// EXCEPT for centurial years which are not also divisible by 400.
    	return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
	}
	
	function isIntegerInRange (s, a, b)
	{   if (isEmpty(s)) 
	       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
	       else return (isIntegerInRange.arguments[1] == true);
	
	    // Catch non-integer strings to avoid creating a NaN below,
	    // which isn't available on JavaScript 1.0 for Windows.
	    if (!isInteger(s, false)) return false;
	
	    // Now, explicitly change the type to integer via parseInt
	    // so that the comparison code below will work both on 
	    // JavaScript 1.2 (which typechecks in equality comparisons)
	    // and JavaScript 1.1 and before (which doesn't).
	    var num = parseInt (s);
	    return ((num >= a) && (num <= b));
	}
	
	function isNonnegativeInteger (s)	{   
		var secondArg = defaultEmptyOK;
	
	    if (isNonnegativeInteger.arguments.length > 1)
	        secondArg = isNonnegativeInteger.arguments[1];
	
	    // The next line is a bit byzantine.  What it means is:
	    // a) s must be a signed integer, AND
	    // b) one of the following must be true:
	    //    i)  s is empty and we are supposed to return true for
	    //        empty strings
	    //    ii) this is a number >= 0
	
	    return (isSignedInteger(s, secondArg)
	         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
	}
	
	function isSignedInteger (s)

	{   if (isEmpty(s)) 
	       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
	       else return (isSignedInteger.arguments[1] == true);
	
	    else {
	        var startPos = 0;
	        var secondArg = defaultEmptyOK;
	
	        if (isSignedInteger.arguments.length > 1)
	            secondArg = isSignedInteger.arguments[1];
	
	        // skip leading + or -
	        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
	           startPos = 1;    
	        return (isInteger(s.substring(startPos, s.length), secondArg))
	    }
	}

	function isInteger (s) {   
		var i;
	    if (isEmpty(s)) 
	       if (isInteger.arguments.length == 1) return defaultEmptyOK;
	       else return (isInteger.arguments[1] == true);
	
	    // Search through string's characters one by one
	    // until we find a non-numeric character.
	    // When we do, return false; if we don't, return true.
	
	    for (i = 0; i < s.length; i++)
	    {   
	        // Check that current character is number.
	        var c = s.charAt(i);
	
	        if (!isDigit(c)) return false;
	    }
	
	    // All characters are numbers.
	    return true;
	}

	function isDigit (c) {
	   return ((c >= "0") && (c <= "9"))
	}

	function isEmpty(s) {
	   return ((s == null) || (s.length == 0))
	}

	
	function isYear (s)	{
		if (isEmpty(s)) 
	       if (isYear.arguments.length == 1) return defaultEmptyOK;
	       else return (isYear.arguments[1] == true);
	    if (!isNonnegativeInteger(s)) return false;
	    return ((s.length == 2) || (s.length == 4));
	}
		
	function isMonth (s) {
		if (isEmpty(s)) 
    	   if (isMonth.arguments.length == 1) 
		   	   return defaultEmptyOK;
       	   else 
		   	   return (isMonth.arguments[1] == true);
    	return isIntegerInRange (s, 1, 12);
	}
	
	function isDay (s) {
		if (isEmpty(s)) 
       		if (isDay.arguments.length == 1) 
				return defaultEmptyOK;
       		else 
				return (isDay.arguments[1] == true);   
    	return isIntegerInRange (s, 1, 31);
	}

 	function inherit() {
          if (document.layers) {
              alert('Questo layout non funziona per NN4!');
          }
          else if (document.getElementById) {
     
              Corpo = document.getElementById('corpo');
              Destra = document.getElementById('col-destra');
              Centro = document.getElementById('col-centro');
             
              Corpo.style.height = Destra.offsetHeight + 150 + 'px';
              Centro.style.display = 'block';
             
              return true
              }
      }
	  
	  
	function validEMail (emailStr) {
		/* The following pattern is used to check if the entered e-mail address
		   fits the user@domain format.  It also is used to separate the username
		   from the domain. */
		var emailPat=/^(.+)@(.+)$/;
		/* The following string represents the pattern for matching all special
		   characters.  We don't want to allow special characters in the address. 
		   These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]\'";
		/* The following string represents the range of characters allowed in a 
		   username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]";
		/* The following pattern applies if the "user" is a quoted string (in
		   which case, there are no rules about which characters are allowed
		   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		   is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")";
		/* The following pattern applies for domains that are IP addresses,
		   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		   e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		/* The following string represents an atom (basically a series of
		   non-special characters.) */
		var atom=validChars + '+';
		/* The following string represents one word in the typical username.
		   For example, in john.doe@somewhere.com, john and doe are words.
		   Basically, a word is either an atom or quoted string. */
		var word= "(" + atom + "|" + quotedUser + ")";
		// The following pattern describes the structure of the user
		var userPat= new RegExp("^" + word + "(\\." + word + ")*$");
		/* The following pattern describes the structure of a normal symbolic
		   domain, as opposed to ipDomainPat, shown above. */
		var domainPat= new RegExp("^" + atom + "(\\." + atom +")*$");
		
		
		/* Finally, let's start trying to figure out if the supplied address is
		   valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray = emailStr.match(emailPat);
		if (matchArray == null) {
		  /* Too many/few @'s or something; basically, this address doesn't
		     even fit the general mould of a valid e-mail address. */
			 return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		
		// See if "user" is valid 
		if (user.match(userPat) == null) {
		    // user is not valid
		    return false;
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
		    // this is an IP address
		  	for (var i=1;i<=4;i++) {
		    	if (IPArray[i]>255) {
		        	return false;
		    	}
	      	}
		    return true;
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			return false;
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding 
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		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) {
		   // the address must end in a two letter or three letter word.
		   return false;
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   return false;
		}
		
		// If we've gotten this far, everything's valid!
		return true;
	}
	//  End 	  
	
	function insertTag(aId, aTag){
		var string = document.getElementById(aId).value;		
		switch(aTag){
			case "ul":
				string = string + "\n" + "<ul>\n\t<li></li>\n</ul>";
				break;
			case "ol":
				string = string + "\n" + "<ol>\n\t<li></li>\n</ol>";
				break;
			case "br":
				string = string + " " + "<br/>";
				break;		
			case "a":
				string = string + " " + "<a href='http://'>Inserire nome del link</a>";
				break;										
			default:
				string = string + " " + "<" + aTag + "></" + aTag + ">";
		}
		document.getElementById(aId).value = string;
	}	
	
  function selectUnSelectAll(toSelect){
    for(i=0; i<arrayListaInteressi.length; i++){
      var obj = document.getElementById(arrayListaInteressi[i]);  
      if(obj)
        obj.checked=toSelect;
    }
  }
	
