function trim(str){if (!str)return str;while (str.length && (str.substring(0,1) == " " ||str.substring(0,1) == "\t" ))str = str.substring(1, str.length);while (str.length && (str.substring(str.length - 1, str.length) == " " || str.substring(str.length - 1, str.length) == "\t"))    str = str.substring(0, str.length - 1);  return str;}
function displayChanger(obj,newStyle){if(obj != null){if(obj.style.display != newStyle){obj.style.display = newStyle;}}return true;}
function ricercaInCorso(showIt){if(parent.document.getElementById('searching') != null){if(showIt){parent.document.getElementById('searching').className = 'searchingDisplay';}else{analisiInCorso(showIt);parent.document.getElementById('searching').className = 'searching';}}}
function analisiInCorso(showIt){if(parent.document.getElementById('searchingDirectory') != null){if(showIt){parent.document.getElementById('searchingDirectory').className = 'searchingDirectory';}else{parent.document.getElementById('searchingDirectory').className = 'searching';}}}
function closePortal(/*string*/toWhere){if(toWhere!= null && toWhere != 'undefined'){window.location=toWhere;}else{testPortal = top.window.opener;if(testPortal == 'undefined' || testPortal == null){window.location='/archivioluce';}else{window.close();}}}
//function closePortal(/*string*/toWhere){document.location='http://archivio.luce.xdams.net/archivioluce/regioni/veneto/indice.jsp';}
function errorMessage(showIt,theMessage){if(parent.document.getElementById('errorMessage') != null){if(showIt){parent.document.getElementById('textMessage').innerHTML = theMessage;parent.document.getElementById('errorMessage').className = '';}else{parent.document.getElementById('errorMessage').className = 'searching';}}}
function urlOpener(percorso,ilTarget){while(percorso.indexOf("&amp;")>0){percorso = percorso.replace("&amp;","\&");};if(document.getElementById(ilTarget) != null){document.getElementById(ilTarget).src = percorso;}return true;}
function urlTester(percorso,ilTarget){
	while(percorso.indexOf("&amp;")>0){percorso = percorso.replace("&amp;","\&");}
	percorsoTest = percorso;
	if(percorso.length>10)
		percorsoTest = percorso.substring(0,20)

	if(document.getElementById(ilTarget) != null){
		ilSrc=document.getElementById(ilTarget).src;
		//alert(document.getElementById(ilTarget).location+"\n"+ilSrc)
		if(ilSrc.indexOf(percorsoTest) == -1)
			document.getElementById(ilTarget).src = percorso;
	}
	return true;
}
function openPlayer(percorso,theId,ilTarget){
	while(percorso.indexOf("&amp;")>0){percorso = percorso.replace("&amp;","\&");}
	if(theId.indexOf("&") != -1){
		theId = "&id="+theId
	}
	percorso = "/archivioluce/jsp/schede/videoPlayer.jsp?tipologia="+percorso+theId;
	window.open(percorso,'thePlayer','scrollbars=auto,toolbar=no,location=no,width=500,height=550');
	return true;
}
function buildBread(bradId,visText,theLink,onClick,theTarget){
	if(document.getElementById('briciole'+bradId)!=null){
		totBriciole = 4;
		laBriciola = '&#160;/ '
		if(theLink != ''){
			if(theTarget == '')
				theTarget = '_self'
			laBriciola += '<a class="navigazione" href="'+theLink+'" onclick="'+onClick+'" target="'+theTarget+'">'+visText+'</a>'
		}
		else
			laBriciola += '<span class="navigazione">'+visText+'</span>'
		document.getElementById('briciole'+bradId).innerHTML = laBriciola;
		for(i=bradId;i<totBriciole;i++){
			document.getElementById('briciole'+(i+1)).innerHTML = '';
		}
	}
	return true;

}

function openWindow(ilPercorso){
	while(ilPercorso.indexOf("&amp;")>0){ilPercorso = ilPercorso.replace("&amp;","\&");}
	laUserWindow = window.open(ilPercorso,'userWindow','scrollbars=yes,toolbar=no,location=no,status=no,width=332,height=490');
	laUserWindow.moveTo(0,0)
}

function addElement(titoloH,archivioH,numdocH,id_tipologia_allegatoH){
	percorso = '/archivioluce/users/forward_to_add_record.jsp?'
	percorso += 'titoloH='+titoloH
	percorso += '&archivioH='+archivioH
	percorso += '&numdocH='+numdocH
	if(id_tipologia_allegatoH == 'video')
		id_tipologia_allegatoH= '01';
	if(id_tipologia_allegatoH == 'foto')
		id_tipologia_allegatoH= '02';
	if(id_tipologia_allegatoH == 'audio')
		id_tipologia_allegatoH= '03';
	percorso += '&id_tipologia_allegatoH='+id_tipologia_allegatoH
	openWindow(percorso)
	return true;
}
function addElementCart(theId,theArch,fotoId,titolo,nomeFondo,pathImg){
	percorso = '/archivioluce/users/addImg.jsp?'
	percorso += 'id_img='+fotoId
	percorso += '&id_servizio='+theId
	percorso += '&theArch='+theArch
	percorso += '&nomeFondo='+nomeFondo
	percorso += '&titoloBsk='+titolo
	percorso += '&pathImg='+escape(pathImg)
    window.open(percorso,"carrello","toolbar=0,status=0,width=600,height=500,scrollbars=0");
	return true;
}

function htmlPrint(archivio,numdoc,tipologia){
	percorso = '/archivioluce/jsp/stampa/htmlPrint.jsp?'
	percorso += 'archivio='+archivio
	percorso += '&numdoc='+numdoc
	percorso += '&tipologia='+tipologia
	openWindow(percorso)
	return true;
}
function pdfPrint(archivio,numdoc){
	percorso = '/archivioluce/ViewPDFServlet?';
	percorso += 'theArch='+archivio;
	percorso += '&id='+numdoc;
// 	openWindow(percorso)
	laUserWindow = window.open(percorso,'userWindow','scrollbars=yes,toolbar=no,location=no,status=no,resizable=yes,width=332,height=490');
	laUserWindow.moveTo(0,0)

	return true;
}
function showHidePrint(ck,toHideShow){
	if(ck.checked==true){
		document.getElementById(toHideShow).style.display='';
        }else{
                document.getElementById(toHideShow).style.display='none';
        }

}
function printScheda(toHideShow){

	document.getElementById(toHideShow).innerHTML='';
	window.print();
	window.close();
}
function toAFriend(archivio,numdoc,tipologia){
	percorso = '/archivioluce/users/toAFriend.jsp?'
	percorso += 'archivio='+archivio
	percorso += '&numdoc='+numdoc
	percorso += '&tipologia='+tipologia
	window.open(percorso,'toAFriend','scrollbars=no,toolbar=no,location=no,width=300,height=250');
	return true;
}
function submitToAFriend(archivio,numdoc,tipologia){

	if(trim(document.mailForm.e_mail_friend.value)!=''){
		//alert('invia');
		document.mailForm.submit();
	}else{
	   alert('Inserire l\'inidizzo e-mail a cui si desidera inviare la scheda');
	}
	return true;
}
function openPortal(/*string*/ thePath){
while(thePath.indexOf("&amp;")>0){thePath = thePath.replace("&amp;","\&");}
	theWindow = window.open(thePath,'portale','');
//	theWindow.moveTo(0,0)
	theWindow.focus()
	return true;
}


function acquistaFoto(){
	urlOpener("/archivioluce/jsp/ricerca/ricerca_fotografico.jsp","content_1")
}