/* General client side functions for the CMS */ //=== Browser Identifier variables var isOpera = navigator.userAgent.indexOf("Opera") > -1; var isIE = (navigator.userAgent.indexOf("MSIE") > 1 && !isOpera); var isMoz = (navigator.userAgent.indexOf("Mozilla/5.") == 0 && !isOpera); /* Antispam e-mail link */ function CMS_GetEmailLink(sUser, sDomain, sATagAttributes, sLinkText, sSubject, sTitle) { if (sLinkText == null) sLinkText = sUser + "@" + sDomain; if (sSubject == null) sSubject = "E-mail from '" + sDomain + "'"; if (sTitle == null) sTitle = "Send e-mail"; sSubject = sSubject.replace (/ /g, " ") sSubject = sSubject.replace (/"/g, """) document.write("" + sLinkText + ""); } /* Open new window and insert some html code into */ function CMS_OpenInNewWindow (psURL, piWidth, piHeight, psInsertHtml) { document.body.ShowMainImage_Params = psInsertHtml; var $windowName = ""; if (piHeight > screen.height) piHeight = screen.height - 50; if (piWidth > screen.width) piWidth = screen.width - 50; window.open (psURL, $windowName, "scrollbars=yes,status=no,location=no,menubar=no,resizable=yes,toolbar=no,dependent=no,dialog=yes,minimizable=no,alwaysRaised=no, top=" + (screen.height - piHeight) / 2 + ", left=" + (screen.width - piWidth) / 2 + ", width=" + piWidth + ", height=" + piHeight); }; /* Open new window with main image */ function CMS_ShowMainImage(pathToRoot, image) { CMS_OpenInNewWindow(pathToRoot + 'MainImage.aspx?' + escape(image.src), parseInt(image.getAttribute("mainImageWidth")) + 50, parseInt(image.getAttribute("mainImageHeight")) + 50, null); }; function CMS_RenderMainImage() { document.body.innerHTML = opener.document.body.ShowMainImage_Params; } function CMS_IsStringEmpty(str) { if (str == null || str == "") return true; return false; } function CMS_IfNull(str, value) { if (str == null && value == null) return ""; if (str == null) return value; return str; } function CMS_IfEmpty(str, value) { if (al_IsStringEmpty(str) && al_IsStringEmpty(value)) return ""; if (al_IsStringEmpty(str)) return value; return str; } function CMS_GetKeyCode(evt) { if(isMoz) return evt.charCode; return evt.keyCode; } function CMS_CancelEvent(evt) { evt.cancelBubble = true; evt.returnValue = false; } function CMS_StartText_Initialize(element) { if (CMS_StartText_NeedSet(element)) { element.value = element.getAttribute("startText"); element.onfocus = function() { CMS_StartText_ClearElementValue(this); }; } } function CMS_StartText_NeedSet(element) { if (element.tagName != "INPUT" && element.tagName != "TEXTAREA") return false; if (element.tagName == "INPUT" && element.getAttribute("type") != "text" && element.getAttribute("type") != null) return false; if (element.getAttribute("startText") == null) return false; return true; } function CMS_StartText_ClearElementValue(element) { if (element.getAttribute("cms_isCleared") != "1") { element.setAttribute("cms_isCleared", "1"); element.value = ''; } } // === Events function CMS_addEvent($obj, $eventName, $function) { if ($obj.attachEvent) $obj.attachEvent("on" + $eventName, $function); else if ($obj.addEventListener) $obj.addEventListener($eventName, $function, true); } function CMS_removeEvent($obj, $eventName, $function) { if ($obj.detachEvent) $obj.detachEvent('on' + $eventName, $function); else if ($obj.removeEventListener) $obj.removeEventListener($eventName, $function, true); } function CMS_CancelEvent(evt) { evt.cancelBubble = true; evt.returnValue = false; }