var qs = { scriptBaseUrl: null, wzTooltipIncluded: false, create: function() { return function() { this.initialize.apply(this, arguments); } }, getScriptBaseUrl: function () { if (null === qs.scriptBaseUrl) { var list = document.getElementsByTagName("script"); for (i = 0; i < list.length; i++) { if (list[i].src.match(/lib\/qs\.js$/)) { qs.scriptBaseUrl = list[i].src.replace('/lib/qs.js', ''); break; } } } return qs.scriptBaseUrl; }, includeBodyScript: function(src) { $.ajaxSetup({async: false}); $.getScript(qs.getScriptBaseUrl() + '/' + src); $.ajaxSetup({async: true}); }, includeWzTooltip: function() { if (qs.wzTooltipIncluded) { return false; } qs.includeBodyScript('wz_tooltip.js'); qs.includeBodyScript('tip_balloon.js'); qs.wzTooltipIncluded = true; return true; }, getParentTag: function (obj, tag) { var tmp = obj; while (tmp = tmp.parentNode) { if (tmp.nodeName == tag) { return tmp; } } return null; }, getPreviousTag: function(obj, tag) { var tmp = obj; while (tmp = tmp.previousSibling) { if (tmp.nodeName == tag) { return tmp; } } return null; }, getNextTag: function(obj, tag) { var tmp = obj; while (tmp = tmp.nextSibling) { if (tmp.nodeName == tag) { return tmp; } } return null; }, openPopupByLocation: function(location, target, width, height) { if (typeof width != 'number') { if (width == 'MAX') { width = screen.width; } else { width = screen.width/2; } } if (typeof height != 'number') { if (height == 'MAX') { height = screen.height; } else { height = screen.height - screen.height/3; } } var top = screen.height/2-height/2; var left = screen.width/2-width/2; var params = 'toolbar=0,location=0,menubar=0,resizable=1,status=0,scrollbars=yes,screenX=' + left + ',screenY=' + top + ',top=' + top + ',left=' + left + ',width=' + width + ',height=' + height; var wnd = window.open(location, target, params); wnd.opener = self; wnd.focus(); }, openPopup: function (a, width, height) { qs.openPopupByLocation(a.href, a.getAttribute('target'), width, height); return false; }, // getElementPos getPosition: function (obj) { var l = 0; var t = 0; var w = obj.offsetWidth; var h = obj.offsetHeight; while (obj) { l += obj.offsetLeft; t += obj.offsetTop; if ((obj.tagName != "TABLE") && (obj.tagName != "BODY")) { l += (obj.clientLeft)?obj.clientLeft:0; t += (obj.clientTop)?obj.clientTop:0; } obj = obj.offsetParent; } var res = new Object(); res.x = l; res.y = t; res.left = l; res.top = t; res.w = w; res.h = h; res.width = w; res.height = h; return res; }, popupImage: function (url) { var startW = 150; var startH = 100; var top = screen.height/2-startH; var left = screen.width/2-startW/2; var params = 'Toolbar=0,location=0,Menubar=0,resizable=0,Scrollbars=no';//,screenX='+left+',screenY='+top+',top='+top+',left='+left; var wnd = window.open('', 'ppimg', params); wnd.resizeTo(300, 450); wnd.document.writeln(''); wnd.document.writeln('
'); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.writeln(''); wnd.document.close(); return false; }, getPageSize: function () { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; // console.log(self.innerWidth); // console.log(document.documentElement.clientWidth); if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // console.log("xScroll " + xScroll) // console.log("windowWidth " + windowWidth) // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } // console.log("pageWidth " + pageWidth) arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) return arrayPageSize; }, array_key: function(arr) { for (var k in arr) { return k; } return false; }, ajaxError: function(jqXHR, textStatus, errorThrown) { if (typeof DEBUG != 'undefined' && DEBUG) { alert(jqXHR.responseText); return false; } alert(textStatus + ' ' + errorThrown); }, ajaxSuccess: function (response) { if (typeof $.fancybox != 'undefined') { $.fancybox.hideActivity(); } if (!response.isValid) { alert(response.message); return false; } if (typeof response.callbacks != 'undefined') { qs.processCallbacks(response.callbacks); } return true; }, processCallbacks: function (callbacks) { var name; for (var i in callbacks) { name = callbacks[i]; qs.callback(name); } }, callback: function (spec) { if (typeof spec == 'function') { spec.call(); } else if (typeof spec == 'string') { $.globalEval(spec + '.call(this)'); } else if (typeof spec == 'object' && spec != null) { var scriptHtml = ''; for (var callback in spec) { var params = new Array(); if (is_numeric(callback)) { if (typeof spec[callback] == 'string') { callback = spec[callback] } else if (typeof spec[callback] == 'object' && typeof spec[callback] != null ) { var key = array_key(spec[callback]); params = spec[callback][key]; callback = key; } else { continue; } } else { params = spec[callback]; } scriptHtml += callback; if (params.length) { var _params = []; for (var i in params) { _params.push(json_encode(params[i])); } scriptHtml += '(' + _params.join(', ') + ');\n'; } else { scriptHtml += '();\n'; } } if (scriptHtml.length) { $.globalEval(scriptHtml); } } } }; var Qs_Message = qs.create(); Qs_Message.prototype = { initialize: function (messages) { this.messages = messages; }, get: function (name, language) { if (typeof language == 'undefined') { language = CURR_LANG; } if (typeof this.messages[language] == 'undefined') { return ''; } if (typeof this.messages[language][name] == 'string') { return this.messages[language][name]; } if (typeof this.messages[DEF_LANG][name] == 'string') { return this.messages[DEF_LANG][name]; } return ''; } }