function addPrint(id, maxPrint) {
	var printlist = getCookie(window, "printlist");
	if (printlist == null || printlist.length == 0) {
		printlist = id;
	} else if (printlist.indexOf(id) < 0) {
		if (printlist.split(",").length >= maxPrint) {
			if (id.charAt(0) == "C")
				alert("打印列表內已滿" + maxPrint + "條條文");
			else
				alert("Maximum of " + maxPrint + " provisions have been added to printing list");
			return;
		}
		else
			printlist = printlist + "," + id;
	}
	setCookie(window, "printlist", printlist, null, "", null, null);
	setOpacity("divPrintList" + id, 0);
	setTimeout('setOpacity("divPrintList' + id + '", 10);', 200);
}

function setOpacity(id, opacity) {
	document.getElementById(id).style.opacity = opacity / 10;
	document.getElementById(id).style.filter = 'alpha(opacity=' + opacity * 10 + ')';
}

function openPrintList(lang) {
	var url = "WebPrintList" + QM_KHBYPASS + "OpenAgent&lang=" + lang + "&r=" + Math.random();
	var w = window.open(url, "BlisPrintList", "toolbar=1,location=0, directories=0, status=1, menubar=0, fullscreen=no, scrollbars=2, resizable=1,copyhistory=0,width=800,height=768");
	if (w) w.focus();
}

function printFriendly(lang) {
	var url = "WebPrintFriendly" + QM_KHBYPASS + "OpenAgent&lang=" + lang + "&r=" + Math.random();
	window.open(url, "BlisPrintFriendly", "toolbar=1,location=0, directories=0, status=1, menubar=1, fullscreen=no, scrollbars=2, resizable=1,copyhistory=0,width=1024,height=768");
}

function removePrint() {
	var elements = document.fmSections.elements;
	var printlist = getCookie(window, "printlist");
	var id = printlist.split(",");
	var newlist = "";
	for (var i = 0; i < id.length; i++) {
		if (!elements["cbx" + id[i]].checked) {
			if (newlist.length == 0) {
				newlist = id[i];
			} else {
				newlist = newlist + "," + id[i];
			}
		}
	}
	if (newlist != printlist) setCookie(window, "printlist", newlist, null, "", null, null);
	window.location.reload(true);
}

function removeAllPrint() {
	setCookie(window, "printlist", "", null, "", null, null);
	window.location.reload(true);
}
