
function openPopup(location) {
/*	size = "width=600,height=500";
	winName = "popUp";
	win = window.open(location, winName, "menubar=0,status=0,resizable=0,location=0," + size);
	win.focus();
*/
	openPopupSized(location,"width=800","popUp");
}

function openPopupSized(location,size,winName) {
	win = window.open(location, winName, "menubar=0,status=0,resizable=1,location=0,scrollbars=1," + size);
	win.focus();
}

function stampa(objForm, action) {
	objForm.target = "_blank";
	var oldAction = objForm.action;
	objForm.action = action;
	objForm.submit();
	objForm.target = "_self";
	objForm.action = oldAction;
}
function postForm(objForm, originalAction, operationName) {
	objForm.target = "_self";
	if (operationName != null) {
		objForm.action = originalAction + "_" + operationName;
	} else {
		objForm.action = originalAction;
	}
	return true;
}

function postFormByID(formId, mantieniScroll) {
	var formToPost = document.getElementById(formId);
	if(formToPost!=null){

		if(mantieniScroll){
		var scrollX = document.documentElement.scrollLeft;
        var scrollY = document.documentElement.scrollTop;

        if( isNaN(scrollX)  || isNaN(scrollY)){
            scrollX = window.pageXOffset;
            scrollY = window.pageYOffset;
        }

		var oldAction = formToPost.action;
        formToPost.action= oldAction+"?scrollX="+scrollX+"&scrollY="+scrollY;
		formToPost.submit();
		formToPost.action = oldAction;
		}else{
			formToPost.submit();
		}
	}
}


function postFormWithConfirm(objForm, originalAction, operationName, alertMsg) {
	if (confirm(alertMsg)) {
		return postForm(objForm, originalAction, operationName);
	} else {
		return false;
	}
}
function doppioClick(objForm, originalAction, operationName) {
	objForm.target = "_self";
	if (operationName != null) {
		objForm.action = originalAction + "_" + operationName;
	} else {
		objForm.action = originalAction;
	}
	objForm.submit();
}
function multilingua(param) {
	location = "Main.uri?lang=" + param;
}
function printPage() {
	var divs = document.getElementsByName("NO_PRINT");
	if (divs.length == null) {
		divs.style.visibility = "hidden";
		window.print();
		divs.style.visibility = "visible";
	} else {
		for (var i = 0; i < divs.length; i += 1) {
			divs[i].style.visibility = "hidden";
		}
		document.getElementById("PRINT_AREA").style.position = "absolute";
		document.getElementById("PRINT_AREA").style.overflow = "hidden";
		document.getElementById("PRINT_AREA").style.top = 0;
		document.getElementById("PRINT_AREA").style.left = 0;
		document.getElementById("PRINT_AREA").style.height = "";
		window.print();
		document.getElementById("PRINT_AREA").style.overflow = "auto";
		document.getElementById("PRINT_AREA").style.position = "static";
		document.getElementById("PRINT_AREA").style.height = "450";
		for (i = 0; i < divs.length; i++) {
			divs[i].style.visibility = "visible";
		}
	}
	return false;
}
function resizeIframe() {
	resizeRecursive(window);
}
function resizeRecursive(win) {
	if (win.parent != null) {
		if (win.name != null && "" != win.name) {
			var iFrame = win.parent.document.getElementById(win.name);
			if (iFrame != null) {
				var iHeight = win.document.body.scrollHeight;
				iFrame.style.height = iHeight + "px";
				resizeRecursive(win.parent);
			}
		}
	}
}

// x tabs statefull
function attivaSottoTab(idTab, iframeSrc, ulName) {
	var i = 0;
	var a;
	var il;
	var ul = document.getElementById(ulName);
	for (var j in ul.childNodes) {
		il = ul.childNodes[j];
		if (il.id == "noactive" || il.id == "activelink") {
			if (i != idTab) {
				il.id = "noactive";
				a = document.getElementById("a" + i);
				if (a != null) {
					a.href = "javascript:selezionaTab(" + i + ")";
				}
			} else {
				il.id = "activelink";
				a = document.getElementById("a" + i);
				if (a != null) {
					a.href = "javascript:void(0)";
				}
			}
			i = i + 1;
		}
	}
	var iframe = document.getElementById("innerTab");
	iframe.src = iframeSrc;
}

// x tabs "stateless" in StrutturaBoxFE/PacchettoBoxFE
function attivaMultiTab(idTab, iframeSrc, ulName, objId, itemId) {
	var i = 0;
	var a;
	var il;
	var ul = document.getElementById(ulName);
	for (var j in ul.childNodes) {
		il = ul.childNodes[j];
		if (il.id == "noactive" || il.id == "activelink") {
			if (i != idTab) {
				il.id = "noactive";
				a = document.getElementById("a" + ulName + i);
				if (a != null) {
					a.href = "javascript:void(0);";
					a.onClick = "javascript:selezionaTab(" + ulName + "," + i + "," + objId + "," + itemId + ")";
				}
			} else {
				il.id = "activelink";
				a = document.getElementById("a" + ulName + i);
				if (a != null) {
					a.href = "javascript:void(0)";
				}
			}
			i = i + 1;
		}
	}
	var iframe = document.getElementById("iftabs" + ulName);
	iframe.src = iframeSrc;
}
function closeBox(tabName) {
	document.getElementById("outerDiv" + tabName).style.display = "none";
}
function toggleBox(tabName) {
	if (document.getElementById("contentDiv" + tabName).style.display == "none") {
		document.getElementById("contentDiv" + tabName).style.display = "inline";
	} else {
		document.getElementById("contentDiv" + tabName).style.display = "none";
	}
}
function collapseBoxTabs(tabName) {
	document.getElementById("iftabs" + tabName).style.display = "none";
}

function toggleAltreSistemazioni(tabName) {
	toggleDiv(tabName);
}

function toggleDiv(divID){
	if (document.getElementById(divID).style.display == "none") {
		document.getElementById(divID).style.display = "inline";
	} else {
		document.getElementById(divID).style.display = "none";
	}
}


