

// Function to confirm form submission
// Author : Nilesh Dosooye
// pass message to popup to function and it will send true or false depending on user choice
// call it with onSubmit on a form

function userConfirmationAlert(message)
{

	 var whatToReturn = true;
     if (!confirm(message)) 
	 {
	   whatToReturn = false;
	 }
	 return (whatToReturn);
}


// Functions to Check and Uncheck all CheckBoxes
// Author : Nilesh Dosooye
// Usage : <input type=button name="CheckAll"   value="Check All" onClick="checkAll(document.myform.list)">
//         <input type=button name="UnCheckAll" value="Uncheck All" onClick="uncheckAll(document.myform.list)">

function checkAll(field)
{
        for (i = 0; i < field.length; i++)
        field[i].checked = true ;
}

function uncheckAll(field)
{
        for (i = 0; i < field.length; i++)
        field[i].checked = false ;
}

// Function to open a Modal Window
// Author : Nilesh Dosooye
// Users can specify all parameters needed as hidden variables
// e.g
//<input type=hidden name="toolbar" value="0">
//<input type=hidden name="location" value="0">
//<input type=hidden name="directories" value="0">
//<input type=hidden name="status" value="0">
//<input type=hidden name="menubar" value="0">
//<input type=hidden name="scrollbars" value="0">
//<input type=hidden name="resizable" value="0">
//<input type=hidden name="width" value="800">
//<input type=hidden name="height" value="800">
// <input type=hidden name="url" value="http://nilesh.dosooye.com/">

function openNewModalWindow(form1) {    

var address = form1.url.value;   
var option = "toolbar=" + form1.toolbar.value +",location=" + form1.location.value +",directories=" + form1.directories.value +",status=" + form1.status.value +",menubar="+ form1.menubar.value +",scrollbars=" + form1.scrollbars.value  +",resizable=" + form1.resizable.value +",width="+ form1.width.value +",height=" + form1.height.value;
var win4 = window.open(address, form1.windowName.value,option);
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openNewModalWindowAndCloseParent(form1,window1) {    

var address = form1.url.value;   
var option = "toolbar=" + form1.toolbar.value +",location=" + form1.location.value +",directories=" + form1.directories.value +",status=" + form1.status.value +",menubar="+ form1.menubar.value +",scrollbars=" + form1.scrollbars.value  +",resizable=" + form1.resizable.value +",width="+ form1.width.value +",height=" + form1.height.value;
var win4 = window.open(address, form1.windowName.value,option);

if (window1.name!="mainWindow")
	{
	window1.close();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ChangeLabel(lang, itlab, enlab)
{
	var labelrs = document.getElementById('labelrs');
	if (lang=='it') { 
		labelrs.innerHTML = itlab;
	}
	if (lang=='en') { 
		labelrs.innerHTML = enlab;
	}
}

function DoCustomCheckValidationIt()
{
  var cb = document.getElementById('checkbox');
  if(cb.checked)
  {
    return true;
  }
  else
  {
	alert('Necessario Accettare i termini');
    return false;
  }
}

function DoCustomCheckValidationEn()
{
  var cb = document.getElementById('checkbox');
  if(cb.checked)
  {
    return true;
  }
  else
  {
	alert('Accept the terms');
    return false;
  }
}

function LoadImage(newsrc,newcom)
{
	var imgch = document.getElementById('imgprinc');
	imgch.src = newsrc;
	var commento = document.getElementById('commento');
	commento.innerHTML = newcom;
}




