<!--
	function wait(delay, destinazione){
  //alert (destinazione);
	setTimeout(function(){redirect(destinazione)},delay);
	}
	
	function redirect(destinazione) {
		window.location=destinazione;
		//confirm ("redirect");
		//history.back();
	}
	
// show/hide div
	var state = 'none';

	function focus_rollover(ref) {
		element = document.getElementById(ref);
		element.focus();
	}

	function showhide(layer_ref) {
		//alert (document.getElementById(layer_ref).display);
		
		
		//document.getElementById(layer_ref).focus();
		var state = document.getElementById(layer_ref).style.display;
		
		
		if (state == 'block') {
		//state = 'none';
		document.getElementById(layer_ref).style.display = 'none';
		}
		else {
		//state = 'block';
		document.getElementById(layer_ref).style.display = 'block';
		}
		//alert ("state="+state);
		/*
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.display = state");
		}
		if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].display = state;
		}
		if (document.getElementById &&!document.all) {
		hza = document.getElementById(layer_ref);

		
		hza.style.display = state;
		}
		*/

		
	} 	
	
	function toggle_value(elementbyid, text1, text2) {
		element = document.getElementById(elementbyid);
		element.focus();
		if (element.innerHTML==text1) {
			element.innerHTML=text2;
		} else {
			element.innerHTML=text1;	
		}
		
		
	} 
	
	function add_categoria (elementbyid, text, messaggio_errore) {
	
	
	
	element = document.getElementById(elementbyid);
	
	
	
		element.disabled=false;

		if (element.value=='') {
			element.value = text;
		} else {
			array_elementi = element.value.split(",");
			
			if (array_elementi.length>2) {
				alert (messaggio_errore);
				return false;
			} else {
				element.value += ", "+text;	
			}
			
		}
		//alert (element.value);
		element.disabled=true;
	}

// swap images
	
function swapImage(elementbyid, element2byid, filename, caption) {
	//alert (filename);
	//element.focus();
	
	element = document.getElementById(elementbyid);
	element2 = document.getElementById(element2byid);
  // Get the element whose ID is 'mainimage'
 /* var img_obj = element;
  
  if (img_obj) {img_obj.src = filename;}*/
  element.style.display = "";
  element2.style.display = "none";
  // And now the caption
  //var cap_obj = caption;
  //if (cap_obj) {cap_obj.innerHTML = caption;}
  return true;
  
}

//*******************************
// footer
<!--
		function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		
		function setFooter() {
			
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentHeight = document.getElementById('wrapper').offsetHeight;
					//alert ("contentHeight="+contentHeight)
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					//alert ("footerHeight="+footerHeight)
					var contentElement = document.getElementById('content');
					//alert ("windowHeight="+windowHeight+"\n"+"contentHeight="+contentHeight)
					//alert (windowHeight - (contentHeight + footerHeight))
					if (windowHeight - (contentHeight + footerHeight) >= 0) {
						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
						//alert ("footerElement.style.top="+footerElement.style.top)
						
						
						
					}
					else {
						footerElement.style.top = '0px';
					}
					
					
				}
				
			}
		}
		window.onload = function() {
			setFooter();
		}
		
		window.onresize = function() {
			setFooter();
		}

function abilita_campo_form(elementbyid) {
	//alert(elementbyid)
	element = document.getElementById(elementbyid);
	element.disabled=false;
}

function sto_caricando() {
	alert("sto caricando");
}

//
// form offerta

// A utility function that returns true if a string contains only 
// whitespace characters
/*
function isblank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '	')) return false;
    }
    return true;
}

function verify(form_id, field_id) {
	alert ("icao");
var form = getElementById(form_id);
var e = form.field_id;
        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {
            // First check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

            // Now check for fields that are supposed to be numeric
            if (e.numeric || (e.min != null) || (e.max != null)) { 
                var v = parseFloat(e.value);
                if (isNaN(v) || 
                    ((e.min != null) && (v < e.min)) || 
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null) 
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null) 
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
}
*/
//-->


function checkboxlimit(checkgroup, limit){
	var checkgroup = document.getElementById(checkgroup)
	//var checkgroup=checkgroup
	var limit=limit
	//alert (checkgroup.length);
	for (var i=0; i<checkgroup.length; i++){
		checkgroup[i].onclick=function(){
		var checkedcount=0
		for (var i=0; i<checkgroup.length; i++)
			checkedcount+=(checkgroup[i].checked)? 1 : 0
		if (checkedcount>limit){
			alert("Puoi selezionare un massimo di "+limit+" categorie")
			this.checked=false
			}
		}
	}
}

<!--
//initial checkCount of zero
var checkCount=0

//maximum number of allowed checked boxes
//var maxChecks=3

function setChecks(obj, maxChecks){
//increment/decrement checkCount
if(obj.checked){
checkCount=checkCount+1
}else{
checkCount=checkCount-1
}
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert
if (checkCount>=maxChecks){
obj.checked=false
checkCount=checkCount-1
alert("Puoi selezionare un massimo di "+maxChecks+' categorie')
}
}
//--> 
