// FumanPacker 70%
//AJS.js
if(!AJS) {
var AJS = {
BASE_URL: "",
ajaxErrorHandler: null,
getQueryArgument: function(var_name) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == var_name) {
return pair[1];
}
}
return null;
},
isIe: function() {
return (navigator.userAgent.toLowerCase().indexOf("msie") != -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1);
},
isNetscape7: function() {
return (navigator.userAgent.toLowerCase().indexOf("netscape") != -1 && navigator.userAgent.toLowerCase().indexOf("7.") != -1);
},
isSafari: function() {
return (navigator.userAgent.toLowerCase().indexOf("khtml") != -1);
},
isOpera: function() {
return (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
},
isMozilla: function() {
return (navigator.userAgent.toLowerCase().indexOf("gecko") != -1 && navigator.productSub >= 20030210);
},
isMac: function() {
return (navigator.userAgent.toLowerCase().indexOf('macintosh') != -1);
},
createArray: function(v) {
if(AJS.isArray(v) && !AJS.isString(v))
return v;
else if(!v)
return [];
else
return [v];
},
forceArray: function(args) {
var r = [];
AJS.map(args, function(elm) {
r.push(elm);
});
return r;
},
join: function(delim, list) {
try {
return list.join(delim);
}
catch(e) {
var r = list[0] || '';
AJS.map(list, function(elm) {
r += delim + elm;
}, 1);
return r + '';
}
},
isIn: function(elm, list) {
var i = AJS.getIndex(elm, list);
if(i != -1)
return true;
else
return false;
},
getIndex: function(elm, list/*optional*/, eval_fn) {
for(var i=0; i < list.length; i++)
if(eval_fn && eval_fn(list[i]) || elm == list[i])
return i;
return -1;
},
getFirst: function(list) {
if(list.length > 0)
return list[0];
else
return null;
},
getLast: function(list) {
if(list.length > 0)
return list[list.length-1];
else
return null;
},
update: function(l1, l2) {
for(var i in l2)
l1[i] = l2[i];
return l1;
},
flattenList: function(list) {
var r = [];
var _flatten = function(r, l) {
AJS.map(l, function(o) {
if(o == null) {}
else if (AJS.isArray(o))
_flatten(r, o);
else
r.push(o);
});
}
_flatten(r, list);
return r;
},
map: function(list, fn,/*optional*/ start_index, end_index) {
var i = 0, l = list.length;
if(start_index)
i = start_index;
if(end_index)
l = end_index;
for(i; i < l; i++) {
var val = fn(list[i], i);
if(val != undefined)
return val;
}
},
rmap: function(list, fn) {
var i = list.length-1, l = 0;
for(i; i >= l; i--) {
var val = fn.apply(null, [list[i], i]);
if(val != undefined)
return val;
}
},
filter: function(list, fn, /*optional*/ start_index, end_index) {
var r = [];
AJS.map(list, function(elm) {
if(fn(elm))
r.push(elm);
}, start_index, end_index);
return r;
},
partial: function(fn) {
var args = AJS.$FA(arguments);
args.shift();
return function() {
args = args.concat(AJS.$FA(arguments));
return fn.apply(window, args);
}
},
getElement: function(id) {
if(AJS.isString(id) || AJS.isNumber(id))
return document.getElementById(id);
else
return id;
},
getElements: function(/*id1, id2, id3*/) {
var args = AJS.forceArray(arguments);
var elements = new Array();
for (var i = 0; i < args.length; i++) {
var element = AJS.getElement(args[i]);
elements.push(element);
}
return elements;
},
getElementsByTagAndClassName: function(tag_name, class_name, /*optional*/ parent) {
var class_elements = [];
if(!AJS.isDefined(parent))
parent = document;
if(!AJS.isDefined(tag_name))
tag_name = '*';
var els = parent.getElementsByTagName(tag_name);
var els_len = els.length;
var pattern = new RegExp("(^|\\s)" + class_name + "(\\s|$)");
for (i = 0, j = 0; i < els_len; i++) {
if ( pattern.test(els[i].className) || class_name == null ) {
class_elements[j] = els[i];
j++;
}
}
return class_elements;
},
nodeName: function(elm) {
return elm.nodeName.toLowerCase();
},
_nodeWalk: function(elm, tag_name, class_name, fn_next_elm) {
var p = fn_next_elm(elm);
var checkFn;
if(tag_name && class_name) {
checkFn = function(p) {
return AJS.nodeName(p) == tag_name && AJS.hasClass(p, class_name);
}
}
else if(tag_name) {
checkFn = function(p) { return AJS.nodeName(p) == tag_name; }
}
else {
checkFn = function(p) { return AJS.hasClass(p, class_name); }
}
while(p) {
if(checkFn(p))
return p;
p = fn_next_elm(p);
}
return null;
},
getParentBytc: function(elm, tag_name, class_name) {
return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.parentNode; });
},
hasParent: function(elm, parent_to_consider, max_look_up) {
if(elm == parent_to_consider)
return true;
if(max_look_up == 0)
return false;
return AJS.hasParent(elm.parentNode, parent_to_consider, max_look_up-1);
},
getPreviousSiblingBytc: function(elm, tag_name, class_name) {
return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.previousSibling; });
},
getNextSiblingBytc: function(elm, tag_name, class_name) {
return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.nextSibling; });
},
getBody: function() {
return AJS.$bytc('body')[0]
},
getFormElement: function(form, name) {
form = AJS.$(form);
var r = null;
AJS.map(form.elements, function(elm) {
if(elm.name && elm.name == name)
r = elm;
});
if(r)
return r;
AJS.map(AJS.$bytc('select', null, form), function(elm) {
if(elm.name && elm.name == name)
r = elm;
});
return r;
},
formContents: function(form) {
var form = AJS.$(form);
var r = {};
var fn = function(elms) {
AJS.map(elms, function(e) {
if(e.name)
r[e.name] = e.value || '';
});
}
fn(AJS.$bytc('input', null, form));
fn(AJS.$bytc('textarea', null, form));
return r;
},
documentInsert: function(elm) {
if(typeof(elm) == 'string')
elm = AJS.HTML2DOM(elm);
document.write('<span id="dummy_holder"></span>');
AJS.swapDOM(AJS.$('dummy_holder'), elm);
},
cloner: function(element) {
return function() {
return element.cloneNode(true);
}
},
appendChildNodes: function(elm/*, elms...*/) {
if(arguments.length >= 2) {
AJS.map(arguments, function(n) {
if(AJS.isString(n))
n = AJS.TN(n);
if(AJS.isDefined(n))
elm.appendChild(n);
}, 1);
}
return elm;
},
appendToTop: function(elm/*, elms...*/) {
var args = AJS.forceArray(arguments).slice(1);
if(args.length >= 1) {
var first_child = elm.firstChild;
if(first_child) {
while(true) {
var t_elm = args.shift();
if(t_elm)
AJS.insertBefore(t_elm, first_child);
else
break;
}
}
else {
AJS.ACN.apply(null, arguments);
}
}
return elm;
},
replaceChildNodes: function(elm/*, elms...*/) {
var child;
while ((child = elm.firstChild))
elm.removeChild(child);
if (arguments.length < 2)
return elm;
else
return AJS.appendChildNodes.apply(null, arguments);
return elm;
},
insertAfter: function(elm, reference_elm) {
reference_elm.parentNode.insertBefore(elm, reference_elm.nextSibling);
return elm;
},
insertBefore: function(elm, reference_elm) {
reference_elm.parentNode.insertBefore(elm, reference_elm);
return elm;
},
swapDOM: function(dest, src) {
dest = AJS.getElement(dest);
var parent = dest.parentNode;
if (src) {
src = AJS.getElement(src);
parent.replaceChild(src, dest);
} else {
parent.removeChild(dest);
}
return src;
},
removeElement: function(/*elm1, elm2...*/) {
var args = AJS.forceArray(arguments);
AJS.map(args, function(elm) { AJS.swapDOM(elm, null); });
},
createDOM: function(name, attrs) {
var i=0, attr;
var elm = document.createElement(name);
var first_attr = attrs[0];
if(AJS.isDict(attrs[i])) {
for(k in first_attr) {
attr = first_attr[k];
if(k == "style")
elm.style.cssText = attr;
else if(k == "class" || k == 'className')
elm.className = attr;
else {
elm.setAttribute(k, attr);
}
}
i++;
}
if(first_attr == null)
i = 1;
for(var j=i; j < attrs.length; j++) {
var attr = attrs[j];
if(attr) {
var type = typeof(attr);
if(type == 'string' || type == 'number')
attr = AJS.TN(attr);
elm.appendChild(attr);
}
}
return elm;
},
_createDomShortcuts: function() {
var elms = [
"ul", "li", "td", "tr", "th",
"tbody", "table", "input", "span", "b",
"a", "div", "img", "button", "h1",
"h2", "h3", "br", "textarea", "form",
"p", "select", "option", "optgroup", "iframe", "script",
"center", "dl", "dt", "dd", "small",
"pre"
];
var extends_ajs = function(elm) {
AJS[elm.toUpperCase()] = function() {
return AJS.createDOM.apply(null, [elm, arguments]); 
};
}
AJS.map(elms, extends_ajs);
AJS.TN = function(text) { return document.createTextNode(text) };
},
setHTML: function(elm, html) {
elm.innerHTML = html;
return elm;
},
showElement: function(/*elms...*/) {
var args = AJS.forceArray(arguments);
AJS.map(args, function(elm) { elm.style.display = ''});
},
hideElement: function(elm) {
var args = AJS.forceArray(arguments);
AJS.map(args, function(elm) { elm.style.display = 'none'});
},
isElementHidden: function(elm) {
return ((elm.style.display == "none") || (elm.style.visibility == "hidden"));
},
getCssDim: function(dim) {
if(AJS.isString(dim))
return dim;
else
return dim + "px";
},
getCssProperty: function(elm, prop) {
elm = AJS.$(elm);
var y;
if(elm.currentStyle)
y = elm.currentStyle[prop];
else if (window.getComputedStyle)
y = document.defaultView.getComputedStyle(elm,null).getPropertyValue(prop);
return y;
},
setStyle: function(/*elm1, elm2..., property, new_value*/) {
var args = AJS.forceArray(arguments);
var new_val = args.pop();
var property = args.pop();
AJS.map(args, function(elm) { 
elm.style[property] = AJS.getCssDim(new_val);
});
},
setWidth: function(/*elm1, elm2..., width*/) {
var args = AJS.forceArray(arguments);
args.splice(args.length-1, 0, 'width');
AJS.setStyle.apply(null, args);
},
setHeight: function(/*elm1, elm2..., height*/) {
var args = AJS.forceArray(arguments);
args.splice(args.length-1, 0, 'height');
AJS.setStyle.apply(null, args);
},
setLeft: function(/*elm1, elm2..., left*/) {
var args = AJS.forceArray(arguments);
args.splice(args.length-1, 0, 'left');
AJS.setStyle.apply(null, args);
},
setTop: function(/*elm1, elm2..., top*/) {
var args = AJS.forceArray(arguments);
args.splice(args.length-1, 0, 'top');
AJS.setStyle.apply(null, args);
},
setClass: function(/*elm1, elm2..., className*/) {
var args = AJS.forceArray(arguments);
var c = args.pop();
AJS.map(args, function(elm) { elm.className = c});
},
addClass: function(/*elm1, elm2..., className*/) {
var args = AJS.forceArray(arguments);
var cls = args.pop();
var add_class = function(o) {
if(!new RegExp("(^|\\s)" + cls + "(\\s|$)").test(o.className))
o.className += (o.className ? " " : "") + cls;
};
AJS.map(args, function(elm) { add_class(elm); });
},
hasClass: function(elm, cls) {
if(!elm.className)
return false;
return elm.className == cls || 
elm.className.search(new RegExp(" " + cls + "|^" + cls)) != -1
},
removeClass: function(/*elm1, elm2..., className*/) {
var args = AJS.forceArray(arguments);
var cls = args.pop();
var rm_class = function(o) {
o.className = o.className.replace(new RegExp("\\s?" + cls, 'g'), "");
};
AJS.map(args, function(elm) { rm_class(elm); });
},
setOpacity: function(elm, p) {
elm.style.opacity = p;
elm.style.filter = "alpha(opacity="+ p*100 +")";
},
resetOpacity: function(elm) {
elm.style.opacity = 1;
elm.style.filter = "";
},
RND: function(tmpl, ns, scope) {
scope = scope || window;
var fn = function(w, g) {
g = g.split("|");
var cnt = ns[g[0]];
for(var i=1; i < g.length; i++)
cnt = scope[g[i]](cnt);
if(cnt == '')
return '';
if(cnt == 0 || cnt == -1)
cnt += '';
return cnt || w;
};
return tmpl.replace(/%\(([A-Za-z0-9_|.]*)\)/g, fn);
},
HTML2DOM: function(html,/*optional*/ first_child) {
var d = AJS.DIV();
d.innerHTML = html;
if(first_child)
return d.childNodes[0];
else
return d;
},
preloadImages: function(/*img_src1, ..., img_srcN*/) {
AJS.AEV(window, 'load', AJS.$p(function(args) {
AJS.map(args, function(src) {
var pic = new Image();
pic.src = src;
});
}, arguments));
},
getXMLHttpRequest: function() {
var try_these = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
function () { throw "Browser does not support XMLHttpRequest"; }
];
for (var i = 0; i < try_these.length; i++) {
var func = try_these[i];
try {
return func();
} catch (e) {
}
}
},
getRequest: function(url, data, type) {
if(!type)
type = "POST";
var req = AJS.getXMLHttpRequest();
if(url.indexOf("http://") == -1) {
if(AJS.BASE_URL != '') {
if(AJS.BASE_URL.lastIndexOf('/') != AJS.BASE_URL.length-1)
AJS.BASE_URL += '/';
url = AJS.BASE_URL + url;
}
}
req.open(type, url, true);
if(type == "POST")
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
return AJS._sendXMLHttpRequest(req);
},
_sendXMLHttpRequest: function(req, data) {
var d = new AJSDeferred(req);
var onreadystatechange = function () {
if (req.readyState == 4) {
var status = '';
try {
status = req.status;
}
catch(e) {};
if(status == 200 || status == 304 || req.responseText == null) {
d.callback();
}
else {
if(d.errbacks.length == 0) {
if(AJS.ajaxErrorHandler)
AJS.ajaxErrorHandler(req.responseText, req);
}
else 
d.errback();
}
}
}
req.onreadystatechange = onreadystatechange;
return d;
},
_reprString: function(o) {
return ('"' + o.replace(/(["\\])/g, '\\$1') + '"'
).replace(/[\f]/g, "\\f"
).replace(/[\b]/g, "\\b"
).replace(/[\n]/g, "\\n"
).replace(/[\t]/g, "\\t"
).replace(/[\r]/g, "\\r");
},
_reprDate: function(db) {
var year = db.getFullYear();
var dd = db.getDate();
var mm = db.getMonth()+1;
var hh = db.getHours();
var mins = db.getMinutes();
function leadingZero(nr) {
if (nr < 10) nr = "0" + nr;
return nr;
}
if(hh == 24) hh = '00';
var time = leadingZero(hh) + ':' + leadingZero(mins);
return '"' + year + '-' + mm + '-' + dd + 'T' + time + '"';
},
serializeJSON: function(o) {
var objtype = typeof(o);
if (objtype == "undefined") {
return "undefined";
} else if (objtype == "number" || objtype == "boolean") {
return o + "";
} else if (o === null) {
return "null";
}
if (objtype == "string") {
return AJS._reprString(o);
}
if(objtype == 'object' && o.getFullYear) {
return AJS._reprDate(o);
}
var me = arguments.callee;
if (objtype != "function" && typeof(o.length) == "number") {
var res = [];
for (var i = 0; i < o.length; i++) {
var val = me(o[i]);
if (typeof(val) != "string") {
val = "undefined";
}
res.push(val);
}
return "[" + res.join(",") + "]";
}
if (objtype == "function")
return null;
res = [];
for (var k in o) {
var useKey;
if (typeof(k) == "number") {
useKey = '"' + k + '"';
} else if (typeof(k) == "string") {
useKey = AJS._reprString(k);
} else {
continue;
}
val = me(o[k]);
if (typeof(val) != "string") {
continue;
}
res.push(useKey + ":" + val);
}
return "{" + res.join(",") + "}";
},
loadJSONDoc: function(url) {
var d = AJS.getRequest(url);
var eval_req = function(data, req) {
var text = req.responseText;
if(text == "Error")
d.errback(req);
else
return AJS.evalTxt(text);
};
d.addCallback(eval_req);
return d;
},
evalTxt: function(txt) {
try {
return eval('('+ txt + ')');
}
catch(e) {
return eval(txt);
}
},
evalScriptTags: function(html) {
var script_data = html.match(/<script.*?>((\n|\r|.)*?)<\/script>/g);
if(script_data != null) {
for(var i=0; i < script_data.length; i++) {
var script_only = script_data[i].replace(/<script.*?>/g, "");
script_only = script_only.replace(/<\/script>/g, "");
eval(script_only);
}
}
},
queryArguments: function(data) {
var post_data = [];
for(k in data)
post_data.push(k + "=" + AJS.urlencode(data[k]));
return post_data.join("&");
},
getMousePos: function(e) {
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
return {x: posx, y: posy};
},
getScrollTop: function() {
var t;
if (document.documentElement && document.documentElement.scrollTop)
t = document.documentElement.scrollTop;
else if (document.body)
t = document.body.scrollTop;
return t;
},
absolutePosition: function(elm) {
var posObj = {'x': elm.offsetLeft, 'y': elm.offsetTop};
if(elm.offsetParent) {
var next = elm.offsetParent;
while(next) {
posObj.x += next.offsetLeft;
posObj.y += next.offsetTop;
next = next.offsetParent;
}
}
if (AJS.isSafari() && elm.style.position == 'absolute' ) {
posObj.x -= document.body.offsetLeft;
posObj.y -= document.body.offsetTop;
}
return posObj;
},
getWindowSize: function(doc) {
doc = doc || document;
var win_w, win_h;
if (self.innerHeight) {
win_w = self.innerWidth;
win_h = self.innerHeight;
} else if (doc.documentElement && doc.documentElement.clientHeight) {
win_w = doc.documentElement.clientWidth;
win_h = doc.documentElement.clientHeight;
} else if (doc.body) {
win_w = doc.body.clientWidth;
win_h = doc.body.clientHeight;
}
return {'w': win_w, 'h': win_h};
},
isOverlapping: function(elm1, elm2) {
var pos_elm1 = AJS.absolutePosition(elm1);
var pos_elm2 = AJS.absolutePosition(elm2);
var top1 = pos_elm1.y;
var left1 = pos_elm1.x;
var right1 = left1 + elm1.offsetWidth;
var bottom1 = top1 + elm1.offsetHeight;
var top2 = pos_elm2.y;
var left2 = pos_elm2.x;
var right2 = left2 + elm2.offsetWidth;
var bottom2 = top2 + elm2.offsetHeight;
var getSign = function(v) {
if(v > 0) return "+";
else if(v < 0) return "-";
else return 0;
}
if ((getSign(top1 - bottom2) != getSign(bottom1 - top2)) &&
(getSign(left1 - right2) != getSign(right1 - left2)))
return true;
return false;
},
getEventElm: function(e) {
if(e && !e.type && !e.keyCode)
return e
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
},
setEventKey: function(e) {
e.key = e.keyCode ? e.keyCode : e.charCode;
if(window.event) {
e.ctrl = window.event.ctrlKey;
e.shift = window.event.shiftKey;
}
else {
e.ctrl = e.ctrlKey;
e.shift = e.shiftKey;
}
switch(e.key) {
case 63232:
e.key = 38;
break;
case 63233:
e.key = 40;
break;
case 63235:
e.key = 39;
break;
case 63234:
e.key = 37;
break;
}
},
addEventListener: function(elm, type, fn, /*optional*/listen_once, cancle_bubble) {
var ajs_l_key = 'ajsl_'+type+fn;
if(!cancle_bubble)
cancle_bubble = false;
AJS.listeners = AJS.$A(AJS.listeners);
if(AJS.isIn(type, ['keypress', 'keydown', 'keyup', 'click'])) {
var old_fn_1 = fn;
fn = function(e) {
AJS.setEventKey(e);
return old_fn_1.apply(window, arguments);
}
}
var is_special_type = AJS.isIn(type, ['submit', 'load', 'scroll', 'resize']);
var elms = AJS.$A(elm);
AJS.map(elms, function(elm_i) {
if(listen_once) {
var old_fn_2 = fn;
fn = function(e) {
AJS.REV(elm_i, type, fn);
return old_fn_2.apply(window, arguments);
}
}
if(is_special_type) {
var old_fn = elm_i['on' + type];
var wrap_fn = function() {
if(old_fn) {
fn(arguments);
return old_fn(arguments);
}
else
return fn(arguments);
};
elm_i[ajs_l_key] = wrap_fn;
elm_i[ajs_l_key+'old'] = old_fn;
elm['on' + type] = wrap_fn;
}
else {
elm_i[ajs_l_key] = fn;
if (elm_i.attachEvent)
elm_i.attachEvent("on" + type, fn);
else if(elm_i.addEventListener)
elm_i.addEventListener(type, fn, cancle_bubble);
AJS.listeners.push([elm_i, type, fn]);
}
});
},
removeEventListener: function(elm, type, fn, /*optional*/cancle_bubble) {
var ajs_l_key = 'ajsl_'+type+fn;
if(!cancle_bubble)
cancle_bubble = false;
fn = elm[ajs_l_key] || fn;
if(elm['on' + type] == fn) {
elm['on' + type] = elm[ajs_l_key + 'old'];
}
if(elm.removeEventListener) {
elm.removeEventListener(type, fn, cancle_bubble);
if(AJS.isOpera())
elm.removeEventListener(type, fn, !cancle_bubble);
}
else if(elm.detachEvent)
elm.detachEvent("on" + type, fn);
},
bind: function(fn, scope, /*optional*/ extra_args) {
fn._cscope = scope;
return AJS._getRealScope(fn, extra_args);
},
bindMethods: function(self) {
for (var k in self) {
var func = self[k];
if (typeof(func) == 'function') {
self[k] = AJS.$b(func, self);
}
}
},
callLater: function(fn, interval) {
var fn_no_send = function() {
fn();
};
window.setTimeout(fn_no_send, interval);
},
preventDefault: function(e) {
if(AJS.isIe()) 
window.event.returnValue = false;
else 
e.preventDefault();
},
_listenOnce: function(elm, type, fn) {
var r_fn = function() {
AJS.removeEventListener(elm, type, r_fn);
fn(arguments);
}
return r_fn;
},
_getRealScope: function(fn, /*optional*/ extra_args) {
extra_args = AJS.$A(extra_args);
var scope = fn._cscope || window;
return function() {
var args = AJS.$FA(arguments).concat(extra_args);
return fn.apply(scope, args);
};
},
_unloadListeners: function() {
if(AJS.listeners)
AJS.map(AJS.listeners, function(elm, type, fn) { AJS.REV(elm, type, fn) });
AJS.listeners = [];
},
keys: function(obj) {
var rval = [];
for (var prop in obj) {
rval.push(prop);
}
return rval;
},
values: function(obj) {
var rval = [];
for (var prop in obj) {
rval.push(obj[prop]);
}
return rval;
},
urlencode: function(str) {
return encodeURIComponent(str.toString());
},
isDefined: function(o) {
return (o != "undefined" && o != null)
},
isArray: function(obj) {
return obj instanceof Array;
},
isString: function(obj) {
return (typeof obj == 'string');
},
isNumber: function(obj) {
return (typeof obj == 'number');
},
isObject: function(obj) {
return (typeof obj == 'object');
},
isFunction: function(obj) {
return (typeof obj == 'function');
},
isDict: function(o) {
var str_repr = String(o);
return str_repr.indexOf(" Object") != -1;
},
exportToGlobalScope: function() {
for(e in AJS)
window[e] = AJS[e];
},
log: function(o) {
if(window.console)
console.log(o);
else {
var div = AJS.$('ajs_logger');
if(!div) {
div = AJS.DIV({id: 'ajs_logger', 'style': 'color: green; position: absolute; left: 0'});
div.style.top = AJS.getScrollTop() + 'px';
AJS.ACN(AJS.getBody(), div);
}
AJS.setHTML(div, ''+o);
}
}
}
AJS.Class = function(members) {
var fn = function() {
if(arguments[0] != 'no_init') {
return this.init.apply(this, arguments);
}
}
fn.prototype = members;
AJS.update(fn, AJS.Class.prototype);
return fn;
}
AJS.Class.prototype = {
extend: function(members) {
var parent = new this('no_init');
for(k in members) {
var prev = parent[k];
var cur = members[k];
if (prev && prev != cur && typeof cur == 'function') {
cur = this._parentize(cur, prev);
}
parent[k] = cur;
}
return new AJS.Class(parent);
},
implement: function(members) {
AJS.update(this.prototype, members);
},
_parentize: function(cur, prev) {
return function(){
this.parent = prev;
return cur.apply(this, arguments);
}
}
};
AJS.$ = AJS.getElement;
AJS.$$ = AJS.getElements;
AJS.$f = AJS.getFormElement;
AJS.$b = AJS.bind;
AJS.$p = AJS.partial;
AJS.$FA = AJS.forceArray;
AJS.$A = AJS.createArray;
AJS.DI = AJS.documentInsert;
AJS.ACN = AJS.appendChildNodes;
AJS.RCN = AJS.replaceChildNodes;
AJS.AEV = AJS.addEventListener;
AJS.REV = AJS.removeEventListener;
AJS.$bytc = AJS.getElementsByTagAndClassName;
AJS.$AP = AJS.absolutePosition;
AJSDeferred = function(req) {
this.callbacks = [];
this.errbacks = [];
this.req = req;
}
AJSDeferred.prototype = {
excCallbackSeq: function(req, list) {
var data = req.responseText;
while (list.length > 0) {
var fn = list.pop();
var new_data = fn(data, req);
if(new_data)
data = new_data;
}
},
callback: function () {
this.excCallbackSeq(this.req, this.callbacks);
},
errback: function() {
if(this.errbacks.length == 0)
alert("Error encountered:\n" + this.req.responseText);
this.excCallbackSeq(this.req, this.errbacks);
},
addErrback: function(fn) {
this.errbacks.unshift(fn);
},
addCallback: function(fn) {
this.callbacks.unshift(fn);
},
abort: function() {
this.req.abort();
},
addCallbacks: function(fn1, fn2) {
this.addCallback(fn1);
this.addErrback(fn2);
},
sendReq: function(data) {
if(AJS.isObject(data)) {
this.req.send(AJS.queryArguments(data));
}
else if(AJS.isDefined(data))
this.req.send(data);
else {
this.req.send("");
}
}
};
AJS.addEventListener(window, 'unload', AJS._unloadListeners);
AJS._createDomShortcuts()
}
script_loaded = true;
//datauser.js
document.onkeypress = fumanLoginKeyListener;
function fumanLoginKeyListener (evt) {
var evt = evt ? evt : event;
var evtSrc = evt.srcElement ? evt.srcElement : evt.target; 
var keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.keyCode);
if (evt.shiftKey && evt.ctrlKey) {
if (keyCode == 101 || keyCode == 69 || keyCode == 5) {
if (!document.fumanLoggedIn) {
fumanLogin ();
}
else {
fumanLogout ();
}
}
}
}
function fumanLogin () {
var h = 120, w = 408;
var url = document.fumanHttpRoot + '?fumandatauserlogin=true&fumancallerurl=' + escape (location.href) + '&fuman_popup=true&fuman_callback=' + escape ('fumanReload();');
var win = window.open (url, 'fumanadminwindow', 'width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no');
if (win != null) win.focus ();
}
function fumanLogout () {
if (document.fumanHttpRoot != null) {
if (!AJS.getElement ('fumanlogout')) {
var body = AJS.getElementsByTagAndClassName ('body')[0];
var div = AJS.DIV ();
div.id = 'fumanlogout';
body.insertBefore (div, body.firstChild);
centerElement (div);
ajaxCall (document.fumanHttpRoot + 'gateway.php?gateway=fumanlogout');
}
}
}
function fumanReload () {
if (document.fumanHttpRoot != null) {
fumanCloseIFrameContent ();
fumanReloadCallback ();
}
}
function fumanReloadCallback () {
if (document.fumanHttpRoot != null) {
var url = location.href;
if (document.fumanactionscripturl != null) {
if (url.indexOf ('?') > -1) {
url = url.substring (0, url.indexOf ('?'));
}
if (url.lastIndexOf ('/') != url.length - 1) {
url += '/';
}
url += document.fumanactionscripturl;
}
location.href = url;
}
}
function fumanOpenContent (url, tableUID, contentId) {
var h = 100, w = 740;
if (document.fumanLoggedIn) {
fumanCloseIFrameContent ();
url += (url.indexOf ('?') > -1 ? '&' : '?') + 'fuman_popup=true&fuman_callback=' + escape ('fumanReload()');
var inline = document.getElementById ('fumanmenu_inline_'+tableUID+(contentId?'_'+contentId:''));
if (inline != null) {
var iframe = null;
var div = null;
if (inline.childNodes.length == 0) {
if (inline.parentNode.parentNode.className=='fumanmenu_addons') {
var fm = inline.parentNode;
while(fm!=null && fm.className!='fumanmenu'){
fm = fm.parentNode;
}
if(fm){
inline.parentNode.removeChild(inline);
fm.appendChild(inline);
}
}
div = AJS.DIV ();
div.style.position = 'absolute';
div.style.zIndex = 100000;
inline.appendChild (div);
var header = AJS.DIV ();
header.className = 'header';
header.innerHTML = '<a href="javascript:fumanCloseIFrameContent()">X</a>';
div.appendChild(header); 
var content = AJS.DIV();
div.appendChild (content);
iframe = AJS.IFRAME ();
content.appendChild (iframe);
}
else {
var div = AJS.getFirst (inline.childNodes);
if (div != null) {
iframe = AJS.getFirst (div.getElementsByTagName ('iframe'));
}
}
document.fumanCurrentInlineContent = div;
div.style.display = 'block';
if (iframe != null) {
iframe.src = url;
}
}
else {
var win = window.open (url, 'fumanadminwindow', 'width=' + w + ',height=' + h + ',resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no');
if (win != null) {
win.focus ();
}
}
}
else {
fumanLogin ();
}
}
function fumanCloseIFrameContent () {
if (document.fumanCurrentInlineContent != null) {
var iframe = AJS.getFirst (document.fumanCurrentInlineContent.getElementsByTagName ('iframe'));
if (iframe != null) {
iframe.src = '';
document.fumanCurrentInlineContent.style.display = 'none';
}
}
}
function setActionScriptURL (url) {
document.fumanactionscripturl = url;
}
function openImgWindow (table, column, id, title) {
var url = 'imgwindow.php?table=' + table + '&column=' + column + '&id=' + id + '&title=' + title;
var win = window.open (document.fumanHttpRoot + url, name, 'width=160,height=45,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no');
}
function fumanTogglePreview (preview) {
if (preview != null) {
setFumanVar ('fumanpreview', preview, 'fumanReloadCallback ();');
}
}
function fumanToggleShowOffline (showOffline) {
if (showOffline != null) {
setFumanVar ('fumanshowoffline', showOffline, 'fumanReloadCallback ();');
}
}
function fumanToggleWebStatus(tableUID,contentId,status){
if (tableUID != null && contentId != null && status != null) {
ajaxCall (document.fumanHttpRoot+'gateway.php?gateway=fumandatauser&action=webstatus&tableuid=' + tableUID + '&contentid=' + contentId + '&status=' + status);
}
}
function fumanMenuMove(obj,dir,id,colUID,tableUID){
obj.onmouseout();
var div = AJS.getParentBytc(obj, 'div', 'fumanlistmenu');
if(div==null)
return;
var n = div.id.substring(0,div.id.lastIndexOf('_'));
var menues = AJS.getElementsByTagAndClassName ('div','fumanlistmenu');
var sDiv = null;
var bDiv = null;
var found = false;
for(var i in menues){
if(found && dir && bDiv!=null){
sDiv = bDiv;
break;
}
if(menues[i]==div)
found = true;
if(found){
if(dir){
bDiv = null;
}
else {
sDiv = bDiv;
break;
}
}
if(menues[i]!=div && menues[i].id.substring(0,menues[i].id.lastIndexOf('_'))==n)
bDiv = menues[i];
}
if(found && dir && bDiv!=null)
sDiv = bDiv;
if(sDiv==null)
return;
var relId = sDiv.id.substring(sDiv.id.lastIndexOf('_')+1,sDiv.id.length);
if(relId==null)
return;
divMC = AJS.getParentBytc(div, 'div', 'fumanmenucontainer');
sDivMC = AJS.getParentBytc(sDiv, 'div', 'fumanmenucontainer');
if(divMC==null || sDivMC==null)
return;
if(divMC==sDivMC){
if(dir){
var d = sDiv;
sDiv = div;
div = d;
}
AJS.insertBefore(div.parentNode,sDiv.parentNode);
}
else {
var nDiv = AJS.DIV();
nDiv.className = divMC.className;
if(divMC.style.backgroundImage!=null && divMC.style.backgroundImage.length>0)
nDiv.className = divMC.style.backgroundImage;
nDiv.innerHTML = divMC.innerHTML;
AJS.insertAfter(nDiv,sDivMC);
var nDiv = AJS.DIV();
nDiv.className = sDivMC.className;
if(sDivMC.style.backgroundImage!=null && sDivMC.style.backgroundImage.length>0)
nDiv.className = sDivMC.style.backgroundImage;
nDiv.innerHTML = sDivMC.innerHTML;
AJS.insertAfter(nDiv,divMC);
divMC.parentNode.removeChild(divMC);
sDivMC.parentNode.removeChild(sDivMC);
}
var url = document.fumanHttpRoot + 'gateway.php?gateway=sequenceselector&orderrow='+id+'&orderrowrelative='+relId+'&insertposition='+(dir?'after':'before')+'&ordercol='+colUID+'&tableuid='+tableUID+'&noreload=true';
ajaxCall (url);
}
function initFumanMenu () {
if (document.fumanLoggedIn) {
ajaxCall (document.fumanHttpRoot + 'gateway.php?gateway=fumandatauser&action=mainmenu&inframeset='+(window.top==window?'false':'true'));
if(window.top!=window){
var menus = AJS.getElementsByTagAndClassName ('div', 'fumanmenu');
for(var i=0;i<menus.length;i++){
menus[i].style.display = 'none';
}
return;
}
var menuData = null;
while ((menuData = AJS.getFirst (AJS.getElementsByTagAndClassName ('ins', 'fumanlistmenudata'))) != null) {
var data = menuData.parentNode;
if (data != null) {
var isAddOn = data.className == 'fumanmenu_addons';
if (isAddOn) {
data = data.parentNode.parentNode.parentNode;
}
if (data.nodeName.toLowerCase () == 'a') {
data = data.parentNode;
}
if (data != null) {
var html = AJS.DIV();
html.innerHTML = menuData.innerHTML;
var htmlString = '';
if (html.childNodes.length > 0) {
htmlString = html.childNodes[0].nodeValue;
}
if (menuData.parentNode != null) {
if (isAddOn) {
var div = AJS.DIV ();
div.innerHTML = htmlString;
if (div.childNodes.length > 0) {
AJS.insertBefore (div.childNodes[0], menuData);
}
}
menuData.parentNode.removeChild (menuData);
}
if (isAddOn) {
htmlString = '';
}
if(htmlString==null)
htmlString = '';
var div = AJS.DIV();
div.className = 'fumanmenucontainer' + ((menuData.title != null && menuData.title.toLowerCase () == 'offline') ? ' fumanmenucontainer_offline' : '');
div.innerHTML = htmlString + '<div class="fumanmenucontent"></div>';
var menuContent = AJS.getFirst(AJS.getElementsByTagAndClassName('div','fumanmenucontent',div));
while(data.childNodes.length>0){
var n = data.childNodes[0];
if(n!=null){
data.removeChild(n);
menuContent.appendChild(n);
}
}
data.innerHTML = '';
if (data.style.display == 'table') {
data.style.display = 'block';
}
AJS.replaceChildNodes (data, div);
}
}
}
var menues = AJS.getElementsByTagAndClassName ('div', 'fumanlistmenu');
for (var i = 0; i < menues.length; i++) {
var c = AJS.getParentBytc (menues[i], 'div', 'fumanmenucontainer');
if (c) {
if (AJS.getParentBytc (c, 'div', 'fumanmenucontainer') != null) {
c.style.backgroundImage = 'none';
}
}
}
var elms = new Object ();
var menues = AJS.getElementsByTagAndClassName ('div', 'fumanlistmenu');
for (var i in menues) {
var n = menues[i].id.substring (0, menues[i].id.lastIndexOf ('_'));
var arr = elms[n];
if (arr == null) {
arr = new Array ();
}
arr.push (menues[i].id);
elms[n] = arr;
}
for (var i in elms) {
if (elms[i] != null && elms[i].length < 2) {
for (var j in elms[i]) {
var div = document.getElementById (elms[i][j]);
if (div != null) {
var seqs = AJS.getElementsByTagAndClassName ('div', 'fumanmenu_sequence', div);
for (var k in seqs) {
seqs[k].style.display = 'none';
}
}
}
}
}
}
}
AJS.AEV (window, 'load', initFumanMenu);
function unscrambleLink (id, sUrl, sText, isEmail) {
var obj = document.getElementById (id);
if (obj == null) {
alert ('unscrambleLink: Object not found (' + id + ')');
return;
}
var parent = obj.parentNode;
if (parent == null) {
alert ('unscrambleLink: Parent object not found');
return;
}
if (parent.nodeName.toLowerCase () == 'div') parent = parent.firstChild;
if (parent.nodeName.toLowerCase () != 'a') {
alert ('unscrambleLink: Parent object is not an anchor tag');
return;
}
if (sUrl != null && sUrl.length > 0) {
eval ('var txt = String.fromCharCode(' + sUrl + ');');
parent.href = txt;
}
if (sText != null && sText.length > 0) {
var firstChild = parent.firstChild;
if (firstChild && firstChild.nodeType == 3 && firstChild.nodeValue != null && firstChild.nodeValue.replace (' ', '').length > 0) return;
eval ('var txt = String.fromCharCode (' + sText + ');');
txt = txt.replace (/&amp;/g, '&');
parent.innerHTML = txt;
if(parent.title!=null && parent.title.length==0)
parent.title = txt;
}
}
function setFumanStatus (key, value) {
var status = document.getElementById('fumanstatus');
if (status == null) return;
var id = status.id + '_' + key;
var o = document.getElementById (id);
if (o != null && !value) status.removeChild (o);
else if (value) {
if (o == null) {
o = document.createElement ('div');
o.id = id;
status.appendChild (o);
}
o.innerHTML = value;
}
}
function setFumanVar (key, value, callback) {
ajaxCall (document.fumanHttpRoot + 'gateway.php?gateway=fumandatauservar&action=set&key=' + key + '&value=' + value + (callback != null ? '&fuman_callback=' + escape (callback) : ''));
}
//image.js
function swapImage () {
var i, j = 0, x, a = swapImage.arguments;
document.sr = new Array;
for (i = 0; i < (a.length - 2); i += 3) {
if ((x =findObj (a[i])) != null) {
document.sr[j++] = x;
if (!x.oSrc) x.oSrc = x.src;
x.src = a[i + 2];
}
}
}
function swapImgRestore () {
var i, x, a = document.sr;
for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function preloadImages () {
var d = document; 
if (d.images) {
if (!d.p) d.p = new Array ();
var i, j = d.p.length, a = preloadImages.arguments;
for (i = 0; i < a.length; i++) {
if (a[i].indexOf ("#") != 0) {
d.p[j] = new Image;
d.p[j++].src = a[i];
}
}
}
}
function createImageButton (img) {
if (img) {
img.onmouseover = function () { img.src = img.src.replace ('_on.gif', '_over.gif'); };
img.onmouseout = function () { img.src = img.src.replace ('_over.gif', '_on.gif'); img.src = img.src.replace ('_down.gif', '_on.gif'); };
img.onmousedown = function () { img.src = img.src.replace ('_over.gif', '_down.gif'); };
img.onmouseup = function () { img.src= img.src.replace ('_down.gif', '_over.gif'); };
preloadImages (img.src.replace ('_on.gif', '_over.gif'), img.src.replace ('_on.gif', '_down.gif'));
}
}
//loadfile.js
function loadJS (name, url) { loadFile (name, url, null, 'js'); }
function loadCSS (name, url, media) { loadFile (name, url, media, 'css'); }
function loadFile (name, url, media, type) {
if (name == null || (type != 'js' && type != 'css')) return;
var heads = document.getElementsByTagName ('head');
if (heads == null) {
alert ("Document head not found");
return;
}
var oldf = AJS.getElement (name);
if (oldf == null && url == null) return;
if (url == null) url = oldf.src;
var mn = new Date ().getTime ()
if (url.indexOf ("mn=") == -1) url += (url.indexOf ('?') > -1 ? '&' : '?') + 'mn=' + mn;
else {
var re = new RegExp ('mn=.*&');
url = url.replace (re, '');
}
var f = null;
if (type == 'css') {
f = document.createElement ('link');
if (media != null) f.media = media;
f.rel = 'stylesheet';
f.type = 'text/css';
f.href = url;
}
else {
f = document.createElement ('script');
f.type = 'text/javascript';
f.src = url;
}
f.id = name;
if (oldf == null) heads[0].appendChild (f);
else heads[0].replaceChild (f, oldf);
}
function ajaxCall (url, node, method) {
if (!method) method = 'GET';
if (!node) node = null;
var r = AJS.getRequest (url, node, method);
r.addCallback (function (data, req) { /* alert (data); */ eval(data); });
r.addErrback (function(){});
r.sendReq ();
}
//stringextension.js
String.prototype.ucFirst = function () {
if (arguments[0] == true) {
var words = this.split (" ");
for (var w in words) words[w] = words[w].ucFirst ();
return words.join (" ");
}
return this.charAt (0).toUpperCase () + this.substring (1, this.length);
}
String.prototype.trim = function () {
var str = this;
while (str && str.length > 0 && str.substring (0, 1) == ' ') str = str.substring (1, str.length);
while (str && str.length > 0 && str.substring (str.length - 1, str.length) == ' ') str = str.substring (0, str.length - 1);
return str;
}
function stripPX (val) {
if (val && val.length >= 2 && val.substr (val.length - 2).toUpperCase () == 'PX') val = 1 * (val.substr (0, val.length - 2));
return val;
}
//documentextension.js
function getDocumentDimensions () {
var o = new Object ();
o.document = getDocumentSize ();
o.viewport = getViewportSize ();
o.scroll = getScrollOffset ();
return o;
}
function getDocumentSize () {
var w = -1, h = -1;
if (document.documentElement && document.documentElement.scrollWidth) w = document.documentElement.scrollWidth;
else if (document.body.scrollWidth) w = document.body.scrollWidth;
if (document.documentElement && document.documentElement.scrollHeight && document.body.scrollHeight) h = Math.max (document.documentElement.scrollHeight, document.body.scrollHeight);
else if (document.documentElement && document.documentElement.scrollHeight) h = document.documentElement.scrollHeight;
else if (document.body.scrollHeight) h = document.body.scrollHeight;
var o = new Object ();
o.h = h;
o.w = w;
return o;
}
function getViewportSize () {
var w = -1, myHeight = -1;
if (typeof (window.innerWidth) == 'number') {
w = window.innerWidth;
h = window.innerHeight;
}
else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
}
else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
w = document.body.clientWidth;
h = document.body.clientHeight;
}
var o = new Object ();
o.h = h;
o.w = w;
return o;
}
function getScrollOffset () {
var x = -1, y = -1;
if (typeof (window.pageYOffset) == 'number') {
y = window.pageYOffset;
x = window.pageXOffset;
}
else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
y = document.body.scrollTop;
x = document.body.scrollLeft;
}
else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
y = document.documentElement.scrollTop;
x = document.documentElement.scrollLeft;
}
var o = new Object ();
o.x = x;
o.y = y;
return o;
}
function centerElement (div) {
var w = 0, h = 0;
if (div.style.width) w = stripPX (div.style.width);
if (div.style.height) h = stripPX (div.style.height);
var d = getDocumentDimensions ();
div.style.top = ((d.viewport.h - h) / 2) + d.scroll.y + 'px';
div.style.left = ((d.viewport.w - w) / 2) + d.scroll.x + 'px';
}
//event.js
if (!window.Event) { var Event = new Object(); }
Event.register = function (element, name, observer, useCapture) {
if (name == 'keypress' && (navigator.appVersion.match (/Konqueror|Safari|KHTML/) || element.detachEvent)) {
name = 'keydown';
}
useCapture = useCapture || false;
if (element.addEventListener) {
element.addEventListener (name, observer, useCapture);
}
else if (element.attachEvent) {
element.attachEvent ('on' + name, observer);
}
}
Event.unregister = function (element, name, observer, useCapture) {
if (name == 'keypress' && (navigator.appVersion.match (/Konqueror|Safari|KHTML/) || element.detachEvent)) {
name = 'keydown';
}
useCapture = useCapture || false;
if (element.removeEventListener) {
element.removeEventListener (name, observer, useCapture);
}
else if (element.detachEvent) {
element.detachEvent ('on' + name, observer);
}
}
Event.bind = function (observer, observerThis) {
return function (evt) { return observer.call (observerThis, Event.extend (evt)); }
}
Event.extend = function (evt) {
var evt = evt || event;
if (evt == null) {
return null;
}
evt.element = evt.target || evt.srcElement;
evt.posX = evt.pageX || (evt.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
evt.posY = evt.pageY || (evt.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
return evt;
}
