/** * Kelare * --------------------------------------------------------------------------- * Copyright, Akretio SPRL. All Rights Reserved. * * This file is part of the Kelare project and can not be distributed or * used in any application without prior consent of Akretio SPRL. * Contact us for any information or authorisation. * ---------------------------------------------------------------------------- * Created: May 17, 2004 * ---------------------------------------------------------------------------- */ /** * XCombos * --------------------------------------------------------------------------- */ var XCombos = new Array(); var XCombosClicked = false; function XFindPosX(AObject) { var result = 0; if (AObject.offsetParent) { while (AObject.offsetParent) { if (AObject.currentStyle) lPosition = AObject.currentStyle["position"]; else if (window.getComputedStyle){ var lStyle = window.getComputedStyle(AObject, ""); lPosition = lStyle.getPropertyValue("position"); } else lPosition = ""; result += AObject.offsetLeft; AObject = AObject.offsetParent; } } else if (AObject.x) result += AObject.x; return result; } function XFindPosY(AObject) { var result = 0; if (AObject.offsetParent) { while (AObject.offsetParent) { if (AObject.currentStyle) lPosition = AObject.currentStyle["position"]; else if (window.getComputedStyle){ var lStyle = window.getComputedStyle(AObject, ""); lPosition = lStyle.getPropertyValue("position"); } else lPosition = ""; result += AObject.offsetTop; AObject = AObject.offsetParent; } } else if (AObject.y) result += AObject.y; return result; } function XShowCombo(AElement, AName) { var lElement = document.getElementById(AName + '_Div'); if (lElement.style.visibility != "visible") { XComboHideAll(); lElement.style.top = (XFindPosY(AElement) + AElement.offsetHeight + 5) + "px"; lElement.style.left = XFindPosX(AElement) + "px"; lElement.style.visibility = "visible"; document.onclick = XComboHideAll; XCombos[XCombos.length] = AName; XCombosClicked = true; } else lElement.style.visibility = "hidden"; } function XApplyCombo(AElement, AName, AId) { var lElement = document.getElementById(AElement + '_Edit'); if (lElement) lElement.value = AName; lElement = document.getElementById(AElement); if (lElement) { if (AId.length == 0) AId = AName; lElement.value = AId; } } function XHideCombo(AName) { var lElement = document.getElementById(AName + '_Div'); lElement.style.visibility = "hidden"; } function XComboHideAll() { if (XCombosClicked) XCombosClicked = false; else { for(i=0;i= AMin) && (0 <= AMax)) lVal = 0 else lVal = AMin; } AElement.value = lVal; if ((lVal + AValue <= AMax) && (lVal + AValue >= AMin)) AElement.value = lVal + AValue; } /** * XScrollPanel * --------------------------------------------------------------------------- */ function ShowHide(element, image, title) { if (element.className == "xscrollpaneldata") { element.className = "xscrollpaneldatahidden"; image.src = "images/xscrolldown.png"; title.className = "xscrollpaneltitlehidden"; } else { element.className = "xscrollpaneldata"; image.src = "images/xscrollup.png"; title.className = "xscrollpaneltitle"; } } /** * XDateTime * --------------------------------------------------------------------------- */ var GMouseDown = false; var GCount = 0; function XFormatDate(ADate) { if (ADate.getUTCDate) return ADate.getUTCDate() + '/' + (ADate.getUTCMonth()+1) + '/' + ADate.getUTCFullYear(); else return ADate.toLocaleDateString(); } function XDaysInMonth(AValue) { lDate2 = new Date(AValue); lDate2.setUTCMonth(lDate.getMonth() + 1); lDate2.setUTCDate(0); return lDate2.getUTCDate(); } function XApplyMonthDays(ABaseName) { lValue = parseFloat(document.getElementById(ABaseName + '_browse').value); lCurrentValue = new Date(parseFloat(document.getElementById(ABaseName).value)); lCurrentValue = XFormatDate(lCurrentValue); lTodayValue = new Date(); lTodayValue = XFormatDate(lTodayValue); lDate = new Date(lValue); lDays = XDaysInMonth(lDate); j = lDate.getUTCDay(); j = j==0?-5:-j+2; k = lDate.getTime(); for (i=0; i<42; i++) { lElement = document.getElementById(ABaseName + '_d' + i); if ((j <= 0) || (j > lDays)) lElement.innerHTML = ""; else { lElement.href = "javascript:XSetMonth('" + ABaseName + "', '" + k + "');"; l = new Date(k); l = XFormatDate(l); if (l == lCurrentValue) lElement.className = "xdatetimecurrent"; else if(l == lTodayValue) lElement.className = "xdatetimetoday"; else lElement.className = ""; k += 86400000; lElement.innerHTML = j; } j++; } } function XApplyMonth(ABaseName, ADifference) { lValue = parseFloat(document.getElementById(ABaseName + '_browse').value); if (lValue == -2209161600000) lDate = new Date(); else lDate = new Date(lValue); //Change month lDate.setUTCMonth(lDate.getMonth() + ADifference); lDate.setUTCDate(1); document.getElementById(ABaseName + '_browse').value = lDate.getTime(); XApplyMonthDays(ABaseName); //Change month in select lElement = document.getElementById(ABaseName + '_month'); lElement.value = lDate.getMonth(); lElement = document.getElementById(ABaseName + '_yearcombo'); lElement.value = lDate.getFullYear(); } function XShowMonth(AElement, AName) { lElement = document.getElementById(AName + '_div'); if (lElement.style.visibility != "visible") { lValue = document.getElementById(AName).value; document.getElementById(AName + '_browse').value = lValue; lElement.style.visibility = "visible"; lElement.style.top = (XFindPosY(AElement) + AElement.offsetHeight + 5) + "px"; lElement.style.left = XFindPosX(AElement) + "px"; XApplyMonth(AName, 0); } else lElement.style.visibility = "hidden"; } function XHideMonth(AName) { lElement = document.getElementById(AName + '_div'); lElement.style.visibility = "hidden"; } function XSetMonth(ABaseName, AValue) { document.getElementById(ABaseName).value = AValue; lDate = new Date(parseFloat(AValue)); document.getElementById(ABaseName+"_input_year").value = lDate.getUTCFullYear(AValue); document.getElementById(ABaseName+"_input_month").value = lDate.getUTCMonth(AValue); document.getElementById(ABaseName+"_input_day").value = lDate.getUTCDate(AValue); //document.getElementById(ABaseName + '_input').value = XFormatDate(lDate); XHideMonth(ABaseName); } function XApplySetMonth(AElement, ABaseName) { lValue = parseFloat(document.getElementById(ABaseName + '_browse').value); lDate = new Date(lValue); //Change month lDate.setUTCMonth(AElement.value); document.getElementById(ABaseName + '_browse').value = lDate.getTime(); XApplyMonth(ABaseName, 0); } function XApplySetYear(AElement, ABaseName) { lValue = parseFloat(document.getElementById(ABaseName + '_browse').value); lDate = new Date(lValue); //Change month lDate.setUTCFullYear(AElement.value); document.getElementById(ABaseName + '_browse').value = lDate.getTime(); XApplyMonth(ABaseName, 0); } function XApplySetDirectYear(AElement, ABaseName) { lCurrentValue = new Date(parseFloat(document.getElementById(ABaseName).value)); if (AElement.value > 0) lCurrentValue.setUTCFullYear(AElement.value); else lCurrentValue = 0; document.getElementById(ABaseName).value = lCurrentValue.getTime(); } function XApplySetDirectMonth(AElement, ABaseName) { lCurrentValue = new Date(parseFloat(document.getElementById(ABaseName).value)); if (AElement.value >= 0) { lCurrentValue.setUTCMonth(AElement.value); document.getElementById(ABaseName).value = lCurrentValue.getTime(); } else lCurrentValue = 0; } function XApplySetDirectDay(AElement, ABaseName) { lCurrentValue = new Date(parseFloat(document.getElementById(ABaseName).value)); if (AElement.value > 0) lCurrentValue.setUTCDate(AElement.value); else lCurrentValue = 0; document.getElementById(ABaseName).value = lCurrentValue.getTime(); } function XApplySetDate(ABaseName, AValue) { lDate = new Date(parseFloat(AValue)); document.getElementById(ABaseName + '_browse').value = lDate.getTime(); XApplyMonth(ABaseName, 0); } function XApplyDown(ABase, ACount) { if (GMouseDown) { GCount++; if (GCount > 10) XApplyMonth(ABase, ACount * 10); else XApplyMonth(ABase, ACount); setTimeout("XApplyDown('" + ABase + "', " + ACount + ")", 500); } } function XApplyUp() { GMouseDown = false; GCount = 0; } /** * XPanel * --------------------------------------------------------------------------- */ function XContains (container, containee) { while (containee) { if (container == containee) { return true; } containee = containee.parentNode; } return false; } function XHideOnLeave(AElem, event) { lX = XFindPosX(AElem); lY = XFindPosY(AElem); if (! event.toElement) { if (! XContains(AElem, event.relatedTarget)) AElem.style.visibility = 'hidden'; } else if (! XContains(AElem, event.toElement)) AElem.style.visibility = 'hidden'; } /** * XTabSheets * --------------------------------------------------------------------------- */ function XTabSheet(Atabs, Acurrent) { for (var i=0; i