//browser detection
if (navigator.appName == "Netscape")var isNetscape = true;
if (navigator.appName == "Microsoft Internet Explorer") var isExplorer = true;
if (window.opera) var isOpera = true;
if (navigator.userAgent.toLowerCase().indexOf("safari") != -1) var isSafari=true;
//OS detection
if (navigator.appVersion.indexOf("Win") != -1) var isWin = true;
if (navigator.appVersion.indexOf("Mac") != -1) var isMac = true;
if (navigator.appVersion.indexOf("X11") != -1) var isUnix = true;
if (navigator.appVersion.indexOf("Linux") != -1) var isLinux = true;
//Version detection
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var version = navigator.appVersion.substring(0, 1);
//windowDimensionDetection
var winWidth,winHeight;
function obj(objId) {
return document.getElementById(objId);
}
function createEl(theEl) {
return document.createElement(theEl);
}
function selectAllCheckBoxes(formId) {
var f = obj(formId);
for (var k = 0; k < f.elements.length; k++) {
var e = f.elements[k];
if (e.type.toLowerCase() == 'checkbox')
e.checked = 'true';
}
}
function getWindowDimensionH() {
if (isNetscape) {
winHeight = top.window.innerHeight;
}
if (isExplorer) {
winHeight = document.documentElement.offsetHeight;
}
return winHeight;
}
function getWindowDimensionW() {
if (isNetscape) {
winWidth = top.window.innerWidth;
}
if (isExplorer) {
winWidth = document.documentElement.offsetWidth;
}
return winWidth;
}
function sendWindowResizeMessage() {
obj("commander").src = "/commons/tools/command.jsp?_VP_V_ID=6315970&CM=UPDATEWINSIZE&PAGE_HEIGHT=" + getWindowDimensionH() + "&PAGE_WIDTH=" + getWindowDimensionW();
}
function getEvent(){
return window.event;
}
//mouse position detection
if (!isExplorer) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var mouseX = 0
var mouseY = 0
function getMouseXY(e) {
if (isExplorer) {
mouseX = event.clientX + document.body.scrollLeft
mouseY = event.clientY + document.body.scrollTop
} else {
mouseX = e.pageX
mouseY = e.pageY
}
if (mouseX < 0) {
mouseX = 0
}
if (mouseY < 0) {
mouseY = 0
}
return true
}
function showHideDiv(divId) {
if (obj(divId))
if (obj(divId).style.visibility == 'hidden') {
obj(divId).style.visibility = 'visible';
} else {
obj(divId).style.visibility = 'hidden';
}
}
function showHideSpan(spanId) {
if (obj(spanId))
if (obj(spanId).style.display == 'none') {
obj(spanId).style.display = '';
} else {
obj(spanId).style.display = 'none';
}
}
function displayDiv(divId) {
if (obj(divId))
obj(divId).style.display = '';
var i=0;
}
function displayNoneDiv(divId) {
if (obj(divId))
obj(divId).style.display = 'none';
}
function hideDiv(divId) {
if (obj(divId))
obj(divId).style.visibility = 'hidden';
}
function showDiv(divId) {
if (obj(divId))
obj(divId).style.visibility = 'visible';
}
function centerPopup(url, nome, w, h, scroll, resiz) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
if(!resiz) resiz=true;
resizable="resizable="+resiz;
winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ','+resizable+', toolbars=false';
win = window.open(url, nome, winprops)
if (parseInt(navigator.appVersion) >= 4) {
win.window.focus();
}
}
//----------------------------------positioning------------------------------------------------------
// to determinate the real x position of the element
function getAbsoluteLeft(el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
// to determinate the real y position of the element
function getAbsoluteTop(el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
function getAbsoluteLeftWin(el) {
if (isExplorer)
xPos = window.screenLeft + getAbsoluteLeft(el);
else
xPos = window.screenX + getAbsoluteLeft(el);
return xPos;
}
function getAbsoluteTopWin(el) {
if (isExplorer)
yPos = window.screenTop + getAbsoluteTop(el);
else
yPos = window.screenY + getAbsoluteTop(el);
return yPos;
}
function positionIt(where, theObj) {
//if (!distanceY) distanceY = 0;
//if (!distanceX) distanceX = 0;
var el = document.all ? document.all(where) : obj ? obj(where) : null;
var target = document.all ? document.all(theObj) : obj ? obj(theObj) : null;
if (el) {
trueX = getAbsoluteLeft(el);
//trueX += distanceX;
trueY = getAbsoluteTop(el);
var h = el.offsetHeight;
elHeight = parseFloat(h);
trueY += parseFloat(elHeight); //+ distanceY;
target.style.left = trueX;
target.style.top = trueY;
}
}
//END positioning
function centerObject(objId) {
if (obj(objId)) {
var theObject = obj(objId)
theObject.style.position = "absolute";
theObject.style.top = (document.body.clientHeight - parseFloat(theObject.offsetHeight)) / 2;
theObject.style.left = (document.body.clientWidth - parseFloat(theObject.offsetWidth)) / 2;
//alert("H:"+theObject.offsetHeight+" W:"+theObject.offsetWidth);
}
}
//END positioning
// event handling START -------------------------------
function getTarget(e) {
if (isExplorer) {
return e.srcElement;
}
if (isNetscape) {
return e.target;
}
}
function getKeyCode(e) {
if (isExplorer) {
return e.keyCode;
}
if (isNetscape) {
return e.which;
}
}
function stopBubble(e){
if (isNetscape)
e.stopPropagation();
e.cancelBubble = true;
return false;
}
// event handling END -------------------------------
// START xmlHttpRequestObject -------------------------------------------
var xmlHttpRequestObject;
function getXMLObj() {
if (xmlHttpRequestObject) {
return xmlHttpRequestObject;
} else {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
xmlHttpRequestObject = req;
return req;
}
}
function loadSyncroContent(href, objId) {
req = getXMLObj();
//req.open('POST', href, false);
req.open('GET', href, false);
req.send(null);
if (req.status == 200) {
var ret = req.responseText;
obj(objId).innerHTML = ret;
}
}
// END xmlHttpRequestObject -------------------------------------------
// debugger ----------------------------------------------------------------------------
var debugPopup;
var str = "";
function scriptDebugger() {
str = str + "
";
for (i = 0; i < arguments.length; i++) {
str += arguments[i] + "
-------------------------------------------------------------
";
}
if (!debugPopup)
debugPopup = window.open("", "debugWin", "width=300,height=200,resizable"); // a window object
debugPopup.document.open("text/html", "replace");
debugPopup.document.write("
New Document" + str + "");
debugPopup.document.close();
}
// isRequired ----------------------------------------------------------------------------
function findTab(theEl){
while ((theEl.getAttribute('isTabSetDiv')!="true")) {
if(theEl.nodeName=='BODY') return "";
theEl =isNetscape ? theEl.parentNode: theEl.parentElement;
}
return theEl.id;
}
var theRequiredTabset="";
var theOldtabSelId;
var allDiv;
function canSubmitForm(idForm) {
var canSubmit=true;
//var alertMessage=""
elementsq= obj(idForm).elements.length;
for (h=0;h<=elementsq; h++){
theElement= obj(idForm).elements[h];
if (theElement && theElement.className=="formElementsError")
theElement.className="formElements";
if (theElement && (theElement.value=="" || theElement.value.length==0) && theElement.getAttribute('required')=="true" && theElement.type!="hidden"){
theElement.className="formElementsError";
//alertMessage+= theElement.name +'\n';
canSubmit=false;
if (theRequiredTabset=="")
theRequiredTabset=findTab(theElement);
}
}
/*
for (h=0;h<=elementsq; h++){
theElement= obj(idForm).elements[h];
if (theElement.className && theElement.className=="formElementsError")
theElement.className="formElements";
//if (theElement && !(theElement.value==''))
// alert(theElement.name)
if (theElement &&
(theElement.value=="" || theElement.value.length==0) &&
theElement.getAttribute('required')=="true" &&
(theElement.type!="hidden")){
theElement.className="formElementsError";
//alertMessage+= theElement.name +'\n';
canSubmit=false;
if (theRequiredTabset=="")
theRequiredTabset=findTab(theElement);
}
}
*/
//if (alertMessage!="")
// alert(alertMessage+"campi obbligatori")
if (canSubmit==false) {
if (theRequiredTabset!=""){
theSuffix="div_tabset_";
therequiredTabLinkId=theRequiredTabset.substring(theSuffix.length, theRequiredTabset.length);
allTabLabel= document.getElementsByTagName('TD');
if (allTabLabel.length>0){
for (i=0;i<=allTabLabel.length;i++){
if (allTabLabel[i] && allTabLabel[i].className=="tabSelected"){
allTabLabel[i].className="tabUnselected";
//alert(allTabLabel[i].id+" class= "+allTabLabel[i].className)
}
}
}
obj(therequiredTabLinkId).className="tabSelected";
if(obj(theOldtabSelId)) obj(theOldtabSelId).className="tabUnselected";
allDiv= document.getElementsByTagName('DIV');
if (allDiv.length>0){
for (i=0;i<=allDiv.length;i++){
if (allDiv[i] && allDiv[i].id!=theRequiredTabset && allDiv[i].getAttribute('isTabSetDiv')=="true") allDiv[i].style.display="none";
obj(theRequiredTabset).style.display="";
}
}
theRequiredTabset=""
}
}
return canSubmit;
}
// verify before unload ----------------------------------------------------------------------------
document.onchange= init;
window.onbeforeunload = unloadMess;
var isChanged=false;
function findtheForm(theEl){
while (theEl.nodeName != "FORM") {
if(theEl.nodeName=='BODY') return "";
theEl =isNetscape ? theEl.parentNode: theEl.parentElement;
//scriptDebugger(theEl.nodeName+" id= "+theEl.id+" name= "+theEl.name)
}
return theEl;
}
function findValueElementAttribute(theElement, theAttribute){
if (!theAttribute) theAttribute="alertOnChange";
if (!theElement) theElement=document.body;
if (theElement.getAttribute(theAttribute)) return theElement.getAttribute(theAttribute);
}
function init(e){
if (!e) e = event;
//window.focus();
var theSource=getDOMSourceEvent(e);
var theForm=findtheForm(theSource);
if('true'==''+ findValueElementAttribute(theForm)){
isChanged=true;
}
}
function getDOMSourceEvent(e){
if (!e)
e = event;
return source = (e.target) ? e.target : e.srcElement;
}
function unloadMess(){
if (isChanged!=false) {
//mess = "missing_FORM_IS_CHANGED"
return mess;
}
}
function addEvent(obj,event_name,func_name){
if (obj.attachEvent){
obj.attachEvent("on"+event_name, func_name);
}else if(obj.addEventListener){
obj.addEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = func_name;
}
}
// Removes an event from the object
function removeEvent(obj,event_name,func_name){
if (obj.detachEvent){
obj.detachEvent("on"+event_name,func_name);
}else if(obj.removeEventListener){
obj.removeEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = null;
}
}
// Stop an event from bubbling up the event DOM
function stopEvent(evt){
evt || window.event;
if (evt.stopPropagation){
evt.stopPropagation();
evt.preventDefault();
}else if(typeof evt.cancelBubble != "undefined"){
evt.cancelBubble = true;
evt.returnValue = false;
}
return false;
}
// Get the obj that starts the event
function getElement(evt){
if (window.event){
return window.event.srcElement;
}else{
return evt.currentTarget;
}
}
// Get the obj that triggers off the event
function getTargetElement(evt){
if (window.event){
return window.event.srcElement;
}else{
return evt.target;
}
}
// For IE only, stops the obj from being selected
function stopSelect(obj){
if (typeof obj.onselectstart != 'undefined'){
addEvent(obj,"selectstart",function(){ return false;});
}
}
/* Caret Functions */
// Get the end position of the caret in the object. Note that the obj needs to be in focus first
function getCaretEnd(obj){
if(typeof obj.selectionEnd != "undefined"){
return obj.selectionEnd;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
var Lp=obj.createTextRange();
Lp.setEndPoint("EndToEnd",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
// Get the start position of the caret in the object
function getCaretStart(obj){
if(typeof obj.selectionStart != "undefined"){
return obj.selectionStart;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
var Lp=obj.createTextRange();
Lp.setEndPoint("EndToStart",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
// sets the caret position to l in the object
function setCaret(obj,l){
obj.focus();
if (obj.setSelectionRange){
obj.setSelectionRange(l,l);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',l);
m.collapse();
m.select();
}
}
// sets the caret selection from s to e in the object
function setSelection(obj,s,e){
obj.focus();
if (obj.setSelectionRange){
obj.setSelectionRange(s,e);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',s);
m.moveEnd('character',e);
m.select();
}
}
/* Escape function */
String.prototype.addslashes = function(){
return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};
/* --- Escape --- */
/* Offset position from top of the screen */
function curTop(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetTop;
obj = obj.offsetParent;
}
return toreturn;
}
function curLeft(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetLeft;
obj = obj.offsetParent;
}
return toreturn;
}
/* ------ End of Offset function ------- */
/* Types Function */
// is a given input a number?
function isNumber(a) {
return typeof a == 'number' && isFinite(a);
}
/* Object Functions */
function replaceHTML(obj,text){
while(el == obj.childNodes[0]){
obj.removeChild(el);
};
obj.appendChild(document.createTextNode(text));
}
function addToFavorites(favoriteTitle){
if(!favoriteTitle)favoriteTitle=document.title;
if( window.sidebar && window.sidebar.addPanel ) {
//Gecko (Netscape 6 etc.) - add to Sidebar
window.sidebar.addPanel( favoriteTitle ? favoriteTitle:document.title, document.location.href, '' );
} else if( window.external && ( navigator.platform == 'Win32' ||
( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
//IE Win32 or iCab - checking for AddFavorite produces errors in
//IE for no good reason, so I use a platform and browser detect.
//adds the current page page as a favourite; if this is unwanted,
//simply write the desired page in here instead of 'location.href'
window.external.AddFavorite( location.href, favoriteTitle ? favoriteTitle:document.title );
} else if( window.opera && window.print ) {
//Opera 6+ - add as sidebar panel to Hotlist
return true;
} else if( document.layers ) {
//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
//not target page)
window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
} else {
//other browsers - tell them to add a bookmark (adds current page, not target page)
window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
}
return false;
}
/*
// centralized onload system
*/
var setQA,setStart,setDrop, setInitTree, setInitSizeTree;
init= function(){
if (setStart==true) start();
if (setQA==true) quickAccessPos();
if (setDrop==true) dropInit();
if (setInitTree==true) inittree();
if (setInitSizeTree==true) initSizeTree();
}
window.onload=init;