<!--
// Form Validation JavaScript

var checkobj

function accetta(el){
checkobj=el
	if (document.all||document.getElementById){
		for (i=0;i<checkobj.form.length;i++){  
var tempobj=checkobj.form.elements[i]
	if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
							}
						}
					}

function disabilita(el){
	if (!document.all&&!document.getElementById){
			if (window.checkobj&&checkobj.checked)
return true
		else{
alert("Per favore accetta i termini del contratto")
return false
						}
					}
				}


function EW_onError(form_object, input_object, object_type, error_message)
    {
		alert(error_message);
	if (object_type == "RADIO" || object_type == "CHECKBOX") {
		if (input_object[0])
				input_object[0].focus();
			else
				input_object.focus();
		}
		else
			input_object.focus();
		if (object_type == "TEXT" || object_type == "PASSWORD")
			input_object.select();		
	return false;	
    }


function EW_checknumber(object_value)
    {
    if (object_value.length == 0)
	return true;

	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

	check_char = start_format.indexOf(object_value.charAt(0))
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
	
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
		}
	    else if (trailing_blank)
			return false;
		else
			digits = true;
	}	

    return true
    }

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

// -->

/***********************************************
* Funzione per testo espandibile
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)

		function toggleAll()
		{
		    var sa = document.getElementById("chkViewAll");
		    var ch = sa.checked;
		    toggleQuestions(ch);
		}



if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined")
revivecontent()
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate


function clearFocus()
{
no_bordo = function(){this.blur()} 
for(i=0;i<document.links.length;i++) 
{ 
document.links[i].onfocus=no_bordo; 
} 
} 
onload=clearFocus; 

//Popup normale
function openWindow(url, name, w, h,scroll ) {
  popupWin = window.open(url, name, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars='+scroll+',resizable=no,width='+ w + ',height='+ h + ',top=10,left=10')
}


