function setData(input,data){
	document.getElementById(input).value=data;
}
function checkdate(){
	if (document.form1.dtdal.value == "" || document.form1.dtal.value == ""){
		alert('Specificare entrambe le date');
	}else{
		document.form1.submit();
	}
}

function  contratti(){
	document.formcontratto.submit();
}
function noacc(){
	alert('Funzione non abilitata per questo utente')
}

function changeto(highlightcolor){
source=event.srcElement
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TD")
source=source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function changeback(originalcolor){
if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
return
if (event.toElement!=source)
source.style.backgroundColor=originalcolor
}

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 canc(id) {
	if(window.confirm('Sicuro di voler cancellare questo utente?')) {
					  document.location.href="elencoutenti.php?del="+id;
					  }
}
function cancnews(id) {
	if(window.confirm('Sicuro di voler cancellare questa news?')) {
					  document.location.href="elenconews.php?del="+id;
					  }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function insertAtCursor(myField, myValue) {
			myField.focus();
	
		//IE support
		if (document.selection) {
			myField.focus();
			sel = document.selection.createRange();
			sel.text = myValue;
		}
		//MOZILLA/NETSCAPE support
		else if (myField.selectionStart || myField.selectionStart == '0') {
			var startPos = myField.selectionStart;
			var endPos = myField.selectionEnd;
			myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
		} else {
			myField.value += myValue;
		}
	}

var j = 0;
var k = 0;

function insertBold(form) {
		if (j % 2 == 0) {
			insertAtCursor(form, '[b]');
		} else {
			insertAtCursor(form, '[/b]');
		}
		j += 1;
	}	
function insertItalic(form) {
		if (k % 2 == 0) {
			insertAtCursor(form, '[i]');
		} else {
			insertAtCursor(form, '[/i]');
		}
		k += 1;
	}		
function showHideRow(a) {
if(document.getElementById(a).style.display == "block"){
 document.getElementById(a).style.display = "none";
}
else{
  document.getElementById(a).style.display = "block";
}
}
function check(a){
	document.getElementById("chk"+a).value='1';
}
function quest(n) {
	var totcheck=0;
	for(a=1;a<=n;a++){
		if(document.getElementById("chk"+a).value=='1'){
		totcheck++
		}
	}
	if(totcheck<n){
		alert('Hai risposto solo a '+totcheck+' domande. Completare il questionario.');
	}else{
		document.form1.submit();
	}
}
function ptfexp2(){
	if(document.formexp2.nomeptf.value==0){
		alert('Specificare la PTF di Riferimento');
	}else{
		document.formexp2.submit();
	}
}

function NoteExpress(){
	alert('Per coloro che gestiscono dall`interrogazione clienti la visualizzazione dei pdf dei documenti archiviati,\r\nsi rende noto che con l`installazione di questa ptf grafica, al fine di visualizzare un documento in pdf \r\n(laddove il sistema sia predisposto ed il reperimento dei file pdf sia possibile), occorre effettuare doppio click \r\nsull`icona del pdf o su un qualunque punto della riga desiderata nel subfile di interrogazione clienti \r\n(dettaglio ordini in nota, bolle/corrispettivi, fatture/note credito-debito) e non più il singolo click sull`icona pdf.\r\n\r\nL`opzione di default per questi subfile è dunque stata modificata da "1=Scelta" a "V=Visualizza/Stampa PDF".\r\nPer scegliere l`opzione "1=Scelta" è ovviamente sempre possibile selezionarla facendo click con  il tasto destro del mouse sulla riga del subfile.');
}
function delapp(id){
var domanda = window.confirm('Sei sicuro di voler eliminare questo appuntamento?');
	if(domanda){
		document.location.href="calendario.php?mode=del&idapp="+id;
	}
}
function nodelapp(){
	alert('Impossibile eliminare attività di altri utenti')
}
function nomodapp(){
	alert('Impossibile modificare attività di altri utenti')
}
