/** * Open specified url in new window * Default width and height is 800 x 600 */ function openWindow(url, width, height) { if (!width) width = 800; if (!height) height = 600; var left = (screen.width/2) - width/2; var top = (screen.height/2) - height/2; window.open(url, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+''); } /** * Open specified url in new window for printing * Default width and height is 800 x 600 */ function openPrintWindow(url, width, height) { if (!width) width = 800; if (!height) height = 600; var left = (screen.width/2) - width/2; var top = (screen.height/2) - height/2; window.open(url, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+''); } // close an opened window function closeWindow() { window.close(); } // go to a specified url function goToUrl(url) { window.location.href = url; } // print content of current window function printWindow(form) { // hide all control in form before printing for (var i = 0; i < form.elements.length; i++) { var e = form.elements[i]; e.style.display = "none"; } window.print(); window.close(); } // delete confirmation function deleteConfirm(hasChild) { if ((hasChild == null) || (hasChild == 0)) return confirm("Bent u zeker dat u dit item wil verwijderen"); return confirm("???nl.label.delete-confirm-haschild???"); } // window sizing utils function centerScreenIE() { var w = window.document.body.offsetWidth + 6; var h = window.document.body.offsetHeight + 25; var W = screen.availWidth; var H = screen.availHeight - 20; window.moveTo((W - w) / 2, (H - h) / 2); } function centerScreenGecko() { var w = window.outerWidth; var h = window.outerHeight; var W = screen.availWidth; var H = screen.availHeight - 20; window.moveTo((W - w) / 2, (H - h) / 2); } function centerScreen() { if(global.isGecko) { centerScreenGecko(); } else { centerScreenIE(); } } //emulating the sizeToContent function for the bad guy IE var heightDiff = 0; var global = new Object(); global.SAFE_MARGIN_H = 20; global.SAFE_MARGIN_W = 20; global.getContentElement = function () { if (document.documentElement.clientHeight) { return document.documentElement; } return document.body; }; global.sizeToContentImpl = function(finalize) { if(!window.sizeToContent) { var anchor = document.createElement("div"); document.body.appendChild(anchor); anchor.style.clear = "both"; anchor.style.overflow = "hidden"; anchor.style.height = "3px"; anchor.style.backgroundColor = "red"; anchor.style.styleFloat = "none"; var w = anchor.offsetWidth; var h = anchor.offsetTop + 0; var deltaH = h - global.getContentElement().clientHeight; //alert("h = " + h + "\ndeltaH = " + deltaH + "\nclientHeight = " + global.getContentElement().clientHeight); var deltaW = 0 window.resizeBy(deltaW, deltaH); deltaH = global.getContentElement().scrollHeight - global.getContentElement().clientHeight; deltaW = global.getContentElement().scrollWidth - global.getContentElement().clientWidth; //alert("document.body.scrollHeight = " + document.body.scrollHeight + "\ndeltaH = " + deltaH + "\nclientHeight = " + document.body.clientHeight + "\ndeltaW = " + deltaW); window.resizeBy(deltaW, deltaH); //alert("after resize"); document.body.removeChild(anchor); } else { window.sizeToContent(); } if (finalize) { if (window.outerWidth) { var maxW = screen.availWidth - global.SAFE_MARGIN_H; var maxH = screen.availHeight - global.SAFE_MARGIN_W; var deltaH = 0; var deltaW = 0; var w = window.outerWidth; var h = window.outerHeight; deltaW = w > maxW ? maxW - w : 0; deltaH = h > maxH ? maxH - h : 0; window.resizeBy(deltaW, deltaH); } global.centerScreen(); } }; global.sizeToContent = function () { window.resizeTo(50, 50); global.sizeToContentImpl(); window.setTimeout('global.sizeToContentImpl(true);', 10); window.setTimeout('global.sizeToContentImpl(true);', 30); }; global.centerScreenIE = function () { var w = window.document.body.offsetWidth + 6; var h = window.document.body.offsetHeight + 25; var W = screen.availWidth; var H = screen.availHeight - 20; window.moveTo((W - w) / 2, (H - h) / 2); }; global.centerScreenGecko = function () { var w = window.outerWidth; var h = window.outerHeight; var W = screen.availWidth; var H = screen.availHeight - 20; window.moveTo((W - w) / 2, (H - h) / 2); }; global.centerScreen = function () { if(window.outerWidth) { global.centerScreenGecko(); } else { global.centerScreenIE(); } }; global.fitToContent = function(hoz_margin,vert_margin){ window.resizeTo(document.body.scrollWidth + hoz_margin, document.body.scrollHeight + vert_margin + heightDiff); heightDiff = 0; } global.isGecko = (navigator.userAgent.indexOf("Gecko") > 0); /** * Add event handler for an element (cross browser support) */ function XBrowserAddHandler(target, eventName, fnHandler) { if ( target.addEventListener ) { target.addEventListener(eventName, fnHandler, false); } else if (target.attachEvent) { target.attachEvent("on" + eventName, fnHandler); } else { target["on" + eventName] = fnHandler; } } // pr-minhvo added here function removeSelectObjValue(selectObjId){ var selectObj = document.getElementById(selectObjId); var elements = selectObj.options; for(var i = elements.length - 1; i >=0 ; i--){ selectObj.removeChild(elements[i]); } } function addSelectObjValue(selectObjId, value, text){ var selectObj = document.getElementById(selectObjId); for(var i = 0; i < value.length; i++){ var newNode = document.createElement("option"); newNode.setAttribute("value", value[i]); newNode.innerHTML = text[i]; selectObj.appendChild(newNode); } } function copyOptions(sourceSelectObj, destSelectObj){ removeSelectObjValue(destSelectObj.id); var options = sourceSelectObj.options; for(var i = 0; i < options.length; i++){ var newNode = document.createElement("option"); newNode.setAttribute("value", options[i].value); newNode.innerHTML = options[i].innerHTML; destSelectObj.appendChild(newNode); } } function onSelect(activeId, inActiveId){ var activeDivObj = document.getElementById(activeId); var activeSelectObjs = activeDivObj.getElementsByTagName("select"); var activeInputObjs = activeDivObj.getElementsByTagName("input"); activeInput(activeSelectObjs); activeInput(activeInputObjs); var inActiveDivObj = document.getElementById(inActiveId); var inActiveSelectObjs = inActiveDivObj.getElementsByTagName("select"); var inActiveInputObjs = inActiveDivObj.getElementsByTagName("input"); inactiveInput(inActiveSelectObjs); inactiveInput(inActiveInputObjs); // the first checkbox must be enable inActiveInputObjs[0].disabled = false; } function inactiveInput(objs){ for(var i = 0; i < objs.length; i++){ objs[i].disabled = true; if(objs[i].type=="button" || objs[i].type=="submit" || objs[i].type=="reset"){ objs[i].className += " DisableButton"; } } } function activeInput(objs){ for(var i = 0; i < objs.length; i++){ objs[i].disabled = false; objs[i].className = objs[i].className.replace("DisableButton", ""); } } var dtYEAR = "yyyy"; var dtMONTH = "MM"; var dtDAY = "dd"; var dtHOUR = "HH"; var dtMINUTE = "mm"; var dtSECOND = "ss"; function parse_datetime(strdatetime, pattern) { var date = new Date(); var index; try { index = pattern.indexOf(dtYEAR); if(index >= 0) { date.setFullYear(strdatetime.substring(index, index + dtYEAR.length)); } index = pattern.indexOf(dtMONTH); if(index >= 0) { date.setMonth(strdatetime.substring(index, index + dtMONTH.length) - 1); } index = pattern.indexOf(dtDAY); if(index >= 0) { date.setDate(strdatetime.substring(index, index + dtDAY.length)); } index = pattern.indexOf(dtHOUR); if(index >= 0) { date.setHours(strdatetime.substring(index, index + dtHOUR.length)); } index = pattern.indexOf(dtMINUTE); if(index >= 0) { date.setMinutes(strdatetime.substring(index, index + dtMINUTE.length)); } index = pattern.indexOf(dtSECOND); if(index >= 0) { date.setSeconds(strdatetime.substring(index, index + dtSECOND.length)); } } catch(e) { date = null; } return date; } function format_datetime(datetime, pattern) { var strdatetime = pattern; strdatetime = strdatetime.replace(dtYEAR, 1900 + datetime.getYear()); strdatetime = strdatetime.replace(dtMONTH, String(100 + datetime.getMonth() + 1).substring(1)); strdatetime = strdatetime.replace(dtDAY, String(100 + datetime.getDate()).substring(1)); strdatetime = strdatetime.replace(dtHOUR, String(100 + datetime.getHours()).substring(1)); strdatetime = strdatetime.replace(dtMINUTE, String(100 + datetime.getMinutes()).substring(1)); strdatetime = strdatetime.replace(dtSECOND, String(100 + datetime.getSeconds()).substring(1)); return strdatetime; } function countdown(textbox, maxcount, countDisplayId) { var length = textbox.value.length; var chars_left = maxcount; if (length > maxcount) { textbox.value = textbox.value.substring(0, maxcount); chars_left = 0; } else { chars_left = maxcount - length; } var countDisplay = document.getElementById(countDisplayId); countDisplay.innerHTML = "" + chars_left; } // Removes leading whitespaces function LTrim( value ) { var re = /\s*((\S+\s*)*)/; return value.replace(re, "$1"); } // Removes ending whitespaces function RTrim( value ) { var re = /((\s*\S+)*)\s*/; return value.replace(re, "$1"); } // Removes leading and ending whitespaces function trim( value ) { return LTrim(RTrim(value)); } // get elements by class name and tag name function getElementsbyClassName(rootObj, tagName, className){ var elms = new Array(); var tags = rootObj.getElementsByTagName(tagName); if(tags && tags.length){ for(i = 0; i < tags.length; i++){ if (tags[i].className == className){ elms[elms.length] = tags[i]; } } } return elms; }