var g_js_httpRoot="/",g_js_appExec="/de",g_js_version="306280";
var hasSelectorsAPI = !!document.querySelector;
function $strip (s) {
return s.replace(/^\s+/, '').replace(/\s+$/, '');
}
function $IsString (o) {
return typeof o == "string";
}
function $qs(s)
{
if(hasSelectorsAPI)
{
return document.querySelector (s);
}
else
{
return null;
}
}
function $oqs(o,s)
{
return o.querySelector (s);
}
function $oqa(o,s)
{
return o.querySelectorAll (s);
}
function $onx(o)
{
n = null;
if(o)
{
n = o.nextSibling;
while (n && (o.tagName != n.tagName))
{
n = n.nextSibling;
}
}
return n;
}
function $qa(s)
{
if(hasSelectorsAPI)
{
return document.querySelectorAll (s);
}
else
{
return new Array();
}
}
function $gebid (id)
{
return document.getElementById(id);
}
function $gebtn(t)
{
return document.getElementsByTagName(t)
}
function $w(s) {
if(!$IsString(s))return[];
s = $strip(s);
return s?s.split(/\s+/):[];
}
function set_thumbnail_size (oThis)
{
var val = oThis.value;
var styleSelector = "ul.animate li img,ul.previewList li img";
var styleDef = "{height:"+val+"px}";
updatePagePersistStyles (styleSelector, styleDef);
}
function ctrl_u_thumbnail_size (oThis, keyCode)
{
set_thumbnail_size (oThis);
}
function get_pager_href (dir)
{
var next, oNext, oPager = $("pager"), href="";
if(hasBodyClass ("u_option_animation_reverse"))
{
if("backward" == dir)
{
dir = "forward";
}
else
{
dir = "backward";
}
}
if(oPager)
{
next = oPager.down("li."+dir+" a");
if(!next)
{
if("backward" == dir)
{
oNext = oPager.down("li.lnkEnd");
if(oNext)
{
next = oNext.down("a");
}
else
{
if(oPager.down("li.forward"))
{
next = oPager.down("li.forward").previous("li").down("a");
}
}
}
else
{
next = oPager.down("li:not([class=backward]) a");
}
}
if(next)
{
href = next.href;
}
}
return href;
}
function slideshow_pager_next ()
{
var next, oPager = $("pager"), dir="forward", href="";
if(oPager)
{
if(hasBodyClass ("u_option_animation_reverse"))
{
dir = "backward";
}
href = get_pager_href (dir);
if("" != href)
{
if(hasBodyClass ("u_option_animation_ajax"))
{
fire_href(href);
}
else
{
window.location = href;
}
}
}
}
function slideshow_timer_next ()
{
if(hasBodyClass ("u_option_animation_play") && hasBodyClass ("hasAnimations"))
{
slideshow_pager_next();
}
}
function doContentTransitionPrepareObject (oObj)
{
$$("#areaContent > *.prev,#areaContent > *.next").each(function(el)
{
el.removeClassName("prev");
})
$$("#areaContent > *[data-src].active").each(function(el)
{
el.addClassName("prev");
el.removeClassName("active");
})
if(oObj)
{
oObj.addClassName ("active");
oObj = oObj.next();
if(oObj)
{
}
}
}
function addPreloadContent (path)
{
var href, oContent = $('areaTransitionContent').down();
oContent.insert({bottom: "<div title='"+$('preloadBcc').down("h1").innerHTML+"' class='hidden cachedPager'>"+$('preloadPager').innerHTML+"</div>"});
oContent.setAttribute ("data-src", getRawBaseRelPath(path));
$('areaContent').insert({bottom: $('areaTransitionContent').innerHTML});
}
function getAjaxPreloadContent ()
{
var href = get_pager_href ("forward"),relPath, dataSrc;
if(hasBodyClass("u_page_backward"))
{
href = get_pager_href ("backward")
}
dataSrc = getRawBaseRelPath(href);
if("" != dataSrc)
{
oObj = $("areaContent").down("*[data-src='"+dataSrc+"']");
if(!oObj || dataSrc != oObj.getAttribute("data-src"))
{
buildContainer ("preloadPager", "hidden");
buildContainer ("preloadBcc", "hidden");
get_ajaxHrefTransitionContent (href, "ajaxPreloadContent");
}
}
}
function transition_activate ()
{
oContent = $("areaContent").down(".activate");
oContent.removeClassName("activate");
oContent.addClassName("active");
oContent = $("areaContent").down(".deactivate");
if(oContent)
{
oContent.removeClassName("deactivate");
oContent.addClassName("prev");
}
}
function prepareTransitionEffect ()
{
var cur, next, effects = "fade,fly_in,slide,rotate,zoom,spin";
if("" == getBodyClassValue("u_animation_"))
{
addBodyClass ("u_animation_off");
}
if(hasBodyClass ("u_option_animation_random"))
{
cur = getBodyClassValue("u_animation_");
effects += "," + effects;
next = effects.split(cur + ",")[1];
next = next.split(",")[0];
removeBodyClass ("u_animation_" + cur);
addBodyClass ("u_animation_" + next);
}
}
function doContentTransition (path)
{
var oTemp, href, dataSrc, oContent = $('areaTransitionContent').down();
if(oContent)
{
if($('pager'))
{
oTemp = $('bct').down("h1");
if(oTemp)
{
oContent.insert({bottom: "<div title='"+$('bct').down("h1").innerHTML+"' class='hidden cachedPager'>"+$('pager').innerHTML+"</div>"});
}
}
oContent.removeClassName("active");
doContentTransitionPrepareObject ();
dataSrc = getRawBaseRelPath(path);
oContent.setAttribute ("data-src", dataSrc);
$('areaContent').insert({bottom: $('areaTransitionContent').innerHTML});
$('areaContent').addClassName("animate");
oContent = $("areaContent").down("*[data-src='"+dataSrc+"']");
oContent.addClassName("activate");
window.setTimeout(transition_activate, 1);
getAjaxPreloadContent ();
slideshow_step ();
pager_ajax_init ();
}
}
function getInputValue(id,def)
{
var dur = def;
if($(id))
{
dur = $(id).value;
if(dur < 100)
{
dur = 100;
}
}
return dur;
}
function setAnimTransitionStyleSelector (speed)
{
var styleSelector = ".animate > *";
speed = speed / 1000;
var styleDef = "{transition-duration:"+speed+"s !important}";
updatePagePersistStyles (styleSelector, styleDef);
}
function slideshow_duration ()
{
var speed = getBodyClassValue("u_animate_transition_duration_"),
dur = getBodyClassValue("u_animate_view_livetime_");
if("" == speed)
{
speed = 1000;
}
if("" == dur)
{
dur = 1800;
}
setAnimTransitionStyleSelector (speed);
return dur;
}
function animationTransitionDuration ()
{
var dur = getBodyClassValue("u_animate_transition_duration_");
removeBodyClass ("u_animate_transition_duration_" + dur);
var dur = getInputValue("u_animate_transition_durationareaFooter",1000);
addBodyClass ("u_animate_transition_duration_" + dur);
setAnimTransitionStyleSelector (dur);
}
function animationLiveTime ()
{
var dur = getBodyClassValue("u_animate_view_livetime_");
removeBodyClass ("u_animate_view_livetime_" + dur);
dur = getInputValue("u_animate_view_livetimeareaFooter",1569)
addBodyClass ("u_animate_view_livetime_" + dur);
}
function slideshow_ajax_init ()
{
addBodyClass ("u_option_animation_ajax");
if(hasBodyClass ("u_option_animation_play"))
{
window.setTimeout(slideshow_timer_next, slideshow_duration ());
}
}
function get_pager_direction (oThis)
{
var dir = "", a;
$$("#pager li").each(function(el)
{
a = el.down("a");
if(el.hasClassName ("active"))
{
if("" == dir)
{
dir = "forward";
}
return dir;
}
if(a && a.href == oThis.href)
{
if("" == dir)
{
dir = "backward";
}
return dir;
}
})
return dir;
}
function set_pager_direction (oThis)
{
var dir = get_pager_direction (oThis);
removeBodyClasses("u_page_backward u_page_forward");
addBodyClass("u_page_" + dir);
}
function pager_ajax_init ()
{
$$("#pager li:not([class=bodyClass]) a").each(function(el)
{
el.onclick = function()
{
set_pager_direction (el)
fire_href(el.href);
return false;
}
})
}
function slideshow_step ()
{
if(hasBodyClass ("u_option_animation_play"))
{
window.setTimeout(slideshow_timer_next, slideshow_duration ());
}
else
{
slideshow_duration ();
}
}
function slideshow_init ()
{
if(hasBodyClass ("u_ajax_submenu_open"))
{
$$(".nav").each(function(el)
{
el.addClassName("ajaxOpen");
})
}
pager_ajax_init ();
slideshow_step ();
if(hasBodyClass ("u_ajax_navi_content"))
{
navigation_ajax_init ();
}
slideshow_list_init ();
}
function listshow_pager_next ()
{
var oN,aList,oAnim = $A($$(".animate"));
if(oAnim && oAnim.length > 0)
{
oAnim.each(function(anim)
{
anim.select(".prev").each(function(el)
{
el.removeClassName("prev");
})
anim.select(".active").each(function(el)
{
el.removeClassName("active");
el.addClassName("prev");
oN = el.next();
if(oN)
{
oN.addClassName("active");
}
else
{
anim.down().addClassName("active");
}
})
})
window.setTimeout(listshow_timer_next, slideshow_duration ());
}
}
function listshow_timer_next ()
{
if(hasBodyClass ("u_option_animation_play"))
{
listshow_pager_next();
}
}
function slideshow_list_init ()
{
var ply = false, hasAnim = false;
$$(".animate.init").each(function(el)
{
el.removeClassName("init");
hasAnim = true;
if(el.hasClassName("autoplay"))
{
ply = true;
el.removeClassName("autoplay");
el.addClassName("was-auto-play");
}
if(!el.down(".active"))
{
el.down().addClassName("active");
}
})
if(hasAnim)
{
addBodyClass ("hasAnimations");
if(ply || hasBodyClass ("u_option_animation_play"))
{
window.setTimeout(listshow_timer_next, slideshow_duration ());
}
}
}
function u_option_animation_play ()
{
debug_out ("called function u_option_animation_play!");
slideshow_ajax_init ();
slideshow_list_init ();
}
function navigation_ajax_reinit ()
{
removeBodyClass("locationLoading");
debug_out ("navigation_ajax_reinit");
}
function navigation_ajax_init ()
{
var li;
$$(".nav a").each(function(el)
{
if(!hasRelName(el, "noClick"))
{
li = el.up("li");
if(li.hasClassName("submenu"))
{
li.onclick=function()
{
if(!hasBodyClass("locationLoading"))
{
if("function" == typeof (navigation_open_click)) {
addBodyClass("locationLoading");
navigation_open_click ($(this).down('a'));
window.setTimeout(navigation_ajax_reinit, 50);
}
debug_out ("li.onclick: href = " + $(this).down('a').href);
}
else
{
debug_out ("SKIP li.onclick: href = " + $(this).down('a').href);
}
return false;
}
}
el.onclick=function()
{
if(hasBodyClass ("u_ajax_navi_content") && !hasBodyClass ("u_denyajax") && !hasBodyClass ("locationLoading"))
{
addBodyClass("locationLoading");
debug_out ("a.onclick: href = " + this.href);
fire_href(this.href);
window.setTimeout(navigation_ajax_reinit, 50);
if("function" == typeof (navigation_open_click)) {navigation_open_click (this);}
return false;
}
debug_out ("SUBMIT a.onclick: href = " + this.href);
if(!hasBodyClass ("u_ajax_navi_content"))
{
window.location = this.href;
}
return true;
}
}
})
}
var Prototype = {
Version: '1.6.0.3',
Browser: {
IE:     !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1),
Opera:  navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
BrowserFeatures: {
XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
document.createElement('div')['__proto__'] &&
document.createElement('div')['__proto__'] !==
document.createElement('form')['__proto__']
},
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function() { },
K: function(x) { return x }
};
if(Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;
var Class = {
create: function() {
var parent = null, properties = $A(arguments);
if(Object.isFunction(properties[0]))
parent = properties.shift();
function klass() {
this.initialize.apply(this, arguments);
}
Object.extend(klass, Class.Methods);
klass.superclass = parent;
klass.subclasses = [];
if(parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
parent.subclasses.push(klass);
}
for (var i = 0; i < properties.length; i++)
klass.addMethods(properties[i]);
if(!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;
klass.prototype.constructor = klass;
return klass;
}
};
Class.Methods = {
addMethods: function(source) {
var ancestor   = this.superclass && this.superclass.prototype;
var properties = Object.keys(source);
if(!Object.keys({ toString: true }).length)
properties.push("toString", "valueOf");
for (var i = 0, length = properties.length; i < length; i++) {
var property = properties[i], value = source[property];
if(ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
var method = value;
value = (function(m) {
return function() { return ancestor[m].apply(this, arguments) };
})(property).wrap(method);
value.valueOf = method.valueOf.bind(method);
value.toString = method.toString.bind(method);
}
this.prototype[property] = value;
}
return this;
}
};
var Abstract = { };
Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
Object.extend(Object, {
inspect: function(object) {
try {
if(Object.isUndefined(object)) return 'undefined';
if(object === null) return 'null';
return object.inspect ? object.inspect() : String(object);
}catch (e) {
if(e instanceof RangeError) return '...';
throw e;
}
},
toJSON: function(object) {
var type = typeof object;
switch (type) {
case 'undefined':
case 'function':
case 'unknown': return;
case 'boolean': return object.toString();
}
if(object === null) return 'null';
if(object.toJSON) return object.toJSON();
if(Object.isElement(object)) return;
var results = [];
for (var property in object) {
var value = Object.toJSON(object[property]);
if(!Object.isUndefined(value))
results.push(property.toJSON() + ': ' + value);
}
return '{' + results.join(', ') + '}';
},
toQueryString: function(object) {
return $H(object).toQueryString();
},
toHTML: function(object) {
return object && object.toHTML ? object.toHTML() : String.interpret(object);
},
keys: function(object) {
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},
values: function(object) {
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},
clone: function(object) {
return Object.extend({ }, object);
},
isElement: function(object) {
return !!(object && object.nodeType == 1);
},
isArray: function(object) {
return object != null && typeof object == "object" &&
'splice' in object && 'join' in object;
},
isHash: function(object) {
return object instanceof Hash;
},
isFunction: function(object) {
return typeof object == "function";
},
isString: function(object) {
return typeof object == "string";
},
isNumber: function(object) {
return typeof object == "number";
},
isUndefined: function(object) {
return typeof object == "undefined";
}
});
Object.extend(Function.prototype, {
argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1].replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names;
},
bind: function() {
if(arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
},
bindAsEventListener: function() {
var __method = this, args = $A(arguments), object = args.shift();
return function(event) {
return __method.apply(object, [event || window.event].concat(args));
}
},
curry: function() {
if(!arguments.length) return this;
var __method = this, args = $A(arguments);
return function() {
return __method.apply(this, args.concat($A(arguments)));
}
},
delay: function() {
var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
return window.setTimeout(function() {
return __method.apply(__method, args);
}, timeout);
},
defer: function() {
var args = [0.01].concat($A(arguments));
return this.delay.apply(this, args);
},
wrap: function(wrapper) {
var __method = this;
return function() {
return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
}
},
methodize: function() {
if(this._methodized) return this._methodized;
var __method = this;
return this._methodized = function() {
return __method.apply(null, [this].concat($A(arguments)));
};
}
});
Date.prototype.toJSON = function() {
return '"' + this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
this.getUTCDate().toPaddedString(2) + 'T' +
this.getUTCHours().toPaddedString(2) + ':' +
this.getUTCMinutes().toPaddedString(2) + ':' +
this.getUTCSeconds().toPaddedString(2) + 'Z"';
};
var Try = {
these: function() {
var returnValue;
for (var i = 0, length = arguments.length; i < length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
}catch (e) { }
}
return returnValue;
}
};
RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};
var PeriodicalExecuter = Class.create({
initialize: function(callback, frequency) {
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;
this.registerCallback();
},
registerCallback: function() {
this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
execute: function() {
this.callback(this);
},
stop: function() {
if(!this.timer) return;
clearInterval(this.timer);
this.timer = null;
},
onTimerEvent: function() {
if(!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.execute();
} finally {
this.currentlyExecuting = false;
}
}
}
});
Object.extend(String, {
interpret: function(value) {
return value == null ? '' : String(value);
},
specialChar: {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'\\': '\\\\'
}
});
Object.extend(String.prototype, {
gsub: function(pattern, replacement) {
var result = '', source = this, match;
replacement = arguments.callee.prepareReplacement(replacement);
while (source.length > 0) {
if(match = source.match(pattern)) {
result += source.slice(0, match.index);
result += String.interpret(replacement(match));
source  = source.slice(match.index + match[0].length);
}else{
result += source, source = '';
}
}
return result;
},
sub: function(pattern, replacement, count) {
replacement = this.gsub.prepareReplacement(replacement);
count = Object.isUndefined(count) ? 1 : count;
return this.gsub(pattern, function(match) {
if(--count < 0) return match[0];
return replacement(match);
});
},
scan: function(pattern, iterator) {
this.gsub(pattern, iterator);
return String(this);
},
truncate: function(length, truncation) {
length = length || 30;
truncation = Object.isUndefined(truncation) ? '...' : truncation;
return this.length > length ?
this.slice(0, length - truncation.length) + truncation : String(this);
},
strip: function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
},
stripTags: function() {
return this.replace(/<\/?[^>]+>/gi, '');
},
stripScripts: function() {
return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
},
extractScripts: function() {
var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
return (this.match(matchAll) || []).map(function(scriptTag) {
return (scriptTag.match(matchOne) || ['', ''])[1];
});
},
evalScripts: function() {
return this.extractScripts().map(function(script) { return eval(script) });
},
escapeHTML: function() {
var self = arguments.callee;
self.text.data = this;
return self.div.innerHTML;
},
unescapeHTML: function() {
var div = new Element('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
$A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
div.childNodes[0].nodeValue) : '';
},
toQueryParams: function(separator) {
var match = this.strip().match(/([^?#]*)(#.*)?$/);
if(!match) return { };
return match[1].split(separator || '&').inject({ }, function(hash, pair) {
if((pair = pair.split('='))[0]) {
var key = decodeURIComponent(pair.shift());
var value = pair.length > 1 ? pair.join('=') : pair[0];
if(value != undefined) value = decodeURIComponent(value);
if(key in hash) {
if(!Object.isArray(hash[key])) hash[key] = [hash[key]];
hash[key].push(value);
}
else hash[key] = value;
}
return hash;
});
},
toArray: function() {
return this.split('');
},
succ: function() {
return this.slice(0, this.length - 1) +
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},
times: function(count) {
return count < 1 ? '' : new Array(count + 1).join(this);
},
camelize: function() {
var parts = this.split('-'), len = parts.length;
if(len == 1) return parts[0];
var camelized = this.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
: parts[0];
for (var i = 1; i < len; i++)
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
return camelized;
},
capitalize: function() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},
underscore: function() {
return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
},
dasherize: function() {
return this.gsub(/_/,'-');
},
inspect: function(useDoubleQuotes) {
var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
var character = String.specialChar[match[0]];
return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
});
if(useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
return "'" + escapedString.replace(/'/g, '\\\'') + "'";
},
toJSON: function() {
return this.inspect(true);
},
unfilterJSON: function(filter) {
return this.sub(filter || Prototype.JSONFilter, '#{1}');
},
isJSON: function() {
var str = this;
if(str.blank()) return false;
str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},
evalJSON: function(sanitize) {
var json = this.unfilterJSON();
try {
if(!sanitize || json.isJSON()) return eval('(' + json + ')');
}catch (e) { }
throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
},
include: function(pattern) {
return this.indexOf(pattern) > -1;
},
startsWith: function(pattern) {
return this.indexOf(pattern) === 0;
},
endsWith: function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
},
empty: function() {
return this == '';
},
blank: function() {
return /^\s*$/.test(this);
},
interpolate: function(object, pattern) {
return new Template(this, pattern).evaluate(object);
}
});
if(Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
escapeHTML: function() {
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
},
unescapeHTML: function() {
return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
}
});
String.prototype.gsub.prepareReplacement = function(replacement) {
if(Object.isFunction(replacement)) return replacement;
var template = new Template(replacement);
return function(match) { return template.evaluate(match) };
};
String.prototype.parseQuery = String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML, {
div:  document.createElement('div'),
text: document.createTextNode('')
});
String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
var Template = Class.create({
initialize: function(template, pattern) {
this.template = template.toString();
this.pattern = pattern || Template.Pattern;
},
evaluate: function(object) {
if(Object.isFunction(object.toTemplateReplacements))
object = object.toTemplateReplacements();
return this.template.gsub(this.pattern, function(match) {
if(object == null) return '';
var before = match[1] || '';
if(before == '\\') return match[2];
var ctx = object, expr = match[3];
var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
match = pattern.exec(expr);
if(match == null) return before;
while (match != null) {
var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
ctx = ctx[comp];
if(null == ctx || '' == match[3]) break;
expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
match = pattern.exec(expr);
}
return before + String.interpret(ctx);
});
}
});
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
var $break = { };
var Enumerable = {
each: function(iterator, context) {
var index = 0;
try {
this._each(function(value) {
iterator.call(context, value, index++);
});
}catch (e) {
if(e != $break) throw e;
}
return this;
},
eachSlice: function(number, iterator, context) {
var index = -number, slices = [], array = this.toArray();
if(number < 1) return array;
while ((index += number) < array.length)
slices.push(array.slice(index, index+number));
return slices.collect(iterator, context);
},
all: function(iterator, context) {
iterator = iterator || Prototype.K;
var result = true;
this.each(function(value, index) {
result = result && !!iterator.call(context, value, index);
if(!result) throw $break;
});
return result;
},
any: function(iterator, context) {
iterator = iterator || Prototype.K;
var result = false;
this.each(function(value, index) {
if(result = !!iterator.call(context, value, index))
throw $break;
});
return result;
},
collect: function(iterator, context) {
iterator = iterator || Prototype.K;
var results = [];
this.each(function(value, index) {
results.push(iterator.call(context, value, index));
});
return results;
},
detect: function(iterator, context) {
var result;
this.each(function(value, index) {
if(iterator.call(context, value, index)) {
result = value;
throw $break;
}
});
return result;
},
findAll: function(iterator, context) {
var results = [];
this.each(function(value, index) {
if(iterator.call(context, value, index))
results.push(value);
});
return results;
},
grep: function(filter, iterator, context) {
iterator = iterator || Prototype.K;
var results = [];
if(Object.isString(filter))
filter = new RegExp(filter);
this.each(function(value, index) {
if(filter.match(value))
results.push(iterator.call(context, value, index));
});
return results;
},
include: function(object) {
if(Object.isFunction(this.indexOf))
if(this.indexOf(object) != -1) return true;
var found = false;
this.each(function(value) {
if(value == object) {
found = true;
throw $break;
}
});
return found;
},
inGroupsOf: function(number, fillWith) {
fillWith = Object.isUndefined(fillWith) ? null : fillWith;
return this.eachSlice(number, function(slice) {
while(slice.length < number) slice.push(fillWith);
return slice;
});
},
inject: function(memo, iterator, context) {
this.each(function(value, index) {
memo = iterator.call(context, memo, value, index);
});
return memo;
},
invoke: function(method) {
var args = $A(arguments).slice(1);
return this.map(function(value) {
return value[method].apply(value, args);
});
},
max: function(iterator, context) {
iterator = iterator || Prototype.K;
var result;
this.each(function(value, index) {
value = iterator.call(context, value, index);
if(result == null || value >= result)
result = value;
});
return result;
},
min: function(iterator, context) {
iterator = iterator || Prototype.K;
var result;
this.each(function(value, index) {
value = iterator.call(context, value, index);
if(result == null || value < result)
result = value;
});
return result;
},
partition: function(iterator, context) {
iterator = iterator || Prototype.K;
var trues = [], falses = [];
this.each(function(value, index) {
(iterator.call(context, value, index) ?
trues : falses).push(value);
});
return [trues, falses];
},
pluck: function(property) {
var results = [];
this.each(function(value) {
results.push(value[property]);
});
return results;
},
reject: function(iterator, context) {
var results = [];
this.each(function(value, index) {
if(!iterator.call(context, value, index))
results.push(value);
});
return results;
},
sortBy: function(iterator, context) {
return this.map(function(value, index) {
return {
value: value,
criteria: iterator.call(context, value, index)
};
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}).pluck('value');
},
toArray: function() {
return this.map();
},
zip: function() {
var iterator = Prototype.K, args = $A(arguments);
if(Object.isFunction(args.last()))
iterator = args.pop();
var collections = [this].concat(args).map($A);
return this.map(function(value, index) {
return iterator(collections.pluck(index));
});
},
size: function() {
return this.toArray().length;
},
inspect: function() {
return '#<Enumerable:' + this.toArray().inspect() + '>';
}
};
Object.extend(Enumerable, {
map:     Enumerable.collect,
find:    Enumerable.detect,
select:  Enumerable.findAll,
filter:  Enumerable.findAll,
member:  Enumerable.include,
entries: Enumerable.toArray,
every:   Enumerable.all,
some:    Enumerable.any
});
function $A(iterable) {
if(!iterable) return [];
if(iterable.toArray) return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
}
if(Prototype.Browser.WebKit) {
$A = function(iterable) {
if(!iterable) return [];
if(!(typeof iterable === 'function' && typeof iterable.length ===
'number' && typeof iterable.item === 'function') && iterable.toArray)
return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
};
}
Array.from = $A;
Object.extend(Array.prototype, Enumerable);
if(!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;
Object.extend(Array.prototype, {
_each: function(iterator) {
for (var i = 0, length = this.length; i < length; i++)
iterator(this[i]);
},
clear: function() {
this.length = 0;
return this;
},
first: function() {
return this[0];
},
last: function() {
return this[this.length - 1];
},
compact: function() {
return this.select(function(value) {
return value != null;
});
},
flatten: function() {
return this.inject([], function(array, value) {
return array.concat(Object.isArray(value) ?
value.flatten() : [value]);
});
},
without: function() {
var values = $A(arguments);
return this.select(function(value) {
return !values.include(value);
});
},
reverse: function(inline) {
return (inline !== false ? this : this.toArray())._reverse();
},
reduce: function() {
return this.length > 1 ? this : this[0];
},
uniq: function(sorted) {
return this.inject([], function(array, value, index) {
if(0 == index || (sorted ? array.last() != value : !array.include(value)))
array.push(value);
return array;
});
},
intersect: function(array) {
return this.uniq().findAll(function(item) {
return array.detect(function(value) { return item === value });
});
},
clone: function() {
return [].concat(this);
},
size: function() {
return this.length;
},
inspect: function() {
return '[' + this.map(Object.inspect).join(', ') + ']';
},
toJSON: function() {
var results = [];
this.each(function(object) {
var value = Object.toJSON(object);
if(!Object.isUndefined(value)) results.push(value);
});
return '[' + results.join(', ') + ']';
}
});
if(Object.isFunction(Array.prototype.forEach))
Array.prototype._each = Array.prototype.forEach;
if(!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
i || (i = 0);
var length = this.length;
if(i < 0) i = length + i;
for (; i < length; i++)
if(this[i] === item) return i;
return -1;
};
if(!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
var n = this.slice(0, i).reverse().indexOf(item);
return (n < 0) ? n : i - n - 1;
};
Array.prototype.toArray = Array.prototype.clone;
function $w(string) {
if(!Object.isString(string)) return [];
string = string.strip();
return string ? string.split(/\s+/) : [];
}
if(Prototype.Browser.Opera){
Array.prototype.concat = function() {
var array = [];
for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
for (var i = 0, length = arguments.length; i < length; i++) {
if(Object.isArray(arguments[i])) {
for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
array.push(arguments[i][j]);
}else{
array.push(arguments[i]);
}
}
return array;
};
}
Object.extend(Number.prototype, {
toColorPart: function() {
return this.toPaddedString(2, 16);
},
succ: function() {
return this + 1;
},
times: function(iterator, context) {
$R(0, this, true).each(iterator, context);
return this;
},
toPaddedString: function(length, radix) {
var string = this.toString(radix || 10);
return '0'.times(length - string.length) + string;
},
toJSON: function() {
return isFinite(this) ? this.toString() : 'null';
}
});
$w('abs round ceil floor').each(function(method){
Number.prototype[method] = Math[method].methodize();
});
function $H(object) {
return new Hash(object);
};
var Hash = Class.create(Enumerable, (function() {
function toQueryPair(key, value) {
if(Object.isUndefined(value)) return key;
return key + '=' + encodeURIComponent(String.interpret(value));
}
return {
initialize: function(object) {
this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
},
_each: function(iterator) {
for (var key in this._object) {
var value = this._object[key], pair = [key, value];
pair.key = key;
pair.value = value;
iterator(pair);
}
},
set: function(key, value) {
return this._object[key] = value;
},
get: function(key) {
if(this._object[key] !== Object.prototype[key])
return this._object[key];
},
unset: function(key) {
var value = this._object[key];
delete this._object[key];
return value;
},
toObject: function() {
return Object.clone(this._object);
},
keys: function() {
return this.pluck('key');
},
values: function() {
return this.pluck('value');
},
index: function(value) {
var match = this.detect(function(pair) {
return pair.value === value;
});
return match && match.key;
},
merge: function(object) {
return this.clone().update(object);
},
update: function(object) {
return new Hash(object).inject(this, function(result, pair) {
result.set(pair.key, pair.value);
return result;
});
},
toQueryString: function() {
return this.inject([], function(results, pair) {
var key = encodeURIComponent(pair.key), values = pair.value;
if(values && typeof values == 'object') {
if(Object.isArray(values))
return results.concat(values.map(toQueryPair.curry(key)));
} else results.push(toQueryPair(key, values));
return results;
}).join('&');
},
inspect: function() {
return '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');
}).join(', ') + '}>';
},
toJSON: function() {
return Object.toJSON(this.toObject());
},
clone: function() {
return new Hash(this);
}
}
})());
Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
Hash.from = $H;
var ObjectRange = Class.create(Enumerable, {
initialize: function(start, end, exclusive) {
this.start = start;
this.end = end;
this.exclusive = exclusive;
},
_each: function(iterator) {
var value = this.start;
while (this.include(value)) {
iterator(value);
value = value.succ();
}
},
include: function(value) {
if(value < this.start)
return false;
if(this.exclusive)
return value < this.end;
return value <= this.end;
}
});
var $R = function(start, end, exclusive) {
return new ObjectRange(start, end, exclusive);
};
var Ajax = {
getTransport: function() {
return Try.these(
function() {return new XMLHttpRequest()},
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')}
) || false;
},
activeRequestCount: 0
};
Ajax.Responders = {
responders: [],
_each: function(iterator) {
this.responders._each(iterator);
},
register: function(responder) {
if(!this.include(responder))
this.responders.push(responder);
},
unregister: function(responder) {
this.responders = this.responders.without(responder);
},
dispatch: function(callback, request, transport, json) {
this.each(function(responder) {
if(Object.isFunction(responder[callback])) {
try {
responder[callback].apply(responder, [request, transport, json]);
}catch (e) { }
}
});
}
};
Object.extend(Ajax.Responders, Enumerable);
Ajax.Responders.register({
onCreate:   function() { Ajax.activeRequestCount++ },
onComplete: function() { Ajax.activeRequestCount-- }
});
Ajax.Base = Class.create({
initialize: function(options) {
this.options = {
method:       'post',
asynchronous: true,
contentType:  'application/x-www-form-urlencoded',
encoding:     'UTF-8',
parameters:   '',
evalJSON:     true,
evalJS:       true
};
Object.extend(this.options, options || { });
this.options.method = this.options.method.toLowerCase();
if(Object.isString(this.options.parameters))
this.options.parameters = this.options.parameters.toQueryParams();
else if(Object.isHash(this.options.parameters))
this.options.parameters = this.options.parameters.toObject();
}
});
Ajax.Request = Class.create(Ajax.Base, {
_complete: false,
initialize: function($super, url, options) {
$super(options);
this.transport = Ajax.getTransport();
this.request(url);
},
request: function(url) {
this.url = url;
this.method = this.options.method;
var params = Object.clone(this.options.parameters);
if(!['get', 'post'].include(this.method)) {
params['_method'] = this.method;
this.method = 'post';
}
this.parameters = params;
if(params = Object.toQueryString(params)) {
if(this.method == 'get')
this.url += (this.url.include('?') ? '&' : '?') + params;
else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params += '&_=';
}
try {
var response = new Ajax.Response(this);
if(this.options.onCreate) this.options.onCreate(response);
Ajax.Responders.dispatch('onCreate', this, response);
this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);
if(this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
this.body = this.method == 'post' ? (this.options.postBody || params) : null;
this.transport.send(this.body);
if(!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange();
}
catch (e) {
this.dispatchException(e);
}
},
onStateChange: function() {
var readyState = this.transport.readyState;
if(readyState > 1 && !((readyState == 4) && this._complete))
this.respondToReadyState(this.transport.readyState);
},
setRequestHeaders: function() {
var headers = {
'X-Requested-With': 'XMLHttpRequest',
'X-Prototype-Version': Prototype.Version,
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};
if(this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');
if(this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
headers['Connection'] = 'close';
}
if(typeof this.options.requestHeaders == 'object') {
var extras = this.options.requestHeaders;
if(Object.isFunction(extras.push))
for (var i = 0, length = extras.length; i < length; i += 2)
headers[extras[i]] = extras[i+1];
else
$H(extras).each(function(pair) { headers[pair.key] = pair.value });
}
for (var name in headers)
this.transport.setRequestHeader(name, headers[name]);
},
success: function() {
var status = this.getStatus();
return !status || (status >= 200 && status < 300);
},
getStatus: function() {
try {
return this.transport.status || 0;
}catch (e) { return 0 }
},
respondToReadyState: function(readyState) {
var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
if(state == 'Complete') {
try {
this._complete = true;
(this.options['on' + response.status]
|| this.options['on' + (this.success() ? 'Success' : 'Failure')]
|| Prototype.emptyFunction)(response, response.headerJSON);
}catch (e) {
this.dispatchException(e);
}
var contentType = response.getHeader('Content-type');
if(this.options.evalJS == 'force'
|| (this.options.evalJS && this.isSameOrigin() && contentType
&& contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
this.evalResponse();
}
try {
(this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
}catch (e) {
this.dispatchException(e);
}
if(state == 'Complete') {
this.transport.onreadystatechange = Prototype.emptyFunction;
}
},
isSameOrigin: function() {
var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
protocol: location.protocol,
domain: document.domain,
port: location.port ? ':' + location.port : ''
}));
},
getHeader: function(name) {
try {
return this.transport.getResponseHeader(name) || null;
}catch (e) { return null }
},
evalResponse: function() {
try {
return eval((this.transport.responseText || '').unfilterJSON());
}catch (e) {
this.dispatchException(e);
}
},
dispatchException: function(exception) {
(this.options.onException || Prototype.emptyFunction)(this, exception);
Ajax.Responders.dispatch('onException', this, exception);
}
});
Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
Ajax.Response = Class.create({
initialize: function(request){
this.request = request;
var transport  = this.transport  = request.transport,
readyState = this.readyState = transport.readyState;
if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
this.status       = this.getStatus();
this.statusText   = this.getStatusText();
this.responseText = String.interpret(transport.responseText);
this.headerJSON   = this._getHeaderJSON();
}
if(readyState == 4) {
var xml = transport.responseXML;
this.responseXML  = Object.isUndefined(xml) ? null : xml;
this.responseJSON = this._getResponseJSON();
}
},
status:      0,
statusText: '',
getStatus: Ajax.Request.prototype.getStatus,
getStatusText: function() {
try {
return this.transport.statusText || '';
}catch (e) { return '' }
},
getHeader: Ajax.Request.prototype.getHeader,
getAllHeaders: function() {
try {
return this.getAllResponseHeaders();
}catch (e) { return null }
},
getResponseHeader: function(name) {
return this.transport.getResponseHeader(name);
},
getAllResponseHeaders: function() {
return this.transport.getAllResponseHeaders();
},
_getHeaderJSON: function() {
var json = this.getHeader('X-JSON');
if(!json) return null;
json = decodeURIComponent(escape(json));
try {
return json.evalJSON(this.request.options.sanitizeJSON ||
!this.request.isSameOrigin());
}catch (e) {
this.request.dispatchException(e);
}
},
_getResponseJSON: function() {
var options = this.request.options;
if(!options.evalJSON || (options.evalJSON != 'force' &&
!(this.getHeader('Content-type') || '').include('application/json')) ||
this.responseText.blank())
return null;
try {
return this.responseText.evalJSON(options.sanitizeJSON ||
!this.request.isSameOrigin());
}catch (e) {
this.request.dispatchException(e);
}
}
});
Ajax.Updater = Class.create(Ajax.Request, {
initialize: function($super, container, url, options) {
this.container = {
success: (container.success || container),
failure: (container.failure || (container.success ? null : container))
};
options = Object.clone(options);
var onComplete = options.onComplete;
options.onComplete = (function(response, json) {
this.updateContent(response.responseText);
if(Object.isFunction(onComplete)) onComplete(response, json);
}).bind(this);
$super(url, options);
},
updateContent: function(responseText) {
var receiver = this.container[this.success() ? 'success' : 'failure'],
options = this.options;
if(!options.evalScripts) responseText = responseText.stripScripts();
if(receiver = $(receiver)) {
if(options.insertion) {
if(Object.isString(options.insertion)) {
var insertion = { }; insertion[options.insertion] = responseText;
receiver.insert(insertion);
}
else options.insertion(receiver, responseText);
}
else receiver.update(responseText);
}
}
});
Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function($super, container, url, options) {
$super(options);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = { };
this.container = container;
this.url = url;
this.start();
},
start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},
stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},
updateComplete: function(response) {
if(this.options.decay) {
this.decay = (response.responseText == this.lastText ?
this.decay * this.options.decay : 1);
this.lastText = response.responseText;
}
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
function $(element) {
if(arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if(Object.isString(element))
element = document.getElementById(element);
return Element.extend(element);
}
if(Prototype.BrowserFeatures.XPath) {
document._getElementsByXPath = function(expression, parentElement) {
var results = [];
var query = document.evaluate(expression, $(parentElement) || document,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, length = query.snapshotLength; i < length; i++)
results.push(Element.extend(query.snapshotItem(i)));
return results;
};
}
if(!window.Node) var Node = { };
if(!Node.ELEMENT_NODE) {
Object.extend(Node, {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
});
}
(function() {
var element = this.Element;
this.Element = function(tagName, attributes) {
attributes = attributes || { };
tagName = tagName.toLowerCase();
var cache = Element.cache;
if(Prototype.Browser.IE && attributes.name) {
tagName = '<' + tagName + ' name="' + attributes.name + '">';
delete attributes.name;
return Element.writeAttribute(document.createElement(tagName), attributes);
}
if(!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
};
Object.extend(this.Element, element || { });
if(element) this.Element.prototype = element.prototype;
}).call(window);
Element.cache = { };
Element.Methods = {
visible: function(element) {
return $(element).style.display != 'none';
},
toggle: function(element) {
element = $(element);
Element[Element.visible(element) ? 'hide' : 'show'](element);
return element;
},
hide: function(element) {
element = $(element);
element.style.display = 'none';
return element;
},
show: function(element) {
element = $(element);
element.style.display = '';
return element;
},
remove: function(element) {
element = $(element);
element.parentNode.removeChild(element);
return element;
},
update: function(element, content) {
element = $(element);
if(content && content.toElement) content = content.toElement();
if(Object.isElement(content)) return element.update().insert(content);
content = Object.toHTML(content);
element.innerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
},
replace: function(element, content) {
element = $(element);
if(content && content.toElement) content = content.toElement();
else if(!Object.isElement(content)) {
content = Object.toHTML(content);
var range = element.ownerDocument.createRange();
range.selectNode(element);
content.evalScripts.bind(content).defer();
content = range.createContextualFragment(content.stripScripts());
}
element.parentNode.replaceChild(content, element);
return element;
},
insert: function(element, insertions) {
element = $(element);
if(Object.isString(insertions) || Object.isNumber(insertions) ||
Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
var content, insert, tagName, childNodes;
for (var position in insertions) {
content  = insertions[position];
position = position.toLowerCase();
insert = Element._insertionTranslations[position];
if(content && content.toElement) content = content.toElement();
if(Object.isElement(content)) {
insert(element, content);
continue;
}
content = Object.toHTML(content);
tagName = ((position == 'before' || position == 'after')
? element.parentNode : element).tagName.toUpperCase();
childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
if(position == 'top' || position == 'after') childNodes.reverse();
childNodes.each(insert.curry(element));
content.evalScripts.bind(content).defer();
}
return element;
},
wrap: function(element, wrapper, attributes) {
element = $(element);
if(Object.isElement(wrapper))
$(wrapper).writeAttribute(attributes || { });
else if(Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
else wrapper = new Element('div', wrapper);
if(element.parentNode)
element.parentNode.replaceChild(wrapper, element);
wrapper.appendChild(element);
return wrapper;
},
inspect: function(element) {
element = $(element);
var result = '<' + element.tagName.toLowerCase();
$H({'id': 'id', 'className': 'class'}).each(function(pair) {
var property = pair.first(), attribute = pair.last();
var value = (element[property] || '').toString();
if(value) result += ' ' + attribute + '=' + value.inspect(true);
});
return result + '>';
},
recursivelyCollect: function(element, property) {
element = $(element);
var elements = [];
while (element = element[property])
if(element.nodeType == 1)
elements.push(Element.extend(element));
return elements;
},
ancestors: function(element) {
return $(element).recursivelyCollect('parentNode');
},
descendants: function(element) {
return $(element).select("*");
},
firstDescendant: function(element) {
element = $(element).firstChild;
while (element && element.nodeType != 1) element = element.nextSibling;
return $(element);
},
immediateDescendants: function(element) {
if(!(element = $(element).firstChild)) return [];
while (element && element.nodeType != 1) element = element.nextSibling;
if(element) return [element].concat($(element).nextSiblings());
return [];
},
previousSiblings: function(element) {
return $(element).recursivelyCollect('previousSibling');
},
nextSiblings: function(element) {
return $(element).recursivelyCollect('nextSibling');
},
siblings: function(element) {
element = $(element);
return element.previousSiblings().reverse().concat(element.nextSiblings());
},
match: function(element, selector) {
if(Object.isString(selector))
selector = new Selector(selector);
return selector.match($(element));
},
up: function(element, expression, index) {
element = $(element);
if(arguments.length == 1) return $(element.parentNode);
var ancestors = element.ancestors();
return Object.isNumber(expression) ? ancestors[expression] :
Selector.findElement(ancestors, expression, index);
},
down: function(element, expression, index) {
element = $(element);
if(arguments.length == 1) return element.firstDescendant();
return Object.isNumber(expression) ? element.descendants()[expression] :
Element.select(element, expression)[index || 0];
},
previous: function(element, expression, index) {
element = $(element);
if(arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
var previousSiblings = element.previousSiblings();
return Object.isNumber(expression) ? previousSiblings[expression] :
Selector.findElement(previousSiblings, expression, index);
},
next: function(element, expression, index) {
element = $(element);
if(arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
var nextSiblings = element.nextSiblings();
return Object.isNumber(expression) ? nextSiblings[expression] :
Selector.findElement(nextSiblings, expression, index);
},
select: function() {
var args = $A(arguments), element = $(args.shift());
return Selector.findChildElements(element, args);
},
adjacent: function() {
var args = $A(arguments), element = $(args.shift());
return Selector.findChildElements(element.parentNode, args).without(element);
},
identify: function(element) {
element = $(element);
var id = element.readAttribute('id'), self = arguments.callee;
if(id) return id;
do { id = 'anonymous_element_' + self.counter++ } while ($(id));
element.writeAttribute('id', id);
return id;
},
readAttribute: function(element, name) {
element = $(element);
if(Prototype.Browser.IE) {
var t = Element._attributeTranslations.read;
if(t.values[name]) return t.values[name](element, name);
if(t.names[name]) name = t.names[name];
if(name.include(':')) {
return (!element.attributes || !element.attributes[name]) ? null :
element.attributes[name].value;
}
}
return element.getAttribute(name);
},
writeAttribute: function(element, name, value) {
element = $(element);
var attributes = { }, t = Element._attributeTranslations.write;
if(typeof name == 'object') attributes = name;
else attributes[name] = Object.isUndefined(value) ? true : value;
for (var attr in attributes) {
name = t.names[attr] || attr;
value = attributes[attr];
if(t.values[attr]) name = t.values[attr](element, value);
if(value === false || value === null)
element.removeAttribute(name);
else if(value === true)
element.setAttribute(name, name);
else element.setAttribute(name, value);
}
return element;
},
getHeight: function(element) {
return $(element).getDimensions().height;
},
getWidth: function(element) {
return $(element).getDimensions().width;
},
classNames: function(element) {
return new Element.ClassNames(element);
},
hasClassName: function(element, className) {
if(!(element = $(element))) return;
var elementClassName = element.className;
return (elementClassName.length > 0 && (elementClassName == className ||
new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
},
addClassName: function(element, className) {
if(!(element = $(element))) return;
if(!element.hasClassName(className))
element.className += (element.className ? ' ' : '') + className;
return element;
},
removeClassName: function(element, className) {
if(!(element = $(element))) return;
element.className = element.className.replace(
new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
return element;
},
toggleClassName: function(element, className) {
if(!(element = $(element))) return;
return element[element.hasClassName(className) ?
'removeClassName' : 'addClassName'](className);
},
cleanWhitespace: function(element) {
element = $(element);
var node = element.firstChild;
while (node) {
var nextNode = node.nextSibling;
if(node.nodeType == 3 && !/\S/.test(node.nodeValue))
element.removeChild(node);
node = nextNode;
}
return element;
},
empty: function(element) {
return $(element).innerHTML.blank();
},
descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
if(element.compareDocumentPosition)
return (element.compareDocumentPosition(ancestor) & 8) === 8;
if(ancestor.contains)
return ancestor.contains(element) && ancestor !== element;
while (element = element.parentNode)
if(element == ancestor) return true;
return false;
},
scrollTo: function(element) {
element = $(element);
var pos = element.cumulativeOffset();
window.scrollTo(pos[0], pos[1]);
return element;
},
getStyle: function(element, style) {
element = $(element);
style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style];
if(!value || value == 'auto') {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null;
}
if(style == 'opacity') return value ? parseFloat(value) : 1.0;
return value == 'auto' ? null : value;
},
getOpacity: function(element) {
return $(element).getStyle('opacity');
},
setStyle: function(element, styles) {
element = $(element);
var elementStyle = element.style, match;
if(Object.isString(styles)) {
element.style.cssText += ';' + styles;
return styles.include('opacity') ?
element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
}
for (var property in styles)
if(property == 'opacity') element.setOpacity(styles[property]);
else
elementStyle[(property == 'float' || property == 'cssFloat') ?
(Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
property] = styles[property];
return element;
},
setOpacity: function(element, value) {
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '' :
(value < 0.00001) ? 0 : value;
return element;
},
getDimensions: function(element) {
element = $(element);
var display = element.getStyle('display');
if(display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
},
makePositioned: function(element) {
element = $(element);
var pos = Element.getStyle(element, 'position');
if(pos == 'static' || !pos) {
element._madePositioned = true;
element.style.position = 'relative';
if(Prototype.Browser.Opera) {
element.style.top = 0;
element.style.left = 0;
}
}
return element;
},
undoPositioned: function(element) {
element = $(element);
if(element._madePositioned) {
element._madePositioned = undefined;
element.style.position =
element.style.top =
element.style.left =
element.style.bottom =
element.style.right = '';
}
return element;
},
makeClipping: function(element) {
element = $(element);
if(element._overflow) return element;
element._overflow = Element.getStyle(element, 'overflow') || 'auto';
if(element._overflow !== 'hidden')
element.style.overflow = 'hidden';
return element;
},
undoClipping: function(element) {
element = $(element);
if(!element._overflow) return element;
element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
element._overflow = null;
return element;
},
cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return Element._returnOffset(valueL, valueT);
},
positionedOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if(element) {
if(element.tagName.toUpperCase() == 'BODY') break;
var p = Element.getStyle(element, 'position');
if(p !== 'static') break;
}
} while (element);
return Element._returnOffset(valueL, valueT);
},
absolutize: function(element) {
element = $(element);
if(element.getStyle('position') == 'absolute') return element;
var offsets = element.positionedOffset();
var top     = offsets[1];
var left    = offsets[0];
var width   = element.clientWidth;
var height  = element.clientHeight;
element._originalLeft   = left - parseFloat(element.style.left  || 0);
element._originalTop    = top  - parseFloat(element.style.top || 0);
element._originalWidth  = element.style.width;
element._originalHeight = element.style.height;
element.style.position = 'absolute';
element.style.top    = top + 'px';
element.style.left   = left + 'px';
element.style.width  = width + 'px';
element.style.height = height + 'px';
return element;
},
relativize: function(element) {
element = $(element);
if(element.getStyle('position') == 'relative') return element;
element.style.position = 'relative';
var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
element.style.top    = top + 'px';
element.style.left   = left + 'px';
element.style.height = element._originalHeight;
element.style.width  = element._originalWidth;
return element;
},
cumulativeScrollOffset: function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.scrollTop  || 0;
valueL += element.scrollLeft || 0;
element = element.parentNode;
} while (element);
return Element._returnOffset(valueL, valueT);
},
getOffsetParent: function(element) {
if(element.offsetParent) return $(element.offsetParent);
if(element == document.body) return $(element);
while ((element = element.parentNode) && element != document.body)
if(Element.getStyle(element, 'position') != 'static')
return $(element);
return $(document.body);
},
viewportOffset: function(forElement) {
var valueT = 0, valueL = 0;
var element = forElement;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
if(element.offsetParent == document.body &&
Element.getStyle(element, 'position') == 'absolute') break;
} while (element = element.offsetParent);
element = forElement;
do {
if(!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
valueT -= element.scrollTop  || 0;
valueL -= element.scrollLeft || 0;
}
} while (element = element.parentNode);
return Element._returnOffset(valueL, valueT);
},
clonePosition: function(element, source) {
var options = Object.extend({
setLeft:    true,
setTop:     true,
setWidth:   true,
setHeight:  true,
offsetTop:  0,
offsetLeft: 0
}, arguments[2] || { });
source = $(source);
var p = source.viewportOffset();
element = $(element);
var delta = [0, 0];
var parent = null;
if(Element.getStyle(element, 'position') == 'absolute') {
parent = element.getOffsetParent();
delta = parent.viewportOffset();
}
if(parent == document.body) {
delta[0] -= document.body.offsetLeft;
delta[1] -= document.body.offsetTop;
}
if(options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
if(options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
if(options.setWidth)  element.style.width = source.offsetWidth + 'px';
if(options.setHeight) element.style.height = source.offsetHeight + 'px';
return element;
}
};
Element.Methods.identify.counter = 1;
Object.extend(Element.Methods, {
getElementsBySelector: Element.Methods.select,
childElements: Element.Methods.immediateDescendants
});
Element._attributeTranslations = {
write: {
names: {
className: 'class',
htmlFor:   'for'
},
values: { }
}
};
if(Prototype.Browser.Opera) {
Element.Methods.getStyle = Element.Methods.getStyle.wrap(
function(proceed, element, style) {
switch (style) {
case 'left': case 'top': case 'right': case 'bottom':
if(proceed(element, 'position') === 'static') return null;
case 'height': case 'width':
if(!Element.visible(element)) return null;
var dim = parseInt(proceed(element, style), 10);
if(dim !== element['offset' + style.capitalize()])
return dim + 'px';
var properties;
if(style === 'height') {
properties = ['border-top-width', 'padding-top',
'padding-bottom', 'border-bottom-width'];
}
else {
properties = ['border-left-width', 'padding-left',
'padding-right', 'border-right-width'];
}
return properties.inject(dim, function(memo, property) {
var val = proceed(element, property);
return val === null ? memo : memo - parseInt(val, 10);
}) + 'px';
default: return proceed(element, style);
}
}
);
Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
function(proceed, element, attribute) {
if(attribute === 'title') return element.title;
return proceed(element, attribute);
}
);
}
else if(Prototype.Browser.IE) {
Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
function(proceed, element) {
element = $(element);
try { element.offsetParent }
catch(e) { return $(document.body) }
var position = element.getStyle('position');
if(position !== 'static') return proceed(element);
element.setStyle({ position: 'relative' });
var value = proceed(element);
element.setStyle({ position: position });
return value;
}
);
$w('positionedOffset viewportOffset').each(function(method) {
Element.Methods[method] = Element.Methods[method].wrap(
function(proceed, element) {
element = $(element);
try { element.offsetParent }
catch(e) { return Element._returnOffset(0,0) }
var position = element.getStyle('position');
if(position !== 'static') return proceed(element);
var offsetParent = element.getOffsetParent();
if(offsetParent && offsetParent.getStyle('position') === 'fixed')
offsetParent.setStyle({ zoom: 1 });
element.setStyle({ position: 'relative' });
var value = proceed(element);
element.setStyle({ position: position });
return value;
}
);
});
Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
function(proceed, element) {
try { element.offsetParent }
catch(e) { return Element._returnOffset(0,0) }
return proceed(element);
}
);
Element.Methods.getStyle = function(element, style) {
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
var value = element.style[style];
if(!value && element.currentStyle) value = element.currentStyle[style];
if(style == 'opacity') {
if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
if(value[1]) return parseFloat(value[1]) / 100;
return 1.0;
}
if(value == 'auto') {
if((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
return element['offset' + style.capitalize()] + 'px';
return null;
}
return value;
};
Element.Methods.setOpacity = function(element, value) {
function stripAlpha(filter){
return filter.replace(/alpha\([^\)]*\)/gi,'');
}
element = $(element);
var currentStyle = element.currentStyle;
if((currentStyle && !currentStyle.hasLayout) ||
(!currentStyle && element.style.zoom == 'normal'))
element.style.zoom = 1;
var filter = element.getStyle('filter'), style = element.style;
if(value == 1 || value === '') {
(filter = stripAlpha(filter)) ?
style.filter = filter : style.removeAttribute('filter');
return element;
} else if(value < 0.00001) value = 0;
style.filter = stripAlpha(filter) +
'alpha(opacity=' + (value * 100) + ')';
return element;
};
Element._attributeTranslations = {
read: {
names: {
'class': 'className',
'for':   'htmlFor'
},
values: {
_getAttr: function(element, attribute) {
return element.getAttribute(attribute, 2);
},
_getAttrNode: function(element, attribute) {
var node = element.getAttributeNode(attribute);
return node ? node.value : "";
},
_getEv: function(element, attribute) {
attribute = element.getAttribute(attribute);
return attribute ? attribute.toString().slice(23, -2) : null;
},
_flag: function(element, attribute) {
return $(element).hasAttribute(attribute) ? attribute : null;
},
style: function(element) {
return element.style.cssText.toLowerCase();
},
title: function(element) {
return element.title;
}
}
}
};
Element._attributeTranslations.write = {
names: Object.extend({
cellpadding: 'cellPadding',
cellspacing: 'cellSpacing'
}, Element._attributeTranslations.read.names),
values: {
checked: function(element, value) {
element.checked = !!value;
},
style: function(element, value) {
element.style.cssText = value ? value : '';
}
}
};
Element._attributeTranslations.has = {};
$w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
Element._attributeTranslations.has[attr.toLowerCase()] = attr;
});
(function(v) {
Object.extend(v, {
href:        v._getAttr,
src:         v._getAttr,
type:        v._getAttr,
action:      v._getAttrNode,
disabled:    v._flag,
checked:     v._flag,
readonly:    v._flag,
multiple:    v._flag,
onload:      v._getEv,
onunload:    v._getEv,
onclick:     v._getEv,
ondblclick:  v._getEv,
onmousedown: v._getEv,
onmouseup:   v._getEv,
onmouseover: v._getEv,
onmousemove: v._getEv,
onmouseout:  v._getEv,
onfocus:     v._getEv,
onblur:      v._getEv,
onkeypress:  v._getEv,
onkeydown:   v._getEv,
onkeyup:     v._getEv,
onsubmit:    v._getEv,
onreset:     v._getEv,
onselect:    v._getEv,
onchange:    v._getEv
});
})(Element._attributeTranslations.read.values);
}
else if(Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1) ? 0.999999 :
(value === '') ? '' : (value < 0.00001) ? 0 : value;
return element;
};
}
else if(Prototype.Browser.WebKit) {
Element.Methods.setOpacity = function(element, value) {
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '' :
(value < 0.00001) ? 0 : value;
if(value == 1)
if(element.tagName.toUpperCase() == 'IMG' && element.width) {
element.width++; element.width--;
} else try {
var n = document.createTextNode(' ');
element.appendChild(n);
element.removeChild(n);
}catch (e) { }
return element;
};
Element.Methods.cumulativeOffset = function(element) {
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop  || 0;
valueL += element.offsetLeft || 0;
if(element.offsetParent == document.body)
if(Element.getStyle(element, 'position') == 'absolute') break;
element = element.offsetParent;
} while (element);
return Element._returnOffset(valueL, valueT);
};
}
if(Prototype.Browser.IE || Prototype.Browser.Opera) {
Element.Methods.update = function(element, content) {
element = $(element);
if(content && content.toElement) content = content.toElement();
if(Object.isElement(content)) return element.update().insert(content);
content = Object.toHTML(content);
var tagName = element.tagName.toUpperCase();
if(tagName in Element._insertionTranslations.tags) {
$A(element.childNodes).each(function(node) { element.removeChild(node) });
Element._getContentFromAnonymousElement(tagName, content.stripScripts())
.each(function(node) { element.appendChild(node) });
}
else element.innerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
};
}
if('outerHTML' in document.createElement('div')) {
Element.Methods.replace = function(element, content) {
element = $(element);
if(content && content.toElement) content = content.toElement();
if(Object.isElement(content)) {
element.parentNode.replaceChild(content, element);
return element;
}
content = Object.toHTML(content);
var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
if(Element._insertionTranslations.tags[tagName]) {
var nextSibling = element.next();
var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
parent.removeChild(element);
if(nextSibling)
fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
else
fragments.each(function(node) { parent.appendChild(node) });
}
else element.outerHTML = content.stripScripts();
content.evalScripts.bind(content).defer();
return element;
};
}
Element._returnOffset = function(l, t) {
var result = [l, t];
result.left = l;
result.top = t;
return result;
};
Element._getContentFromAnonymousElement = function(tagName, html) {
var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
if(t) {
div.innerHTML = t[0] + html + t[1];
t[2].times(function() { div = div.firstChild });
} else div.innerHTML = html;
return $A(div.childNodes);
};
Element._insertionTranslations = {
before: function(element, node) {
element.parentNode.insertBefore(node, element);
},
top: function(element, node) {
element.insertBefore(node, element.firstChild);
},
bottom: function(element, node) {
element.appendChild(node);
},
after: function(element, node) {
element.parentNode.insertBefore(node, element.nextSibling);
},
tags: {
TABLE:  ['<table>',                '</table>',                   1],
TBODY:  ['<table><tbody>',         '</tbody></table>',           2],
TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],
TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
SELECT: ['<select>',               '</select>',                  1]
}
};
(function() {
Object.extend(this.tags, {
THEAD: this.tags.TBODY,
TFOOT: this.tags.TBODY,
TH:    this.tags.TD
});
}).call(Element._insertionTranslations);
Element.Methods.Simulated = {
hasAttribute: function(element, attribute) {
attribute = Element._attributeTranslations.has[attribute] || attribute;
var node = $(element).getAttributeNode(attribute);
return !!(node && node.specified);
}
};
Element.Methods.ByTag = { };
Object.extend(Element, Element.Methods);
if(!Prototype.BrowserFeatures.ElementExtensions &&
document.createElement('div')['__proto__']) {
window.HTMLElement = { };
window.HTMLElement.prototype = document.createElement('div')['__proto__'];
Prototype.BrowserFeatures.ElementExtensions = true;
}
Element.extend = (function() {
if(Prototype.BrowserFeatures.SpecificElementExtensions)
return Prototype.K;
var Methods = { }, ByTag = Element.Methods.ByTag;
var extend = Object.extend(function(element) {
if(!element || element._extendedByPrototype ||
element.nodeType != 1 || element == window) return element;
var methods = Object.clone(Methods),
tagName = element.tagName.toUpperCase(), property, value;
if(ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
for (property in methods) {
value = methods[property];
if(Object.isFunction(value) && !(property in element))
element[property] = value.methodize();
}
element._extendedByPrototype = Prototype.emptyFunction;
return element;
}, {
refresh: function() {
if(!Prototype.BrowserFeatures.ElementExtensions) {
Object.extend(Methods, Element.Methods);
Object.extend(Methods, Element.Methods.Simulated);
}
}
});
extend.refresh();
return extend;
})();
Element.hasAttribute = function(element, attribute) {
if(element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element, attribute);
};
Element.addMethods = function(methods) {
var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
if(!methods) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM":     Object.clone(Form.Methods),
"INPUT":    Object.clone(Form.Element.Methods),
"SELECT":   Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods)
});
}
if(arguments.length == 2) {
var tagName = methods;
methods = arguments[1];
}
if(!tagName) Object.extend(Element.Methods, methods || { });
else {
if(Object.isArray(tagName)) tagName.each(extend);
else extend(tagName);
}
function extend(tagName) {
tagName = tagName.toUpperCase();
if(!Element.Methods.ByTag[tagName])
Element.Methods.ByTag[tagName] = { };
Object.extend(Element.Methods.ByTag[tagName], methods);
}
function copy(methods, destination, onlyIfAbsent) {
onlyIfAbsent = onlyIfAbsent || false;
for (var property in methods) {
var value = methods[property];
if(!Object.isFunction(value)) continue;
if(!onlyIfAbsent || !(property in destination))
destination[property] = value.methodize();
}
}
function findDOMClass(tagName) {
var klass;
var trans = {
"OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
"FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
"DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
"H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
"INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
"TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
"TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
"TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
"FrameSet", "IFRAME": "IFrame"
};
if(trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
if(window[klass]) return window[klass];
klass = 'HTML' + tagName + 'Element';
if(window[klass]) return window[klass];
klass = 'HTML' + tagName.capitalize() + 'Element';
if(window[klass]) return window[klass];
window[klass] = { };
window[klass].prototype = document.createElement(tagName)['__proto__'];
return window[klass];
}
if(F.ElementExtensions) {
copy(Element.Methods, HTMLElement.prototype);
copy(Element.Methods.Simulated, HTMLElement.prototype, true);
}
if(F.SpecificElementExtensions) {
for (var tag in Element.Methods.ByTag) {
var klass = findDOMClass(tag);
if(Object.isUndefined(klass)) continue;
copy(T[tag], klass.prototype);
}
}
Object.extend(Element, Element.Methods);
delete Element.ByTag;
if(Element.extend.refresh) Element.extend.refresh();
Element.cache = { };
};
document.viewport = {
getDimensions: function() {
var dimensions = { }, B = Prototype.Browser;
$w('width height').each(function(d) {
var D = d.capitalize();
if(B.WebKit && !document.evaluate) {
dimensions[d] = self['inner' + D];
} else if(B.Opera && parseFloat(window.opera.version()) < 9.5) {
dimensions[d] = document.body['client' + D]
}else{
dimensions[d] = document.documentElement['client' + D];
}
});
return dimensions;
},
getWidth: function() {
return this.getDimensions().width;
},
getHeight: function() {
return this.getDimensions().height;
},
getScrollOffsets: function() {
return Element._returnOffset(
window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
}
};
var Selector = Class.create({
initialize: function(expression) {
this.expression = expression.strip();
if(this.shouldUseSelectorsAPI()) {
this.mode = 'selectorsAPI';
} else if(this.shouldUseXPath()) {
this.mode = 'xpath';
this.compileXPathMatcher();
}else{
this.mode = "normal";
this.compileMatcher();
}
},
shouldUseXPath: function() {
if(!Prototype.BrowserFeatures.XPath) return false;
var e = this.expression;
if(Prototype.Browser.WebKit &&
(e.include("-of-type") || e.include(":empty")))
return false;
if((/(\[[\w-]*?:|:checked)/).test(e))
return false;
return true;
},
shouldUseSelectorsAPI: function() {
if(!Prototype.BrowserFeatures.SelectorsAPI) return false;
if(!Selector._div) Selector._div = new Element('div');
try {
Selector._div.querySelector(this.expression);
}catch(e) {
return false;
}
return true;
},
compileMatcher: function() {
var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
c = Selector.criteria, le, p, m;
if(Selector._cache[e]) {
this.matcher = Selector._cache[e];
return;
}
this.matcher = ["this.matcher = function(root) {",
"var r = root, h = Selector.handlers, c = false, n;"];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
p = ps[i];
if(m = e.match(p)) {
this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
new Template(c[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join('\n'));
Selector._cache[this.expression] = this.matcher;
},
compileXPathMatcher: function() {
var e = this.expression, ps = Selector.patterns,
x = Selector.xpath, le, m;
if(Selector._cache[e]) {
this.xpath = Selector._cache[e]; return;
}
this.matcher = ['.//*'];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
if(m = e.match(ps[i])) {
this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
new Template(x[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
}
}
this.xpath = this.matcher.join('');
Selector._cache[this.expression] = this.xpath;
},
findElements: function(root) {
root = root || document;
var e = this.expression, results;
switch (this.mode) {
case 'selectorsAPI':
if(root !== document) {
var oldId = root.id, id = $(root).identify();
e = "#" + id + " " + e;
}
results = $A(root.querySelectorAll(e)).map(Element.extend);
root.id = oldId;
return results;
case 'xpath':
return document._getElementsByXPath(this.xpath, root);
default:
return this.matcher(root);
}
},
match: function(element) {
this.tokens = [];
var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
var le, p, m;
while (e && le !== e && (/\S/).test(e)) {
le = e;
for (var i in ps) {
p = ps[i];
if(m = e.match(p)) {
if(as[i]) {
this.tokens.push([i, Object.clone(m)]);
e = e.replace(m[0], '');
}else{
return this.findElements(document).include(element);
}
}
}
}
var match = true, name, matches;
for (var i = 0, token; token = this.tokens[i]; i++) {
name = token[0], matches = token[1];
if(!Selector.assertions[name](element, matches)) {
match = false; break;
}
}
return match;
},
toString: function() {
return this.expression;
},
inspect: function() {
return "#<Selector:" + this.expression.inspect() + ">";
}
});
Object.extend(Selector, {
_cache: { },
xpath: {
descendant:   "//*",
child:        "/*",
adjacent:     "/following-sibling::*[1]",
laterSibling: '/following-sibling::*',
tagName:      function(m) {
if(m[1] == '*') return '';
return "[local-name()='" + m[1].toLowerCase() +
"' or local-name()='" + m[1].toUpperCase() + "']";
},
className:    "[contains(concat(' ', @class, ' '), ' #{1} ')]",
id:           "[@id='#{1}']",
attrPresence: function(m) {
m[1] = m[1].toLowerCase();
return new Template("[@#{1}]").evaluate(m);
},
attr: function(m) {
m[1] = m[1].toLowerCase();
m[3] = m[5] || m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},
pseudo: function(m) {
var h = Selector.xpath.pseudos[m[1]];
if(!h) return '';
if(Object.isFunction(h)) return h(m);
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},
operators: {
'=':  "[@#{1}='#{3}']",
'!=': "[@#{1}!='#{3}']",
'^=': "[starts-with(@#{1}, '#{3}')]",
'$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
'*=': "[contains(@#{1}, '#{3}')]",
'~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
'|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
},
pseudos: {
'first-child': '[not(preceding-sibling::*)]',
'last-child':  '[not(following-sibling::*)]',
'only-child':  '[not(preceding-sibling::* or following-sibling::*)]',
'empty':       "[count(*) = 0 and (count(text()) = 0)]",
'checked':     "[@checked]",
'disabled':    "[(@disabled) and (@type!='hidden')]",
'enabled':     "[not(@disabled) and (@type!='hidden')]",
'not': function(m) {
var e = m[6], p = Selector.patterns,
x = Selector.xpath, le, v;
var exclusion = [];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i in p) {
if(m = e.match(p[i])) {
v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
exclusion.push("(" + v.substring(1, v.length - 1) + ")");
e = e.replace(m[0], '');
break;
}
}
}
return "[not(" + exclusion.join(" and ") + ")]";
},
'nth-child':      function(m) {
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
},
'nth-last-child': function(m) {
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
},
'nth-of-type':    function(m) {
return Selector.xpath.pseudos.nth("position() ", m);
},
'nth-last-of-type': function(m) {
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
},
'first-of-type':  function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
},
'last-of-type':   function(m) {
m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
},
'only-of-type':   function(m) {
var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
},
nth: function(fragment, m) {
var mm, formula = m[6], predicate;
if(formula == 'even') formula = '2n+0';
if(formula == 'odd')  formula = '2n+1';
if(mm = formula.match(/^(\d+)$/)) // digit only
return '[' + fragment + "= " + mm[1] + ']';
if(mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if(mm[1] == "-") mm[1] = -1;
var a = mm[1] ? Number(mm[1]) : 1;
var b = mm[2] ? Number(mm[2]) : 0;
predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({
fragment: fragment, a: a, b: b });
}
}
}
},
criteria: {
tagName:      'n = h.tagName(n, r, "#{1}", c);      c = false;',
className:    'n = h.className(n, r, "#{1}", c);    c = false;',
id:           'n = h.id(n, r, "#{1}", c);           c = false;',
attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
attr: function(m) {
m[3] = (m[5] || m[6]);
return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
},
pseudo: function(m) {
if(m[6]) m[6] = m[6].replace(/"/g, '\\"');
return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
},
descendant:   'c = "descendant";',
child:        'c = "child";',
adjacent:     'c = "adjacent";',
laterSibling: 'c = "laterSibling";'
},
patterns: {
laterSibling: /^\s*~\s*/,
child:        /^\s*>\s*/,
adjacent:     /^\s*\+\s*/,
descendant:   /^\s/,
tagName:      /^\s*(\*|[\w\-]+)(\b|$)?/,
id:           /^#([\w\-\*]+)(\b|$)/,
className:    /^\.([\w\-\*]+)(\b|$)/,
pseudo:
/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
attr:         /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
},
assertions: {
tagName: function(element, matches) {
return matches[1].toUpperCase() == element.tagName.toUpperCase();
},
className: function(element, matches) {
return Element.hasClassName(element, matches[1]);
},
id: function(element, matches) {
return element.id === matches[1];
},
attrPresence: function(element, matches) {
return Element.hasAttribute(element, matches[1]);
},
attr: function(element, matches) {
var nodeValue = Element.readAttribute(element, matches[1]);
return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
}
},
handlers: {
concat: function(a, b) {
for (var i = 0, node; node = b[i]; i++)
a.push(node);
return a;
},
mark: function(nodes) {
var _true = Prototype.emptyFunction;
for (var i = 0, node; node = nodes[i]; i++)
node._countedByPrototype = _true;
return nodes;
},
unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node._countedByPrototype = undefined;
return nodes;
},
index: function(parentNode, reverse, ofType) {
parentNode._countedByPrototype = Prototype.emptyFunction;
if(reverse) {
for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
var node = nodes[i];
if(node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
}
}else{
for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
if(node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
}
},
unique: function(nodes) {
if(nodes.length == 0) return nodes;
var results = [], n;
for (var i = 0, l = nodes.length; i < l; i++)
if(!(n = nodes[i])._countedByPrototype) {
n._countedByPrototype = Prototype.emptyFunction;
results.push(Element.extend(n));
}
return Selector.handlers.unmark(results);
},
descendant: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName('*'));
return results;
},
child: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++) {
for (var j = 0, child; child = node.childNodes[j]; j++)
if(child.nodeType == 1 && child.tagName != '!') results.push(child);
}
return results;
},
adjacent: function(nodes) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
var next = this.nextElementSibling(node);
if(next) results.push(next);
}
return results;
},
laterSibling: function(nodes) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
h.concat(results, Element.nextSiblings(node));
return results;
},
nextElementSibling: function(node) {
while (node = node.nextSibling)
if(node.nodeType == 1) return node;
return null;
},
previousElementSibling: function(node) {
while (node = node.previousSibling)
if(node.nodeType == 1) return node;
return null;
},
tagName: function(nodes, root, tagName, combinator) {
var uTagName = tagName.toUpperCase();
var results = [], h = Selector.handlers;
if(nodes) {
if(combinator) {
if(combinator == "descendant") {
for (var i = 0, node; node = nodes[i]; i++)
h.concat(results, node.getElementsByTagName(tagName));
return results;
} else nodes = this[combinator](nodes);
if(tagName == "*") return nodes;
}
for (var i = 0, node; node = nodes[i]; i++)
if(node.tagName.toUpperCase() === uTagName) results.push(node);
return results;
} else return root.getElementsByTagName(tagName);
},
id: function(nodes, root, id, combinator) {
var targetNode = $(id), h = Selector.handlers;
if(!targetNode) return [];
if(!nodes && root == document) return [targetNode];
if(nodes) {
if(combinator) {
if(combinator == 'child') {
for (var i = 0, node; node = nodes[i]; i++)
if(targetNode.parentNode == node) return [targetNode];
} else if(combinator == 'descendant') {
for (var i = 0, node; node = nodes[i]; i++)
if(Element.descendantOf(targetNode, node)) return [targetNode];
} else if(combinator == 'adjacent') {
for (var i = 0, node; node = nodes[i]; i++)
if(Selector.handlers.previousElementSibling(targetNode) == node)
return [targetNode];
} else nodes = h[combinator](nodes);
}
for (var i = 0, node; node = nodes[i]; i++)
if(node == targetNode) return [targetNode];
return [];
}
return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
},
className: function(nodes, root, className, combinator) {
if(nodes && combinator) nodes = this[combinator](nodes);
return Selector.handlers.byClassName(nodes, root, className);
},
byClassName: function(nodes, root, className) {
if(!nodes) nodes = Selector.handlers.descendant([root]);
var needle = ' ' + className + ' ';
for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
nodeClassName = node.className;
if(nodeClassName.length == 0) continue;
if(nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
results.push(node);
}
return results;
},
attrPresence: function(nodes, root, attr, combinator) {
if(!nodes) nodes = root.getElementsByTagName("*");
if(nodes && combinator) nodes = this[combinator](nodes);
var results = [];
for (var i = 0, node; node = nodes[i]; i++)
if(Element.hasAttribute(node, attr)) results.push(node);
return results;
},
attr: function(nodes, root, attr, value, operator, combinator) {
if(!nodes) nodes = root.getElementsByTagName("*");
if(nodes && combinator) nodes = this[combinator](nodes);
var handler = Selector.operators[operator], results = [];
for (var i = 0, node; node = nodes[i]; i++) {
var nodeValue = Element.readAttribute(node, attr);
if(nodeValue === null) continue;
if(handler(nodeValue, value)) results.push(node);
}
return results;
},
pseudo: function(nodes, name, value, root, combinator) {
if(nodes && combinator) nodes = this[combinator](nodes);
if(!nodes) nodes = root.getElementsByTagName("*");
return Selector.pseudos[name](nodes, value, root);
}
},
pseudos: {
'first-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if(Selector.handlers.previousElementSibling(node)) continue;
results.push(node);
}
return results;
},
'last-child': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if(Selector.handlers.nextElementSibling(node)) continue;
results.push(node);
}
return results;
},
'only-child': function(nodes, value, root) {
var h = Selector.handlers;
for (var i = 0, results = [], node; node = nodes[i]; i++)
if(!h.previousElementSibling(node) && !h.nextElementSibling(node))
results.push(node);
return results;
},
'nth-child':        function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root);
},
'nth-last-child':   function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true);
},
'nth-of-type':      function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, false, true);
},
'nth-last-of-type': function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, formula, root, true, true);
},
'first-of-type':    function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, false, true);
},
'last-of-type':     function(nodes, formula, root) {
return Selector.pseudos.nth(nodes, "1", root, true, true);
},
'only-of-type':     function(nodes, formula, root) {
var p = Selector.pseudos;
return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
},
getIndices: function(a, b, total) {
if(a == 0) return b > 0 ? [b] : [];
return $R(1, total).inject([], function(memo, i) {
if(0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
return memo;
});
},
nth: function(nodes, formula, root, reverse, ofType) {
if(nodes.length == 0) return [];
if(formula == 'even') formula = '2n+0';
if(formula == 'odd')  formula = '2n+1';
var h = Selector.handlers, results = [], indexed = [], m;
h.mark(nodes);
for (var i = 0, node; node = nodes[i]; i++) {
if(!node.parentNode._countedByPrototype) {
h.index(node.parentNode, reverse, ofType);
indexed.push(node.parentNode);
}
}
if(formula.match(/^\d+$/)) { // just a number
formula = Number(formula);
for (var i = 0, node; node = nodes[i]; i++)
if(node.nodeIndex == formula) results.push(node);
} else if(m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
if(m[1] == "-") m[1] = -1;
var a = m[1] ? Number(m[1]) : 1;
var b = m[2] ? Number(m[2]) : 0;
var indices = Selector.pseudos.getIndices(a, b, nodes.length);
for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
for (var j = 0; j < l; j++)
if(node.nodeIndex == indices[j]) results.push(node);
}
}
h.unmark(nodes);
h.unmark(indexed);
return results;
},
'empty': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
if(node.tagName == '!' || node.firstChild) continue;
results.push(node);
}
return results;
},
'not': function(nodes, selector, root) {
var h = Selector.handlers, selectorType, m;
var exclusions = new Selector(selector).findElements(root);
h.mark(exclusions);
for (var i = 0, results = [], node; node = nodes[i]; i++)
if(!node._countedByPrototype) results.push(node);
h.unmark(exclusions);
return results;
},
'enabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if(!node.disabled && (!node.type || node.type !== 'hidden'))
results.push(node);
return results;
},
'disabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if(node.disabled) results.push(node);
return results;
},
'checked': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
if(node.checked) results.push(node);
return results;
}
},
operators: {
'=':  function(nv, v) { return nv == v; },
'!=': function(nv, v) { return nv != v; },
'^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
'$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
'*=': function(nv, v) { return nv == v || nv && nv.include(v); },
'$=': function(nv, v) { return nv.endsWith(v); },
'*=': function(nv, v) { return nv.include(v); },
'~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
'|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
'-').include('-' + (v || "").toUpperCase() + '-'); }
},
split: function(expression) {
var expressions = [];
expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
expressions.push(m[1].strip());
});
return expressions;
},
matchElements: function(elements, expression) {
var matches = $$(expression), h = Selector.handlers;
h.mark(matches);
for (var i = 0, results = [], element; element = elements[i]; i++)
if(element._countedByPrototype) results.push(element);
h.unmark(matches);
return results;
},
findElement: function(elements, expression, index) {
if(Object.isNumber(expression)) {
index = expression; expression = false;
}
return Selector.matchElements(elements, expression || '*')[index || 0];
},
findChildElements: function(element, expressions) {
expressions = Selector.split(expressions.join(','));
var results = [], h = Selector.handlers;
for (var i = 0, l = expressions.length, selector; i < l; i++) {
selector = new Selector(expressions[i].strip());
h.concat(results, selector.findElements(element));
}
return (l > 1) ? h.unique(results) : results;
}
});
if(Prototype.Browser.IE) {
Object.extend(Selector.handlers, {
concat: function(a, b) {
for (var i = 0, node; node = b[i]; i++)
if(node.tagName !== "!") a.push(node);
return a;
},
unmark: function(nodes) {
for (var i = 0, node; node = nodes[i]; i++)
node.removeAttribute('_countedByPrototype');
return nodes;
}
});
}
function $$() {
return Selector.findChildElements(document, $A(arguments));
}
var Form = {
reset: function(form) {
$(form).reset();
return form;
},
serializeElements: function(elements, options) {
if(typeof options != 'object') options = { hash: !!options };
else if(Object.isUndefined(options.hash)) options.hash = true;
var key, value, submitted = false, submit = options.submit;
var data = elements.inject({ }, function(result, element) {
if(!element.disabled && element.name) {
key = element.name; value = $(element).getValue();
if(value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
submit !== false && (!submit || key == submit) && (submitted = true)))) {
if(key in result) {
if(!Object.isArray(result[key])) result[key] = [result[key]];
result[key].push(value);
}
else result[key] = value;
}
}
return result;
});
return options.hash ? data : Object.toQueryString(data);
}
};
Form.Methods = {
serialize: function(form, options) {
return Form.serializeElements(Form.getElements(form), options);
},
getElements: function(form) {
return $A($(form).getElementsByTagName('*')).inject([],
function(elements, child) {
if(Form.Element.Serializers[child.tagName.toLowerCase()])
elements.push(Element.extend(child));
return elements;
}
);
},
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
if(!typeName && !name) return $A(inputs).map(Element.extend);
for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
var input = inputs[i];
if((typeName && input.type != typeName) || (name && input.name != name))
continue;
matchingInputs.push(Element.extend(input));
}
return matchingInputs;
},
disable: function(form) {
form = $(form);
Form.getElements(form).invoke('disable');
return form;
},
enable: function(form) {
form = $(form);
Form.getElements(form).invoke('enable');
return form;
},
findFirstElement: function(form) {
var elements = $(form).getElements().findAll(function(element) {
return 'hidden' != element.type && !element.disabled;
});
var firstByIndex = elements.findAll(function(element) {
return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
}).sortBy(function(element) { return element.tabIndex }).first();
return firstByIndex ? firstByIndex : elements.find(function(element) {
return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
});
},
focusFirstElement: function(form) {
form = $(form);
form.findFirstElement().activate();
return form;
},
request: function(form, options) {
form = $(form), options = Object.clone(options || { });
var params = options.parameters, action = form.readAttribute('action') || '';
if(action.blank()) action = window.location.href;
options.parameters = form.serialize(true);
if(params) {
if(Object.isString(params)) params = params.toQueryParams();
Object.extend(options.parameters, params);
}
if(form.hasAttribute('method') && !options.method)
options.method = form.method;
return new Ajax.Request(action, options);
}
};
Form.Element = {
focus: function(element) {
$(element).focus();
return element;
},
select: function(element) {
$(element).select();
return element;
}
};
Form.Element.Methods = {
serialize: function(element) {
element = $(element);
if(!element.disabled && element.name) {
var value = element.getValue();
if(value != undefined) {
var pair = { };
pair[element.name] = value;
return Object.toQueryString(pair);
}
}
return '';
},
getValue: function(element) {
element = $(element);
if(element) {
var method = element.tagName;
if(method) {
method = method.toLowerCase()
}
return Form.Element.Serializers[method](element);
}
return '';
},
setValue: function(element, value) {
element = $(element);
var method = element.tagName;
if(method) {
method = method.toLowerCase()
}
Form.Element.Serializers[method](element, value);
return element;
},
clear: function(element) {
$(element).value = '';
return element;
},
present: function(element) {
return $(element).value != '';
},
activate: function(element) {
element = $(element);
try {
element.focus();
if(element.select && (element.tagName.toLowerCase() != 'input' ||
!['button', 'reset', 'submit'].include(element.type)))
element.select();
}catch (e) { }
return element;
},
disable: function(element) {
element = $(element);
element.disabled = true;
return element;
},
enable: function(element) {
element = $(element);
element.disabled = false;
return element;
}
};
var Field = Form.Element;
var $F = Form.Element.Methods.getValue;
Form.Element.Serializers = {
input: function(element, value) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element, value);
default:
return Form.Element.Serializers.textarea(element, value);
}
},
inputSelector: function(element, value) {
if(Object.isUndefined(value)) return element.checked ? element.value : null;
else element.checked = !!value;
},
textarea: function(element, value) {
if(Object.isUndefined(value)) return element.value;
else element.value = value;
},
select: function(element, value) {
if(Object.isUndefined(value))
return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
else {
var opt, currentValue, single = !Object.isArray(value);
for (var i = 0, length = element.length; i < length; i++) {
opt = element.options[i];
currentValue = this.optionValue(opt);
if(single) {
if(currentValue == value) {
opt.selected = true;
return;
}
}
else opt.selected = value.include(currentValue);
}
}
},
selectOne: function(element) {
var index = element.selectedIndex;
return index >= 0 ? this.optionValue(element.options[index]) : null;
},
selectMany: function(element) {
var values, length = element.length;
if(!length) return null;
for (var i = 0, values = []; i < length; i++) {
var opt = element.options[i];
if(opt.selected) values.push(this.optionValue(opt));
}
return values;
},
optionValue: function(opt) {
return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
}
};
Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
initialize: function($super, element, frequency, callback) {
$super(callback, frequency);
this.element   = $(element);
this.lastValue = this.getValue();
},
execute: function() {
var value = this.getValue();
if(Object.isString(this.lastValue) && Object.isString(value) ?
this.lastValue != value : String(this.lastValue) != String(value)) {
this.callback(this.element, value);
this.lastValue = value;
}
}
});
Form.Element.Observer = Class.create(Abstract.TimedObserver, {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.Observer = Class.create(Abstract.TimedObserver, {
getValue: function() {
return Form.serialize(this.element);
}
});
Abstract.EventObserver = Class.create({
initialize: function(element, callback) {
this.element  = $(element);
this.callback = callback;
this.lastValue = this.getValue();
if(this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},
onElementEvent: function() {
var value = this.getValue();
if(this.lastValue != value) {
this.callback(this.element, value);
this.lastValue = value;
}
},
registerFormCallbacks: function() {
Form.getElements(this.element).each(this.registerCallback, this);
},
registerCallback: function(element) {
if(element.type) {
switch (element.type.toLowerCase()) {
case 'checkbox':
case 'radio':
Event.observe(element, 'click', this.onElementEvent.bind(this));
break;
default:
Event.observe(element, 'change', this.onElementEvent.bind(this));
break;
}
}
}
});
Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function() {
return Form.Element.getValue(this.element);
}
});
Form.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function() {
return Form.serialize(this.element);
}
});
if(!window.Event) var Event = { };
Object.extend(Event, {
KEY_BACKSPACE: 8,
KEY_TAB:       9,
KEY_RETURN:   13,
KEY_ESC:      27,
KEY_LEFT:     37,
KEY_UP:       38,
KEY_RIGHT:    39,
KEY_DOWN:     40,
KEY_DELETE:   46,
KEY_HOME:     36,
KEY_END:      35,
KEY_PAGEUP:   33,
KEY_PAGEDOWN: 34,
KEY_INSERT:   45,
cache: { },
relatedTarget: function(event) {
var element;
switch(event.type) {
case 'mouseover': element = event.fromElement; break;
case 'mouseout':  element = event.toElement;   break;
default: return null;
}
return Element.extend(element);
}
});
Event.Methods = (function() {
var isButton;
if(Prototype.Browser.IE) {
var buttonMap = { 0: 1, 1: 4, 2: 2 };
isButton = function(event, code) {
return event.button == buttonMap[code];
};
} else if(Prototype.Browser.WebKit) {
isButton = function(event, code) {
switch (code) {
case 0: return event.which == 1 && !event.metaKey;
case 1: return event.which == 1 && event.metaKey;
default: return false;
}
};
}else{
isButton = function(event, code) {
return event.which ? (event.which === code + 1) : (event.button === code);
};
}
return {
isLeftClick:   function(event) { return isButton(event, 0) },
isMiddleClick: function(event) { return isButton(event, 1) },
isRightClick:  function(event) { return isButton(event, 2) },
element: function(event) {
event = Event.extend(event);
var node          = event.target,
type          = event.type,
currentTarget = event.currentTarget;
if(currentTarget && currentTarget.tagName) {
if(type === 'load' || type === 'error' ||
(type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
&& currentTarget.type === 'radio'))
node = currentTarget;
}
if(node.nodeType == Node.TEXT_NODE) node = node.parentNode;
return Element.extend(node);
},
findElement: function(event, expression) {
var element = Event.element(event);
if(!expression) return element;
var elements = [element].concat(element.ancestors());
return Selector.findElement(elements, expression, 0);
},
pointer: function(event) {
var docElement = document.documentElement,
body = document.body || { scrollLeft: 0, scrollTop: 0 };
return {
x: event.pageX || (event.clientX +
(docElement.scrollLeft || body.scrollLeft) -
(docElement.clientLeft || 0)),
y: event.pageY || (event.clientY +
(docElement.scrollTop || body.scrollTop) -
(docElement.clientTop || 0))
};
},
pointerX: function(event) { return Event.pointer(event).x },
pointerY: function(event) { return Event.pointer(event).y },
stop: function(event) {
Event.extend(event);
event.preventDefault();
event.stopPropagation();
event.stopped = true;
}
};
})();
Event.extend = (function() {
var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
m[name] = Event.Methods[name].methodize();
return m;
});
if(Prototype.Browser.IE) {
Object.extend(methods, {
stopPropagation: function() { this.cancelBubble = true },
preventDefault:  function() { this.returnValue = false },
inspect: function() { return "[object Event]" }
});
return function(event) {
if(!event) return false;
if(event._extendedByPrototype) return event;
event._extendedByPrototype = Prototype.emptyFunction;
var pointer = Event.pointer(event);
Object.extend(event, {
target: event.srcElement,
relatedTarget: Event.relatedTarget(event),
pageX:  pointer.x,
pageY:  pointer.y
});
return Object.extend(event, methods);
};
}else{
Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__'];
Object.extend(Event.prototype, methods);
return Prototype.K;
}
})();
Object.extend(Event, (function() {
var cache = Event.cache;
function getEventID(element) {
if(element._prototypeEventID) return element._prototypeEventID[0];
arguments.callee.id = arguments.callee.id || 1;
return element._prototypeEventID = [++arguments.callee.id];
}
function getDOMEventName(eventName) {
if(eventName && eventName.include(':')) return "dataavailable";
return eventName;
}
function getCacheForID(id) {
return cache[id] = cache[id] || { };
}
function getWrappersForEventName(id, eventName) {
var c = getCacheForID(id);
return c[eventName] = c[eventName] || [];
}
function createWrapper(element, eventName, handler) {
var id = getEventID(element);
var c = getWrappersForEventName(id, eventName);
if(c.pluck("handler").include(handler)) return false;
var wrapper = function(event) {
if(!Event || !Event.extend ||
(event.eventName && event.eventName != eventName))
return false;
Event.extend(event);
handler.call(element, event);
};
wrapper.handler = handler;
c.push(wrapper);
return wrapper;
}
function findWrapper(id, eventName, handler) {
var c = getWrappersForEventName(id, eventName);
return c.find(function(wrapper) { return wrapper.handler == handler });
}
function destroyWrapper(id, eventName, handler) {
var c = getCacheForID(id);
if(!c[eventName]) return false;
c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
}
function destroyCache() {
for (var id in cache)
for (var eventName in cache[id])
cache[id][eventName] = null;
}
if(window.attachEvent) {
window.attachEvent("onunload", destroyCache);
}
if(Prototype.Browser.WebKit) {
window.addEventListener('unload', Prototype.emptyFunction, false);
}
return {
observe: function(element, eventName, handler) {
element = $(element);
var name = getDOMEventName(eventName);
var wrapper = createWrapper(element, eventName, handler);
if(!wrapper) return element;
if(element.addEventListener) {
element.addEventListener(name, wrapper, false);
}else{
element.attachEvent("on" + name, wrapper);
}
return element;
},
stopObserving: function(element, eventName, handler) {
element = $(element);
var id = getEventID(element), name = getDOMEventName(eventName);
if(!handler && eventName) {
getWrappersForEventName(id, eventName).each(function(wrapper) {
element.stopObserving(eventName, wrapper.handler);
});
return element;
} else if(!eventName) {
Object.keys(getCacheForID(id)).each(function(eventName) {
element.stopObserving(eventName);
});
return element;
}
var wrapper = findWrapper(id, eventName, handler);
if(!wrapper) return element;
if(element.removeEventListener) {
element.removeEventListener(name, wrapper, false);
}else{
element.detachEvent("on" + name, wrapper);
}
destroyWrapper(id, eventName, handler);
return element;
},
fire: function(element, eventName, memo) {
element = $(element);
if(element == document && document.createEvent && !element.dispatchEvent)
element = document.documentElement;
var event;
if(document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent("dataavailable", true, true);
}else{
event = document.createEventObject();
event.eventType = "ondataavailable";
}
event.eventName = eventName;
event.memo = memo || { };
if(document.createEvent) {
element.dispatchEvent(event);
}else{
element.fireEvent(event.eventType, event);
}
return Event.extend(event);
}
};
})());
Object.extend(Event, Event.Methods);
Element.addMethods({
fire:          Event.fire,
observe:       Event.observe,
stopObserving: Event.stopObserving
});
Object.extend(document, {
fire:          Element.Methods.fire.methodize(),
observe:       Element.Methods.observe.methodize(),
stopObserving: Element.Methods.stopObserving.methodize(),
loaded:        false
});
(function() {
var timer;
function fireContentLoadedEvent() {
if(document.loaded) return;
if(timer) window.clearInterval(timer);
document.fire("dom:loaded");
document.loaded = true;
}
if(document.addEventListener) {
if(Prototype.Browser.WebKit) {
timer = window.setInterval(function() {
if(/loaded|complete/.test(document.readyState))
fireContentLoadedEvent();
}, 0);
Event.observe(window, "load", fireContentLoadedEvent);
}else{
document.addEventListener("DOMContentLoaded",
fireContentLoadedEvent, false);
}
}else{
document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
$("__onDOMContentLoaded").onreadystatechange = function() {
if(this.readyState == "complete") {
this.onreadystatechange = null;
fireContentLoadedEvent();
}
};
}
})();
Hash.toQueryString = Object.toQueryString;
var Toggle = { display: Element.toggle };
Element.Methods.childOf = Element.Methods.descendantOf;
var Insertion = {
Before: function(element, content) {
return Element.insert(element, {before:content});
},
Top: function(element, content) {
return Element.insert(element, {top:content});
},
Bottom: function(element, content) {
return Element.insert(element, {bottom:content});
},
After: function(element, content) {
return Element.insert(element, {after:content});
}
};
var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
var Position = {
includeScrollOffsets: false,
prepare: function() {
this.deltaX =  window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY =  window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
},
within: function(element, x, y) {
if(this.includeScrollOffsets)
return this.withinIncludingScrolloffsets(element, x, y);
this.xcomp = x;
this.ycomp = y;
this.offset = Element.cumulativeOffset(element);
return (y >= this.offset[1] &&
y <  this.offset[1] + element.offsetHeight &&
x >= this.offset[0] &&
x <  this.offset[0] + element.offsetWidth);
},
withinIncludingScrolloffsets: function(element, x, y) {
var offsetcache = Element.cumulativeScrollOffset(element);
this.xcomp = x + offsetcache[0] - this.deltaX;
this.ycomp = y + offsetcache[1] - this.deltaY;
this.offset = Element.cumulativeOffset(element);
return (this.ycomp >= this.offset[1] &&
this.ycomp <  this.offset[1] + element.offsetHeight &&
this.xcomp >= this.offset[0] &&
this.xcomp <  this.offset[0] + element.offsetWidth);
},
overlap: function(mode, element) {
if(!mode) return 0;
if(mode == 'vertical')
return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
element.offsetHeight;
if(mode == 'horizontal')
return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
element.offsetWidth;
},
cumulativeOffset: Element.Methods.cumulativeOffset,
positionedOffset: Element.Methods.positionedOffset,
absolutize: function(element) {
Position.prepare();
return Element.absolutize(element);
},
relativize: function(element) {
Position.prepare();
return Element.relativize(element);
},
realOffset: Element.Methods.cumulativeScrollOffset,
offsetParent: Element.Methods.getOffsetParent,
page: Element.Methods.viewportOffset,
clone: function(source, target, options) {
options = options || { };
return Element.clonePosition(target, source, options);
}
};
if(!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
function iter(name) {
return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
}
instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
function(element, className) {
className = className.toString().strip();
var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
} : function(element, className) {
className = className.toString().strip();
var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
if(!classNames && !className) return elements;
var nodes = $(element).getElementsByTagName('*');
className = ' ' + className + ' ';
for (var i = 0, child, cn; child = nodes[i]; i++) {
if(child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
(classNames && classNames.all(function(name) {
return !name.toString().blank() && cn.include(' ' + name + ' ');
}))))
elements.push(Element.extend(child));
}
return elements;
};
return function(className, parentElement) {
return $(parentElement || document.body).getElementsByClassName(className);
};
}(Element.Methods);
Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
initialize: function(element) {
this.element = $(element);
},
_each: function(iterator) {
this.element.className.split(/\s+/).select(function(name) {
return name.length > 0;
})._each(iterator);
},
set: function(className) {
this.element.className = className;
},
add: function(classNameToAdd) {
if(this.include(classNameToAdd)) return;
this.set($A(this).concat(classNameToAdd).join(' '));
},
remove: function(classNameToRemove) {
if(!this.include(classNameToRemove)) return;
this.set($A(this).without(classNameToRemove).join(' '));
},
toString: function() {
return $A(this).join(' ');
}
};
Object.extend(Element.ClassNames.prototype, Enumerable);
Element.addMethods();
String.prototype.parseColor = function() {
var color = '#';
if(this.slice(0,4) == 'rgb(') {
var cols = this.slice(4,this.length-1).split(',');
var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
}else{
if(this.slice(0,1) == '#') {
if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
if(this.length==7) color = this.toLowerCase();
}
}
return (color.length==7 ? color : (arguments[0] || this));
};
Element.collectTextNodes = function(element) {
return $A($(element).childNodes).collect( function(node) {
return (node.nodeType==3 ? node.nodeValue :
(node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
}).flatten().join('');
};
Element.collectTextNodesIgnoreClass = function(element, className) {
return $A($(element).childNodes).collect( function(node) {
return (node.nodeType==3 ? node.nodeValue :
((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
Element.collectTextNodesIgnoreClass(node, className) : ''));
}).flatten().join('');
};
Element.setContentZoom = function(element, percent) {
element = $(element);
element.setStyle({fontSize: (percent/100) + 'em'});
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
return element;
};
Element.getInlineOpacity = function(element){
return $(element).style.opacity || '';
};
Element.forceRerendering = function(element) {
try {
element = $(element);
var n = document.createTextNode(' ');
element.appendChild(n);
element.removeChild(n);
}catch(e) { }
};
var Effect = {
_elementDoesNotExistError: {
name: 'ElementDoesNotExistError',
message: 'The specified DOM element does not exist, but is required for this effect to operate'
},
Transitions: {
linear: Prototype.K,
sinoidal: function(pos) {
return (-Math.cos(pos*Math.PI)/2) + .5;
},
reverse: function(pos) {
return 1-pos;
},
flicker: function(pos) {
var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;
return pos > 1 ? 1 : pos;
},
wobble: function(pos) {
return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5;
},
pulse: function(pos, pulses) {
return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5;
},
spring: function(pos) {
return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
},
none: function(pos) {
return 0;
},
full: function(pos) {
return 1;
}
},
DefaultOptions: {
duration:   1.0,   // seconds
fps:        100,   // 100= assume 66fps max.
sync:       false, // true for combining
from:       0.0,
to:         1.0,
delay:      0.0,
queue:      'parallel'
},
tagifyText: function(element) {
var tagifyStyle = 'position:relative';
if(Prototype.Browser.IE) tagifyStyle += ';zoom:1';
element = $(element);
$A(element.childNodes).each( function(child) {
if(child.nodeType==3) {
child.nodeValue.toArray().each( function(character) {
element.insertBefore(
new Element('span', {style: tagifyStyle}).update(
character == ' ' ? String.fromCharCode(160) : character),
child);
});
Element.remove(child);
}
});
},
multiple: function(element, effect) {
var elements;
if(((typeof element == 'object') ||
Object.isFunction(element)) &&
(element.length))
elements = element;
else
elements = $(element).childNodes;
var options = Object.extend({
speed: 0.1,
delay: 0.0
}, arguments[2] || { });
var masterDelay = options.delay;
$A(elements).each( function(element, index) {
new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
});
},
PAIRS: {
'slide':  ['SlideDown','SlideUp'],
'blind':  ['BlindDown','BlindUp'],
'appear': ['Appear','Fade']
},
toggle: function(element, effect) {
element = $(element);
effect = (effect || 'appear').toLowerCase();
var options = Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, arguments[2] || { });
Effect[element.visible() ?
Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
}
};
Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
Effect.ScopedQueue = Class.create(Enumerable, {
initialize: function() {
this.effects  = [];
this.interval = null;
},
_each: function(iterator) {
this.effects._each(iterator);
},
add: function(effect) {
var timestamp = new Date().getTime();
var position = Object.isString(effect.options.queue) ?
effect.options.queue : effect.options.queue.position;
switch(position) {
case 'front':
this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
e.startOn  += effect.finishOn;
e.finishOn += effect.finishOn;
});
break;
case 'with-last':
timestamp = this.effects.pluck('startOn').max() || timestamp;
break;
case 'end':
timestamp = this.effects.pluck('finishOn').max() || timestamp;
break;
}
effect.startOn  += timestamp;
effect.finishOn += timestamp;
if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
this.effects.push(effect);
if(!this.interval)
this.interval = setInterval(this.loop.bind(this), 15);
},
remove: function(effect) {
this.effects = this.effects.reject(function(e) { return e==effect });
if(this.effects.length == 0) {
clearInterval(this.interval);
this.interval = null;
}
},
loop: function() {
var timePos = new Date().getTime();
for(var i=0, len=this.effects.length;i<len;i++)
this.effects[i] && this.effects[i].loop(timePos);
}
});
Effect.Queues = {
instances: $H(),
get: function(queueName) {
if(!Object.isString(queueName)) return queueName;
return this.instances.get(queueName) ||
this.instances.set(queueName, new Effect.ScopedQueue());
}
};
Effect.Queue = Effect.Queues.get('global');
Effect.Base = Class.create({
position: null,
start: function(options) {
function codeForEvent(options,eventName){
return (
(options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
(options[eventName] ? 'this.options.'+eventName+'(this);' : '')
);
}
if(options && options.transition === false) options.transition = Effect.Transitions.linear;
this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
this.currentFrame = 0;
this.state        = 'idle';
this.startOn      = this.options.delay*1000;
this.finishOn     = this.startOn+(this.options.duration*1000);
this.fromToDelta  = this.options.to-this.options.from;
this.totalTime    = this.finishOn-this.startOn;
this.totalFrames  = this.options.fps*this.options.duration;
this.render = (function() {
function dispatch(effect, eventName) {
if(effect.options[eventName + 'Internal'])
effect.options[eventName + 'Internal'](effect);
if(effect.options[eventName])
effect.options[eventName](effect);
}
return function(pos) {
if(this.state === "idle") {
this.state = "running";
dispatch(this, 'beforeSetup');
if(this.setup) this.setup();
dispatch(this, 'afterSetup');
}
if(this.state === "running") {
pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from;
this.position = pos;
dispatch(this, 'beforeUpdate');
if(this.update) this.update(pos);
dispatch(this, 'afterUpdate');
}
};
})();
this.event('beforeStart');
if(!this.options.sync)
Effect.Queues.get(Object.isString(this.options.queue) ?
'global' : this.options.queue.scope).add(this);
},
loop: function(timePos) {
if(timePos >= this.startOn) {
if(timePos >= this.finishOn) {
this.render(1.0);
this.cancel();
this.event('beforeFinish');
if(this.finish) this.finish();
this.event('afterFinish');
return;
}
var pos   = (timePos - this.startOn) / this.totalTime,
frame = (pos * this.totalFrames).round();
if(frame > this.currentFrame) {
this.render(pos);
this.currentFrame = frame;
}
}
},
cancel: function() {
if(!this.options.sync)
Effect.Queues.get(Object.isString(this.options.queue) ?
'global' : this.options.queue.scope).remove(this);
this.state = 'finished';
},
event: function(eventName) {
if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
if(this.options[eventName]) this.options[eventName](this);
},
inspect: function() {
var data = $H();
for(property in this)
if(!Object.isFunction(this[property])) data.set(property, this[property]);
return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
}
});
Effect.Parallel = Class.create(Effect.Base, {
initialize: function(effects) {
this.effects = effects || [];
this.start(arguments[1]);
},
update: function(position) {
this.effects.invoke('render', position);
},
finish: function(position) {
this.effects.each( function(effect) {
effect.render(1.0);
effect.cancel();
effect.event('beforeFinish');
if(effect.finish) effect.finish(position);
effect.event('afterFinish');
});
}
});
Effect.Tween = Class.create(Effect.Base, {
initialize: function(object, from, to) {
object = Object.isString(object) ? $(object) : object;
var args = $A(arguments), method = args.last(),
options = args.length == 5 ? args[3] : null;
this.method = Object.isFunction(method) ? method.bind(object) :
Object.isFunction(object[method]) ? object[method].bind(object) :
function(value) { object[method] = value };
this.start(Object.extend({ from: from, to: to }, options || { }));
},
update: function(position) {
this.method(position);
}
});
Effect.Event = Class.create(Effect.Base, {
initialize: function() {
this.start(Object.extend({ duration: 0 }, arguments[0] || { }));
},
update: Prototype.emptyFunction
});
Effect.Opacity = Class.create(Effect.Base, {
initialize: function(element) {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
var options = Object.extend({
from: this.element.getOpacity() || 0.0,
to:   1.0
}, arguments[1] || { });
this.start(options);
},
update: function(position) {
this.element.setOpacity(position);
}
});
Effect.Move = Class.create(Effect.Base, {
initialize: function(element) {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
var options = Object.extend({
x:    0,
y:    0,
mode: 'relative'
}, arguments[1] || { });
this.start(options);
},
setup: function() {
this.element.makePositioned();
this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');
if(this.options.mode == 'absolute') {
this.options.x = this.options.x - this.originalLeft;
this.options.y = this.options.y - this.originalTop;
}
},
update: function(position) {
this.element.setStyle({
left: (this.options.x  * position + this.originalLeft).round() + 'px',
top:  (this.options.y  * position + this.originalTop).round()  + 'px'
});
}
});
Effect.MoveBy = function(element, toTop, toLeft) {
return new Effect.Move(element,
Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
};
Effect.Scale = Class.create(Effect.Base, {
initialize: function(element, percent) {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
var options = Object.extend({
scaleX: true,
scaleY: true,
scaleContent: true,
scaleFromCenter: false,
scaleMode: 'box',        // 'box' or 'contents' or { } with provided values
scaleFrom: 100.0,
scaleTo:   percent
}, arguments[2] || { });
this.start(options);
},
setup: function() {
this.restoreAfterFinish = this.options.restoreAfterFinish || false;
this.elementPositioning = this.element.getStyle('position');
this.originalStyle = { };
['top','left','width','height','fontSize'].each( function(k) {
this.originalStyle[k] = this.element.style[k];
}.bind(this));
this.originalTop  = this.element.offsetTop;
this.originalLeft = this.element.offsetLeft;
var fontSize = this.element.getStyle('font-size') || '100%';
['em','px','%','pt'].each( function(fontSizeType) {
if(fontSize.indexOf(fontSizeType)>0) {
this.fontSize     = parseFloat(fontSize);
this.fontSizeType = fontSizeType;
}
}.bind(this));
this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
this.dims = null;
if(this.options.scaleMode=='box')
this.dims = [this.element.offsetHeight, this.element.offsetWidth];
if(/^content/.test(this.options.scaleMode))
this.dims = [this.element.scrollHeight, this.element.scrollWidth];
if(!this.dims)
this.dims = [this.options.scaleMode.originalHeight,
this.options.scaleMode.originalWidth];
},
update: function(position) {
var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
if(this.options.scaleContent && this.fontSize)
this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
},
finish: function(position) {
if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
},
setDimensions: function(height, width) {
var d = { };
if(this.options.scaleX) d.width = width.round() + 'px';
if(this.options.scaleY) d.height = height.round() + 'px';
if(this.options.scaleFromCenter) {
var topd  = (height - this.dims[0])/2;
var leftd = (width  - this.dims[1])/2;
if(this.elementPositioning == 'absolute') {
if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
}else{
if(this.options.scaleY) d.top = -topd + 'px';
if(this.options.scaleX) d.left = -leftd + 'px';
}
}
this.element.setStyle(d);
}
});
Effect.Highlight = Class.create(Effect.Base, {
initialize: function(element) {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });
this.start(options);
},
setup: function() {
if(this.element.getStyle('display')=='none') { this.cancel(); return; }
this.oldStyle = { };
if(!this.options.keepBackgroundImage) {
this.oldStyle.backgroundImage = this.element.getStyle('background-image');
this.element.setStyle({backgroundImage: 'none'});
}
if(!this.options.endcolor)
this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
if(!this.options.restorecolor)
this.options.restorecolor = this.element.getStyle('background-color');
this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
},
update: function(position) {
this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });
},
finish: function() {
this.element.setStyle(Object.extend(this.oldStyle, {
backgroundColor: this.options.restorecolor
}));
}
});
Effect.ScrollTo = function(element) {
var options = arguments[1] || { },
scrollOffsets = document.viewport.getScrollOffsets(),
elementOffsets = $(element).cumulativeOffset();
if(options.offset) elementOffsets[1] += options.offset;
return new Effect.Tween(null,
scrollOffsets.top,
elementOffsets[1],
options,
function(p){ scrollTo(scrollOffsets.left, p.round()); }
);
};
Effect.Fade = function(element) {
element = $(element);
var oldOpacity = element.getInlineOpacity();
var options = Object.extend({
from: element.getOpacity() || 1.0,
to:   0.0,
afterFinishInternal: function(effect) {
if(effect.options.to!=0) return;
effect.element.hide().setStyle({opacity: oldOpacity});
}
}, arguments[1] || { });
return new Effect.Opacity(element,options);
};
Effect.Appear = function(element) {
element = $(element);
var options = Object.extend({
from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
to:   1.0,
afterFinishInternal: function(effect) {
effect.element.forceRerendering();
},
beforeSetup: function(effect) {
effect.element.setOpacity(effect.options.from).show();
}}, arguments[1] || { });
return new Effect.Opacity(element,options);
};
Effect.Puff = function(element) {
element = $(element);
var oldStyle = {
opacity: element.getInlineOpacity(),
position: element.getStyle('position'),
top:  element.style.top,
left: element.style.left,
width: element.style.width,
height: element.style.height
};
return new Effect.Parallel(
[ new Effect.Scale(element, 200,
{ sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
Object.extend({ duration: 1.0,
beforeSetupInternal: function(effect) {
Position.absolutize(effect.effects[0].element);
},
afterFinishInternal: function(effect) {
effect.effects[0].element.hide().setStyle(oldStyle); }
}, arguments[1] || { })
);
};
Effect.BlindUp = function(element) {
element = $(element);
element.makeClipping();
return new Effect.Scale(element, 0,
Object.extend({ scaleContent: false,
scaleX: false,
restoreAfterFinish: true,
afterFinishInternal: function(effect) {
effect.element.hide().undoClipping();
}
}, arguments[1] || { })
);
};
Effect.BlindDown = function(element) {
element = $(element);
var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100, Object.extend({
scaleContent: false,
scaleX: false,
scaleFrom: 0,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
afterSetup: function(effect) {
effect.element.makeClipping().setStyle({height: '0px'}).show();
},
afterFinishInternal: function(effect) {
effect.element.undoClipping();
}
}, arguments[1] || { }));
};
Effect.SwitchOff = function(element) {
element = $(element);
var oldOpacity = element.getInlineOpacity();
return new Effect.Appear(element, Object.extend({
duration: 0.4,
from: 0,
transition: Effect.Transitions.flicker,
afterFinishInternal: function(effect) {
new Effect.Scale(effect.element, 1, {
duration: 0.3, scaleFromCenter: true,
scaleX: false, scaleContent: false, restoreAfterFinish: true,
beforeSetup: function(effect) {
effect.element.makePositioned().makeClipping();
},
afterFinishInternal: function(effect) {
effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
}
});
}
}, arguments[1] || { }));
};
Effect.DropOut = function(element) {
element = $(element);
var oldStyle = {
top: element.getStyle('top'),
left: element.getStyle('left'),
opacity: element.getInlineOpacity() };
return new Effect.Parallel(
[ new Effect.Move(element, {x: 0, y: 100, sync: true }),
new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
Object.extend(
{ duration: 0.5,
beforeSetup: function(effect) {
effect.effects[0].element.makePositioned();
},
afterFinishInternal: function(effect) {
effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
}
}, arguments[1] || { }));
};
Effect.Shake = function(element) {
element = $(element);
var options = Object.extend({
distance: 20,
duration: 0.5
}, arguments[1] || {});
var distance = parseFloat(options.distance);
var split = parseFloat(options.duration) / 10.0;
var oldStyle = {
top: element.getStyle('top'),
left: element.getStyle('left') };
return new Effect.Move(element,
{ x:  distance, y: 0, duration: split, afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
{ x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
{ x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
{ x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
{ x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
new Effect.Move(effect.element,
{ x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
effect.element.undoPositioned().setStyle(oldStyle);
}}); }}); }}); }}); }}); }});
};
Effect.SlideDown = function(element) {
element = $(element).cleanWhitespace();
var oldInnerBottom = element.down().getStyle('bottom');
var elementDimensions = element.getDimensions();
return new Effect.Scale(element, 100, Object.extend({
scaleContent: false,
scaleX: false,
scaleFrom: window.opera ? 0 : 1,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
afterSetup: function(effect) {
effect.element.makePositioned();
effect.element.down().makePositioned();
if(window.opera) effect.element.setStyle({top: ''});
effect.element.makeClipping().setStyle({height: '0px'}).show();
},
afterUpdateInternal: function(effect) {
effect.element.down().setStyle({bottom:
(effect.dims[0] - effect.element.clientHeight) + 'px' });
},
afterFinishInternal: function(effect) {
effect.element.undoClipping().undoPositioned();
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
}, arguments[1] || { })
);
};
Effect.SlideUp = function(element) {
element = $(element).cleanWhitespace();
var oldInnerBottom = element.down().getStyle('bottom');
var elementDimensions = element.getDimensions();
return new Effect.Scale(element, window.opera ? 0 : 1,
Object.extend({ scaleContent: false,
scaleX: false,
scaleMode: 'box',
scaleFrom: 100,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
afterSetup: function(effect) {
effect.element.makePositioned();
effect.element.down().makePositioned();
if(window.opera) effect.element.setStyle({top: ''});
effect.element.makeClipping().show();
},
afterUpdateInternal: function(effect) {
effect.element.down().setStyle({bottom:
(effect.dims[0] - effect.element.clientHeight) + 'px' });
},
afterFinishInternal: function(effect) {
effect.element.hide().undoClipping().undoPositioned();
effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});
}
}, arguments[1] || { })
);
};
Effect.Squish = function(element) {
return new Effect.Scale(element, window.opera ? 1 : 0, {
restoreAfterFinish: true,
beforeSetup: function(effect) {
effect.element.makeClipping();
},
afterFinishInternal: function(effect) {
effect.element.hide().undoClipping();
}
});
};
Effect.Grow = function(element) {
element = $(element);
var options = Object.extend({
direction: 'center',
moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.full
}, arguments[1] || { });
var oldStyle = {
top: element.style.top,
left: element.style.left,
height: element.style.height,
width: element.style.width,
opacity: element.getInlineOpacity() };
var dims = element.getDimensions();
var initialMoveX, initialMoveY;
var moveX, moveY;
switch (options.direction) {
case 'top-left':
initialMoveX = initialMoveY = moveX = moveY = 0;
break;
case 'top-right':
initialMoveX = dims.width;
initialMoveY = moveY = 0;
moveX = -dims.width;
break;
case 'bottom-left':
initialMoveX = moveX = 0;
initialMoveY = dims.height;
moveY = -dims.height;
break;
case 'bottom-right':
initialMoveX = dims.width;
initialMoveY = dims.height;
moveX = -dims.width;
moveY = -dims.height;
break;
case 'center':
initialMoveX = dims.width / 2;
initialMoveY = dims.height / 2;
moveX = -dims.width / 2;
moveY = -dims.height / 2;
break;
}
return new Effect.Move(element, {
x: initialMoveX,
y: initialMoveY,
duration: 0.01,
beforeSetup: function(effect) {
effect.element.hide().makeClipping().makePositioned();
},
afterFinishInternal: function(effect) {
new Effect.Parallel(
[ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
new Effect.Scale(effect.element, 100, {
scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
], Object.extend({
beforeSetup: function(effect) {
effect.effects[0].element.setStyle({height: '0px'}).show();
},
afterFinishInternal: function(effect) {
effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
}
}, options)
);
}
});
};
Effect.Shrink = function(element) {
element = $(element);
var options = Object.extend({
direction: 'center',
moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.none
}, arguments[1] || { });
var oldStyle = {
top: element.style.top,
left: element.style.left,
height: element.style.height,
width: element.style.width,
opacity: element.getInlineOpacity() };
var dims = element.getDimensions();
var moveX, moveY;
switch (options.direction) {
case 'top-left':
moveX = moveY = 0;
break;
case 'top-right':
moveX = dims.width;
moveY = 0;
break;
case 'bottom-left':
moveX = 0;
moveY = dims.height;
break;
case 'bottom-right':
moveX = dims.width;
moveY = dims.height;
break;
case 'center':
moveX = dims.width / 2;
moveY = dims.height / 2;
break;
}
return new Effect.Parallel(
[ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
], Object.extend({
beforeStartInternal: function(effect) {
effect.effects[0].element.makePositioned().makeClipping();
},
afterFinishInternal: function(effect) {
effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
}, options)
);
};
Effect.Pulsate = function(element) {
element = $(element);
var options    = arguments[1] || { },
oldOpacity = element.getInlineOpacity(),
transition = options.transition || Effect.Transitions.linear,
reverser   = function(pos){
return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5);
};
return new Effect.Opacity(element,
Object.extend(Object.extend({  duration: 2.0, from: 0,
afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
}, options), {transition: reverser}));
};
Effect.Fold = function(element) {
element = $(element);
var oldStyle = {
top: element.style.top,
left: element.style.left,
width: element.style.width,
height: element.style.height };
element.makeClipping();
return new Effect.Scale(element, 5, Object.extend({
scaleContent: false,
scaleX: false,
afterFinishInternal: function(effect) {
new Effect.Scale(element, 1, {
scaleContent: false,
scaleY: false,
afterFinishInternal: function(effect) {
effect.element.hide().undoClipping().setStyle(oldStyle);
} });
}}, arguments[1] || { }));
};
Effect.Morph = Class.create(Effect.Base, {
initialize: function(element) {
this.element = $(element);
if(!this.element) throw(Effect._elementDoesNotExistError);
var options = Object.extend({
style: { }
}, arguments[1] || { });
if(!Object.isString(options.style)) this.style = $H(options.style);
else {
if(options.style.include(':'))
this.style = options.style.parseStyle();
else {
this.element.addClassName(options.style);
this.style = $H(this.element.getStyles());
this.element.removeClassName(options.style);
var css = this.element.getStyles();
this.style = this.style.reject(function(style) {
return style.value == css[style.key];
});
options.afterFinishInternal = function(effect) {
effect.element.addClassName(effect.options.style);
effect.transforms.each(function(transform) {
effect.element.style[transform.style] = '';
});
};
}
}
this.start(options);
},
setup: function(){
function parseColor(color){
if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
color = color.parseColor();
return $R(0,2).map(function(i){
return parseInt( color.slice(i*2+1,i*2+3), 16 );
});
}
this.transforms = this.style.map(function(pair){
var property = pair[0], value = pair[1], unit = null;
if(value.parseColor('#zzzzzz') != '#zzzzzz') {
value = value.parseColor();
unit  = 'color';
} else if(property == 'opacity') {
value = parseFloat(value);
if(Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom: 1});
} else if(Element.CSS_LENGTH.test(value)) {
var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
value = parseFloat(components[1]);
unit = (components.length == 3) ? components[2] : null;
}
var originalValue = this.element.getStyle(property);
return {
style: property.camelize(),
originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),
targetValue: unit=='color' ? parseColor(value) : value,
unit: unit
};
}.bind(this)).reject(function(transform){
return (
(transform.originalValue == transform.targetValue) ||
(
transform.unit != 'color' &&
(isNaN(transform.originalValue) || isNaN(transform.targetValue))
)
);
});
},
update: function(position) {
var style = { }, transform, i = this.transforms.length;
while(i--)
style[(transform = this.transforms[i]).style] =
transform.unit=='color' ? '#'+
(Math.round(transform.originalValue[0]+
(transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
(Math.round(transform.originalValue[1]+
(transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
(Math.round(transform.originalValue[2]+
(transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
(transform.originalValue +
(transform.targetValue - transform.originalValue) * position).toFixed(3) +
(transform.unit === null ? '' : transform.unit);
this.element.setStyle(style, true);
}
});
Effect.Transform = Class.create({
initialize: function(tracks){
this.tracks  = [];
this.options = arguments[1] || { };
this.addTracks(tracks);
},
addTracks: function(tracks){
tracks.each(function(track){
track = $H(track);
var data = track.values().first();
this.tracks.push($H({
ids:     track.keys().first(),
effect:  Effect.Morph,
options: { style: data }
}));
}.bind(this));
return this;
},
play: function(){
return new Effect.Parallel(
this.tracks.map(function(track){
var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');
var elements = [$(ids) || $$(ids)].flatten();
return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });
}).flatten(),
this.options
);
}
});
Element.CSS_PROPERTIES = $w(
'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +
'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
'fontSize fontWeight height left letterSpacing lineHeight ' +
'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
'right textIndent top width wordSpacing zIndex');
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
String.__parseStyleElement = document.createElement('div');
String.prototype.parseStyle = function(){
var style, styleRules = $H();
if(Prototype.Browser.WebKit)
style = new Element('div',{style:this}).style;
else {
String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
style = String.__parseStyleElement.childNodes[0].style;
}
Element.CSS_PROPERTIES.each(function(property){
if(style[property]) styleRules.set(property, style[property]);
});
if(Prototype.Browser.IE && this.include('opacity'))
styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
return styleRules;
};
if(document.defaultView && document.defaultView.getComputedStyle) {
Element.getStyles = function(element) {
var css = document.defaultView.getComputedStyle($(element), null);
return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {
styles[property] = css[property];
return styles;
});
};
}else{
Element.getStyles = function(element) {
element = $(element);
var css = element.currentStyle, styles;
styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) {
results[property] = css[property];
return results;
});
if(!styles.opacity) styles.opacity = element.getOpacity();
return styles;
};
}
Effect.Methods = {
morph: function(element, style) {
element = $(element);
new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
return element;
},
visualEffect: function(element, effect, options) {
element = $(element);
var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
new Effect[klass](element, options);
return element;
},
highlight: function(element, options) {
element = $(element);
new Effect.Highlight(element, options);
return element;
}
};
$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
'pulsate shake puff squish switchOff dropOut').each(
function(effect) {
Effect.Methods[effect] = function(element, options){
element = $(element);
Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
return element;
};
}
);
$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(
function(f) { Effect.Methods[f] = Element[f]; }
);
Element.addMethods(Effect.Methods);
if(Object.isUndefined(Effect))
throw("dragdrop.js requires including script.aculo.us' effects.js library");
var Droppables = {
drops: [],
remove: function(element) {
this.drops = this.drops.reject(function(d) { return d.element==$(element) });
},
add: function(element) {
element = $(element);
var options = Object.extend({
greedy:     true,
hoverclass: null,
tree:       false
}, arguments[1] || { });
if(options.containment) {
options._containers = [];
var containment = options.containment;
if(Object.isArray(containment)) {
containment.each( function(c) { options._containers.push($(c)) });
}else{
options._containers.push($(containment));
}
}
if(options.accept) options.accept = [options.accept].flatten();
Element.makePositioned(element); // fix IE
options.element = element;
this.drops.push(options);
},
findDeepestChild: function(drops) {
deepest = drops[0];
for (i = 1; i < drops.length; ++i)
if(Element.isParent(drops[i].element, deepest.element))
deepest = drops[i];
return deepest;
},
isContained: function(element, drop) {
var containmentNode;
if(drop.tree) {
containmentNode = element.treeNode;
}else{
containmentNode = element.parentNode;
}
return drop._containers.detect(function(c) { return containmentNode == c });
},
isAffected: function(point, element, drop) {
return (
(drop.element!=element) &&
((!drop._containers) ||
this.isContained(element, drop)) &&
((!drop.accept) ||
(Element.classNames(element).detect(
function(v) { return drop.accept.include(v) } ) )) &&
Position.within(drop.element, point[0], point[1]) );
},
deactivate: function(drop) {
if(drop.hoverclass)
Element.removeClassName(drop.element, drop.hoverclass);
this.last_active = null;
},
activate: function(drop) {
if(drop.hoverclass)
Element.addClassName(drop.element, drop.hoverclass);
this.last_active = drop;
},
show: function(point, element) {
if(!this.drops.length) return;
var drop, affected = [];
this.drops.each( function(drop) {
if(Droppables.isAffected(point, element, drop))
affected.push(drop);
});
if(affected.length>0)
drop = Droppables.findDeepestChild(affected);
if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
if(drop) {
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
if(drop != this.last_active) Droppables.activate(drop);
}
},
fire: function(event, element) {
if(!this.last_active) return;
Position.prepare();
if(this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if(this.last_active.onDrop) {
this.last_active.onDrop(element, this.last_active.element, event);
return true;
}
},
reset: function() {
if(this.last_active)
this.deactivate(this.last_active);
}
};
var Draggables = {
drags: [],
observers: [],
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp   = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress  = this.keyPress.bindAsEventListener(this);
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
Event.stopObserving(document, "mouseup", this.eventMouseUp);
Event.stopObserving(document, "mousemove", this.eventMouseMove);
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
activate: function(draggable) {
if(draggable.options.delay) {
this._timeout = setTimeout(function() {
Draggables._timeout = null;
window.focus();
Draggables.activeDraggable = draggable;
}.bind(this), draggable.options.delay);
}else{
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
}
},
deactivate: function() {
this.activeDraggable = null;
},
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer;
this.activeDraggable.updateDrag(event, pointer);
},
endDrag: function(event) {
if(this._timeout) {
clearTimeout(this._timeout);
this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
removeObserver: function(element) {  // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
notify: function(eventName, draggable, event) {  // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
if(o[eventName]) o[eventName](eventName, draggable, event);
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
function(o) { return o[eventName]; }
).length;
});
}
};
/*--------------------------------------------------------------------------*/
var Draggable = Class.create({
initialize: function(element) {
var defaults = {
handle: false,
reverteffect: function(element, top_offset, left_offset) {
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
queue: {scope:'_draggable', position:'end'}
});
},
endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
afterFinish: function(){
Draggable._dragging[element] = false
}
});
},
zindex: 9999,
revert: false,
quiet: false,
scroll: false,
scrollSensitivity: 20,
scrollSpeed: 15,
snap: false,  // false, or xy or [x,y] or function(x,y){ return [x,y] }
delay: 0
};
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
Object.extend(defaults, {
starteffect: function(element) {
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
}
});
var options = Object.extend(defaults, arguments[1] || { });
this.element = $(element);
if(options.handle && Object.isString(options.handle))
this.handle = this.element.down('.'+options.handle, 0);
if(!this.handle) this.handle = $(options.handle);
if(!this.handle) this.handle = this.element;
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
options.scroll = $(options.scroll);
this._isScrollChild = Element.childOf(this.element, options.scroll);
}
Element.makePositioned(this.element); // fix IE
this.options  = options;
this.dragging = false;
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
Draggables.register(this);
},
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Draggables.unregister(this);
},
currentDelta: function() {
return([
parseInt(Element.getStyle(this.element,'left') || '0'),
parseInt(Element.getStyle(this.element,'top') || '0')]);
},
initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event)) {
var src = Event.element(event);
if((tag_name = src.tagName.toUpperCase()) && (
tag_name=='INPUT' ||
tag_name=='SELECT' ||
tag_name=='OPTION' ||
tag_name=='BUTTON' ||
tag_name=='TEXTAREA')) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos     = Position.cumulativeOffset(this.element);
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
Draggables.activate(this);
Event.stop(event);
}
},
startDrag: function(event) {
this.dragging = true;
if(!this.delta)
this.delta = this.currentDelta();
if(this.options.zindex) {
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
this.element.style.zIndex = this.options.zindex;
}
if(this.options.ghosting) {
this._clone = this.element.cloneNode(true);
this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
if(!this._originallyAbsolute)
Position.absolutize(this.element);
this.element.parentNode.insertBefore(this._clone, this.element);
}
if(this.options.scroll) {
if(this.options.scroll == window) {
var where = this._getWindowScroll(this.options.scroll);
this.originalScrollLeft = where.left;
this.originalScrollTop = where.top;
}else{
this.originalScrollLeft = this.options.scroll.scrollLeft;
this.originalScrollTop = this.options.scroll.scrollTop;
}
}
Draggables.notify('onStart', this, event);
if(this.options.starteffect) this.options.starteffect(this.element);
},
updateDrag: function(event, pointer) {
if(!this.dragging) this.startDrag(event);
if(!this.options.quiet){
Position.prepare();
Droppables.show(pointer, this.element);
}
Draggables.notify('onDrag', this, event);
this.draw(pointer);
if(this.options.change) this.options.change(this);
if(this.options.scroll) {
this.stopScrolling();
var p;
if(this.options.scroll == window) {
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
}else{
p = Position.page(this.options.scroll);
p[0] += this.options.scroll.scrollLeft + Position.deltaX;
p[1] += this.options.scroll.scrollTop + Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight);
}
var speed = [0,0];
if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
this.startScrolling(speed);
}
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
Event.stop(event);
},
finishDrag: function(event, success) {
this.dragging = false;
if(this.options.quiet){
Position.prepare();
var pointer = [Event.pointerX(event), Event.pointerY(event)];
Droppables.show(pointer, this.element);
}
if(this.options.ghosting) {
if(!this._originallyAbsolute)
Position.relativize(this.element);
delete this._originallyAbsolute;
Element.remove(this._clone);
this._clone = null;
}
var dropped = false;
if(success) {
dropped = Droppables.fire(event, this.element);
if(!dropped) dropped = false;
}
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
Draggables.notify('onEnd', this, event);
var revert = this.options.revert;
if(revert && Object.isFunction(revert)) revert = revert(this.element);
var d = this.currentDelta();
if(revert && this.options.reverteffect) {
if(dropped == 0 || revert != 'failure')
this.options.reverteffect(this.element,
d[1]-this.delta[1], d[0]-this.delta[0]);
}else{
this.delta = d;
}
if(this.options.zindex)
this.element.style.zIndex = this.originalZ;
if(this.options.endeffect)
this.options.endeffect(this.element);
Draggables.deactivate(this);
Droppables.reset();
},
keyPress: function(event) {
if(event.keyCode!=Event.KEY_ESC) return;
this.finishDrag(event, false);
Event.stop(event);
},
endDrag: function(event) {
if(!this.dragging) return;
this.stopScrolling();
this.finishDrag(event, true);
Event.stop(event);
},
draw: function(point) {
var pos = Position.cumulativeOffset(this.element);
if(this.options.ghosting) {
var r   = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
}
var d = this.currentDelta();
pos[0] -= d[0]; pos[1] -= d[1];
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
}
var p = [0,1].map(function(i){
return (point[i]-pos[i]-this.offset[i])
}.bind(this));
if(this.options.snap) {
if(Object.isFunction(this.options.snap)) {
p = this.options.snap(p[0],p[1],this);
}else{
if(Object.isArray(this.options.snap)) {
p = p.map( function(v, i) {
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
}else{
p = p.map( function(v) {
return (v/this.options.snap).round()*this.options.snap }.bind(this));
}
}}
var style = this.element.style;
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
style.left = p[0] + "px";
if((!this.options.constraint) || (this.options.constraint=='vertical'))
style.top  = p[1] + "px";
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
},
stopScrolling: function() {
if(this.scrollInterval) {
clearInterval(this.scrollInterval);
this.scrollInterval = null;
Draggables._lastScrollPointer = null;
}
},
startScrolling: function(speed) {
if(!(speed[0] || speed[1])) return;
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
this.lastScrolled = new Date();
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
},
scroll: function() {
var current = new Date();
var delta = current - this.lastScrolled;
this.lastScrolled = current;
if(this.options.scroll == window) {
with (this._getWindowScroll(this.options.scroll)) {
if(this.scrollSpeed[0] || this.scrollSpeed[1]) {
var d = delta / 1000;
this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
}
}
}else{
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
this.options.scroll.scrollTop  += this.scrollSpeed[1] * delta / 1000;
}
Position.prepare();
Droppables.show(Draggables._lastPointer, this.element);
Draggables.notify('onDrag', this);
if(this._isScrollChild) {
Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
if(Draggables._lastScrollPointer[0] < 0)
Draggables._lastScrollPointer[0] = 0;
if(Draggables._lastScrollPointer[1] < 0)
Draggables._lastScrollPointer[1] = 0;
this.draw(Draggables._lastScrollPointer);
}
if(this.options.change) this.options.change(this);
},
_getWindowScroll: function(w) {
var T, L, W, H;
with (w.document) {
if(w.document.documentElement && documentElement.scrollTop) {
T = documentElement.scrollTop;
L = documentElement.scrollLeft;
} else if(w.document.body) {
T = body.scrollTop;
L = body.scrollLeft;
}
if(w.innerWidth) {
W = w.innerWidth;
H = w.innerHeight;
} else if(w.document.documentElement && documentElement.clientWidth) {
W = documentElement.clientWidth;
H = documentElement.clientHeight;
}else{
W = body.offsetWidth;
H = body.offsetHeight;
}
}
return { top: T, left: L, width: W, height: H };
}
});
Draggable._dragging = { };
/*--------------------------------------------------------------------------*/
var SortableObserver = Class.create({
initialize: function(element, observer) {
this.element   = $(element);
this.observer  = observer;
this.lastValue = Sortable.serialize(this.element);
},
onStart: function() {
this.lastValue = Sortable.serialize(this.element);
},
onEnd: function() {
Sortable.unmark();
if(this.lastValue != Sortable.serialize(this.element))
this.observer(this.element)
}
});
var Sortable = {
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
sortables: { },
_findRootElement: function(element) {
while (element.tagName.toUpperCase() != "BODY") {
if(element.id && Sortable.sortables[element.id]) return element;
element = element.parentNode;
}
},
options: function(element) {
element = Sortable._findRootElement($(element));
if(!element) return;
return Sortable.sortables[element.id];
},
destroy: function(element){
element = $(element);
var s = Sortable.sortables[element.id];
if(s) {
Draggables.removeObserver(s.element);
s.droppables.each(function(d){ Droppables.remove(d) });
s.draggables.invoke('destroy');
delete Sortable.sortables[s.element.id];
}
},
create: function(element) {
element = $(element);
var options = Object.extend({
element:     element,
tag:         'li',       // assumes li children, override with tag: 'tagname'
dropOnEmpty: false,
tree:        false,
treeTag:     'ul',
overlap:     'vertical', // one of 'vertical', 'horizontal'
constraint:  'vertical', // one of 'vertical', 'horizontal', false
containment: element,    // also takes array of elements (or id's); or false
handle:      false,      // or a CSS class
only:        false,
delay:       0,
hoverclass:  null,
ghosting:    false,
quiet:       false,
scroll:      false,
scrollSensitivity: 20,
scrollSpeed: 15,
format:      this.SERIALIZE_RULE,
elements:    false,
handles:     false,
onChange:    Prototype.emptyFunction,
onUpdate:    Prototype.emptyFunction
}, arguments[1] || { });
this.destroy(element);
var options_for_draggable = {
revert:      true,
quiet:       options.quiet,
scroll:      options.scroll,
scrollSpeed: options.scrollSpeed,
scrollSensitivity: options.scrollSensitivity,
delay:       options.delay,
ghosting:    options.ghosting,
constraint:  options.constraint,
handle:      options.handle };
if(options.starteffect)
options_for_draggable.starteffect = options.starteffect;
if(options.reverteffect)
options_for_draggable.reverteffect = options.reverteffect;
else
if(options.ghosting) options_for_draggable.reverteffect = function(element) {
element.style.top  = 0;
element.style.left = 0;
};
if(options.endeffect)
options_for_draggable.endeffect = options.endeffect;
if(options.zindex)
options_for_draggable.zindex = options.zindex;
var options_for_droppable = {
overlap:     options.overlap,
containment: options.containment,
tree:        options.tree,
hoverclass:  options.hoverclass,
onHover:     Sortable.onHover
};
var options_for_tree = {
onHover:      Sortable.onEmptyHover,
overlap:      options.overlap,
containment:  options.containment,
hoverclass:   options.hoverclass
};
Element.cleanWhitespace(element);
options.draggables = [];
options.droppables = [];
if(options.dropOnEmpty || options.tree) {
Droppables.add(element, options_for_tree);
options.droppables.push(element);
}
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
var handle = options.handles ? $(options.handles[i]) :
(options.handle ? $(e).select('.' + options.handle)[0] : e);
options.draggables.push(
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
Droppables.add(e, options_for_droppable);
if(options.tree) e.treeNode = element;
options.droppables.push(e);
});
if(options.tree) {
(Sortable.findTreeElements(element, options) || []).each( function(e) {
Droppables.add(e, options_for_tree);
e.treeNode = element;
options.droppables.push(e);
});
}
this.sortables[element.id] = options;
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
},
findElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.tag);
},
findTreeElements: function(element, options) {
return Element.findChildren(
element, options.only, options.tree ? true : false, options.treeTag);
},
onHover: function(element, dropon, overlap) {
if(Element.isParent(dropon, element)) return;
if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
return;
} else if(overlap>0.5) {
Sortable.mark(dropon, 'before');
if(dropon.previousSibling != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, dropon);
if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
}else{
Sortable.mark(dropon, 'after');
var nextElement = dropon.nextSibling || null;
if(nextElement != element) {
var oldParentNode = element.parentNode;
element.style.visibility = "hidden"; // fix gecko rendering
dropon.parentNode.insertBefore(element, nextElement);
if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);
Sortable.options(dropon.parentNode).onChange(element);
}
}
},
onEmptyHover: function(element, dropon, overlap) {
var oldParentNode = element.parentNode;
var droponOptions = Sortable.options(dropon);
if(!Element.isParent(dropon, element)) {
var index;
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
var child = null;
if(children) {
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
for (index = 0; index < children.length; index += 1) {
if(offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
offset -= Element.offsetSize (children[index], droponOptions.overlap);
} else if(offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
child = index + 1 < children.length ? children[index + 1] : null;
break;
}else{
child = children[index];
break;
}
}
}
dropon.insertBefore(element, child);
Sortable.options(oldParentNode).onChange(element);
droponOptions.onChange(element);
}
},
unmark: function() {
if(Sortable._marker) Sortable._marker.hide();
},
mark: function(dropon, position) {
var sortable = Sortable.options(dropon.parentNode);
if(sortable && !sortable.ghosting) return;
if(!Sortable._marker) {
Sortable._marker =
($('dropmarker') || Element.extend(document.createElement('DIV'))).
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
}
var offsets = Position.cumulativeOffset(dropon);
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
if(position=='after')
if(sortable.overlap == 'horizontal')
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
else
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
Sortable._marker.show();
},
_tree: function(element, options, parent) {
var children = Sortable.findElements(element, options) || [];
for (var i = 0; i < children.length; ++i) {
var match = children[i].id.match(options.format);
if(!match) continue;
var child = {
id: encodeURIComponent(match ? match[1] : null),
element: element,
parent: parent,
children: [],
position: parent.children.length,
container: $(children[i]).down(options.treeTag)
};
/* Get the element containing the children and recurse over it */
if(child.container)
this._tree(child.container, options, child);
parent.children.push (child);
}
return parent;
},
tree: function(element) {
element = $(element);
var sortableOptions = this.options(element);
var options = Object.extend({
tag: sortableOptions.tag,
treeTag: sortableOptions.treeTag,
only: sortableOptions.only,
name: element.id,
format: sortableOptions.format
}, arguments[1] || { });
var root = {
id: null,
parent: null,
children: [],
container: element,
position: 0
};
return Sortable._tree(element, options, root);
},
/* Construct a [i] index for a particular node */
_constructIndex: function(node) {
var index = '';
do {
if(node.id) index = '[' + node.position + ']' + index;
} while ((node = node.parent) != null);
return index;
},
sequence: function(element) {
element = $(element);
var options = Object.extend(this.options(element), arguments[1] || { });
return $(this.findElements(element, options) || []).map( function(item) {
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
});
},
setSequence: function(element, new_sequence) {
element = $(element);
var options = Object.extend(this.options(element), arguments[2] || { });
var nodeMap = { };
this.findElements(element, options).each( function(n) {
if(n.id.match(options.format))
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
n.parentNode.removeChild(n);
});
new_sequence.each(function(ident) {
var n = nodeMap[ident];
if(n) {
n[1].appendChild(n[0]);
delete nodeMap[ident];
}
});
},
serialize: function(element) {
element = $(element);
var options = Object.extend(Sortable.options(element), arguments[1] || { });
var name = encodeURIComponent(
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
if(options.tree) {
return Sortable.tree(element, arguments[1]).children.map( function (item) {
return [name + Sortable._constructIndex(item) + "[id]=" +
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
}).flatten().join('&');
}else{
return Sortable.sequence(element, arguments[1]).map( function(item) {
return name + "[]=" + encodeURIComponent(item);
}).join('&');
}
}
};
Element.isParent = function(child, element) {
if(!child.parentNode || child == element) return false;
if(child.parentNode == element) return true;
return Element.isParent(child.parentNode, element);
};
Element.findChildren = function(element, only, recursive, tagName) {
if(!element.hasChildNodes()) return null;
tagName = tagName.toUpperCase();
if(only) only = [only].flatten();
var elements = [];
$A(element.childNodes).each( function(e) {
if(e.tagName && e.tagName.toUpperCase()==tagName &&
(!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
elements.push(e);
if(recursive) {
var grandchildren = Element.findChildren(e, only, recursive, tagName);
if(grandchildren) elements.push(grandchildren);
}
});
return (elements.length>0 ? elements.flatten() : []);
};
Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
};
function onUnload_behaviour ()
{
addBodyClass("unloading");
}
function emptyFunction(x) { return x}
function delayed_behaviour_fire()
{
var IsWebKit = navigator.userAgent.indexOf('AppleWebKit/') > -1;
if(IsWebKit) {
window.addEventListener('unload', emptyFunction, false);
}
if(window.attachEvent) {
window.attachEvent("onunload", onUnload_behaviour);
}
if(window.addEventListener) {
window.addEventListener("beforeunload", onUnload_behaviour, false);
}
addBodyClass("delayed_fired");
}
function delayed_events()
{
if("function" == typeof (navigation_behaviour_init)) {navigation_behaviour_init ();}
if("function" == typeof (js5_collapsible_behaviour_init)) {js5_collapsible_behaviour_init();}
if("function" == typeof (foot_behaviour_init)) {foot_behaviour_init();}
if("function" == typeof (fnInputRange)) {fnInputRange();}
if("function" == typeof (thisPage_behaviour_init)) {thisPage_behaviour_init ();}
addBodyClass("delayed_events");
}
function delayed_behaviour_init()
{
window.setTimeout(delayed_behaviour_fire, 200);
window.setTimeout(delayed_events, 1);
}
function onBodyKeyDown_init ()
{
window.addEventListener('keydown', onBodyKeyDown, true);
}
function key_body_class(cls, doIt)
{
if(!doIt || $qs("#areaContent input"))
{
return false;
}
toggleBodyClasses(cls);
}
function fire_href(href)
{
if(get_ajaxHrefTransitionContent (href))
{
window.location = href;
}
}
function fire_meta_link(name) {
if($qs("#areaContent input"))
{
return false;
}
var found = false;
$$("html head link[rel='"+name+"']").each(function(el)
{
if(!found)
{
fire_href (el.href);
}
found=true;
})
return found;
}
function canHandleKey(keyCode)
{
switch(keyCode)
{
case 27: // ESC
case 113: // F2
return true;
break;
default:
{
if(hasBodyClass ("u_inplaceedit"))
{
return false;
}
}
break;
}
return true;
}
function handle_key_code(keyCode)
{
removeBodyClasses ("u_page_forward u_page_backward");
switch(keyCode)
{
case 9:  // TAB
case 33: // BILD HOCH
case 34: // BILD RUNTGERu
case 36: // POS1
case 35: // ENDE
case 38: // UP
case 40: // DOWN
break;
case 27: // ESC
if(hasBodyClass ("u_inplaceedit"))
{
inplaceEdit_save_changes();
inplaceEdit_init();
key_body_class("u_inplaceedit", true);
}
break;
case 39:
addBodyClass("u_page_forward");
href = get_pager_href ("forward");
if("" != href)
{
fire_href(href);
}
else
{
fire_meta_link("next");
}
break;
case 37:
addBodyClass("u_page_backward");
href = get_pager_href ("backward");
if("" != href)
{
fire_href(href);
}
else
{
fire_meta_link("prev");
}
break;
case 73: // i = sitemap
fire_meta_link("index");
break;
case 80: // p
fire_meta_link("parent");
break;
case 81: // q query=sitesearch
fire_meta_link("query");
break;
case 83: // s
fire_meta_link("sibling");
break;
case 85: // u
break;
case 86: // v
key_body_class("u_fullscreen_content");
break;
case 78: // n
key_body_class("u_navicollapsed");
break;
case 72: // h
fire_meta_link("home");
break;
case 75: // k
key_body_class("u_headcollapsed");
break;
case 122: // F11
break;
case 113: // F2
if(hasBodyClass ("u_inplaceedit"))
{
handle_key_code(27);
}
else
{
if("function" == typeof (inplaceEdit_init))
{
key_body_class("u_inplaceedit", true);
inplaceEdit_init();
}
}
break;
case 115: // F4
break;
case 32: // SPACE
case 20: // SHIFT CAPS
case 16: // SHIFT
case 17: // CTRL
case 18: // ALT
break;
default:
if(!hasBodyClass ("u_inplaceedit"))
{
debug_out(keyCode);
}
break;
}
return true;
}
function onBodyKeyDown(e)
{
var keyCode = e ? e.which : window.event.keyCode;
if(!canHandleKey(keyCode))
{
return false;
}
var lnk = "";
if(keyCode > 36 && keyCode < 41) { // 37-40: left, up, right, down
}
return handle_key_code(keyCode);
}
var showOwnContextMenu = false; // replace the system context menu?
var hasOwnContextMenu = true;
var mouseIsOverContextMenu = false; // is the mouse over the context menu?
function contextMenu_container_init ()
{
if(!$('areaContextMenu'))
{
getBody().insert("<div id='areaContextMenu' class='hidden'><div class='loader'></div></div>");
$('areaContextMenu').onmouseover = function()
{
mouseIsOverContextMenu = true;
};
$('areaContextMenu').onmouseout = function()
{
mouseIsOverContextMenu = false;
};
}
else
{
$('areaContextMenu').removeAttribute("style");
}
}
function contextMenu_init()
{
document.body.onmousedown = contextMouseDown;
document.body.oncontextmenu = contextMenu_show;
}
function contextMouseDown(event)
{
if(!hasBodyClass("u_pagecontextmenu") || mouseIsOverContextMenu) return;
contextMenu_container_init ();
if(event == null)
event = window.event;
var target = event.target != null ? event.target : event.srcElement;
if(event.button == 2)
{
showOwnContextMenu = true;
}
else if(!mouseIsOverContextMenu)
{
if($('areaContextMenu'))
{
$('areaContextMenu').addClassName('hidden');
}
}
}
function contextMenu_hide()
{
mouseIsOverContextMenu = false;
$('areaContextMenu').addClassName('hidden');
}
function contextMenu_show(event)
{
if(!hasBodyClass("u_pagecontextmenu") || mouseIsOverContextMenu)
{
return true;
}
contextMenu_container_init ();
if(event == null)
event = window.event;
var target = event.target != null ? event.target : event.srcElement;
if(showOwnContextMenu)
{
if($('areaContextMenu'))
{
$('areaContextMenu').addClassName ("reload loader");
var rp = $('areaContextMenu');
if(IsDefined($('areaContextMenu').down(".body")))
{
rp = $('areaContextMenu').down(".body");
}
$('areaContextMenu').removeClassName('hidden');
}
ajaxContentGet ("contextMenu:areaContextMenu", {naviArea:'contextMenu', ajaxPathInfo:getCurrendLocation(),denyMessages:true});
var scrollTop = document.body.scrollTop
? document.body.scrollTop
: document.documentElement.scrollTop;
var scrollLeft = document.body.scrollLeft
? document.body.scrollLeft
: document.documentElement.scrollLeft;
z = 1000;
updatePagePersistStyles ("#areaContextMenu", getWindowStyleDef ($('areaContextMenu'), event.clientY + scrollTop, event.clientX + scrollLeft, z));
showOwnContextMenu = false;
return false;
}
else
{
}
return true;
}
function contextMenu_action_init()
{
$('areaContextMenu').select ('li.disableContextMenu a').each (function(el)
{
el.onclick = function()
{
return contextMenu_disable();
}
})
dragWindow_Behaviour_Selector_Init ("#areaContextMenu");
removeClassNames ($('areaContextMenu'), 'hidden reload');
dragWindowSetOnTop ($('areaContextMenu'));
}
function contextMenu_disable()
{
if($('pagecontextmenu'))
{
$('pagecontextmenu').checked = false;
}
removeBodyClass ("u_pagecontextmenu");
contextMenu_hide();
return false;
}
function contextMenu_enable()
{
mouseIsOverContextMenu = false;
if($('pagecontextmenu'))
{
$('pagecontextmenu').checked = true;
}
addBodyClass ("u_pagecontextmenu");
return false;
}
if(typeof Prototype == 'undefined') alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).");
if(Prototype.Version < "1.6") alert("Prototype 1.6.0 is required.  If using earlier version of prototype, please use calendar_date_select version 1.8.3");
Element.addMethods({
purgeChildren: function(element) { $A(element.childNodes).each(function(e){$(e).remove();}); },
build: function(element, type, options, style) {
var newElement = Element.build(type, options, style);
element.appendChild(newElement);
return newElement;
}
});
Element.build = function(type, options, style)
{
var e = $(document.createElement(type));
$H(options).each(function(pair) { eval("e." + pair.key + " = pair.value" ); });
if(style)
$H(style).each(function(pair) { eval("e.style." + pair.key + " = pair.value" ); });
return e;
};
nil = null;
Date.one_day = 24*60*60*1000;
Date.weekdays = $w("S M D M D F S");
Date.first_day_of_week = 1;
Date.dayNames = $w("Montag Dienstag Mittwoch Donnerstag Freitag Samstag Sonntag");
Date.months = $w("Januar Februar März April Mai Juni Juli August September Oktober November Dezember");
Date.padded2 = function(hour) { var padded2 = parseInt(hour, 10); if(hour < 10) padded2 = "0" + padded2; return padded2; }
Date.prototype.getPaddedMinutes = function() { return Date.padded2(this.getMinutes()); }
Date.prototype.getAMPMHour = function() { var hour = this.getHours(); return (hour == 0) ? 12 : (hour > 12 ? hour - 12 : hour ) }
Date.prototype.getAMPM = function() { return (this.getHours() < 12) ? "AM" : "PM"; }
Date.prototype.stripTime = function() { return new Date(this.getFullYear(), this.getMonth(), this.getDate());};
Date.prototype.daysDistance = function(compare_date) { return Math.round((compare_date - this) / Date.one_day); };
Date.prototype.toFormattedString = function(include_time, format, useText){
var hour, str;
str = Date.months[this.getMonth()] + " " + this.getDate() + ", " + this.getFullYear();
if(include_time) { hour = this.getHours(); str += " " + this.getAMPMHour() + ":" + this.getPaddedMinutes() + " " + this.getAMPM() }
return "default: " +  str;
}
Date.parseFormattedString = function(string,format) { return new Date(string);}
Math.floor_to_interval = function(n, i) { return Math.floor(n/i) * i;}
window.f_height = function() { return( [window.innerHeight ? window.innerHeight : null, document.documentElement ? document.documentElement.clientHeight : null, document.body ? document.body.clientHeight : null].select(function(x){return x>0}).first()||0); }
window.f_scrollTop = function() { return ([window.pageYOffset ? window.pageYOffset : null, document.documentElement ? document.documentElement.scrollTop : null, document.body ? document.body.scrollTop : null].select(function(x){return x>0}).first()||0 ); }
_translations = {
"OK": "OK",
"Now": "Jetzt",
"Today": "Heute"
}
SelectBox = Class.create();
SelectBox.prototype = {
initialize: function(parent_element, values, html_options, style_options) {
this.element = $(parent_element).build("select", html_options, style_options);
this.populate(values);
},
populate: function(values) {
this.element.purgeChildren();
var that = this; $A(values).each(function(pair) { if(typeof(pair)!="object") {pair = [pair, pair]}; that.element.build("option", { value: pair[1], innerHTML: pair[0]}) });
},
setValue: function(value) {
var e = this.element;
var matched = false;
$R(0, e.options.length - 1 ).each(function(i) { if(e.options[i].value==value.toString()) {e.selectedIndex = i; matched = true;}; } );
return matched;
},
getValue: function() { return $F(this.element)}
}
CalendarDateSelect = Class.create();
CalendarDateSelect.prototype = {
initialize: function(target_element, options) {
this.target_element = $(target_element); // make sure it's an element, not a string
if(!this.target_element) { alert("Target element " + target_element + " not found!"); return false;}
if(this.target_element.tagName != "INPUT") this.target_element = this.target_element.down("INPUT")
this.target_element.calendar_date_select = this;
this.last_click_at = 0;
this.options = $H({
embedded: false,
popup: nil,
time: false,
buttons: true,
year_range: 10,
calendar_div: nil,
close_on_click: nil,
minute_interval: 5,
format: "default",
popup_by: this.target_element,
month_year: "dropdowns",
onchange: this.target_element.onchange,
valid_date_check: nil
}).merge(options || {});
this.selection_made = $F(this.target_element).strip()!=="";
this.use_time = this.options.get("time");
this.callback("before_show")
this.calendar_div = $(this.options.get("calendar_div"));
this.parseDate();
if(this.calendar_div == nil) { this.calendar_div = $( this.options.get("embedded") ? this.target_element.parentNode : document.body ).build('div'); }
if(!this.options.get("embedded")) this.calendar_div.setStyle( { position:"absolute", visibility: "hidden", left:0, top:0 } )
this.calendar_div.addClassName("calendar_date_select");
if(this.options.get("embedded")) this.options.set("close_on_click", false);
if(this.options.get("close_on_click")===nil )
{
if(this.options.get("time"))
this.options.set("close_on_click", false);
else
this.options.set("close_on_click", true);
}
if(!this.options.get("embedded")) {
Event.observe(document, "mousedown", this.closeIfClickedOut_handler = this.closeIfClickedOut.bindAsEventListener(this));
Event.observe(document, "keypress", this.keyPress_handler = this.keyPress.bindAsEventListener(this));
}
this.init();
if(!this.options.get("embedded")) { this.positionCalendarDiv() };
this.callback("after_show")
},
positionCalendarDiv: function() {
var above = false;
var c_pos = this.calendar_div.cumulativeOffset(), c_left = c_pos[0], c_top = c_pos[1], c_dim = this.calendar_div.getDimensions(), c_height = c_dim.height, c_width = c_dim.width;
var w_top = window.f_scrollTop(), w_height = window.f_height();
var e_dim = $(this.options.get("popup_by")).cumulativeOffset(), e_top = e_dim[1], e_left = e_dim[0], e_height = $(this.options.get("popup_by")).getDimensions().height, e_bottom = e_top + e_height;
if( (( e_bottom + c_height ) > (w_top + w_height)) && ( e_bottom - c_height > w_top )) above = true;
var left_px = e_left.toString() + "px", top_px = (above ? (e_top - c_height ) : ( e_top + e_height )).toString() + "px";
this.calendar_div.style.left = left_px;  this.calendar_div.style.top = top_px;
this.calendar_div.setStyle({visibility:""});
if(navigator.appName=="Microsoft Internet Explorer") this.iframe = $(document.body).build("iframe", {src: "javascript:false", className: "ie6_blocker"}, { left: left_px, top: top_px, height: c_height.toString()+"px", width: c_width.toString()+"px", border: "0px"})
},
init: function() {
var that = this;
$w("top header body buttons footer bottom").each(function(name) {
eval("var " + name + "_div = that." + name + "_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");
});
this.initHeaderDiv();
this.initButtonsDiv();
this.initCalendarGrid();
this.updateFooter("&#160;");
this.refresh();
this.setUseTime(this.use_time);
},
initHeaderDiv: function() {
var header_div = this.header_div;
this.close_button = header_div.build("a", { innerHTML: "x", href:"#", onclick:function () { this.close(); return false; }.bindAsEventListener(this), className: "close" });
this.next_month_button = header_div.build("a", { innerHTML: "&gt;", href:"#", onclick:function () { this.navMonth(this.date.getMonth() + 1 ); return false; }.bindAsEventListener(this), className: "next" });
this.prev_month_button = header_div.build("a", { innerHTML: "&lt;", href:"#", onclick:function () { this.navMonth(this.date.getMonth() - 1 ); return false; }.bindAsEventListener(this), className: "prev" });
if(this.options.get("month_year")=="dropdowns") {
this.month_select = new SelectBox(header_div, $R(0,11).map(function(m){return [Date.months[m], m]}), {className: "month", onchange: function () { this.navMonth(this.month_select.getValue()) }.bindAsEventListener(this)});
this.year_select = new SelectBox(header_div, [], {className: "year", onchange: function () { this.navYear(this.year_select.getValue()) }.bindAsEventListener(this)});
this.populateYearRange();
}else{
this.month_year_label = header_div.build("span")
}
},
initCalendarGrid: function() {
var body_div = this.body_div;
this.calendar_day_grid = [];
var days_table = body_div.build("table", { cellPadding: "0px", cellSpacing: "0px", width: "100%", className: this.options.get("format")})
var weekdays_row = days_table.build("thead").build("tr");
$R(0,6).each(function(i){weekdays_row.build("th", {innerHTML: Date.weekdays[(i+Date.first_day_of_week)%7]});});
var days_tbody = days_table.build("tbody")
var row_number = 0, weekday;
for(var cell_index = 0; cell_index<42; cell_index++)
{
weekday = (cell_index+Date.first_day_of_week ) % 7;
if( cell_index % 7==0 ) days_row = days_tbody.build("tr", {className: 'row_'+row_number++});
(this.calendar_day_grid[cell_index] = days_row.build("td", {
calendar_date_select: this,
onmouseover: function () { this.calendar_date_select.dayHover(this); },
onmouseout: function () { this.calendar_date_select.dayHoverOut(this) },
onclick: function() { this.calendar_date_select.updateSelectedDate(this, true); },
className: (weekday==0) || (weekday==6) ? " weekend" : "" //clear the class
},
{ cursor: "pointer" }
)).build("div");
}
},
initButtonsDiv: function()
{
var buttons_div = this.buttons_div;
if(this.options.get("time"))
{
var blank_time = $A(this.options.get("time")=="mixed" ? [[" - ", ""]] : []);
buttons_div.build("span", {innerHTML:"@", className: "at_sign"});
var t = new Date();
this.hour_select = new SelectBox(buttons_div,
blank_time.concat($R(0,23).map(function(x) {t.setHours(x); return $A([t.getAMPMHour()+ " " + t.getAMPM(),x])} )),
{
calendar_date_select: this,
onchange: function() { this.calendar_date_select.updateSelectedDate( { hour: this.value });},
className: "hour"
}
);
buttons_div.build("span", {innerHTML:":", className: "seperator"});
var that = this;
this.minute_select = new SelectBox(buttons_div,
blank_time.concat($R(0,59).select(function(x){return (x % that.options.get('minute_interval')==0)}).map(function(x){ return $A([ Date.padded2(x), x]); } ) ),
{
calendar_date_select: this,
onchange: function() { this.calendar_date_select.updateSelectedDate( {minute: this.value }) },
className: "minute"
}
);
} else if(! this.options.get("buttons")) buttons_div.remove();
if(this.options.get("buttons")) {
buttons_div.build("span", {innerHTML: "&#160;"});
if(this.options.get("time")=="mixed" || !this.options.get("time")) b = buttons_div.build("a", {
innerHTML: _translations["Today"],
href: "#",
onclick: function() {this.today(false); return false;}.bindAsEventListener(this)
});
if(this.options.get("time")=="mixed") buttons_div.build("span", {innerHTML: " | ", className:"button_seperator"})
if(this.options.get("time")) b = buttons_div.build("a", {
innerHTML: _translations["Now"],
href: "#",
onclick: function() {this.today(true); return false}.bindAsEventListener(this)
});
if(!this.options.get("embedded"))
{
buttons_div.build("span", {innerHTML: "&#160;"});
buttons_div.build("a", { innerHTML: _translations["OK"], href: "#", onclick: function() {this.close(); return false;}.bindAsEventListener(this) });
}
}
},
refresh: function ()
{
this.refreshMonthYear();
this.refreshCalendarGrid();
this.setSelectedClass();
this.updateFooter();
},
refreshCalendarGrid: function () {
this.beginning_date = new Date(this.date).stripTime();
this.beginning_date.setDate(1);
this.beginning_date.setHours(12); // Prevent daylight savings time boundaries from showing a duplicate day
var pre_days = this.beginning_date.getDay() // draw some days before the fact
if(pre_days < 3) pre_days += 7;
this.beginning_date.setDate(1 - pre_days + Date.first_day_of_week);
var iterator = new Date(this.beginning_date);
var today = new Date().stripTime();
var this_month = this.date.getMonth();
vdc = this.options.get("valid_date_check");
for (var cell_index = 0;cell_index<42; cell_index++)
{
day = iterator.getDate(); month = iterator.getMonth();
cell = this.calendar_day_grid[cell_index];
Element.remove(cell.childNodes[0]); div = cell.build("div", {innerHTML:day});
if(month!=this_month) div.className = "other";
cell.day = day; cell.month = month; cell.year = iterator.getFullYear();
if(vdc) { if(vdc(iterator.stripTime(),this)) cell.removeClassName("disabled"); else cell.addClassName("disabled") };
iterator.setDate( day + 1);
}
if(this.today_cell) this.today_cell.removeClassName("today");
if( $R( 0, 42 ).include(days_until = this.beginning_date.stripTime().daysDistance(today)) ) {
this.today_cell = this.calendar_day_grid[days_until];
this.today_cell.addClassName("today");
}
},
refreshMonthYear: function() {
var m = this.date.getMonth();
var y = this.date.getFullYear();
if(this.options.get("month_year") == "dropdowns")
{
this.month_select.setValue(m, false);
var e = this.year_select.element;
if(this.flexibleYearRange() && (!(this.year_select.setValue(y, false)) || e.selectedIndex <= 1 || e.selectedIndex >= e.options.length - 2 )) this.populateYearRange();
this.year_select.setValue(y);
}else{
this.month_year_label.update( Date.months[m] + " " + y.toString()  );
}
},
populateYearRange: function() {
this.year_select.populate(this.yearRange().toArray());
},
yearRange: function() {
if(!this.flexibleYearRange())
return $R(this.options.get("year_range")[0], this.options.get("year_range")[1]);
var y = this.date.getFullYear();
return $R(y - this.options.get("year_range"), y + this.options.get("year_range"));
},
flexibleYearRange: function() { return (typeof(this.options.get("year_range")) == "number"); },
validYear: function(year) { if(this.flexibleYearRange()) { return true;}else{ return this.yearRange().include(year);}  },
dayHover: function(element) {
var hover_date = new Date(this.selected_date);
hover_date.setYear(element.year); hover_date.setMonth(element.month); hover_date.setDate(element.day);
this.updateFooter(hover_date.toFormattedString(this.use_time, this.options.get("format"), true));
},
dayHoverOut: function(element) { this.updateFooter(); },
setSelectedClass: function() {
if(!this.selection_made) return;
if(this.selected_cell) this.selected_cell.removeClassName("selected");
if($R(0,42).include( days_until = this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()) )) {
this.selected_cell = this.calendar_day_grid[days_until];
this.selected_cell.addClassName("selected");
}
},
reparse: function() { this.parseDate(); this.refresh(); },
dateString: function() {
return (this.selection_made) ? this.selected_date.toFormattedString(this.use_time, this.options.get("format"), false) : "&#160;";
},
parseDate: function()
{
var value = $F(this.target_element).strip()
this.date = value=="" ? NaN : Date.parseFormattedString(this.options.get("date") || value, this.options.get("format"));
if(isNaN(this.date)) this.date = new Date();
if(!this.validYear(this.date.getFullYear())) this.date.setYear( (this.date.getFullYear() < this.yearRange().start) ? this.yearRange().start : this.yearRange().end);
this.selected_date = new Date(this.date);
this.use_time = /[0-9]:[0-9]{2}/.exec(value) ? true : false;
this.date.setDate(1);
},
updateFooter:function(text) { if(!text) text = this.dateString(); this.footer_div.purgeChildren(); this.footer_div.build("span", {innerHTML: text }); },
updateSelectedDate:function(partsOrElement, via_click) {
var parts = $H(partsOrElement);
if((this.target_element.disabled || this.target_element.readOnly) && this.options.get("popup") != "force") return false;
if(parts.get("day")) {
var t_selected_date = this.selected_date, vdc = this.options.get("valid_date_check");
for (var x = 0; x<=3; x++) t_selected_date.setDate(parts.get("day"));
t_selected_date.setYear(parts.get("year"));
t_selected_date.setMonth(parts.get("month"));
if(vdc && ! vdc(t_selected_date.stripTime(),this)) { return false; }
this.selected_date = t_selected_date;
this.selection_made = true;
}
if(!isNaN(parts.get("hour"))) this.selected_date.setHours(parts.get("hour"));
if(!isNaN(parts.get("minute"))) this.selected_date.setMinutes( Math.floor_to_interval(parts.get("minute"), this.options.get("minute_interval")) );
if(parts.get("hour") === "" || parts.get("minute") === "")
this.setUseTime(false);
else if(!isNaN(parts.get("hour")) || !isNaN(parts.get("minute")))
this.setUseTime(true);
this.updateFooter();
this.setSelectedClass();
if(this.selection_made) this.updateValue();
if(this.options.get("close_on_click")) { this.close(); }
if(via_click && !this.options.get("embedded")) {
if((new Date() - this.last_click_at) < 333) this.close();
this.last_click_at = new Date();
}
},
navMonth: function(month) { (target_date = new Date(this.date)).setMonth(month); return (this.navTo(target_date)); },
navYear: function(year) { (target_date = new Date(this.date)).setYear(year); return (this.navTo(target_date)); },
navTo: function(date) {
if(!this.validYear(date.getFullYear())) return false;
this.date = date;
this.date.setDate(1);
this.refresh();
this.callback("after_navigate", this.date);
return true;
},
setUseTime: function(turn_on) {
this.use_time = this.options.get("time") && (this.options.get("time")=="mixed" ? turn_on : true) // force use_time to true if time==true && time!="mixed"
if(this.use_time && this.selected_date) { // only set hour/minute if a date is already selected
var minute = Math.floor_to_interval(this.selected_date.getMinutes(), this.options.get("minute_interval"));
var hour = this.selected_date.getHours();
this.hour_select.setValue(hour);
this.minute_select.setValue(minute)
} else if(this.options.get("time")=="mixed") {
this.hour_select.setValue(""); this.minute_select.setValue("");
}
},
updateValue: function() {
var last_value = this.target_element.value;
this.target_element.value = this.dateString();
if(last_value!=this.target_element.value) this.callback("onchange");
},
today: function(now) {
var d = new Date(); this.date = new Date();
var o = $H({ day: d.getDate(), month: d.getMonth(), year: d.getFullYear(), hour: d.getHours(), minute: d.getMinutes()});
if( ! now ) o = o.merge({hour: "", minute:""});
this.updateSelectedDate(o, true);
this.refresh();
},
close: function() {
if(this.closed) return false;
this.callback("before_close");
this.target_element.calendar_date_select = nil;
Event.stopObserving(document, "mousedown", this.closeIfClickedOut_handler);
Event.stopObserving(document, "keypress", this.keyPress_handler);
this.calendar_div.remove(); this.closed = true;
if(this.iframe) this.iframe.remove();
if(this.target_element.type!="hidden") this.target_element.focus();
this.callback("after_close");
},
closeIfClickedOut: function(e) {
if(! $(Event.element(e)).descendantOf(this.calendar_div) ) this.close();
},
keyPress: function(e) {
if(e.keyCode==Event.KEY_ESC) this.close();
},
callback: function(name, param) { if(this.options.get(name)) { this.options.get(name).bind(this.target_element)(param); } }
}
Date.prototype.toFormattedString = function(useTime, format, useText)
{
str = "";
switch (format)
{
case "isoDate":
str = calendarDateFormat_isoDate(this, useTime, useText);
break;
case "fullDate":
str = calendarDateFormat_fullDate(this, useTime, useText);
break;
case "weekYear":
str = calendarDateFormat_weekYear(this, useTime, useText);
break;
default:
str = calendarDateFormat_default(this, useTime, useText);
break;
}
return str;
}
Date.parseFormattedString = function (string, format)
{
date = new Date();
switch (format)
{
case "weekYear":
var kwYear= string.split("/");
var kw = kwYear[0];
var year = kwYear[1];
var days = 7 * (kw-1) + 3;
month = Math.floor(days / 30)
dayFrac = days - 30*month;
date.setFullYear(year);
date.setMonth(month);
date.setDate(dayFrac);
break;
case "fullDate":
default:
var aDate = string.split(".");
var d = aDate[0];
var m = aDate[1];
var y = aDate[2];
date = (new Date(y, m-1, d)).stripTime();
break;
}
return date;
}
function calendarDateFormat_fullDate(oThis, useTime)
{
var idxDay = (oThis.getDay()+7-Date.first_day_of_week)%7
return Date.dayNames[idxDay] + ", " + Date.padded2(oThis.getDate()) + ". " + Date.months[oThis.getMonth()] + " " + oThis.getFullYear();
}
function calendarDateFormat_isoDate (oThis, useTime)
{
return oThis.getFullYear() + "-" + Date.padded2(oThis.getMonth() + 1) + "-" +Date.padded2(oThis.getDate());
}
MonatsTage= new Array();
MonatsTage[1]= 31; MonatsTage[2]= 28; MonatsTage[3]= 31;
MonatsTage[4]= 30; MonatsTage[5]= 31; MonatsTage[6]= 30;
MonatsTage[7]= 31; MonatsTage[8]= 31; MonatsTage[9]= 30;
MonatsTage[10]= 31; MonatsTage[11]= 30; MonatsTage[12]= 31;
function dattage(Ta, Mo, Ja) {
var dattag = 365 * Ja + Ta;
for (i=1;i<Mo;i++) dattag+= MonatsTage[i]
if(Ja < 1582) {
dattag+= 10;
for (i = 1580; i >= Ja; i-= 4 )
dattag--;
}
else
if(Ja == 1582) {
if(Mo == 10) {
if(Ta < 5) dattag+= 10;
else
if(Ta < 15) dattag = -99;
}
else if(Mo < 10) dattag+= 10;
}
else
if(Ja > 2499) dattag = -99;
else {
for (i = 1584; i < Ja; i+= 4)
dattag++;
for (i = 1700; i < Ja; i+= 100)
if((i % 400) > 0) dattag--;
}
if(dattag > 0) {
if((Ja % 4) == 0 && Mo > 2 & (Ja < 1582 || (Ja % 100) > 0 || (Ja % 400) == 0)) dattag++;
}
return dattag;
}
function dattagT(TaT,MoT,JaT) {
var dt, MonatsTag;
Ta = parseInt(TaT);
Mo = parseInt(MoT);
Ja = parseInt(JaT);
if(Ja > 2499 || Ja < 1) {
return "Als Jahreszahlen sind nur 1 bis 2499 erlaubt!";
}
else {
if(Ja<100) {
return "Jahreszahlen unter 100 werden als Daten des 1. Jahrhunderts n. Chr. interpretiert.";
}
if(Mo > 12 || Mo < 1) {
return "Als Monate bitte nur Zahlen von 1 bis 12 eingeben!";
}
else {
if(Ta > 31 || Ta < 1) {
return "Als Tage bitte nur Zahlen von 1 bis 31 eingeben!";
}
else {
MonatsTag = MonatsTage[Mo];
if(Mo == 2)
{
if((Ja % 4) == 0 && (Ja < 1582 || (Ja % 100) > 0 || (Ja % 400) == 0)) MonatsTag = 29;
}
if(Ta > MonatsTag) {
var zwi="Der Monat " + Mo + " hat nur " + MonatsTag + " Tage!";
if(Mo == 2) {
zwi="Der Monat Februar hat im Jahr "+Ja+" nur " + MonatsTag + " Tage!";
}
return zwi;
}
else
{
dt = dattage(Ta, Mo, Ja);
if(dt <= -20)
{
return "Unerlaubtes Datum!";
}
}
}
}
}
return dt;
}
function kalwv(kJahr,kdtg) {
var wth, datagw, kW;
datagw = dattagT(4, 01, kJahr);
if(isNaN(datagw)){return datagw;}
wth = (datagw + 24) % 7;
datagw = datagw - wth;
kW = Math.floor((kdtg+7-datagw)/7)
return kW;
}
function kalwo(kJ1,dtg) {
var kT, kM, kJ, kalw, kalww, kW, kalJ;
kJ=parseInt(kJ1);
if(kJ>1975 && kJ<2500) {
kalw = kalwv(kJ,dtg)
if(isNaN(kalw)){return kalw;}
if(kalw < 1)
{
kalw = kalwv(kJ-1,dtg);
if(isNaN(kalw)){return kalw;}
kalJ = kJ-1;
}
else { kalJ = kJ;
if(kalw > 52) {
kalww = kalwv(kJ+1,dtg);
if(isNaN(kalww)){return kalww;}
if(kalww>0) { kalw = kalww; kalJ = kJ+1 }
}
}
kW = kalw;
}
else kW="";
return kW;
}
function CalcKalenderWoche(day, mon, year)
{
datag = dattagT(day, mon+1, year);
if(isNaN(datag)){return datag;}
return kalwo(year,datag);
}
function calendarDateFormat_weekYear(oThis, useTime, useText)
{
var kw = CalcKalenderWoche(oThis.getDate(), oThis.getMonth(), oThis.getFullYear());
if(isNaN(kw)){return kw;}
if(useText)
{
return "Kalenderwoche " + Date.padded2(kw) + "/" + oThis.getFullYear();
}
else
{
return Date.padded2(kw) + "/" + oThis.getFullYear();
}
}
function calendarDateFormat_default(oThis, useTime)
{
return Date.padded2(oThis.getDate()) + "." + Date.padded2(oThis.getMonth() + 1) + "." + oThis.getFullYear();
}
function calendar_create_handle (inputCtrl)
{
var choiseHandle = GetClientCtrlHandleHtml (inputCtrl, "<span class='calendarHandle' onclick='Calendar_Show(this)' onblur='Calendar_Hide (this)'></span>")
inputCtrl.insert ({after: choiseHandle});
newId = inputCtrl.next("span.clientCtrl").identify()
$(newId).insert ({top: inputCtrl});
}
function clientCtrl_SetCurrendState (oCtrl)
{
if(oCtrl)
{
if(!oCtrl.hasClassName ("clientCtrl"))
{
oCtrl = oCtrl.up(".clientCtrl");
}
if(oCtrl && IsDefined(oCtrl))
{
var inp = $(oCtrl).down("input");
if(inp && IsDefined(inp))
{
oCtrl.select("span.calendarHandle,span.comboHandle").each(function(handle)
{
if(inp.hasClassName("readonly"))
{
addClassNames (oCtrl, "readonly cursorNoDrop")
addClassNames (handle, "readonly cursorNoDrop")
}
else
{
removeClassNames (oCtrl, "readonly cursorNoDrop")
removeClassNames (handle, "readonly cursorNoDrop")
}
})
}
}
}
}
var aCRefFldCache = new Array();
function CalendarGetLimitDate (limitString)
{
var limitDate = new Date();
if(limitString.startsWith('Today'))
{
var offset = getClassValue (limitString, 'Today');
if(offset.length > 0)
{
limitDate = new Date(limitDate.getFullYear(),limitDate.getMonth(), parseInt(offset) + limitDate.getDate());
}
}
else if(limitString.startsWith('cRef_'))
{
var clsName = getClassValue (limitString, 'cRef_');
if(clsName.length > 0)
{
oFld = aCRefFldCache[clsName];
if(!IsDefined (oFld))
{
var fld = $$("#areaContent input.cName_" + clsName);
if($A(fld).length > 0)
{
var oFld = fld.first();
aCRefFldCache[clsName] = oFld;
}
}
if(IsDefined (oFld))
{
limitDate = getFieldCalendarDate(oFld)
}
}
}
return limitDate.stripTime();
}
function IsInCalendarLimits (date, className)
{
var limitMin = getClassValue (className, 'limitMin_');
if(limitMin.length > 0)
{
var minDate = CalendarGetLimitDate (limitMin);
if(date < minDate)
{
return false;
}
}
var limitMax = getClassValue (className, 'limitMax_');
if(limitMax.length > 0)
{
var maxDate = CalendarGetLimitDate (limitMax);
if(date > maxDate)
{
return false;
}
}
return true;
}
function CalendarValidDateCheck (date, oThis)
{
return IsInCalendarLimits (date, oThis.target_element.className)
}
function Calendar_Show (oThis)
{
var inp = $(oThis).previous("input");
if(!inp)
{
local_alert ("calendar input not found");
return true;
}
else
{
var ctrl = inp.up(".clientCtrl");
clientCtrl_SetCurrendState (ctrl);
if(!inp.hasClassName("readonly"))
{
var format = getClassValue (inp.className, 'Format_');
new CalendarDateSelect (inp, {time:false, year_range:5, format:format,valid_date_check:CalendarValidDateCheck});
}
return false;
}
}
function Calendar_Hide (oThis)
{
return true;
}
function calendar_validate(oThis)
{
var cName = getClassValue (oThis.className, 'cName_');
if(cName.length > 0)
{ // alle Elemente mit Referenz hierauf suchen
var refName = "cRef_"+cName;
oFld = aCRefFldCache[refName];
if(!IsDefined (oFld))
{
$$("#areaContent input.calendar[class*="+refName+"]").each(function(el)
{
oFld = el;
aCRefFldCache[refName] = oFld;
})
}
if(IsDefined (oFld))
{
validatorApply(oFld);
}
}
return true;
}
function calendar_behaviour_init ()
{
$$("input.calendar").each(function(el)
{
calendar_create_handle (el);
clientCtrl_SetCurrendState (el);
el.addClassName("validate");
el.onchange = function()
{
return calendar_validate($(this))
}
})
}
function dsnTabListBox_edit_selector_init(selector)
{
arrangeable_selector_init(selector + " .arrangeable");
$$(selector + " .dsnTabListBoxEditForm").each(function(frm)
{
frm.select ('a[href^=#delete]').each(function(a)
{
a.onclick=function()
{
$(this).up("li").addClassName("deleted");
return false;
}
})
frm.select ('a[href^=#restore]').each(function(a)
{
a.onclick=function()
{
$(this).up("li").removeClassName("deleted");
return false;
}
})
frm.select ('li.createListBoxItem input[type=submit]').each(function(inp)
{
inp.onclick=function()
{
debug_show("createListBoxItem");
return false;
}
})
frm.select ('li.createListBoxItem input[type=text]').each(function(inp)
{
inp.onkeyup=function()
{
var txt = $F(this);
txt = txt.toLowerCase();
txt = txt.replace(/  /g, " ");
txt = txt.replace(/ /g, "-");
txt = txt.replace(/ö/g, "oe");
txt = txt.replace(/ü/g, "ue");
txt = txt.replace(/ä/g, "ae");
txt = txt.replace(/ß/g, "ss");
var oLabel = $(this).up("li").down("label");
oLabel.innerHTML = txt;
return false;
}
})
})
}
function imageChooser_create_handle (inputCtrl)
{
var choiseHandle = GetClientCtrlHandleHtml (inputCtrl, "<span class='imageChooserHandle' onclick='imageChooser_Show(this)' onblur='imageChooser_Hide (this)'></span>")
inputCtrl.insert ({after: choiseHandle});
newId = inputCtrl.next("span.clientCtrl").identify()
$(newId).insert ({top: inputCtrl});
}
function imageChooser_Show (oThis)
{
var inp = $(oThis).previous("input"), oImg, cls;
if(!inp)
{
debug_out ("imageChooser input not found");
return true;
}
else
{
oImg = $(oThis).up("li").down("img");
cls = $(oImg).up("p").className;
debug_out(GetValue (inp) + ": id=" + inp.identify());
ajaxContentGet ('renderImageContent:newDragWindow',
{
directory:getClassValue(cls, "imgRoot_"),
column:getClassValue(cls, "col_"),
ajaxPathInfo:getCurrendPage (),
fieldFormat:"imageName",
connectedField:inp.identify(),
connectedImage:oImg.identify(),
imgDetail:'imgDetail'
});
return false;
}
}
function imageChooser_Hide (oThis)
{
return true;
}
function imageChooser_behaviour_init ()
{
fileUploadButton_behaviour_init ();
$$("input.imageChooser").each(function(el)
{
imageChooser_create_handle (el);
})
}
function fileUploadButton_behaviour_init ()
{
$$("input.fileUpload").each(function(el)
{
el.onclick = function()
{
var curPage = this.name.substr(4); ;
getUploadDragIFrameForm(curPage,'image','modal');
return false;
}
})
}
var g_scrollDuration = "0.5";
function thisNotify(oThis, action)
{
var usp,val = "";
oThis = $(oThis);
switch (oThis.tagName)
{
case "A":
usp = getClassValue (oThis.className, 'u_');
if("" != usp)
{
val = "u_" +  usp;
}
break;
case "INPUT":
val = oThis.value;
break;
case "SELECT":
val = $F(oThis);
break;
default:
debug_out ("thisNotify: undefined tagName (" + oThis.tagName + ")");
break;
}
switch (action)
{
case "closed":
debug_out ("thisNotify: closed (" + oThis.identify() + ")");
switch (oThis.identify())
{
case "devDbgWin":
userSettingsBehaviour ();
break;
case "clone_idCmsButtons":
removeBodyClass ("u_cmseditmode");
oThis.removeClassName("hidden");
userSettingsBehaviour ();
sync_footer_with_bodyClass();
break;
}
break;
case "inputChanged":
var type = oThis.type;
switch (type)
{
case "range":
if("function" == typeof (updateRangeSlider))
{
updateRangeSlider(oThis);
debug_out ("thisNotify: inputChanged ("+type+"): (" + val + "); name = " + oThis.name + "; id = " + oThis.identify());
}
break;
}
val = oThis.name;
break;
case "changed":
switch (val)
{
case "u_showdevelopdebugwin":
var oWin = $(val);
if(!oWin)
{
oWin = $$('.footer input[type=checkbox][value='+val+']').first();
}
developHandleDebugWin (oWin);
break;
case "u_inplaceedit":
inplaceEdit_init();
break;
case "u_inplacearrange":
inplaceArrange_init();
break;
case "u_designmode":
el = $$('.footer input[type=checkbox][value='+val+']').first();
if(el)
{
document.desingnMode = (el.checked) ? "on" : "off";
debug_out ("document.desingnMode = (" + document.desingnMode + ")");
}
break;
default:
debug_out ("thisNotify: default name = " + val + ")");
break;
}
debug_out ("thisNotify: changed (" + val + ")");
break;
default:
debug_out ("thisNotify: undefined action (" + action + ")");
break;
}
if("function" == typeof ($fnCall)) {$fnCall(val, oThis, 0);}else{debug_out("fnCall unknown: " + action) }
return false;
}
function handleMouseClick(e)
{
if(!e) e=event;
debug_out('handleClick: button=' + e.button);
if(document.all)
{
if(event.button==2||event.button==3)
{
debug_out('rmouse');
return false;
}
}
}
function buttonalert(evt)
{
if(!evt) evt=event;
var button;
if(evt.which == null)
button= (evt.button < 2) ? "LEFT" :
((evt.button == 4) ? "MIDDLE" : "RIGHT");
else
button= (evt.which < 2) ? "LEFT" :
((evt.which == 2) ? "MIDDLE" : "RIGHT");
dont(evt);
debug_out(button);
}
function dont(evt)
{
if(evt.preventDefault)
evt.preventDefault();
else
evt.returnValue= false;
return false;
}
String.prototype.trimLeft = function () {
return (this.replace(/^\s+/,""));
};
String.prototype.trimRight = function () {
return (this.replace(/\s+$/,""));
};
String.prototype.trim = function () {
var str = this.replace(/^\s\s*/, ''), ws = /\s/, i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
};
function ie6_dragWindowGetIFrame (theId)
{
if($(theId))
{
var frameId = "iFrameChild_" + getClassValue ($(theId).className, 'iFrameChild_');
return $(frameId);
}
return null;
}
function ie6_dragWindowCreateIFrame (oMainElem, iFrmClsName)
{
if(oMainElem)
{
var iFrmId = "iFrameChild_now" + oMainElem.identify();
var mainId = oMainElem.identify();
if(0 == mainId.indexOf("clone_"))
{
iFrameId = mainId.substr(6);
clonedIFrmId = "iFrameChild_now" + mainId.substr(6);
if($(clonedIFrmId))
{
iFrmId = clonedIFrmId;
}
}
var zIndex = oMainElem.getStyle("z-index");
if(!$(iFrmId))
{
if("string" == typeof (iFrmClsName))
{
iFrmClsName += " ie6IFrameFix";
}
else
{
iFrmClsName = "ie6IFrameFix";
}
var iFrame = '<iframe id="'+iFrmId+'" class="'+iFrmClsName+'" src="/NewadaOnWeb/res/html/iFrameDummyContent.html" border="0"></iframe>';
getBody().insert (iFrame);
}
var oIFrame = $(iFrmId);
oIFrame.setStyle({"z-index": zIndex-1});
oMainElem.addClassName(iFrmId);
Position.clone(oMainElem, oIFrame);
dragWindowReposition (oMainElem.identify(), 2);
}
}
function remove_size_units(size)
{
size = size.replace('px','');
size = size.replace('%','');
size = size.replace('em','');
return size;
}
function ie6_fixes_WindowRedraw (oMainElemId, offset)
{ // hier darf kein debug_out aufgerufen werden, sonst gibt's ne endlosschleife !!!
var oIFrame = ie6_dragWindowGetIFrame(oMainElemId);
if(oIFrame)
{
if(!offset)
{
offset = 0;
}
Position.clone($(oMainElemId), oIFrame);
var t = oIFrame.style.top.replace('px','');
var l = oIFrame.style.left.replace('px','');
var w = oIFrame.style.width.replace('px','');
var h = oIFrame.style.height.replace('px','');
oIFrame.style.left = (1 * l - offset) + "px";
oIFrame.style.top = (1 * t - offset) + "px";
oIFrame.style.width = (1 * w + 2 * offset) + "px";
oIFrame.style.height = (1 * h + 2 * offset) + "px";
}
}
function ie6_fixes_WinReposition (oMainElemId, offset)
{
var oIFrame = ie6_dragWindowGetIFrame(oMainElemId);
if(oIFrame)
{
if(!offset)
{
offset = 0;
}
ie6_fixes_WindowRedraw (oMainElemId, offset);
}
}
function ie6_fixes_Init ()
{
}
window.onerror=fnReportJsError;
window.onError=fnReportJsError;
var g_errorReporting_url = "";
function fnReportJsError(msg, url, line)
{
debug_error ("Javascript-ERROR:", "<li>line: <b>" + line + "</b></li>\n <li>msg: <b>" + msg + "</b></li>\n</ul>");
addBodyClasses('has_scriptError');
return false; // show error alert
return true; // no alert error
}
function dragWindowGetOtherMaxZ (winId)
{
var zMax = -1;
$$(".dragWindow").each(function(win)
{
var z = win.getStyle('z-index');
if(win.identify() != winId)
{
if(z > zMax)
{
zMax = z;
}
}
})
return zMax;
}
function replacePagePersistStyles (styleDef)
{
$$("head style[title='page-persist-styles']").each(function(el)
{
el.remove();
})
var idHeadStyle = $$("head").first().identify();
$(idHeadStyle).insert(styleDef);
}
function updatePagePersistStyles (styleSelector, styleDef)
{
var posB,posE,newStyle,oldStyle = "";
$$("head style[title='page-persist-styles']").each(function(el)
{
oldStyle += el.innerHTML;
})
oldStyle = oldStyle.replace('<!--','');
oldStyle = oldStyle.replace('-->','');
oldStyle = oldStyle.replace(/\n/g,'');
oldStyle = oldStyle.trim();
posB = oldStyle.indexOf(styleSelector +'{');
if(posB > -1)
{
posE = oldStyle.indexOf('}', posB+1);
if(posB < posE)
{
newStyle = oldStyle.substr(posB+styleSelector.length, posE);
if(newStyle == styleDef)
{
return;
}
oldStyle = oldStyle.substr(0, posB) + oldStyle.substr(posE+1);
}
}
oldStyle = oldStyle.replace(/}/g,'}\n');
newStyle = oldStyle + styleSelector + styleDef;
replacePagePersistStyles ("<style type='text/css' title='page-persist-styles'><!--\n" + newStyle + "\n -->\n</style>");
}
function getWindowStyleDef (oWin, top, left, zIndex, important)
{
var t = "" + Math.round(top),
l = "" + Math.round(left);
if(important)
{
return "{top:"+t+"px!important;left:"+l + "px!important;z-index:"+zIndex+"}";
}
return "{top:"+t+"px;left:"+l + "px;z-index:"+zIndex+"}";
}
function dragWindowSetFixed (oThis)
{
var oWin = $(oThis).up(".dragWindow");
if(oWin)
{
var winVal = getClassValue (oWin.className, 'u_');
if("" != winVal)
{
winVal = "u_" + winVal + "Fixed";
if($(oThis).checked)
{
addBodyClasses (winVal);
}
else
{
removeBodyClasses (winVal);
}
}
}
return true;
}
function dragWindowPersistWin (oWin, zIndex)
{
oWin = $(oWin);
if(oWin)
{
var winVal = getClassValue (oWin.className, 'u_');
if("" != winVal)
{
var l = readStyleVal (oWin, 'left');
var t = readStyleVal (oWin, 'top');
if(t < 0)
{
t = 0;
}
var theStyle = getWindowStyleDef (oWin, t, l, zIndex);
ajaxContentPost ("userStylePersist", {styleId:"div.u_"+winVal,styleDef:theStyle,ajaxPersist:true,denyMessages:true});
}
else
{
debug_out ("dragWindowPersistId ("+oWin.identify()+"): no valid classValue ("+winVal+")");
} }
}
function dragWindowPersist (draggable)
{
var winId = draggable.options.winId;
var oWin = $(winId);
if(oWin)
{
var winVal = getClassValue (oWin.className, 'u_');
if("" != winVal)
{
var style = "";
var zMax = dragWindowGetOtherMaxZ (winId);
if(zMax >= draggable.originalZ)
{
zMax++;
draggable.originalZ = zMax;
}
else
{
zMax = draggable.originalZ;
}
dragWindowPersistWin (oWin, zMax);
}
}
}
function dragWindowToggleModal (oThis)
{
set_modal(oThis.checked);
return true;
}
function dragWindowIFrame (oMainElemId)
{
if("function" == typeof (ie6_dragWindowGetIFrame))
{
ie6_dragWindowGetIFrame (oMainElemId);
}
else
{
return null;
}
}
function dragWinIFrameHide (winId)
{
var oIFrame = dragWindowIFrame(winId);
if(oIFrame)
{
oIFrame.hide();
}
}
function dragWinMoveStart (draggable, event)
{
dragWinIFrameHide (draggable.options.winId);
if(need_ie6_IFrame())
{
addBodyClasses('onDragWindowMove');
}
}
function dragWindowReposition (oMainElemId, offset)
{
ie6_fixes_WinReposition (oMainElemId, offset);
}
function dragWindowRedraw (oMainElemId)
{
ie6_fixes_WindowRedraw (oMainElemId);
}
function dragWindowMoved (draggable, event)
{
}
function dragWindowMoveEnd (draggable, event)
{
oWin = $(draggable.options.winId);
if(IsDefined(oWin))
{
var t = readStyleVal (oWin, 'top');
if(t < 0)
{
oWin.setStyle({top:'0'});
}
var l = readStyleVal (oWin, 'left');
var w = readStyleVal (oWin, 'width');
if(l < -w+100)
{
l = -w + 100;
var nLeft = "" + l + "px";
oWin.setStyle({left:nLeft});
}
var oIFrame = dragWindowIFrame(draggable.options.winId);
if(oIFrame)
{
oIFrame.show();
}
dragWindowReposition (draggable.options.winId, 0);
removeBodyClasses("onWindowResizeScroll onDragWindowMove");
dragWindowPersist (draggable);
}
}
function dragWindow_SetToCenter(oDragWnd)
{
if(IsDefined (oDragWnd))
{
var dragSize = oDragWnd.getDimensions();
var viewportSize = document.viewport.getDimensions();
var windowScroll = document.viewport.getScrollOffsets();
var dw = Math.floor((viewportSize.width - dragSize.width) / 2);
var dh = Math.floor((viewportSize.height - dragSize.height) / 2);
dh /= 2; // position oberes drittel
if(dw < 0)
{
dw = 0;
}
if(dh < 0)
{
dh = 0;
}
var z = oDragWnd.getStyle('z-index');
var uspStyle = "";
var uspName = getClassValue (oDragWnd.className, 'u_');
if("" == uspName)
{
uspName = "usp" + oDragWnd.identify();
uspStyle = "tmp_" + uspName;
oDragWnd.addClassName (uspStyle);
}
else
{
uspStyle = "u_" + uspName;
}
var values = getScrollValues ();
var style = "";
if(Prototype.Browser.IE)
{
style = getWindowStyleDef (oDragWnd, dh+values.top, dw, z);
oDragWnd.setStyle(style);
}
else
{
updatePagePersistStyles ("div." + uspStyle, getWindowStyleDef (oDragWnd, dh, dw, z));
}
}
}
function dragWindowCreate(winId, title, content, footer, extraClass)
{
var oDragWnd = $(winId);
if(!oDragWnd || !IsDefined(oDragWnd))
{
var chooseFixed = "";
var usp = getClassValue (extraClass, 'u_');
var clsClosed = "";
if("" != usp)
{
if(IsDefined (g_mCookie))
{
if(("1" == g_mCookie.get ("u_" + usp)))
{
clsClosed = " closed";
}
}
var checked = "";
var uFix = "u_"+usp+"Fix";
chooseFixed = "<span class=\"setFixedCtrl\"><input type=\"checkbox\" class=\"checkbox chooseFixed\" name=\""+uFix+"\" id=\""+uFix+"\" onclick=\"return dragWindowSetFixed(this)\" "+ checked +"/><label for=\""+uFix+"\">fixed</label></span>";
}
var btnMinify = '<span class="head'+clsClosed+'">minify</span>';
if(need_ie6_IFrame())
{
extraClass = extraClass.replace('collapsible','hideMinify');
btnMinify = "";
}
var btnClose = '<a href="#" class="fright abort">[x]</a>';
var btnHead = btnMinify + btnClose;
var dragClass = "dragWindow";
if("string" == typeof (extraClass))
{
dragClass += " " + extraClass;
}
if("" != footer)
{
footer = '<div class="foot buttons">'+ footer+'</div>';
}
var dragDiv = '<div id="'+winId+'" class="'+dragClass+'">\n<h4>'+chooseFixed+'<span class="dragHandle">'+title+'</span>'+btnHead+'</h4>\n<div class="body"><div class="content">'+content+'</div></div>'+footer+'</div>\n';
getBody().insert (dragDiv);
oDragWnd = $(winId);
dragWindow_Behaviour_Selector_Init("#" + winId);
}
return oDragWnd;
}
function dragWindowCloneId (dragWindowId)
{
return "clone_" + dragWindowId;
}
function dragWindowSelect(dragWindow)
{
var oDragWnd = null;
if(dragWindow)
{
if("string" == typeof (dragWindow))
{
oDragWnd = $(dragWindow);
if(!IsDefined(oDragWnd))
{
oDragWnd = $$(dragWindow).first();
}
if(!IsDefined(oDragWnd) || !oDragWnd.hasClassName("dragWindow"))
{
var oCloneWnd = $(dragWindowCloneId (dragWindow));
if(IsDefined (oCloneWnd))
{
oDragWnd = oCloneWnd;
}
else
{
}
}
else
{
}
}
else
{
oDragWnd = $(dragWindow.identify());
if(oDragWnd && !oDragWnd.hasClassName("dragWindow"))
{
var oCloneWnd = $(dragWindowCloneId (dragWindow.identify()));
if(IsDefined (oCloneWnd))
{
oDragWnd = oCloneWnd;
}
else
{
oDragWnd = $(oDragWnd).up(".dragWindow");
}
}
}
if(!oDragWnd || !IsDefined(oDragWnd))
{
}
}
return oDragWnd;
}
function dragWindowHide(dragWindow)
{
var oDragWnd = dragWindowSelect(dragWindow);
if(oDragWnd)
{
oDragWnd.addClassName('hidden');
var oCloneWnd = $(dragWindowCloneId (oDragWnd.identify()));
if(IsDefined (oCloneWnd))
{
oCloneWnd.addClassName('hidden');
}
dragWinIFrameHide (oDragWnd.identify());
}
removeBodyClasses('ie6_displayDragWindow mode_Modal onWindowResizeScroll onDragWindowMove mode_Modal u_wndModal wndModal u_showDevelopDebugWin');
}
function dragWindowShow (dragWindow, modal, posobj, dataSource, dataTaget)
{
var targetData = $(dataTaget);
var sourceData = $(dataSource);
var oDragWnd = dragWindowSelect(dragWindow);
if(oDragWnd)
{
oDragWnd.removeClassName('showOnLoad');
var wndCloneId = dragWindowCloneId (oDragWnd.identify());
var oCloneWnd = $(wndCloneId);
if(oDragWnd.hasClassName("clonedWindow"))
{
oCloneWnd = oDragWnd;
if(posobj && IsDefined(posobj))
{
Position.clone($(posobj), oCloneWnd, { setHeight: false, setWidth: false, offsetTop: $(posobj).offsetHeight - $(posobj).getHeight() });
}
}
else
{
if(!IsDefined (oCloneWnd))
{
if(!oDragWnd.hasClassName("createCloneWindow"))
{
oCloneWnd = oDragWnd;
}
else
{
oDragWnd.removeClassName('createCloneWindow');
var wndCnt = oDragWnd.innerHTML;
var cloneWndCnt = '<div id="'+wndCloneId+'" class="clonedWindow '+oDragWnd.className+'">' + oDragWnd.innerHTML + '<div>';
oDragWnd.innerHTML = "";
oDragWnd.className = "displayNone";
getForm().insert({bottom: cloneWndCnt});
oCloneWnd = $(wndCloneId);
if( targetData != null && sourceData != null )
{
targetData = $(dataTaget);
sourceData = dataSource.up().next();
targetData.innerHTML = sourceData.innerHTML;
}
if(oCloneWnd.hasClassName ("screenCenter"))
{
dragWindow_SetToCenter(oCloneWnd);
}
else if(posobj && IsDefined(posobj))
{
Position.clone($(posobj), oCloneWnd, { setHeight: false, setWidth: false, offsetTop: $(posobj).offsetHeight - $(posobj).getHeight() });
}
}
}
if(("-1px" == oCloneWnd.getStyle("top")) && ("-11px" == oCloneWnd.getStyle("left") ))
{
dragWindow_SetToCenter(oCloneWnd);
dragWindowPersistWin (oCloneWnd, oCloneWnd.getStyle('z-index') || 0);
}
dragWindow_Behaviour_Selector_Init ("#" + oCloneWnd.identify());
}
removeClassNames(oCloneWnd, 'hidden invisible showOnLoad');
dragWindowSetOnTop(oCloneWnd);
if(modal)
{
addBodyClasses('mode_Modal');
}
if(need_ie6_IFrame())
{
removeBodyClasses('onDragWindowMove');
}
}
}
function dragWindowSetOnTop (oThis)
{
var oWin = $(oThis);
var zOrg = oWin.getStyle('z-index') || 0;
var zMax = dragWindowGetOtherMaxZ (oWin.identify());
if(zMax >= zOrg)
{
zMax++;
oThis.style.zIndex = zMax;
}
}
function dragWindow_Behaviour_Selector_Init(selector)
{
$$(selector).each(function(el)
{
var dragId = el.identify();
var drgHandle = el.select(".dragHandle").first();
if(drgHandle && IsDefined(drgHandle))
{
el.addClassName("dragWindow");
drgHandle.addClassName("cursorMove");
if(need_ie6_IFrame())
{
ie6_dragWindowCreateIFrame (el);
new Draggable(el, {handle: drgHandle, onStart: dragWinMoveStart, onDrag: dragWindowMoved, onEnd: dragWindowMoveEnd, winId: dragId});
dragWindowReposition (dragId, 2);
}
else
{
new Draggable(el, {handle: drgHandle, onStart: dragWinMoveStart, onDrag: dragWindowMoved, onEnd: dragWindowMoveEnd, winId: dragId});
}
el.onclick = function()
{
dragWindowSetOnTop(this);
dragWindowRedraw ($(this).identify())
}
el.select (".abort").each(function(abort)
{
abort.onclick = function()
{
var oDragWnd = $(this).up(".dragWindow");
dragWindowHide(oDragWnd.identify());
var buttonSetWindow = $$(".button.settingsWindow");
if(buttonSetWindow.length >0)
{
buttonSetWindow.first().onclick = function(btn)
{
$$(".dragWindow").first().removeClassName('hidden');
removeBodyClasses('mode_Modal u_wndModal wndModal');
}
}
if("function" == typeof (thisNotify)){thisNotify(oDragWnd, "closed");}
return false;
}
})
collapsible_Behaviour_Selector_Init("#" + dragId + ".collapsible");
comboBox_Behaviour_Selector_Init ("#" + dragId + " input.comboBox");
}
else
{
new Draggable(el);
}
if(hasClassNames(el, "showOnLoad createCloneWindow", 1))
{
dragWindowShow(dragId, el.hasClassName("modal"));
}
})
}
function dragWindow_init ()
{
dragWindow_Behaviour_Selector_Init (".dragWindow");
}
g_mCookie = null;
function fnUserBehaviourEvent (evnt, arg)
{
if(g_mCookie) {g_mCookie.set (evnt, arg);}
}
function userBehaviourCookie_Init ()
{
if(!g_mCookie && "function" == typeof(MergedCookie))
{
var cookieId = "userSettings_" + getBodyClassValue("application_");
g_mCookie = new MergedCookie ({cookieName:cookieId, delimiter:',', expireDays:7});
}
else
{
debug_out ("userBehaviourCookie_Init FAILED: MergedCookie = " + typeof(MergedCookie) + "; g_mCookie=" + typeof(g_mCookie));
}
}
g_BodyClassNames = null;
g_oForm = null;
g_oBody = null;
function getBody ()
{
if("undefined" == typeof (g_oBody) || null == g_oBody)
{
g_oBody = $$('body').first();
}
return g_oBody;
}
function getBodyClasses ()
{
if("undefined" == typeof (g_BodyClassNames) || null == g_BodyClassNames)
{
g_BodyClassNames = getBody().className;
}
return g_BodyClassNames;
}
function getForm ()
{
if("undefined" == typeof (g_oForm) || null == g_oForm)
{
g_oForm = $$('form').first();
}
return g_oForm;
}
function lcTagName (obj)
{
return obj.tagName.toLowerCase();
}
function readScriptList (listName)
{
dataList = null;
try
{
dataList = eval(listName);
if(dataList && "string" == typeof dataList && dataList.length > 0)
{
return dataList;
}
}
catch (ex){}
return "";
}
function debug_out (msg,level,modul)
{
if("function" == typeof (developDebugWinCanPrint))
{
var oDbgWnd = $("developDebugWin");
if(developDebugWinCanPrint())
{
developDebugWin_WriteLn (msg,level || "", modul || "");
}
}
}
function debug_show (msg,level,modul)
{
if("function" == typeof (developDebugWinShow))
{
developDebugWinShow (true);
debug_out (msg,level || "", modul || "");
}
}
function debug_error (title, msg)
{
debug_show ("<div class='error'>"+title+"<br />" + msg + "</div>",1000,"A");
}
function IsNumeric(val)
{
val = "" + val;
var numericExpression = /^[0-9]+$/;
return val.match(numericExpression);
}
function IsDefined (oEle, oType)
{
var isDef = false;
try
{
if("undefined" != typeof (oEle))
{
if("string" == typeof (oEle))
{
oObj = $(oEle);
isDef = !Object.isUndefined(oObj) && (oObj !== null);
}
else
{
if(oEle)
{
if("string" == typeof (oEle.tagName) || ("object" == typeof (oEle)) || ("function" == typeof (oEle)))
{
isDef = true;
}
else
{
oObj = $A(oEle);
isDef = (oObj && (oObj !== null) && !Object.isUndefined(oObj) && (oObj.length > 0));
}
}
}
}
}catch (e) {
debug_error ("ERR: Not IsDefined", "execption = (" + e + ")");
isDef = false;
}
if(isDef && "string" == typeof oType)
{
isDef = (typeof oEle.tagName != "undefined") && (oType.toUpperCase() == oEle.tagName.toUpperCase());
}
return isDef;
}
function SetValue (oThis, val)
{
if(oThis)
{
oThis = $(oThis);
}
if(oThis && IsDefined(oThis))
{
switch (lcTagName (oThis))
{
case "input":
{
if( String(oThis.value) !=  String(val) )
{
oThis.value = val;
}
}
break;
case "textarea":
case "legend":
case "label":
case "strong":
case "span":
case "td":
case "a":
case "b":
oThis.innerHTML=val;
break;
case "select":
break;
case "textarea":
if( String(oThis.value) !=  String(val) )
{
oThis.value = val;
}
break;
default:
{
debug_error ("ERR: SetValue", "tagName ("+oThis.tagName+") not implemented!")
}
break;
}
}
}
function GetValue(oThis)
{
var val = "";
if(oThis)
{
oThis = $(oThis);
if(IsDefined(oThis) && oThis.tagName)
{
switch (lcTagName (oThis))
{
case "select":
case "input":
case "textarea":
val = $F(oThis);
break;
case "legend":
case "label":
case "strong":
case "span":
case "td":
case "em":
case "a":
case "b":
val = oThis.innerHTML;
break;
default:
val = oThis.innerHTML;
debug_error ("CHECK: GetValue:", "tagName ("+oThis.tagName+"), id = ("+oThis.identify()+") uses default implementation innerHTML")
break;
}
}
}
if(!val || "undefined" == typeof (val))
{
val = "";
}
return  val;
}
function IsEmpty (oThis)
{
return oThis && 0 == GetValue(oThis).length;
}
function HasValue (obj, testVal)
{
if(obj)
{
if(testVal)
{
return testVal == GetValue(obj);
}
else
{
return GetValue(obj).length > 0;
}
}
return false;
}
function SelectToText (SelectElement, TextElement)
{
SetValue (TextElement, GetValue(SelectElement));
}
function SetDisabled (oThis, isDisabled)
{
oThis = $(oThis);
oThis.disabled = isDisabled;
var tgName = oThis.tagName.toUpperCase();
if("BUTTON" != tgName)
{
}
}
function SetActivate (oThis)
{
$(oThis).activate();
}
function SetFocus (oThis)
{
var ret = false;
if(oThis)
{
oThis = $(oThis);
}
if(oThis && IsDefined(oThis))
{
try
{
if(oThis.hasClassName ("readonly"))
{
return errorMessagesScrollTo (oThis, g_scrollDuration);
}
else
{
if(IsVisibleElement(oThis))
{
oThis.focus();
ret = true;
}
}
}
catch(ex)
{
var vis= oThis.visible();
debug_error ("SetFocus ("+oThis.identify()+") failed.", "Error-Message=" + ex + "; visible=" + vis);
ret = false;
}
}
return ret;
}
function SetReadOnly(ctrl, required, readOnly, delDisable)
{
var inp = $(ctrl);
if(inp != null)
{
if(readOnly)
{
inp.addClassName("readonly");
}
else
{
inp.removeClassName("readonly");
}
if(typeof (inp.readOnly) != "undefined")
{
inp.readOnly = readOnly;
}
else
{
SetDisabled(inp,readOnly);
}
if(readOnly && delDisable)
{
if(inp.tagName == "SELECT")
{
}
else
{
}
}
}
}
function IsVisibleElement (oEle)
{
var isVisible = false;
if(oEle)
{
isVisible = ('hidden' != oEle.type) && oEle.visible() && ("none" != oEle.getStyle("display"));
var oContainer = oEle;
while (isVisible && oContainer && IsDefined (oContainer))
{
oContainer = oContainer.up("*[style*=none]");
if(oContainer && IsDefined (oContainer))
{
isVisible = (oContainer.visible() && ('hidden' != oContainer.type))
if(!isVisible)
{
}
}
}
}
return isVisible;
}
function readStyleVal(obj, key)
{
var val = obj.getStyle(key);
if(!val)
{
return 0;
}
if(val.indexOf("px") > 0)
{
val = val.substr(0, val.indexOf("px"));
}
else if(val.indexOf("%") > 0)
{
val = val.substr(0, val.indexOf("%"));
}
else if(val.indexOf("pt") > 0)
{
val = val.substr(0, val.indexOf("pt"));
}
return Math.round (val);
}
function readStyleUnitVal(obj, key)
{
var val = obj.getStyle(key);
var unit = "px";
if(val.indexOf("%") > 0)
{
unit = "%";
}
return "" + readStyleVal(obj, key) + unit;
}
function getCurrendLocation ()
{
var location = " " + window.location;
var page = location.split('?')[0];
if(!hasBodyClass ("n_sysLevelRoot"))
{
var lang = getBodyClassValue("lang_");
var page = g_js_httpRoot + lang + "/" + page.split('/'+lang+'/')[1];
}
return page;
}
function getCurrendPage ()
{
var aCV = getClassValues(getBodyClasses (), "n_");
return aCV.join("/");
}
function getRelpath ()
{
return g_js_appExec + "/" + getCurrendPage ();
}
function getHRefPathInfo(href)
{
var pInfo, pQuery = href.split("/-/pagePath:")[1];
if(pQuery && pQuery.length > 0)
{
pQuery = pQuery.split(".htm")[0];
return pQuery.replace(/\|/g,"/");
}
else
{
pInfo = href.split("/-/")[0];
return pInfo.split(g_js_appExec + "/")[1];
}
}
function getHRefRelPath(href)
{
return g_js_appExec + "/" + getHRefPathInfo(href);
}
function setCookie (key, value)
{
if(IsDefined (g_mCookie))
{
g_mCookie.set (key, value);
}
}
function getCookie (key)
{
var val = "";
if(IsDefined (g_mCookie))
{
val = g_mCookie.get (key);
}
return val;
}
function u_setCookie (key)
{
if(key.length > 4 && key.indexOf ("u_") == 0)
{
setCookie (key,1);
}
}
function hasRelName(oThis, relName)
{
var hasRel = false;
if(oThis)
{
var rel = $(oThis).readAttribute ("rel");
if(rel && rel.length > 0)
{
rel = " " + rel + " ";
hasRel = (rel.indexOf(" " + relName + " ") >= 0);
}
}
return hasRel;
}
function hasClassNames(oThis, classNames, requiredMatchCount)
{
var hasClsName = false;
if(IsDefined(oThis))
{
var clsCount = 0;
var clsMatchedCount = 0;
$w(classNames).each(function(oneClass)
{
if(oneClass.length > 0)
{
clsCount++;
if(oThis.hasClassName (oneClass))
{
clsMatchedCount++;
}
}
})
if(1 != requiredMatchCount && (!requiredMatchCount))
{
requiredMatchCount = clsCount;
}
hasClsName = (clsMatchedCount >= requiredMatchCount) && (clsMatchedCount > 0);
}
else
{
if(oThis)
{
debug_out ("not defined: " + oThis.tagName)
}
}
return hasClsName;
}
function addClassNames (oThis, classNames)
{
if(IsDefined(oThis))
{
$w(classNames).each(function(oneClass)
{
if(oneClass.length > 0)
{
oThis.addClassName (oneClass);
}
})
}
}
function removeClassNames (oThis, classNames)
{
if(IsDefined(oThis))
{
$w(classNames).each(function(oneClass)
{
if(oneClass.length > 0)
{
oThis.removeClassName (oneClass);
}
})
}
}
function getClassValue(classNames, classKeyName)
{
var classValue = "";
$w(classNames).each(function(oneClass)
{
if(oneClass.indexOf(classKeyName) == 0)
{
classValue = oneClass.substr(classKeyName.length);
}
})
return classValue;
}
function getBodyClassValue(classKeyName)
{
return getClassValue (getBodyClasses (), classKeyName);
}
function getBodyClassFullValue(classKeyName)
{
var val = getClassValue (getBodyClasses (), classKeyName);
if("" != val)
{
debug_out ("getBodyClassFullValue="+classKeyName + val);
return classKeyName + val;
}
return val;
}
function getLanguage()
{
return getClassValue (getBodyClasses (), "lang_");
}
function getClassValues(classNames, classKeyName)
{
var classValues = new Array();
var nCount      = 0;
$w(classNames).each(function(oneClass)
{
if(oneClass.indexOf(classKeyName) == 0)
{
classValues[nCount] = oneClass.substr(classKeyName.length);
nCount++;
}
});
return classValues;
}
function hasBodyClass (className)
{
var bdyClasses = " " +  getBodyClasses() + " ";
return bdyClasses.indexOf (" " +  className + " ") >= 0;
}
function hasBodyClasses (classNames, requiredMatchCount)
{
return hasClassNames (getBody(), classNames, requiredMatchCount);
}
function addBodyClass (className)
{
if(!hasBodyClass (className))
{
addClassNames (getBody(), className);
g_BodyClassNames = null;
u_setCookie (className);
}
}
function addBodyClasses (classNames)
{
$w(classNames).each(function(oneClass)
{
addBodyClass (oneClass);
})
}
function removeBodyClass (className)
{
if(hasBodyClass (className))
{
getBody().removeClassName(className);
g_BodyClassNames = null;
if(IsDefined (g_mCookie))
{
if(className.length > 0)
{
g_mCookie.del (className);
}
}
}
}
function removeBodyClasses (classNames)
{
$w(classNames).each(function(oneClass)
{
removeBodyClass (oneClass);
})
}
function getKeyCode(e)
{
return e ? e.which : window.event.keyCode;
}
function IsControlKey(nKeyCode)
{
var ret=false;
if(nKeyCode)
{
switch (nKeyCode)
{
case Event.KEY_TAB:
case Event.KEY_RETURN:
case Event.KEY_ESC:
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
case Event.KEY_HOME:
case Event.KEY_END:
case Event.KEY_PAGEUP:
case Event.KEY_PAGEDOWN:
case Event.KEY_UP:
case Event.KEY_DOWN:
case 16:  // Shift --> Fehlt in prototype als Konstante
case 17:  // STRG
case 18:  // ALT
case 91:  // WIN
case 93:  // Context  // es fehlen noch einige Tasten
ret=true;
break;
}
}
else
{
ret=true;
}
return ret;
}
function ReplaceBodyClasses (clsNames)
{
getBody ().className = clsNames;
}
function setBodyClass (className, add)
{
if(add)
{
addBodyClasses (className);
}
else
{
removeBodyClasses (className);
}
return false;
}
function toggleBodyClass (oneClass)
{
if(hasBodyClass (oneClass))
{
removeBodyClasses (oneClass);
}
else
{
addBodyClasses (oneClass);
}
}
function toggleBodyClasses (classNames)
{
$w(classNames).each(function(oneClass)
{
toggleBodyClass (oneClass);
})
}
function SyncBodyClass (syncNames)
{
var testNames = " " + syncNames + " ";
curNames = getBody ().className;
$w(curNames).each(function(cls)
{
if((cls.indexOf("sys_") == 0) && (testNames.indexOf(" "  + cls + " ") < 0))
{
removeBodyClasses (cls);
}
})
$w(syncNames).each(function(cls)
{
addBodyClasses (cls);
})
}
function IsRequired(oThis)
{
var isReq = hasClassNames (oThis, "required");
if(!isReq) {isReq = hasClassNames (oThis.up("ul"), "required");}
if(!isReq) {isReq = hasClassNames (oThis.up("li"), "required");}
if(!isReq) {isReq = hasClassNames (oThis.up("div"), "required");}
if(!isReq) {isReq = hasClassNames (oThis.up("fieldset"), "required");}
if(!isReq)
{ // Pflichtfeld, falls das element im Fehlerfenster enthalten ist.
isReq = $A($$('#errReportWin div.body li label[for='+oThis.identify()+']')).length > 0;
}
return isReq;
}
function SetButtonCssClassById (btnId)
{
var oBtn = $(btnId);
if(oBtn)
{
if(oBtn.disabled)
{
oBtn.addClassName("disabled");
}
else
{
oBtn.removeClassName("disabled");
}
}
}
function enableBtn(btnId, enable)
{
var btn = $(btnId);
if(btn != null)
{
SetDisabled(btn,!enable);
SetButtonCssClassById($(btn).identify());
}
}
function SetCtrlVisible(ctrId, enable)
{
var ctrl = $(ctrId);
if(ctrl != null)
{
enable ? $(ctrl).removeClassName('hidden') : $(ctrl).addClassName('hidden');
}
}
function useScript ()
{
return !getBody ().hasClassName("u_DisableScript");
}
function updateRangeSlider (oThis)
{
var val = $F(oThis);
var title = oThis.title;
title = title.split("(")[0];
title = title + "(" + val + ")";
oThis.title = title;
var oC = oThis.up();
oVal = oC.down("span.range_val");
oVal.innerHTML = val;
}
function toggleRangeType (oThis)
{
var type = "range";
var val = $F(oThis);
if(hasBodyClass (val))
{
type = "text";
}
var oC = oThis.up();
oRange = oC.down("input[class*='type_range']")
if(oRange)
{
oRange.type = type;
}
}
var MergedCookie = Class.create();
MergedCookie.prototype = {
initialize: function(options) {
this.options    = options || {};
this.cookieName = this.options.cookieName || 'ClientPersist';
this.delimiter  = this.options.delimiter  || '|';
this.splitter   = this.options.splitter   || '=';
this.expireDays = this.options.expireDays || '';
this.path       = this.options.path       || '/';
this.domain     = this.options.domain     || '';
},
set: function(name,value,cookieName)
{
if(name && name.length > 0)
{
if(!cookieName)
{
cookieName = this.cookieName;
}
var baseCookie = this.getBase(cookieName);
if(baseCookie)
{
var newCookie = "";
var hasKey = false;
var allCookies = baseCookie.split(this.delimiter);
for (var i=0;i < allCookies.length; i++)
{
var cookiePair = allCookies[i].split(this.splitter);
var thisKey = cookiePair[0];
var thisVal = cookiePair[1];
if(thisKey && thisKey.length > 0 && "undefined" != thisKey)
{
if("" != newCookie)
{
newCookie += this.delimiter;
}
if(thisKey == name)
{
thisVal = value;
hasKey = true;
}
newCookie += thisKey + this.splitter + thisVal;
if("undefined" == value)
{
debug_out ("baseCookie: undefined thisVal: set cookie ("+name+"): " + value)
}
if("undefined" == name)
{
debug_out ("baseCookie: undefined name: set cookie ("+name+"): " + value)
}
}
}
if(!hasKey)
{
if("" != newCookie)
{
newCookie += this.delimiter;
}
newCookie += name + this.splitter + value;
if("undefined" == value)
{
debug_out ("undefined thisVal: set cookie ("+name+"): " + value)
}
if("undefined" == name)
{
debug_out ("undefined name: set cookie ("+name+"): " + value)
}
}
baseCookie = newCookie;
}
else
{
baseCookie = name + this.splitter + value;
}
return this.setBase (cookieName, baseCookie, this.expireDays, this.path, this.domain)
}
else
{
return false;
}
},
get: function(name, cookieName)
{
if(!cookieName)
{
cookieName = this.cookieName;
}
var baseCookie = this.getBase(cookieName);
if(baseCookie)
{
var allCookies = baseCookie.split(this.delimiter);
for (var i=0;i < allCookies.length; i++)
{
var cookiePair = allCookies[i].split(this.splitter);
if(cookiePair[0] == name)
{
return cookiePair[1];
}
}
}
return null;
},
getBase: function(cookieName)
{
if(!cookieName)
{
cookieName = this.cookieName;
}
var baseCookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(cookieName) + '=([^;\\s]*)'));
if(baseCookie)
{
baseCookie = unescape(baseCookie[2]);
}
return baseCookie;
},
setBase: function(cookieName, baseValue, baseExpires, basePath, baseDomain)
{
var cookieArgs  = "";
if((baseExpires) && (baseExpires != undefined) && (baseExpires > 0))
{
var expire = '';
var d = new Date();
d.setTime(d.getTime() + (86400000 * parseFloat(baseExpires)));
cookieArgs = '; expires=' + d.toGMTString();
}
if(basePath) {cookieArgs += "; path=" + basePath};
if(baseDomain) {cookieArgs += "; domain=" + baseDomain};
if(!cookieName)
{
cookieName = this.cookieName;
}
return document.cookie = escape(cookieName) + '=' + escape(baseValue || '') + cookieArgs;
},
del: function(name, cookieName)
{
var keyVal = "";
if(name && name.length > 0)
{
if(!cookieName)
{
cookieName = this.cookieName;
}
var baseCookie = this.getBase(cookieName);
if(baseCookie)
{
var newCookie = "";
var allCookies = baseCookie.split(this.delimiter);
for (var i=0;i < allCookies.length; i++)
{
var cookiePair = allCookies[i].split(this.splitter);
var thisKey = cookiePair[0];
if(thisKey && thisKey.length > 0 && "undefined" != thisKey)
{
if("" != newCookie)
{
newCookie += this.delimiter;
}
var thisVal = cookiePair[1];
if(thisKey != name)
{
newCookie += thisKey + this.splitter + thisVal;
if("undefined" == thisVal)
{
debug_out ("undefined thisVal: del cookie ("+thisKey+"): " + thisVal)
}
if("undefined" == thisKey)
{
debug_out ("undefined thisKey: del cookie ("+thisKey+"): " + thisVal)
}
}
else
{
keyVal = thisKey + this.splitter + thisVal;
}
}
}
if("" == newCookie)
{
this.eraseBase (cookieName);
}
else
{
this.setBase (cookieName, newCookie, this.expireDays, this.path, this.domain);
}
}
}
return keyVal;
},
eraseBase: function(cookieName) {
if(!cookieName)
{
cookieName = this.cookieName;
}
var cookie = this.getBase(cookieName) || true;
this.setBase(cookieName, '', -1);
return cookie;
},
accept: function() {
if(typeof navigator.cookieEnabled == 'boolean')
{
return navigator.cookieEnabled;
}
var key = "_this_is_a_test_key";
var val = "_the_test_value";
var bas = "acceptName";
this.set(key, val, bas);
return (this.del(key, bas) == val);
}
}
function GetClientCtrlHandleHtml (oBase, actionHtml)
{
var clsNames = $(oBase).className;
if(IsDefined(clsNames))
{
clsNames = clsNames.replace('clientCtrl','').trim();
clsNames = "clientCtrl " + clsNames;
clsNames = clsNames.trim();
}
else
{
clsNames = "clientCtrl";
}
return "<span class='"+clsNames+"' onmouseover='$(this).addClassName(\"hover\")' onfocus='$(this).addClassName(\"hover\")' onmouseout='$(this).removeClassName(\"hover\")'>"+actionHtml+"</span>";
}
function browser_detect_Init ()
{
var version = "?";
var keyVers = "?";
var pos = -1;
var usrAgent = navigator.userAgent.toLowerCase();
if(Prototype.Browser.IE)
{
Prototype.Browser.KeyName = "IE"
pos = usrAgent.indexOf('msie ');
if(pos > -1)
{
version = usrAgent.substr(pos + 5);
version = $A(version.split(';'))[0],
keyVers = version.substr(0,1);
}
}
else if(Prototype.Browser.Gecko)
{
pos = usrAgent.indexOf('firefox/');
if(pos > -1)
{
Prototype.Browser.KeyName = "Firefox"
version = usrAgent.substr(pos + 8);
keyVers = version.substr(3);
}
else
{
Prototype.Browser.KeyName = "Gecko"
}
}
else if(Prototype.Browser.WebKit)
{
Prototype.Browser.KeyName = "WebKit"
}
else if(Prototype.Browser.Opera)
{
Prototype.Browser.KeyName = "Opera"
}
else if(Prototype.Browser.MobileSafari)
{
Prototype.Browser.KeyName = "MobileSafari"
}
else
{
Prototype.Browser.KeyName = "Other"
}
Prototype.Browser.Version = Prototype.Browser.KeyName + "_" + version;
Prototype.Browser.KeyVersion = Prototype.Browser.KeyName + keyVers;
}
function IsBrowser(check)
{
return Prototype.Browser.KeyName == check;
}
function IsBrowserVersion(check)
{
return Prototype.Browser.KeyVersion == check;
}
function need_ie6_IFrame()
{
if(IsBrowserVersion("IE6"))
{
return ($$("select").length > 0);
}
return false
}
function userSettingsChanged (oInp)
{
if("radio" == oInp.type)
{
var inpName = oInp.name;
var ul = oInp.up("ul");
ul.select("li input[name='"+inpName+"']").each(function (inp)
{
removeBodyClasses (inp.value);
})
}
var add = oInp.checked;
if(oInp.hasClassName("invers"))
{
add = !add;
}
setBodyClass (oInp.value, add)
if("function" == typeof (thisNotify)){thisNotify(oInp, "changed");}
return false;
}
function bodyClassSector_init (selector)
{
$$(selector).each(function(inp)
{
if("radio" == inp.type || "checkbox" == inp.type)
{
inp.onchange = function()
{
userSettingsChanged($(this));
return true;
}
if(inp.hasClassName("invers"))
{
inp.checked = !hasBodyClass(inp.value);
}
else
{
inp.checked = hasBodyClass(inp.value);
if(inp.checked)
{
u_setCookie (inp.value);
}
}
}
else if("A" == inp.tagName)
{
var theCls = getClassValue (inp.className, 'toggle_');
if("" != theCls)
{
inp.onclick = function()
{
var theCls = getClassValue (this.className, 'toggle_');
toggleBodyClasses(theCls);
return false;
}
}
}
})
}
function userSettingsBehaviour ()
{
bodyClassSector_init ('.footer li input[type]');
}
function bodyClassSelectbox_init()
{
$$("select.bodyClass").each(function(inp)
{
inp.onchange = function()
{
var opts = this.getElementsByTagName('option');
for (var i=0; i < opts.length;i++)
{
removeBodyClass (opts[i].value);
}
addBodyClass($F(this));
if("function" == typeof (thisNotify)){thisNotify(this, "changed");}
return true;
}
})
}
function bodyClassInput_init()
{
bodyClassSector_init ('li.bodyClass .inputGroup input[type],.bodyClass > input[type],a.bodyClass');
bodyClassSelectbox_init();
}
var activeInplaceEditId = "";
var activeInplaceNaviId = "";
var activeInplaceLabelId = "";
var oldInplaceContent = "";
var oldInplaceNavi = "";
var activeInplaceButtonId = "";
var oldInplaceButton = "";
var oldInplaceLabel = "";
function inplaceEditSave (oThis)
{
if(oThis)
{
var clsKey = getClassValue (oThis.className, "key_");
var content = oThis.innerHTML;
if(oldInplaceContent != content)
{
var type = getClassValue (oThis.className, "type_");
switch (type)
{
case "dsnTabListBox":
break;
case "ListBoxItem":
var oKey = oThis.up("*[class*=arrangeKey_]");
if(oKey)
{
var key = getClassValue (oKey.className, "arrangeKey_");
if("" != key)
{
oDef = oKey.up("*[class*=arrangeable]");
if(oDef)
{
ajaxContentPost ("dsnTabListItemUpdate:", {dsnTabKeyVal:key, ajaxContent:content, ajaxClassName:oDef.className, xdenyMessages:true});
}
}
}
break;
default:
var thisId = oThis.identify();
debug_out (thisId + ": save Content ("+clsKey+")");
activeInplaceEditId = "";
ajaxContentPost ("inplaceEditSave:", {ajaxClassName:oThis.className, ajaxContent:content, ajaxPathInfo:getCurrendPage(), xdenyMessages:true});
break;
}
}
}
}
function dsnTabListBox_finish ()
{
buildContainer ("ajaxDsnTabListBox").addClassName("hidden");
}
function dsnTabListBox_create (oThis)
{
var id = oThis.identify();
var col = getClassValue (oThis.className, 'col_');
var keyVal = getClassValue (oThis.className, 'keyVal_');
var val = oThis.innerHTML;
buildContainer ("ajaxDsnTabListBox").addClassName("hidden");
Position.clone($(oThis), $("ajaxDsnTabListBox"), { setHeight: false, setWidth: false, offsetTop: $(oThis).offsetHeight - $(oThis).getHeight() });
ajaxContentGet ("dsnTabListBox:ajaxDsnTabListBox", {ajaxClassName:oThis.className, clientRef:id, ajaxFieldVal:val, ajaxPathInfo:getCurrendPage(),denyMessages:true});
}
function dsnTabListBox_update (updateId, clientRef, fieldVal)
{
if($(updateId))
{
$(updateId).addClassName("hidden");
}
if($(clientRef))
{
$(clientRef).innerHTML = fieldVal;
}
}
function dsnTabListBox_perform (action, className, val)
{
var clientRef = getClassValue (className, 'clientRef_');
var col = getClassValue (className, 'col_') + ": "+action+"";
ajaxContentGet ("dsnTabListBox_"+action+":newDragWindow", {ajaxClassName:className, winTitle:col, clientRef:clientRef, ajaxFieldVal:val, ajaxPathInfo:getCurrendPage(),xdenyMessages:true});
}
function dsnTabListBox_edit (oThis)
{
var div = oThis.up("div");
var sel = oThis.up("div").down("select");
dsnTabListBox_perform ("edit", sel.className, $F(sel));
}
function dsnTabListBox_onchange (oThis)
{
var val = $F(oThis);
var clientRef = getClassValue (oThis.className, 'clientRef_');
ajaxContentGet ("dsnTabListBox_change", {ajaxClassName:oThis.className, clientRef:clientRef, ajaxFieldVal:val, ajaxPathInfo:getCurrendPage(),xdenyMessages:true});
dsnTabListBox_finish ();
}
function dsnTabListBox_init (updateId)
{
if($(updateId))
{
$(updateId).removeClassName("hidden");
$(updateId).select("label").invoke ("addClassName", "dragHandle cursorMove");
$(updateId).select("label span").invoke ("addClassName", "cursorMove");
dragWindow_Behaviour_Selector_Init ("#"+updateId);
$(updateId).select("select").each(function(el)
{
el.onchange = function()
{
dsnTabListBox_onchange ($(this));
}
el.onblur = function()
{
dsnTabListBox_finish ();
}
})
$(updateId).down("a[href=#abort]").onclick = function()
{
dsnTabListBox_finish ();
}
$(updateId).down("a[href=#edit]").onclick = function()
{
dsnTabListBox_edit ($(this));
}
}
}
function prepareInplaceEdit(oThis)
{
var type = getClassValue (oThis.className, 'type_');
if("dsnTabListBox" == type)
{
dsnTabListBox_create (oThis);
}
else
{
buildContainer ("ajaxDsnTabListBox").addClassName("hidden");
}
}
function inplaceEditContentPerform(oThis)
{
if("" != activeInplaceNaviId)
{
inplaceEditNaviSave ($(activeInplaceNaviId));
}
if(oThis)
{
var thisId = oThis.identify();
if(thisId != activeInplaceEditId)
{
if("" != activeInplaceEditId)
{
inplaceEditSave ($(activeInplaceEditId));
}
if(hasBodyClass ("u_inplaceedit"))
{
activeInplaceEditId = oThis.identify();
oldInplaceContent = oThis.innerHTML;
oThis.setAttribute("contenteditable", "true");
}
}
}
return false;
}
function inplaceEditNaviSave (oThis)
{
var content = oThis.innerHTML;
if(oldInplaceNavi != content)
{
var loc = "nav";
var oC = $(oThis).up(".nav");
if(oC)
{
locType = getClassValue (oC.className, 'location_');
if("" != locType)
{
loc = locType;
}
}
var id = oThis.identify();
key = getHRefRelPath(oThis.href);
ajaxContentPost ("performInplaceRename", {relPath:key, newValue:content, oldValue:oldInplaceNavi, location:loc, xdenyMessages:true});
oldInplaceNavi = content;
}
else
{
}
}
function inplaceNaviEditPerform(oThis)
{
if("" != activeInplaceEditId)
{
inplaceEditSave ($(activeInplaceEditId));
}
if(oThis)
{
var thisId = oThis.identify();
if(thisId != activeInplaceNaviId)
{
if("" != activeInplaceNaviId)
{
inplaceEditNaviSave ($(activeInplaceNaviId));
}
if(hasBodyClass ("u_inplaceedit"))
{
activeInplaceNaviId = oThis.identify();
oldInplaceNavi = oThis.innerHTML;
oThis.setAttribute("contenteditable", "true");
}
}
}
}
function inplaceNaviRename_init ()
{
if(hasBodyClass ("u_inplaceedit"))
{
$$(".nav a,.tabCtrlHead a").each(function(el)
{
el.onmouseover=function()
{
if(hasBodyClass ("u_inplaceedit"))
{
$(this).addClassName("hover");
$(this).setAttribute("contenteditable", "true");
}
}
el.onclick=function()
{
inplaceNaviEditPerform($(this));
}
el.onfocus=function()
{
inplaceNaviEditPerform($(this));
}
el.onblur=function()
{
inplaceNaviEditPerform($(this));
}
el.onkeyup=function()
{
inplaceNaviEditPerform($(this));
}
})
}
else
{
$$(".nav a").each(function(el)
{
el.removeAttribute("contenteditable");
})
}
}
function inplaceEditButtonSave (oThis)
{
var content = oThis.value;
if(oldInplaceButton != content)
{
var id = oThis.identify();
key = getRelpath ();
ajaxContentPost ("performInplaceRename", {relPath:key, newValue:content, oldValue:oldInplaceButton, location:"btn", xdenyMessages:true});
oldInplaceButton = content;
}
else
{
}
}
function inplaceButtonEditPerform(oThis)
{
if("" != activeInplaceEditId)
{
inplaceEditSave ($(activeInplaceEditId));
}
if(oThis)
{
var thisId = oThis.identify();
if(thisId != activeInplaceButtonId)
{
if("" != activeInplaceButtonId)
{
inplaceEditButtonSave ($(activeInplaceButtonId));
}
if(hasBodyClass ("u_inplaceedit"))
{
activeInplaceButtonId = thisId;
oldInplaceButton = oThis.value;
oThis.setAttribute("contenteditable", "true");
}
}
}
}
function inplaceButtonRename_init ()
{
if(hasBodyClass ("u_inplaceedit"))
{
$$("input[type=submit]").each(function(el)
{
el.onmouseover=function()
{
if(hasBodyClass ("u_inplaceedit"))
{
$(this).addClassName("hover");
$(this).setAttribute("contenteditable", "true");
}
}
el.onclick=function()
{
inplaceButtonEditPerform($(this));
return false;
}
el.onfocus=function()
{
inplaceButtonEditPerform($(this));
}
el.onblur=function()
{
inplaceButtonEditPerform($(this));
}
el.onkeyup=function()
{
inplaceButtonEditPerform($(this));
return true;
}
})
}
else
{
$$("input[type=submit]").each(function(el)
{
el.removeAttribute("contenteditable");
el.onclick=function()
{
inplaceButtonEditPerform($(this));
return true;
}
})
}
}
function inplaceEditLabelSave (oThis)
{
var content = oThis.innerHTML;
if(oldInplaceLabel != content)
{
var locType = "";
var oNav = oThis.up(".nav");
var key = oldInplaceLabel;
if(IsDefined (oNav))
{
locType = getClassValue (oNav.className, 'location_');
}
if("" != locType)
{
}
var id = oThis.identify();
ajaxContentPost ("performInplaceRename", {relPath:key, newValue:content, oldValue:oldInplaceLabel, location:locType, xdenyMessages:true});
oldInplaceLabel = content;
}
else
{
}
}
function inplaceLabelEditPerform(oThis)
{
if("" != activeInplaceEditId)
{
inplaceEditSave ($(activeInplaceEditId));
}
if(oThis)
{
var thisId = oThis.identify();
if(thisId != activeInplaceLabelId)
{
if("" != activeInplaceLabelId)
{
inplaceEditLabelSave ($(activeInplaceLabelId));
}
if(hasBodyClass ("u_inplaceedit"))
{
activeInplaceLabelId = thisId;
oldInplaceLabel = oThis.innerHTML;
oThis.setAttribute("contenteditable", "true");
}
}
}
}
function inplaceGetLabelObject (oThis)
{
obj = $(oThis);
var span = obj.down("span");
if(span)
{
obj = span;
}
return obj;
}
function inplaceMessageServer_init ()
{
var hr,btn,oThis,oUpdate,newMsg;
$$(".msgEdit .buttons a").each(function(el)
{
el.up("li").addClassName("open");
el.onclick = function()
{
oThis = $(this);
hr = "" + this.href;
btn = hr.split("#")[1];
switch (btn)
{
case "save":
newMsg = Html2BBCode(oThis.up(".msgEdit").down("textarea").value);
oUpdate = oThis.up("li").down(".inplaceMsgRename");
ajaxContentGet ("inplaceMsgUpdate:" + oUpdate.identify() + ":update", {ajaxClassName:oUpdate.className, ajaxFieldVal:newMsg, ajaxPathInfo:getCurrendPage(),denyMessages:false});
break;
case "cancel":
oThis.up("li").removeClassName("open");
oThis.up(".msgEdit").remove();
break;
default:
alert ("unsupported button clicked: " + btn);
break;
}
return false;
}
})
}
function inplaceMessageServer_update (updateId, reason)
{
var key;
if($(updateId))
{
var key = getClassValue ($(updateId).className, "msgKey_");
$(updateId).up("ul").select(".msgKey_" + key).each(function(el)
{
el.up("li").addClassName("modified");
})
$(updateId).up("li").removeClassName("open");
$(updateId).next().remove();
}
}
function inplaceMessage_init ()
{
if(hasBodyClass ("u_inplaceedit"))
{
$$(".msg label.inplaceMsgRename").each(function(el)
{
if(!el.hasClassName("initialzed"))
{
el.addClassName("initialzed");
saveAttribFor (el);
el.onclick = function()
{
if(hasBodyClass ("u_inplaceedit"))
{
if(!$(this).next())
{
$(this).up("li").addClassName("editMode");
ajaxContentGet ("inplaceMsgEdit:" + $(this).identify() + ":after", {ajaxClassName:this.className, ajaxFieldVal:this.innerHTML, ajaxPathInfo:getCurrendPage(),denyMessages:true});
}
return false;
}
return true;
}
}
})
}
}
function restoreAttribFor (el)
{
var savedFor = el.getAttribute("savedFor");
if(savedFor && "" != savedFor)
{
el.setAttribute("for", savedFor);
el.removeAttribute("savedFor");
}
}
function saveAttribFor (el)
{
var savedFor = el.getAttribute("for");
if(savedFor && "" != savedFor)
{
el.setAttribute("savedFor", savedFor);
}
el.removeAttribute("for");
}
function inplaceSelectorRename_init (selector)
{
if(hasBodyClass ("u_inplaceedit"))
{
$$(selector).each(function(el)
{
if(!el.hasClassName("inplaceMsgRename"))
{
saveAttribFor (el);
el.onmouseover=function()
{
if(hasBodyClass ("u_inplaceedit"))
{
obj = inplaceGetLabelObject (this);
obj.addClassName("hover");
obj.setAttribute("contenteditable", "true");
}
}
el.onclick=function()
{
inplaceLabelEditPerform(inplaceGetLabelObject (this));
}
el.onfocus=function()
{
inplaceLabelEditPerform(inplaceGetLabelObject (this));
}
el.onblur=function()
{
inplaceLabelEditPerform(inplaceGetLabelObject (this));
}
el.onkeyup=function()
{
inplaceLabelEditPerform(inplaceGetLabelObject (this));
return true;
}
}
})
}
else
{
selector += ", .msg label.inplaceMsgRename";
$$(selector).each(function(el)
{
saveAttribFor (el);
el.removeAttribute("contenteditable");
})
}
}
function inplacePerformBodyEvent(txt)
{
if(hasBodyClass ("u_inplaceedit"))
{
if("" != activeInplaceEditId)
{
inplaceEditContentPerform($(activeInplaceEditId));
}
if("" != activeInplaceNaviId)
{
inplaceNaviEditPerform($(activeInplaceNaviId));
}
}
return true;
}
function inplaceEdit_save_changes ()
{
if("" != activeInplaceEditId)
{
inplaceEditSave ($(activeInplaceEditId));
}
if("" != activeInplaceNaviId)
{
inplaceEditNaviSave ($(activeInplaceNaviId));
}
if("" != activeInplaceLabelId)
{
inplaceEditLabelSave ($(activeInplaceLabelId));
}
}
function inplaceEdit_selector_init(selector, cls)
{
$$(selector).each(function(el)
{
el.addClassName (cls);
if(hasBodyClass ("u_inplaceedit"))
{
el.onmouseover=function()
{
$(this).addClassName("hover");
if(hasBodyClass ("u_inplaceedit"))
{
$(this).setAttribute("contenteditable", "true");
}
}
el.onmouseout=function()
{
$(this).removeClassName("hover");
}
el.onclick=function()
{
prepareInplaceEdit ($(this));
return inplaceEditContentPerform($(this));
}
el.onfocus=function()
{
inplaceEditContentPerform($(this));
}
el.onkeyup=function()
{
inplaceEditContentPerform($(this));
return true;
}
}
else
{
el.removeAttribute("contenteditable");
}
})
}
function inplaceEdit_init()
{
inplaceEdit_save_changes();
if(hasBodyClass ("u_inplaceedit"))
{
$$(".nav,.footer,.contextMenu").each(function(navi)
{
navi.addClassName("navi");
navi.addClassName("location_nav");
})
$$(".tabCtrlHead").each(function(navi)
{
navi.addClassName("navi");
navi.addClassName("location_base");
})
}
else
{
dsnTabListBox_finish ();
}
inplaceNaviRename_init ();
inplaceButtonRename_init ();
inplaceSelectorRename_init ("label,.inplaceRename");
inplaceMessage_init ();
inplaceEdit_selector_init(".inplaceEditable", "");
}
function get_content_by_path (href)
{
var ajaxPathInfo = getHRefPathInfo(href);
ajaxContentGet ('inplaceContentArrange:areaContent', {ajaxPathInfo:ajaxPathInfo,bodyClass:'inplaceContent'});
}
function get_navigation_by_path (href)
{
var navi = $$(".nav").first();
var ajaxPathInfo = getHRefPathInfo(href);
ajaxContentGet ('inplaceNavigation:'+navi.identify(), {ajaxPathInfo:ajaxPathInfo});
}
function get_navi_sort_content_by_path (oThis)
{
var href = oThis.href;
var navi = $(oThis).up(".nav");
var ajaxPathInfo = getHRefPathInfo(href);
ajaxContentGet ('inplaceContentArrange:areaInplaceContent,inplaceNavigation:'+navi.identify(), {ajaxPathInfo:ajaxPathInfo});
}
function inplaceArrange (pInfo, oThis)
{
var actPath = get_active_navi_path();
var href = g_js_appExec + "/" + actPath;
var ajaxPathInfo = getHRefPathInfo(href);
var action = 'inplaceNaviArrange,inplaceContentArrange';
var cmsBtn = $$("div.dragWindow.u_cmsButtons").first();
if(IsDefined(cmsBtn))
{
action += ",cmsActionWindow:" + cmsBtn.identify()+":replace";
}
ajaxContentGet (action, {ajaxPathInfo:ajaxPathInfo,relPath:pInfo,bodyClass:'inplaceNaviArrange inplaceContent',denyMessages:true});
return false;
}
function contentArrange_OnUpdate(list)
{
debug_out("contentArrange_OnUpdate");
var sortType = getClassValue (list.className, 'sortType_');
var pathFile = "";
var theList = "";
var sortAction = "picMngtSortOrder";
$(list).select("li a img").each(function(el)
{
pathFile = el.src.split("/c/")[1];
aPathFile = pathFile.split("/");
aPathFile[aPathFile.length-2] = "";
pathFile = aPathFile.join("/");
pathFile = pathFile.replace('//','/');
theList += pathFile.substr (1+pathFile.lastIndexOf("/"))  + ",";
})
var path = pathFile.substr (0, pathFile.lastIndexOf("/"));
ajaxContentPost (sortAction, {path:path,dirList:theList,sortAction:sortAction});
}
function articleArrange_OnUpdate(list)
{
debug_out("articleArrange_OnUpdate");
var sortType = getClassValue (list.className, 'sortType_');
debug_out("articleArrange_OnUpdate " + list.tagName + ", " + list.className +  "; sortType=" + sortType);
var pathFile = "";
var theList = "";
var sortAction = "contentSortOrder";
$(list).select("li").each(function(el)
{
var theId = getClassValue (el.className, 'article_');
theList += theId + ",";
})
var path = getCurrendPage();
ajaxContentPost (sortAction, {path:path,dirList:theList,sortAction:sortAction});
}
function contentArrange_init()
{
debug_out("contentArrange_init");
var oCtSort = $$("body.inplaceContent #areaContent").first();
if(oCtSort)
{
var fncUpdate = contentArrange_OnUpdate;
var fncClick = returnFalse;
var sType = "sortType_";
var id = 0;
var ul = oCtSort.down("ul.previewList");
if(ul)
{
sType += "previewList";
}
else
{
var ul = oCtSort.down("ul.articleList");
if(ul)
{
fncUpdate = articleArrange_OnUpdate;
sType += "articleList";
}
else
{
fncUpdate = naviArrange_OnUpdate;
fncClick = contentArrange_hrefClick;
var ul = oCtSort.down("ul.dirContent");
sType += "dirContent";
}
}
if(ul)
{
ul.select("li").each(function(el)
{
el.identify();
var a = el.down("a");
if(a)
{
a.onclick = function()
{
return fncClick(this);
}
}
})
ul.addClassName("picSortActive " + sType);
Sortable.create(ul.identify(),{onUpdate:fncUpdate});
}
}
return false;
}
function naviArrange_UpdateRoot()
{
var pathFile = "";
var pathDir= "";
var theList = "";
$$(".nav>ul>li>a:not([href*=/webAdmin/]),.nav>li>a:not([href*=/webAdmin/])").each(function(el)
{
pathFile = el.href.split(".htm")[0];
if("" == pathDir)
{
pathDir = getHRefPathInfo(pathFile);
}
if(pathFile)
{
pathFile = getHRefPathInfo(pathFile);
if("" != theList)
{
theList += ",";
}
theList += pathFile.substr (1+pathFile.lastIndexOf("/"));
}
else
{
debug_out("**** ERR naviArrange_OnUpdate pathFile = " + pathFile + " check g_js_appExec=" + g_js_appExec);
}
})
var path = pathDir.substr (0, pathDir.lastIndexOf("/"));
var sortAction = "picMngtSortDirectoryOrder";
ajaxContentPost (sortAction, {path:path,dirList:theList,sortAction:sortAction});
}
function naviArrange_OnUpdate(list)
{
var pathFile = "";
var pathDir= "";
var theList = "";
$$("#"+list.identify()+">li>a:not([href*=/webAdmin/])").each(function(el)
{
pathFile = el.href.split(".htm")[0];
if("" == pathDir)
{
pathDir = getHRefPathInfo(pathFile);
}
if(pathFile)
{
pathFile = getHRefPathInfo(pathFile);
if("" != theList)
{
theList += ",";
}
theList += pathFile.substr (1+pathFile.lastIndexOf("/"));
}
else
{
debug_out("**** ERR naviArrange_OnUpdate pathFile = " + pathFile + " check g_js_appExec=" + g_js_appExec);
}
})
var path = pathDir.substr (0, pathDir.lastIndexOf("/"));
if("" == path)
{
naviArrange_UpdateRoot();
}
else
{
var sortAction = "picMngtSortDirectoryOrder";
ajaxContentPost (sortAction, {path:path,dirList:theList,sortAction:sortAction});
}
}
function get_active_navi_path ()
{
var actPath="";
$$(".nav li.active>a").each(function(a)
{
var p = a.href.split(".htm")[0];
actPath += p.substr (1+p.lastIndexOf("/"))  + "/";
})
return actPath;
}
function naviArrange_hrefClick(oThis, doUpdate)
{
if(doUpdate)
{
get_ajaxPage (oThis);
}
if($("areaNaviSortFinish"))
{
var actPath = get_active_navi_path();
var href = g_js_appExec + "/" + actPath;
var aHref = "<a href=\""+href+"\">"+actPath+"</a>";
$("areaNaviSortFinish").down("strong").update(aHref);
$("areaNaviSortFinish").down("input").name="btn_" + actPath;
}
return false;
}
function contentArrange_hrefClick(oThis)
{
var href = oThis.href;
var navi = $$(".nav").first();
clickRef = navi.down("ul li a[href="+href+"]");
if(IsDefined(clickRef))
{
naviArrange_hrefClick(clickRef, false);
get_navi_sort_content_by_path(clickRef);
}
return false;
}
function cmsArrange_OnUpdate(list)
{
var path = getCurrendPage ();
var cms = $(list).up("div.cms");
ajaxContentPost ("cmsUpdateContent", {path:path,cmsContent:cms.innerHTML,denyMessages:true});
}
function inplaceNaviArrange_init ()
{
var elemNav,id,a,childElem;
$$(".nav").each(function(navi)
{
navi.select("li a[href*=/webAdmin/]").each(function(el)
{
el.addClassName("displayNone");
})
elemNav = navi;
if(navi.tagName == "UL")
{
elemNav = navi.up();
}
id = elemNav.identify();
elemNav.select("ul").each(function(ul)
{
id = ul.identify();
ul.select("li").each(function(li)
{
li.identify();
var a = li.down("a");
if(a)
{
var childElem = li.immediateDescendants();
if(childElem[1])
{
a.addClassName('activateOnClick');
}
a.removeAttribute("rel");
a.onclick = function()
{
if(hasBodyClass("u_inplacearrange"))
{
return naviArrange_hrefClick(this, true);
}
return true;
}
}
})
ul.addClassName("sortMode");
Sortable.create(id,{onUpdate:naviArrange_OnUpdate});
})
})
return false;
}
function cmsContentArrange_Init()
{
$('areaContent').select("div.cms ul").each(function(ul)
{
var id = ul.identify();
ul.select("li").each(function(li)
{
li.identify();
})
ul.addClassName("sortMode");
Sortable.create(id,{onUpdate:cmsArrange_OnUpdate});
})
return false;
}
function arrangeable_OnUpdate(list)
{
var path = getCurrendPage ();
var sortType = getClassValue (list.className, 'sortType_');
if("" == sortType)
{
sortType = "filelist";
}
var csvList = "";
var aList = $(list).select ("*[class*=arrangeKey_]");
if(aList.length > 0)
{
aList.each(function(li)
{
var id = getClassValue (li.className, "arrangeKey_");
csvList += id + ",";
})
}
else
{
aList = $(list).select("li a img");
aList.each(function(el)
{
pathFile = el.src.split("/c/")[1];
aPathFile = pathFile.split("/");
aPathFile[aPathFile.length-2] = "";
pathFile = aPathFile.join("/");
pathFile = pathFile.replace('//','/');
csvList += pathFile.substr (1+pathFile.lastIndexOf("/"))  + ",";
})
}
ajaxContentPost ("contentSortOrder", {path:path,ajaxClassName:list.className,dirList:csvList,sortAction:sortType,denyMessages:true});
}
function arrangeable_tabCtrl_init(selector)
{
$$(selector).each(function(ul)
{
var cls = ul.className;
var hd = ul.previous("ul.thead");
if(hd)
{
hd.select ("a[href]").each(function(a)
{
a.addClassName (cls);
a.onclick=function()
{
dsnTabListBox_perform (getClassValue (a.className, "action_"), a.className, getClassValue (a.className, "action_"));
return false;
}
})
}
})
}
function arrangeable_selector_init(selector)
{
var sortTag = "li";
var isTable = false;
$$(selector).each(function(ul)
{
var id = ul.identify();
var isTable = (ul.tagName == "TBODY");
var aList = ul.select ("*[class*=arrangeKey_]");
if(aList.length <= 0)
{
aTmp = ul.select("li a img");
if(aTmp.length > 0)
{
aTmp.each(function(img)
{
var oLi = img.up("li");
aList.push(oLi);
})
}
}
aList.each(function(li)
{
li.identify();
if(isTable)
{
li.setStyle({ position: 'relative' });
}
li.select("a").each(function(a)
{
a.onclick=function()
{
if(hasBodyClass("u_inplacearrange"))
{
return false;
}
return true;
}
})
})
ul.addClassName("sortMode");
if(isTable)
{
sortTag = "tr";
}
Sortable.create(id,{tag:sortTag,onUpdate:arrangeable_OnUpdate});
})
return false;
}
function arrangeable_Init()
{
arrangeable_selector_init(".arrangeable")
}
function getPathInfo(href)
{
var pi = getHRefPathInfo (href);
pi =  pi.split(":")[0];
pi =  pi.split(".htm")[0];
return pi;
}
function getLastPathInfo(href)
{
var pi = getPathInfo(href)
var pos = pi.lastIndexOf("/");
if(pos >= 0)
{
pi = pi.substr(pos+1);
}
return pi;
}
function getSubTree(subUl, root)
{
var sTree = "";
subUl.immediateDescendants().each(function(li)
{
var lpi = getLastPathInfo(li.down("a").href);
sTree += root + lpi + ":" + getPathInfo(li.down("a").href) + ",";
if(IsDefined(li.down("ul")))
{
sTree += getSubTree(li.down("ul"), root + lpi + "/");
}
})
return sTree;
}
function performNewTree(oThis)
{
return ajaxContentPost ('performNewTree', {ajaxPathInfo:getCurrendPage (),newTree:getSubTree($$("div.cms.editSitemap>ul").first(), "")});
}
function editableSitemap_OnUpdate(list)
{
cmsArrange_cleanDropTree ()
}
function cmsArrange_cleanDropTree ()
{
var removeList = "";
$('areaContent').select("div.cms.editSitemap ul").each(function(ul)
{
if(!IsDefined(ul.down("li"), "li"))
{
removeList += ul.identify() + " ";
}
})
$w(removeList.trim()).each(function(el)
{
$(el).remove();
})
editableSitemap_init();
}
function cmsArrange_removeTreeElem (oTreeElem)
{
if(IsDefined (oTreeElem))
{
oUlP = oTreeElem.up('ul');
oTreeElem.remove();
if(IsDefined (oUlP, "ul"))
{
var childId = oUlP.identify();
if(!IsDefined (oUlP.down("li"), "li"))
{
oTreeElem.remove();
}
}
}
}
function cmsArrange_dropAsChildMenu (elDrop, elDrag)
{
var oLiP = elDrop.up("li");
var oPH = oLiP.innerHTML;
elDrop.removeClassName ("dropZoneHover");
var childId = elDrag.identify();
var oCH = elDrag.innerHTML;
var newPC = "<li>" + oCH + "</li>";
posLi = oPH.indexOf("<li");
if(posLi >= 0)
{
oLiP.innerHTML = oPH.substr(0, posLi) + newPC + oPH.substr(posLi);
}
else
{
oLiP.innerHTML = oPH + "<ul>" + newPC + "</ul>";
}
oLiP.removeClassName("closed");
cmsArrange_removeTreeElem ($(childId));
cmsArrange_cleanDropTree ();
}
function editableSitemap_init()
{
$('areaContent').select("div.cms.editSitemap>ul").each(function(ul)
{
ul.select("li").each(function(el)
{
el.identify();
var childUl = el.down("ul");
el.removeClassName("moving");
var oCreateDiv = el.down("div.createSubmenu");
var hasCreateDiv = IsDefined (oCreateDiv, "div");
if(hasCreateDiv)
{
oCreateDiv.removeClassName("dropZoneHover");
}
if(IsDefined (childUl))
{
el.addClassName("subMenu");
if(hasCreateDiv)
{
el.down("div.createSubmenu").remove();
}
}
else
{
el.removeClassName("subMenu");
if(!hasCreateDiv)
{
el.insert({top:"<div class='createSubmenu' title='"+GetValue(el.down("a"))+"'>cmsTreeCreateSubmenu</div>"});
}
el.onmousedown = function(msd)
{
$(this).addClassName("moving");
}
el.onmouseup = function(msd)
{
$(this).removeClassName("moving");
}
var dropId = el.down("div.createSubmenu").identify();
Droppables.add(dropId, {
hoverclass:'dropZoneHover dpId_' + dropId,
onDrop: function(elDrag, elDrop) {
cmsArrange_dropAsChildMenu(elDrop, elDrag);
}
});
}
var a = el.down("a");
if(a)
{
a.onclick = function()
{
$(this).up("li").toggleClassName("closed");
return false;
}
}
})
ul.addClassName("editableSitemap sortActive");
Sortable.create(ul.identify(),{tree:true,onUpdate:editableSitemap_OnUpdate});
$('areaContent').down("input[name$=/cmsTreeAllOpen]").onclick = function()
{
$('areaContent').select("div.cms.editSitemap li.subMenu").each(function(li)
{
li.removeClassName ("closed");
})
return false;
}
$('areaContent').down("input[name$=/cmsTreeAllClose]").onclick = function()
{
$('areaContent').select("div.cms.editSitemap li.subMenu").each(function(li)
{
li.addClassName ("closed");
})
return false;
}
$('areaContent').down("input[name$=/cmsTreeSumitChanges]").onclick = function()
{
return performNewTree(this);
}
})
return false;
}
function dsnTabColArrange_OnUpdate()
{
var oTables = $$("table.dsnTabColArrange.dsnTabColMgmnt");
if(oTables.length > 0)
{
var ctId = "";
var oTabContent = $$("table.tableContent.dsnTabColMgmnt");
if(oTabContent.length > 0)
{
ctId = oTabContent.first().identify() + ":replace";
}
var lst = "";
var oTable = oTables.first();
oTable.select("tbody tr").each(function(tr)
{
lst += tr.down("td").innerHTML + ",";
})
ajaxContentGet ('dsnTabColMgmnt:'+ctId, {action:'dsnTabColArrange',dsn:getClassValue (oTable.className, "dsn_"),tab:getClassValue (oTable.className, "tab_"),data:lst,modal:true,sysSubmit:true});
}
}
function dsnTabHeadColArrange_OnUpdate()
{
var oTables = $$("table.dsnTabColArrange.dsnTabColMgmnt");
if(oTables.length > 0)
{
var oTabContent = $$("table.tableContent.dsnTabColMgmnt");
if(oTabContent.length > 0)
{
oTabContent = oTabContent.first();
ctId = oTabContent.identify() + ":replace";
var lst = "";
var oTable = oTables.first();
var key="";
oTabContent.select("thead tr.colNames th").each(function(th)
{
key = th.innerHTML;
if("idx" != key && "id_" != key)
{
lst += key + ",";
}
})
debug_out ("dsnTabHeadColArrange_OnUpdate: lst=" + lst);
ajaxContentGet ('dsnTabColMgmnt:'+ctId, {action:'dsnTabColArrange',dsn:getClassValue (oTable.className, "dsn_"),tab:getClassValue (oTable.className, "tab_"),data:lst,modal:true,sysSubmit:true});
}
}
}
function dsnTabColArrange_Init()
{
$('areaContent').select("table.dsnTabColArrange tbody").each(function(tbody)
{
var id = tbody.identify();
tbody.select("tr").each(function(tr)
{
tr.identify();
})
tbody.addClassName("sortMode");
Sortable.create(id,{tag:'tr', onUpdate:dsnTabColArrange_OnUpdate});
})
$('areaContent').select("table.dsnTabColMgmnt.tableContent thead tr.colNames").each(function(tr)
{
var id = tr.identify();
tr.select("th").each(function(th)
{
th.identify();
})
tr.addClassName("sortMode");
Sortable.create(id,{tag:'th', onUpdate:dsnTabHeadColArrange_OnUpdate});
})
return false;
}
function dsnTabRowArrange_OnUpdate()
{
var oTables = $$(".dsnTabIRowInplaceArrange table.tableContent.dsnTabColMgmnt");
if(oTables.length > 0)
{
var oTable = oTables.first();
var oTabContent = oTables;
var ctId = oTable.identify() + ":replace";
var lst = "";
oTable.select("tbody tr").each(function(tr)
{
lst += tr.identify().substr (1) + ",";
})
ajaxContentGet ('dsnTabRowMgmnt:'+ctId, {action:'dsnTabRowArrange',dsn:getClassValue (oTable.className, "dsn_"),tab:getClassValue (oTable.className, "tab_"),data:lst,modal:true,sysSubmit:true});
}
}
function dsnTabIRowInplaceArrange_Init()
{
var oTables = $$(".dsnTabIRowInplaceArrange table.tableContent.dsnTabColMgmnt");
if(oTables.length > 0)
{
var oTable = oTables.first();
oTable.select("tbody").each(function(tbody)
{
var id = tbody.identify();
tbody.select("tr").each(function(tr)
{
tr.identify();
})
tbody.addClassName("sortMode");
Sortable.create(id,{tag:'tr'});
})
oTable.select("tfoot input[name*=perform:doAcceptRowArrangeChanges]").each(function(btn)
{
btn.onclick = function()
{
dsnTabRowArrange_OnUpdate();
return false;
}
})
}
return false;
}
function inplaceArrange_deinit()
{
debug_out ("end of inplaceArrange");
}
function inplaceArrange_init()
{
if(hasBodyClass ("u_inplacearrange"))
{
inplaceNaviArrange_init ();
dsnTabColArrange_Init();
dsnTabIRowInplaceArrange_Init();
arrangeable_Init();
return cmsContentArrange_Init()
}
else
{
inplaceArrange_deinit();
}
return true;
}
g_devDbgWin_filter_modul = "";
DevDbgWinTreshold_List = "0,1,2,3,4,5,6,7,8,9,10,100,1000,10000";
DevDbgWinModul_List = "-- A=all,-- G=generic,admin";
function getDevDbgWin ()
{
var oDevWin = $('clone_devDbgWin');
if(!oDevWin)
{
var devId = 'devDbgWin';
oDevWin = $(devId);
if(!oDevWin)
{
var clsClosed = "";
if(IsDefined (g_mCookie))
{
if(("1" == g_mCookie.get ("u_developDbgWnd")))
{
clsClosed = " closed";
}
}
var ddw_tl = '<label for="DevDbgWinTreshold"><strong>Print Filter:</strong> Level L &gt;= </label><input class="comboBox DevDbgWinTreshold_List sSize max_2 fixed" id="DevDbgWinTreshold" type="text" maxlength="2" name="DevDbgWinTreshold" />';
var ddw_moduls = '<label for="DevDbgWinModul">Modul = </label><input class="comboBox DevDbgWinModul_List xxmSize max_64 fixed" id="DevDbgWinModul" type="text" maxlength="64" name="DevDbgWinModul" />';
var ddw_btnClear = '<a class="button" href="#" onclick="return developDebugWinClear()">clear</a>';
var ddw_btnSysInfo = '<a class="button" href="#" onclick="return developDebugWinSysInfo()">SysInfo</a>';
var ddw_btnModal = '<input type="checkbox" class="checkbox" name="dbgWndModal" id="dbgWndModal" onclick="return dragWindowToggleModal(this)" /><label for="dbgWndModal">modal</label>';
var ddw_btn = ddw_btnClear + ddw_btnSysInfo + ddw_btnModal;
var ddw_footer = ddw_tl + " " + ddw_moduls + " " + ddw_btn;
oDevWin = dragWindowCreate(devId, "<span class=\"counter\">0</span>: debug_out (messages, level, modul)</span>", "", ddw_footer, "collapsible u_developDbgWnd");
}
}
return oDevWin;
}
function developDebugWinClear ()
{
var devWin = getDevDbgWin ();
devWin.down(".content").update ("");
devWin.down("h4 .counter").update ("0");
dragWindowRedraw ('devDbgWin');
return false;
}
function hasDevelopDebugWin ()
{
return IsDefined ('devDbgWin');
}
function developDebugWinCanPrint ()
{
var canPrint = false;
if(hasDevelopDebugWin ())
{
devWin = getDevDbgWin ();
canPrint = IsDefined (devWin) && (hasBodyClass ("u_showDevelopDebugWin") || devWin.visible());
}
return canPrint;
}
function developDebugWin_OutText (txt,level,modul)
{
outText = "";
var devWin = getDevDbgWin ();
if(devWin)
{
var curTrsHld = $F("DevDbgWinTreshold")
if("undefined" == typeof(level) || "" == level || curTrsHld <= 0)
{
level = 1;
}
if(curTrsHld <= level)
{
var curModul= $F("DevDbgWinModul")
if("undefined" == typeof(modul) || "" == modul)
{
curModul = "";
modul = " - default - "
}
else
{
if("-- A=all" == curModul)
{
curModul = "";
}
else
{
switch (modul) {
case "G":
case "GENERIC":
if("-- G=generic" == curModul)
{
curModul = "";
}
break;
case "A":
case "ALL":
curModul = "";
break;
default:
if(modul == curModul)
{
curModul = "";
}
break;
}
}
}
if(developDebugWinCanPrint() && "" == curModul)
{
outText = "<abbr title='Level="+level+"; Modul="+modul+"'><span title='Level="+level+"; Modul="+modul+"'>L" + level + ":</span></abbr> " + txt;
}
}
}
return outText;
}
function developDebugWin_TagWrite (txt,level,modul,tag)
{
var devWin = getDevDbgWin ();
if(devWin)
{
var curTrsHld = $F("DevDbgWinTreshold")
if("undefined" == typeof(level) || "" == level || curTrsHld <= 0)
{
level = curTrsHld;
}
if("string" != typeof(tag))
{
tag = "p";
}
if(curTrsHld <= level)
{
var curModul= $F("DevDbgWinModul")
if("undefined" == typeof(modul) || "" == modul)
{
curModul = "";
modul = " - default - "
}
else
{
if("-- A=all" == curModul)
{
curModul = "";
}
else
{
switch (modul) {
case "G":
case "GENERIC":
if("-- G=generic" == curModul)
{
curModul = "";
}
break;
case "A":
case "ALL":
curModul = "";
break;
default:
if(modul == curModul)
{
curModul = "";
}
break;
}
}
}
if(developDebugWinCanPrint () && "" == curModul)
{
var oCon = devWin.down(".content");
if(!oCon)
{
oCon = devWin.down(".body");
}
if("" == tag)
{
oCon.insert (developDebugWin_OutText (txt,level,modul));
}
else
{
oCon.insert ("<" + tag + ">" + developDebugWin_OutText (txt,level,modul) + "</" + tag + ">");
}
var oCount = devWin.down("h4 .counter");
var count = 1 * oCount.innerHTML + 1;
oCount.update (count);
}
}
}
}
function developDebugWin_WriteLn (txt,level,modul)
{
developDebugWin_TagWrite (txt,level,modul,"p");
}
function developDebugWinSysInfoOut (msg)
{
developDebugWin_WriteLn (msg, "A", 10);
}
function developDebugWinSysInfo ()
{
var bfXPath = Prototype.BrowserFeatures.XPath ? "XPath " : "";
var bfSelectorsAPI = Prototype.BrowserFeatures.SelectorsAPI ? "SelectorsAPI " : "";
var bfElementExtensions = Prototype.BrowserFeatures.ElementExtensions ? "ElementExtensions " : "";
var bfSpecificElementExtensions= Prototype.BrowserFeatures.SpecificElementExtensions ? "SpecificElementExtensions " : "";
developDebugWinSysInfoOut ("debug-window usage:");
developDebugWinSysInfoOut (" &#160;  <b>debug_out (msg,level,modul)</b>");
developDebugWinSysInfoOut (" &#160;   * <b>msg</b>: the message to display (required)");
developDebugWinSysInfoOut (" &#160;   * <b>level</b>: output-Level L (optional, see Print <b>Filter L</b>)");
developDebugWinSysInfoOut (" &#160;   * <b>modul</b>: Modul-Name, (optional, see Print <b>Filter Modul</b>)<br />");
developDebugWinSysInfoOut ("------ SysInfo: -------");
developDebugWinSysInfoOut ("Prototype Version: " + Prototype.Version);
developDebugWinSysInfoOut ("Browser:  userAgent = " + navigator.userAgent);
developDebugWinSysInfoOut ("Browser:  Browser.Version = " + Prototype.Browser.Version);
developDebugWinSysInfoOut ("Browser:  Browser.KeyName = " + Prototype.Browser.KeyName);
developDebugWinSysInfoOut ("Browser:  Browser.KeyVersion = " + Prototype.Browser.KeyVersion);
developDebugWinSysInfoOut ("Browser:  BrowserFeatures = " + bfXPath + bfSelectorsAPI + bfElementExtensions + bfSpecificElementExtensions);
if(Prototype.Browser.IE)
{
developDebugWinSysInfoOut ("Browser:  IE CompatMode = " + document.compatMode);
}
var windowScroll = document.viewport.getScrollOffsets();
developDebugWinSysInfoOut ("Window:  windowScroll = (" + windowScroll.left + ", " + windowScroll.top + ")");
developDebugWinSysInfoOut ("Window:  location = (" + getCurrendLocation() + ")");
developDebugWinSysInfoOut ("-------------");
dragWindowRedraw ('devDbgWin');
return false;
}
function developDebugWinShow (show)
{
var devWin = getDevDbgWin ();
if(show)
{
dragWindowShow(devWin);
}
else
{
dragWindowHide(devWin);
}
return true;}
function developHandleDebugWin (oThis)
{
developDebugWinShow ($(oThis).checked);
return true;
}
var g_scrollFocus = "";
function setScrollFocus()
{
if(("" != g_scrollFocus) && $(g_scrollFocus))
{
$(g_scrollFocus).focus();
}
g_scrollFocus = "";
}
function fnSoftScrollInit ()
{
if("object" == typeof (Effect))
{
$$('a[href^="#"]').each(function(el)
{
var elHref = el.href.split("#")[1];
if((elHref.length > 1) && ("function" != typeof (el.onclick)))
{
el.onclick = function()
{
if(useScript ())
{
var aName = this.href.split("#")[1];
$$('a[name="'+aName+'"]').each (function(ele)
{
var off = -Position.cumulativeOffset($('container'))[1];
new Effect.ScrollTo(ele,{offset:off});
return false;
})
return false;
}
}
}
})
$$('#msgErrorArea li label[for]').each(function(el)
{
el.onclick = function()
{
var off = -Position.cumulativeOffset($('container'))[1];
off -= 10;
g_scrollFocus = $(this).readAttribute('for');
if($(g_scrollFocus))
{
new Effect.ScrollTo($(g_scrollFocus),{offset:off, afterFinish: setScrollFocus});
}
return false;
}
})
}
}
function doHandleOnScroll ()
{
var windowScroll = document.viewport.getScrollOffsets();
setCookie ("scrollPos", getCurrendLocation () + "$"+windowScroll.top + ";" + windowScroll.left);
}
function getScrollValues ()
{
var top = 0;
var left = 0;
var scrollPos = getCookie ("scrollPos");
if(scrollPos && scrollPos.length > 6)
{
var aPos = scrollPos.split("$");
var scrollPage = aPos[0];
if(scrollPage == getCurrendLocation ())
{
var values = aPos[1];
if(values && values.length > 2)
{
var aValues = values.split(";");
top = 1*Math.round (aValues[0]);
left = 1*Math.round (aValues[1]);
}
}
}
return {top:top,left:left};
}
function handleScrolling (values)
{
window.scrollTo(values.left,values.top);
}
var g_minValidCalendarYear = 1900;
var g_maxValidCalendarYear = 2100;
var g_maxValidCalendarWeekYear = 53; // maximal moegliche Kalenderwoche
var g_defaultYear = 2010; // in der Regel das Folgejahr
var g_invalidYear = -9999;
function i18nGetExclamationMessageTitle (oThis, valOptions)
{
var typeTxt = "";
switch (valOptions.type) {
case "numeric":
typeTxt = " Ziffern";
break;
default:
typeTxt = " Zeichen";
break;
}
var thisTitle = "";
if("" != valOptions.title)
{
thisTitle = valOptions.title + ". \n";
}
if(oThis.hasClassName("calendar"))
{
if(getCalendarMinLength(oThis) <= oThis.value.length)
{
var format = getClassValue (oThis.className, 'Format_');
if("weekYear" == format)
{
thisTitle += "Geben Sie bitte eine gueltige Kalenderwoche ein";
}
else
{
var className = oThis.className;
var format = getClassValue (className, 'Format_');
var date = Date.parseFormattedString ($F(oThis), format);
if(!IsInCalendarLimits (date, oThis.className))
{
var limitMin = getClassValue (className, 'limitMin_');
var limitMax = getClassValue (className, 'limitMax_');
if(limitMax.length > 0)
{
var maxDate = CalendarGetLimitDate (limitMax);
if(limitMin.length > 0)
{
var minDate = CalendarGetLimitDate (limitMin);
thisTitle += "Geben Sie bitte ein Datum im Zeitraum vom " +
minDate.toFormattedString(false, format, true) +
" bis " +
maxDate.toFormattedString(false, format, true) +
" ein. ";
}
else
{
thisTitle += "Geben Sie bitte kein Datum nach dem " +
maxDate.toFormattedString(false, format, true) +
" ein. ";
}
}
else
{
if(limitMin.length > 0)
{
var minDate = CalendarGetLimitDate (limitMin);
thisTitle += "Geben Sie bitte kein Datum vor dem " +
minDate.toFormattedString(false, format, true) +
" ein";
}
else
{
thisTitle += "Geben Sie bitte ein gueltiges Datum ein. ";
}
}
}
else
{
thisTitle += "Geben Sie bitte ein gueltiges Datum ein. ";
}      }
return thisTitle;
}
}
if("" != valOptions.lenList)
{
thisTitle += "Geben Sie hier bitte"+typeTxt+" der folgenden Laenge ein: \n[" + valOptions.lenList + "]";
}
else if("" != valOptions.valueList)
{
thisTitle += "Geben Sie hier bitte einen Wert der folgenden Liste ein: \n[" + valOptions.valueList + "]";
}
else
{
if("" != valOptions.min)
{
if(("" != valOptions.max) && (valOptions.max > 0))
{
if(valOptions.max == valOptions.min)
{
if((valOptions.max == 1) && ("Ziffern" == typeTxt))
{
thisTitle += "Geben Sie hier bitte genau \neine Ziffer ein";
}
else
{
thisTitle += "Geben Sie hier bitte genau \n" + valOptions.max + typeTxt + " ein";
}
}
else
{
if(("" != valOptions.max) && (valOptions.max == 1))
{
thisTitle += "Geben Sie hier bitte \nein " + typeTxt + " ein";
}
else
{
thisTitle += "Geben Sie hier bitte \n" + valOptions.min + "\n bis " + valOptions.max + typeTxt + " ein";
}
}
}
else
{
thisTitle += "Geben Sie hier bitte mindestens\n " + valOptions.min + typeTxt + " \nein";
}
}
else
{
if("" != valOptions.max)
{
if(valOptions.max > 1)
{
thisTitle += "Geben Sie hier bitte 1 bis " + valOptions.max + typeTxt + " ein";
}
else
{
thisTitle += "Geben Sie hier bitte " + valOptions.max + typeTxt + " ein";
}
}
}
}
if("" == thisTitle)
{
switch (valOptions.type) {
case "email":
thisTitle = g_de_TitleEmailExplain;
break;
default:
switch (oThis.tagName) {
case "SELECT":
thisTitle = "Bitte w&auml;hlen Sie einen Eintrag aus";
break;
case "INPUT":
thisTitle = "Bitte geben Sie einen Wert ein";
break;
default:
thisTitle = "F&uuml;r den Feldtyp (" + oThis.tagName + ") ist derzeit leider keine Hilfe verf&uuml;gbar";
break;
}
break;
}
}
if(!IsRequired(oThis))
{
thisTitle += ", \noder lassen Sie das Feld leer.";
}
else
{
thisTitle += ".";
}
return thisTitle;
}
function validateEmail(oThis, classNames)
{
var thisVal = $F(oThis);
if(thisVal && thisVal.length > 0)
{
firstAt = thisVal.indexOf("\@");
lastAt = thisVal.lastIndexOf("@");
lastDot = thisVal.lastIndexOf(".");
if((firstAt < 0) || (lastDot < 0) || (lastDot < firstAt) || (lastAt != firstAt) || (lastDot+3 > thisVal.length))
{
return false;
}
}
return true;
}
function validateMinLength(oThis, minLen)
{
var isValid = false;
var thisVal = $F(oThis);
if(thisVal && thisVal.length >= minLen)
{
isValid = true;
}
return isValid;
}
function validateMaxLength(oThis, maxLen)
{
var isValid = false;
var thisVal = $F(oThis);
if(thisVal && thisVal.length <= maxLen)
{
isValid = true;
}
return isValid;
}
function validateListLength(oThis)
{
var isValid = false;
var valOptions = getValidOptions (oThis);
var thisVal = $F(oThis);
if(thisVal && valOptions.lenList.length > 0)
{
$A(valOptions.lenList.split(",")).each(function(item)
{
if(thisVal.length == item)
{
isValid = true;
}
})
}
else
{
isValid = true;
}
return isValid;
}
function validateValueList(oThis)
{
var isValid = false;
var valOptions = getValidOptions (oThis);
var thisVal = $F(oThis);
if(thisVal && valOptions.valueList.length > 0)
{
$A(valOptions.valueList.split(",")).each(function(item)
{
if(thisVal == item)
{
isValid = true;
}
})
}
else
{
isValid = true;
}
return isValid;
}
function validatePwdConfirm(oThis, classNames)
{
var thisVal = $F(oThis);
if(thisVal && thisVal.length > 0)
{
var aPwd = $$(".required input.password");
if(!aPwd || !aPwd[0] || aPwd[0].value != thisVal)
{
return false;
}
}
return true;
}
function validateCombo(oThis, classNames)
{
if("function" == typeof (InputField2ComboBox_CheckValid))
{
return InputField2ComboBox_CheckValid (oThis);
}
return true;
}
function validateNumeric(oThis, classNames)
{
return IsNumeric($F(oThis));
}
function validatePhone (oThis, classNames)
{
return validateMinLength(oThis, 4);
}
function validatePrice (oThis, classNames)
{
var price = $F(oThis);
reg = /^\$?[0-9]+(\.[0-9]{3})*(,[0-9]{2})?$/;
return reg.test(price);
}
function validateAlpha(oThis, classNames)
{
var thisVal = $F(oThis);
var posNumber = thisVal.search(/\d/);
return (posNumber < 0);
}
function validateAlphaNumeric(oThis, classNames)
{
return validateMinLength(oThis, 4);
}
function getMaxClassFieldLength (oThis, classNames)
{
var maxVal = getClassValue (classNames, 'max_');
if(maxVal.length <= 0)
{
var maxVal = $(oThis).readAttribute ('maxlength');
if(!maxVal || maxVal.length <= 0 || maxVal >= 9999)
{
maxVal = "";
}
}
return maxVal;
}
function getMaxFieldLength (oThis)
{
var maxVal = getMaxClassFieldLength (oThis, oThis.className);
if("" == maxVal)
{
maxVal = 0;
}
return 1*maxVal;
}
function validateLengthRange(oThis, cssNames)
{
var isValid = true;
if(cssNames && cssNames.length > 0)
{
var thisVal = $F(oThis);
var minVal = getClassValue (cssNames, 'min_');
if(minVal.length > 0)
{
isValid = validateMinLength(oThis, minVal);
}
if(isValid)
{
isValid = validateListLength(oThis);
}
if(isValid)
{
var maxVal = getMaxClassFieldLength (oThis, cssNames);
if(maxVal.length > 0)
{
isValid = validateMaxLength(oThis, maxVal);
}
}
}
return isValid;
}
function validateRequired(oThis)
{
return validateMinLength(oThis, 1) && validateListLength(oThis);
}
function validateDefault(oThis, cssName)
{
return validateRequired(oThis);
}
function doHighlightInvalid(oThis)
{
return;
}
function IsValidField (oThis)
{
var isValid = true;
var clsNames = oThis.className;
if(clsNames)
{
clsNames = clsNames.toLowerCase();
$w(clsNames).each(function(cssName)
{
switch (cssName)
{
case "alpha":
isValid = isValid && validateAlpha (oThis, cssName);
break;
case "numeric":
isValid = isValid && validateNumeric (oThis, cssName);
break;
case "alphaNumeric":
isValid = isValid && validateAlphaNumeric (oThis, cssName);
break;
case "phone":
isValid = isValid && validatePhone (oThis, cssName);
break;
case "price":
isValid = isValid && validatePrice (oThis, cssName);
break;
case "email":
isValid = isValid && validateEmail (oThis, cssName);
break;
case "password":
isValid = isValid && validateAlphaNumeric (oThis, cssName);
break;
case "pwdConfirm":
isValid = isValid && validatePwdConfirm (oThis, cssName);
break;
case "combo":
isValid = isValid && validateCombo (oThis, cssName);
break;
case "calendar":
isValid = isValid && validateCalendar (oThis, cssName);
break;
default:
isValid = isValid && validateDefault (oThis, cssName);
break;
}
})
}
if(isValid)
{
isValid = validateLengthRange(oThis, clsNames) && validateRequired (oThis) && validateValueList(oThis);
}
if(!isValid && !IsRequired(oThis))
{
var thisVal = $F(oThis);
if("" == thisVal)
{
isValid = true;
}
}
return isValid;
}
function mustValidate (oThis)
{
var mustValidate = IsRequired(oThis);
if(!mustValidate)
{
if(oThis.hasClassName ("validate"))
{
var thisVal = $F(oThis);
mustValidate = (thisVal && thisVal.length > 0);
}
}
return mustValidate;
}
function IsValid (oThis)
{
var isValid = true;
oThis = $(oThis);
if(mustValidate(oThis))
{
isValid = IsValidField (oThis);
}
return isValid;
}
function getValidOptions (oThis)
{
var valType = "";
var valMin = 0;
var valMax = "";
var valTitle = "";
var ml = $(oThis).readAttribute ('maxlength');
if(ml && ml < 9999)
{
valMax = ml;
}
if(oThis.title)
{
valTitle = oThis.title;
}
var clsNames = oThis.className;
var lenListName = getClassValue (clsNames, 'lenList_');
var valLenList = readScriptList ('lenList_' + lenListName)
var valListName = getClassValue (clsNames, 'valueList_');
var valValueList = readScriptList ('valueList_' + valListName)
if(clsNames)
{
$w(clsNames).each(function(cssName)
{
switch (cssName)
{
case "alpha":
case "numeric":
case "alphaNumeric":
case "phone":
case "email":
case "password":
case "pwdConfirm":
case "combo":
valType = cssName;
break;
case "calendar":
valType = cssName;
var val = getClassValue (clsNames, 'min_');
if(val.length == 0)
{
valMin = getCalendarMinLength(oThis);
}
break;
default:
if(cssName && cssName.length > 0)
{
var val = getClassValue (cssName, 'min_');
if(val.length > 0)
{
valMin = val;
}
val = getClassValue (cssName, 'max_');
if(val.length > 0)
{
valMax = val;
}
}
break;
}
})
}
return {type: valType, min: valMin, max: valMax, lenList: valLenList, valueList: valValueList, title:valTitle };
}
function setValidChecked(oThis)
{
if(mustValidate(oThis) || oThis.hasClassName("validate"))
{
var nxTag = $(oThis).next("span.exclamation");
if(nxTag)
{
nxTag.remove();
}
}
return true;
}
function labelSetClassName(oCtrl, action, clsName)
{
if(oCtrl && oCtrl.id)
{
$$("label[for='"+oCtrl.id+"']").invoke(action + "ClassName", clsName);
}
}
function setExclamation(oThis)
{
var thisTitle = i18nGetExclamationMessageTitle (oThis, getValidOptions (oThis));
var imgErr = '<span title="'+thisTitle+'" class="exclamation">&#160; ! &#160;<span>';
oCtrl = $(oThis);
var nxTag = $(oThis).next("span.exclamation");
if(!nxTag)
{
if(oCtrl.hasClassName ("comboBox"))
{
var oSpan = $(oThis).next("span");
if(oSpan && oSpan.hasClassName ("comboHandle"))
{
oCtrl = $(oSpan);
}
}
$(oCtrl).insert({after: imgErr});
if("function" == typeof (Tooltips_Behaviour_Init)) {Tooltips_Behaviour_Init ("span.exclamation[title]");}
}
nxTag = $(oThis).next("span.exclamation");
var ctrlW = oCtrl.getWidth() - 7;
Position.clone(oCtrl, nxTag, { setHeight: false, setWidth: false, offsetTop:-5, offsetLeft: ctrlW});
labelSetClassName(oCtrl, "add", "invalid");
labelSetClassName(oCtrl, "remove", "valid");
oCtrl.addClassName ("revalidate");
fieldValidatorInitInvalid(oCtrl);
return true;
}
function validatorErrorBehaviour()
{
$$('.validate input.invalid, .validate select.invalid, .validate textarea.invalid').each(function(el)
{
if(!el.hasClassName("ajax"))
{
el.onkeyup = function()
{
return validatorApply(this);
}
}
})
}
function getCalendarMinLength(oThis)
{
var minLen = 4;
var format = getClassValue (oThis.className, 'Format_');
switch (format) {
case "weekYear": // WWYY (Kalenderwoche Jahr) z.B.: 4809
break;
default:
case "": // DDMMYY (Tag Monat Jahr) z.B.: 170309
minLen = 6;
break;
}
return minLen;
}
function calendarWeekYearToString (calDate)
{
var y = calDate.year;
var w = calDate.week;
if((g_invalidYear == y) || !IsNumeric(w) || !IsNumeric(y))
{
return calDate.orign;
}
var wyString = "";;
if(w < 10)
{
wyString = "0"
}
wyString += w + "/";
if(y < 10)
{
wyString += "200"
}
else if(y < 100)
{
wyString += "20"
}
else if(y < 1000)
{
wyString += "2"
}
wyString += y;
return wyString;
}
function calendarDateToString (d,m,y)
{
var dateString = "";
if(d < 10)
{
dateString = "0"
}
dateString += d + ".";
if(m < 10)
{
dateString += "0"
}
dateString += m + ".";
if(y < 10)
{
dateString += "200"
}
else if(y < 100)
{
dateString += "20"
}
else if(y < 1000)
{
dateString += "2"
}
dateString += y;
return dateString;
}
function calendarCalDateToString (calDate)
{
var y = calDate.year;
var d = calDate.day;
var m = calDate.month;
if((g_invalidYear == y) || !IsNumeric(d) || !IsNumeric(m) || !IsNumeric(y))
{
return calDate.orign;
}
return calendarDateToString (d,m,y);
}
function isValidCalendarDate (d,m,y)
{
var isValid = (y != g_invalidYear) && (g_minValidCalendarYear <= y) && (y <= g_maxValidCalendarYear) && (1 <= m) && (m <= 12) && (1 <= d) && (d <= 31);
if(isValid)
{
switch (m)
{
case 2: // 28 oder 29 Tage
if(IsLeapYear(y))
{
isValid = (d <= 29);
}
else
{
isValid = (d <= 28);
}
break;
case 4: // 30 Tage
case 6:
case 9:
case 11:
isValid = (d <= 30);
break;
default:
isValid = (d <= 31);
break;
}
}
return isValid;
}
function parseCalendarDate (calVal)
{
var d = 1;
var m = 1;
var y = g_invalidYear;
calVal = calVal.replace(/\,/g,'\.');
calVal = calVal.replace(/\;/g,'\.');
calVal = calVal.replace(/\-/g,'\.');
calVal = calVal.replace(/\_/g,'\.');
calVal = calVal.replace(/\:/g,'\.');
var firstDot = calVal.indexOf("\.");
if(firstDot >= 0)
{
var lastDot = calVal.lastIndexOf ("\.");
if(lastDot > firstDot)
{
d = calVal.substr(0,firstDot);
m = calVal.substring(firstDot+1, lastDot);
y = calVal.substr(lastDot+1);
}
else
{
d = calVal.substr(0,firstDot);
var m_y = calVal.substr(firstDot+1);
switch (m_y.length)
{
case 1:
m = m_y;
y = g_defaultYear;
break;
case 2:
m = m_y.substr(0,1);
y = m_y.substr(1);
break;
case 3:
m = m_y.substr(0,1);
y = m_y.substr(1);
break;
default:
m = m_y.substr(0,2);
y = m_y.substr(2);
break;
}
}
}
else
{
switch (calVal.length) {
case 2: // DM
d = calVal.substr(0,1);
m = calVal.substr(1,1);
y = g_defaultYear;
break;
case 3: // DMY
case 4: // DMYY
d = calVal.substr(0,1);
if(1*d == 0)
{
d = calVal.substr(1,1);
m = calVal.substr(2,1);
if(1*m == 0)
{
m = calVal.substr(3,1);
y = calVal.substr(4);
}
else
{
y = calVal.substr(3);
}
}
else
{
m = calVal.substr(1,1);
if(1*m == 0)
{
m = calVal.substr(2,1);
y = calVal.substr(3);
}
else
{
y = calVal.substr(2);
}
}
break;
case 5: // DDMMY
case 6: // DDMMYY
case 7: // DDMMYYY
case 8: // DDMMYYYYY
d = calVal.substr(0,2);
if(1*d <= 31)
{
m = calVal.substr(2,2);
if(1*m <= 12)
{
y = calVal.substr(4);
}
else
{
m = calVal.substr(2,1);
y = calVal.substr(3);
}
}
else
{
d = calVal.substr(0,1);
m = calVal.substr(1,2);
if(1*m <= 12)
{
y = calVal.substr(3);
}
else
{
m = calVal.substr(1,1);
y = calVal.substr(2);
}
}
break;
}
}
d = 1*d;
m = 1*m;
y = 1*y;
var isValid = isValidCalendarDate (d,m,y);
return {day: d, month: m, year: y, orign:calVal, valid:isValid};
}
function parseCalendarWeekYear (calVal)
{
var w = 1;
var y = g_invalidYear;
calVal = calVal.replace(/\,/g,'\/');
calVal = calVal.replace(/\./g,'\/');
calVal = calVal.replace(/\-/g,'\/');
calVal = calVal.replace(/\;/g,'\/');
calVal = calVal.replace(/\_/g,'\/');
calVal = calVal.replace(/\:/g,'\/');
var firstSlash = calVal.indexOf("/");
if(firstSlash >= 0)
{
var lastSlash = calVal.lastIndexOf ("/");
if(lastSlash == firstSlash)
{
w = calVal.substr(0,firstSlash);
y = calVal.substring(firstSlash+1);
}
}
else
{
switch (calVal.length) {
case 1: // W
w = calVal;
y = g_defaultYear;
break;
case 2: // WW
w = calVal;
if(1*w > g_maxValidCalendarWeekYear)
{
w = calVal.substr(0,1);
y = calVal.substr(1);
}
else
{
y = g_defaultYear;
}
break;
case 3: // WWY
w = calVal.substr(0,2);
if(1*w > g_maxValidCalendarWeekYear)
{
w = calVal.substr(0,1);
y = "20" + calVal.substr(1);
}
else
{
y = "200" + calVal.substr(2); // Muss alle Jahrhunderte angepasst werden
}
break;
case 4: // WWYY
w = calVal.substr(0,2);
if(1*w > g_maxValidCalendarWeekYear)
{
w = calVal.substr(0,1);
y = "2" + calVal.substr(1); // Muss alle Jahrtausende angepasst werden
}
else
{
y = "20" + calVal.substr(2); // Muss alle Jahrzehnte angepasst werden
}
break;
case 5: // WWYYY
w = calVal.substr(0,2);
if(1*w > g_maxValidCalendarWeekYear)
{
w = calVal.substr(0,1);
y = calVal.substr(1);
}
else
{
y = "2" + calVal.substr(2); // Muss alle Jahrzehnte angepasst werden
}
break;
case 6: // WWYYYYY
w = calVal.substr(0,2);
y = calVal.substr(2);
break;
}
}
w = 1*w;
y = 1*y;
var isValid = (y != g_invalidYear) && (g_minValidCalendarYear <= y) && (y <= g_maxValidCalendarYear) && (1 <= w) && (w <= g_maxValidCalendarWeekYear);
return {week: w, year: y, orign:calVal, valid:isValid};
}
function getCalendarAutoCompleteValue (calFormat, calVal)
{
var retVal = calVal;
switch (calFormat) {
case "weekYear": // WW/YYYY (Kalenderwoche/Jahr) z.B.: 48/2009
var calDate = parseCalendarWeekYear (calVal);
retVal = calendarWeekYearToString (calDate);
break;
default:
case "": // DD.MM.YYYY (Tag.Monat.Jahr) z.B.: 17.03.2009
var calDate = parseCalendarDate (calVal);
retVal = calendarCalDateToString (calDate);
break;
}
return retVal;
}
function IsLeapYear(year)
{
return ((year % 400) == 0) || (((year % 4) == 0) && ((year % 100) != 0));
}
function getFieldCalendarDate(oFld)
{
var date = null;
if(IsDefined(oFld) && oFld.hasClassName("calendar"))
{
var format = getClassValue (oFld.className, 'Format_');
date = Date.parseFormattedString ($F(oFld), format);
}
return date;
}
function validateCalendar(oThis, classNames)
{
var format = getClassValue (oThis.className, 'Format_');
var thisVal = $F(oThis);
var len = thisVal.length;
var isValid = false;
var calValue = getCalendarAutoCompleteValue (format, thisVal);
switch (format) {
case "weekYear": // WW/YYYY (Kalenderwoche/Jahr) z.B.: 48/2009
var calDate = parseCalendarWeekYear (calValue);
isValid = calDate.valid;
break;
default:
case "": // DD.MM.YYYY (Tag.Monat.Jahr) z.B.: 17.03.2009
var calDate = parseCalendarDate (calValue);
isValid = calDate.valid;
if(isValid)
{
var date = Date.parseFormattedString (calValue, format);
isValid = IsInCalendarLimits (date, oThis.className);
}
break;
}
return isValid;
}
function validatorAutoCompleteCalendar (oThis)
{
return getCalendarAutoCompleteValue (getClassValue (oThis.className, 'Format_'), $F(oThis));
}
function validatorAutoComplete (oThis)
{
var thisVal = $F(oThis);
var retVal = thisVal;
var complete = getClassValue (oThis.className, 'complete_');
if("" == complete && oThis.hasClassName("calendar"))
{
complete = "calendar"; // calendar immer autocompete
}
if("" != complete)
{
switch (complete) {
case "modelYear":
if(2 == thisVal.length)
{
retVal = "20" + thisVal; // gilt nur bis zum Jahr 2099 !!! who cares :-)
}
break;
case "calendar":
retVal = validatorAutoCompleteCalendar (oThis);
break;
}
}
return retVal;
}
function keyUpInputBehaviour(oThis, keyCode)
{
if(oThis.hasClassName("uppercase"))
{
SetValue (oThis, oThis.value.toUpperCase());
}
if(oThis.hasClassName("lowercase"))
{
SetValue (oThis, oThis.value.toLowerCase());
}
return true;
}
function keyUpTextareaBehaviour(oThis, keyCode)
{
if(oThis.hasClassName("uppercase"))
{
var org = oThis.innerHTML;
var upper = org.toUpperCase();
if(org != upper)
{
oThis.innerHTML = upper;
}
}
if(oThis.hasClassName("lowercase"))
{
var org = oThis.innerHTML;
var lower = org.toLowerCase();
if(org != lower)
{
oThis.innerHTML = lower;
}
}
return true;
}
function specialFunctionCall(oThis, keyCode)
{
var func = getClassValue (oThis.className, 'func_');
if(func.length > 0)
{
return call_function_by_string (func, oThis, keyCode);
}
return false;
}
function keyUpBehaviour(oThis, keyCode)
{
var tagName = oThis.tagName.toLowerCase();
switch (tagName) {
case "input":
return keyUpInputBehaviour(oThis, keyCode);
break;
case "textarea":
return keyUpTextareaBehaviour(oThis, keyCode);
break;
case "select":
break;
default:
debug_out("UNSUPPORTED KeyUpBehaviour for tagName " + tagName);
break;
}
specialFunctionCall(oThis, keyCode);
return true;
}
function syncAreaError(oThis, valid)
{
if($('errReportWin'))
{
var theId = $(oThis).identify();
$('errReportWin').select("div.body li label[for="+theId+"]").each(function(lbl)
{ // es koennen mehrere labels auf die id zeigen, z.b. Direkteingabemodus Auftragsbearbeitung Aussen- und Innenfarbe
var li = lbl.up("li");
if(valid)
{
li.addClassName("valid");
}
else
{
li.removeClassName("valid");
}
})
}
}
function validatorSetValid(oThis, valid)
{
if(valid)
{
setValidChecked(oThis);
$(oThis).removeClassName('invalid');
$(oThis).addClassName('valid');
labelSetClassName(oThis, "remove", "invalid");
labelSetClassName(oThis, "add", "valid");
}
else
{
$(oThis).addClassName('invalid');
$(oThis).removeClassName('valid');
setExclamation(oThis);
labelSetClassName(oThis, "add", "invalid");
labelSetClassName(oThis, "remove", "valid");
if("function" == typeof (doHighlightInvalid)) {doHighlightInvalid (oThis);}
}
syncAreaError(oThis, valid);
return true;
}
function validatorApply(oThis, keyCode)
{
if(!keyCode || "undefined" == typeof (keyCode))
{
keyCode = 0;
}
validatorSetValid($(oThis), IsValid (oThis));
ret = specialFunctionCall(oThis, keyCode);
return ret;
}
function isValidForm()
{
var isValid = true;
var invalidFields = "";
var now = new Date();
return isValid;
}
function errorDragWindowNotify (elem, eventName)
{
if($('errReportWin'))
{
$('errReportWin').select("div.body li label").each(function(lbl)
{
var li = lbl.up("li");
li.removeClassName ("hasFocus");
})
if("focus" == eventName)
{
var theId = $(elem).identify();
$('errReportWin').select("div.body li label[for="+theId+"]").each(function(lbl)
{
var li = lbl.up("li");
li.addClassName ("hasFocus");
})
}
}
}
function errorDragWindowInit ()
{
var errCnt = 0;
if(!IsBrowserVersion("IE6"))
{
errCnt = $A($$('#areaContent div.areaError div.body li.Error')).length;
}
if(errCnt > 0)
{
addBodyClasses("hasPageErrors pageScrollMargin");
var theErr = "<ul>" + $('areaContent').down('div.areaError div.body li.Error').up("ul").innerHTML + "</ul>";
var btnClose = '<a href="#" class="button abort" title="Fenster schließen">Schlie&szlig;en</a>';
var btnFldPreview = '<input type="checkbox" class="checkbox" name="errFieldPreview" id="errFieldPreview" /><label for="errFieldPreview">Fehlerfeld Vorschau</label>';
var nowDate = getBodyClassValue("date_");
var time= getBodyClassValue("time_");
var aDate = nowDate.split("-");
var aTime = time.split("-");
var sDate = calendarDateToString (aDate[2],aDate[1],aDate[0]) + " " + aTime[0] + ":" + aTime[1];
var sDestApp = getBodyClassValue('mqDestApp_');
var dayTime = '<span class="fRight dayTime"><span class="destApp">'+sDestApp+'</span>-System: '+sDate+'</span>';
var errId = 'errReportWin';
var ddw_footer = btnClose + btnFldPreview + dayTime;
var extraCls = "usp_ErrorWin collapsible";
var oErrWin = $(errId);
var clsClosed = "";
var errWin = '\n<div id="'+errId+'" class="usp_ErrorWin dragWindow collapsible">\n<h4><span class="dragHandle">Fehler</span><span class="head'+clsClosed+'">minify</span><a class="abort close" href="#">[x]</a></h4>\n<div class="body"><div class="content">'+theErr+'</div></div><div class="foot buttons">'+ddw_footer+'</div>\n</div>\n';
getBody().insert (errWin);
oErrWin = $(errId);
ComboBox_Behaviour_Selector_Init ("#" + errId + " input.comboBox");
Collapsible_Behaviour_Selector_Init("#" + errId);
if("-1px" == oErrWin.getStyle("left"))
{
dragWindow_SetToCenter(oErrWin);
}
var validFieldIds = 0;
oErrWin.select("div.body label[for]").each(function(el)
{
var theId = el.readAttribute('for');
if(theId && "" != theId && IsDefined($(theId)))
{
var oFld = $(theId);
el.onclick = function()
{
var theId = $(this).readAttribute('for');
var oPV = $("errFieldPreview");
if(IsDefined(oPV) && oPV.checked)
{
var duration = 0.8;
if(!hasBodyClass ("usp_softScroll"))
{
duration = 0;
}
return errorMessagesScrollTo (theId, duration);
}
return SetFocus(theId);
}
oFld.addClassName("validate revalidate");
fieldValidatorInitElement (oFld);
fieldValidatorInitInvalid (oFld);
validFieldIds++;
el.onmouseover = function()
{
var oPV = $("errFieldPreview");
if(IsDefined(oPV) && oPV.checked)
{
var theId = $(this).readAttribute('for');
if(IsDefined($(theId)))
{
validatorApply($(theId));
return SetFocus(theId);
}
}
}
}
else
{
el.addClassName("missingId");
}
})
if(0 == validFieldIds)
{
oErrWin.addClassName ("noValidFields");
}
}
}
function fieldValidatorInitElement(el)
{
if(IsValidatorField(el))
{
el.onblur = function(evt)
{
var keyCode = getKeyCode(evt);
return fieldValidatorOnBlur(this, keyCode);
}
el.onfocus = function(evt)
{
var keyCode = getKeyCode(evt);
return fieldValidatorOnFocus(this, keyCode);
}
}
}
function fieldValidatorCheck4Activate(oThis,isControlKey)
{
var thisVal = $F(oThis);
var maxLen = getMaxFieldLength (oThis);
if(!IsValidField (oThis))
{
if(!isControlKey && thisVal)
{
if(thisVal.length == maxLen)
{
oThis.activate();
}
}
else
{
}
}
else
{
}
}
function IsValidatorField(el)
{
return ("text" == el.type || "password" == el.type);
}
function fieldValidatorInitInvalid(el)
{
if(IsValidatorField(el) && !el.hasClassName("ajax"))
{
el.onkeyup = function(evt)
{
var keyCode = getKeyCode(evt);
keyUpBehaviour($(this), keyCode);
var ret = validatorApply($(this), keyCode);
fieldValidatorCheck4Activate($(this),IsControlKey(keyCode));
return ret;
}
}
}
function fieldValidatorOnKeyup(oThis, keyCode)
{
oThis = $(oThis);
keyUpBehaviour(oThis, keyCode);
if(hasClassNames(oThis, "invalid valid revalidate", 1))
{
validatorApply(oThis, keyCode);
}
return true;
}
function fieldValidatorOnKeydown(oThis)
{
return true;
}
function fieldValidatorOnFocus(oThis, keyCode)
{
oThis = $(oThis);
if(!IsValid (oThis))
{
if($F(oThis) != "")
{
if("function" == typeof (doHighlightInvalid)) {doHighlightInvalid (oThis);}
}
fieldValidatorCheck4Activate(oThis,false);
}
if(hasClassNames(oThis, "invalid valid revalidate", 1))
{
validatorApply(oThis);
}
errorDragWindowNotify (oThis, "focus");
return true;
}
function fieldValidatorOnBlur(oThis, keyCode)
{
oThis = $(oThis);
keyUpBehaviour (oThis, keyCode);
var val = validatorAutoComplete(oThis );
SetValue(oThis , val);
validatorApply(oThis );
errorDragWindowNotify (oThis , "blur");
return true;
}
function fieldValidatorInit()
{
$$('input.uppercase, input.lowercase').each(function(el)
{
if(!el.hasClassName("ajax"))
{
el.onkeyup = function(evt)
{
var keyCode = getKeyCode(evt);
return fieldValidatorOnKeyup(this, keyCode);
}
}
})
if(!Prototype.Browser.IE)
{
addBodyClasses("validate");
$$('#areaContent input[type=text], #areaContent textarea').each(function(el)
{
if(!el.hasClassName("required"))
{
el.addClassName("validate");
}
})
}
$$('.validate input, .validate select, .validate textarea, input.validate').each(function(el)
{
fieldValidatorInitElement(el);
})
$$('.validate input.invalid, .validate select.invalid, .validate textarea.invalid').each(function(el)
{
fieldValidatorInitInvalid(el);
})
validatorErrorBehaviour();
}
function collapsible_Behaviour_Selector_Init(selector)
{
$$(selector).each(function(el)
{
var headElem = el.down(".head");
if(headElem)
{
el.addClassName("collapsible");
if(headElem.hasClassName("closed"))
{
toggleHeadBody(headElem);
}
else
{
var bdyClsId = getClassValue (el.className, 'u_');
if(("" != bdyClsId) && hasBodyClass("u_" + bdyClsId))
{
el.select(".body").first().hide();
setCollapsibleState(headElem, "closed");
}
}
headElem.addClassName("cursorPointer");
headElem.onclick = function()
{
if(hasBodyClass ("u_inplaceedit"))
{
return true;
}
return toggleHeadBody(this);
}
}
else
{
}
})
if(Prototype.Browser.IE)
{
$$(selector + " .head").each(function(el)
{
el.onmouseover = function()
{
this.addClassName('hover');
}
el.onmouseout = function()
{
this.removeClassName('hover');
}
})
}
}
function collapsible_Behaviour_Init()
{
collapsible_Behaviour_Selector_Init(".collapsible");
}
function getToggleElem(elem)
{
if(elem && !elem.hasClassName ("collapsible"))
{
elem = elem.up(".collapsible");
}
return elem;
}
function setCollapsibleState(oThis, state)
{
var bdyClsId = "";
var collEl = oThis.up(".collapsible");
if(collEl)
{
bdyClsId = getClassValue (collEl.className, 'u_');
if("" != bdyClsId)
{
bdyClsId = "u_" + bdyClsId;
}
}
if("closed" == state)
{
oThis.addClassName ("closed");
addBodyClass(bdyClsId);
}
else
{
oThis.removeClassName ("closed");
removeBodyClass(bdyClsId);
}
}
function toggleHeadBody(oThis)
{
var toggleEl = getToggleElem($(oThis));
toggleEl.select(".body").each(function(el)
{
if(IsDefined(el.down()))
{
if(("TBODY" == el.tagName) && (!Prototype.Browser.Gecko))
{
el.toggle ();
if(el.visible())
{
setCollapsibleState(oThis, "open");
}
else
{
setCollapsibleState(oThis, "closed");
}
}
else
{
if(el.visible())
{
if(Prototype.Browser.IE)
{
el.hide();
}
else
{
new Effect.SlideUp(el, { duration: 0.12, transition: Effect.Transitions.linear });
}
setCollapsibleState(oThis, "closed");
}
else
{
if(Prototype.Browser.IE)
{
el.show();
}
else
{
new Effect.SlideDown(el, { duration: 0.12, transition: Effect.Transitions.linear});
}
setCollapsibleState(oThis, "open");
}
}
}
})
return false;
}
g_omCurErrorMessageId = "";
function fnAfterErrorMessageScroll ()
{
if(IsDefined(g_omCurErrorMessageId))
{
$(g_omCurErrorMessageId).focus();
}
g_omCurErrorMessageId = "";
}
function omErrorMessagesInit ()
{
$$('.areaError li label[for]').each(function(el)
{
el.onclick = function()
{
var theId = $(this).readAttribute('for');
g_omCurErrorMessageId = theId;
var off = 0;
off += -4;
new Effect.ScrollTo($(theId),{offset:off, afterFinish:fnAfterErrorMessageScroll});
return false;
}
})
}
var g_InputField2ComboBox_curHideId = "";
var g_InputField2ComboBox_curId = "";
function InputField2ComboBoxGetListDataByName (listName)
{
var comboData = "";
listName += "_List";
var listClassName = listName + "_Options";
var inpList = $$("input."+listClassName).first();
if(IsDefined (inpList))
{
comboData = $F(inpList);
}
else
{
var comboData = eval(listName);
}
return comboData;
}
function InputField2ComboBoxSelect (oThis)
{
var theUl = $(oThis).up("ul");
var theId = $(theUl.className);
theId.value = oThis.innerHTML.split(':')[0];
theId.value = theId.value.replace(/&nbsp; &nbsp;/, "");
InputField2ComboBox_CheckValid (theId);
theUl.up("div").hide();
if($(theId).hasClassName("doSubmit"))
{
document.forms[0].submit();
}
return false;
}
function InputField2ComboBox_IsValid (inputCtrl)
{
var theValue = inputCtrl.value;
inputCtrl = $(inputCtrl);
dataListName = InputField2ComboBox_GetDataListName (inputCtrl);
if(dataListName && "" != dataListName)
{
var comboData = InputField2ComboBoxGetListDataByName (dataListName);
var isValid = false;
comboData.split(',').each(function(val)
{
if(val.trim().split(':')[0] == theValue)
{
isValid = true;
}
})
return isValid
}
return true;
}
function InputField2ComboBox_CheckValid (inputCtrl)
{
var isValid = InputField2ComboBox_IsValid (inputCtrl);
if(isValid)
{
inputCtrl.removeClassName ("invalid");
}
else
{
inputCtrl.addClassName ("invalid");
}
return isValid;
}
function InputField2ComboBox_AutoCompId (dataListName)
{
return "autocomplete_choices_"+dataListName;
}
function InputField2ComboBox_SetPositon (inputCtrl)
{
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (inputCtrl));
autoCompId += inputCtrl.identify();
if(!IsDefined($(autoCompId)))
{
InputField2ComboBox_Create (inputCtrl);
}
var offset = Position.cumulativeOffset(inputCtrl);
var comboW = "" + inputCtrl.getWidth() + "px";
var comboH = inputCtrl.getHeight();
var comboX = offset[0] + "px";
var comboY = (offset[1] + comboH) + "px";
comboH = "" + comboH + "px";
$(autoCompId).setStyle(
{
position:'absolute',
top:comboY,
left:comboX,
width:comboW,
height:comboH,
'z-index':1002
})
}
function InputField2ComboBox_RePositon (inputCtrl)
{
InputField2ComboBox_SetPositon (inputCtrl);
}
function doUnescape (val)
{
val = val.replace(/&quot;/g, "\"");
return unescape(val);
}
function InputField2ComboBox_Spinner (inputCtrl, curVal, direction)
{
dataListName = InputField2ComboBox_GetDataListName (inputCtrl);
if(dataListName && "" != dataListName)
{
var comboData = InputField2ComboBoxGetListDataByName (dataListName);
var firstOption = "";
var prevOption = "";
var found = false;
if(comboData && comboData.length > 0)
{
comboData.split(',').each (function (el)
{
thisOption = el.trim().split(':')[0];
if("" == firstOption)
{
firstOption = thisOption;
}
if(direction > 0)
{
if((prevOption == curVal) && !found)
{
curVal = doUnescape (thisOption);
found = true;
return curVal;
}
}
else
{
if((thisOption == curVal) && ("" != prevOption) && !found)
{
curVal = doUnescape (prevOption);
found = true;
return curVal;
}
}
prevOption = thisOption;
})
if((prevOption == curVal) && (direction > 0))
{
curVal = doUnescape (firstOption);
found = true;
return curVal;
}
if(!found)
{
if(direction > 0)
{
curVal = doUnescape (firstOption);
}
else
{
curVal = doUnescape (prevOption);
}
return curVal;
}
}
}
return curVal;
}
function InputField2ComboBox_Next (inputCtrl)
{
return InputField2ComboBox_Spinner (inputCtrl, $F(inputCtrl), 1);
}
function InputField2ComboBox_Prev (inputCtrl)
{
return InputField2ComboBox_Spinner (inputCtrl, $F(inputCtrl), -1);
}
function InputField2ComboBox_Build (inputCtrl)
{
dataListName = InputField2ComboBox_GetDataListName (inputCtrl);
if(dataListName && "" != dataListName)
{
try
{
var comboData = InputField2ComboBoxGetListDataByName (dataListName);
if(comboData && comboData.length > 0)
{
var inputCtrlId = inputCtrl.identify();
var aHref = "<a href='#' onclick='return InputField2ComboBoxSelect(this);'>";
var autoCompId = InputField2ComboBox_AutoCompId(dataListName);
autoCompId += inputCtrlId;
if(!IsDefined($(autoCompId)))
{
var comboDataNames = new Array();
comboData.split(',').each (function (el)
{
comboDataNames[comboDataNames.length] = el.trim().split(':')[0];
})
csvNames = comboDataNames.join(",");
csvNames = csvNames.replace(/SYS_EMPTY/g, "&nbsp; &nbsp;");
var divClass = "autocomplete " + inputCtrl.className;
var choiseList = "<ul class='"+inputCtrlId+"'>\n<li>" + aHref + csvNames.replace(/,/g, "</a></li>\n<li>"+aHref) + "</a></li>\n</ul>";
var autoChoiseDiv = '\n<div id="'+autoCompId+'" class="'+divClass+'">\n'+choiseList+'\n</div>\n';
getBody().insert (autoChoiseDiv);
InputField2ComboBox_SetPositon (inputCtrl);
{
if(!inputCtrl.hasClassName ("required"))
{
$(autoCompId).addClassName ("required");
}
}
}
$(autoCompId).hide();
return true;
}
}
catch (e)
{
alert (e);
}
}
return false;
}
function InputField2ComboBox_ComboHandleClick (oThis)
{
oThis = $(oThis);
InputField2ComboBox_Hide ("immediately")
inputCtrl = oThis.previous("input");
if(inputCtrl)
{
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (inputCtrl));
autoCompId += inputCtrl.identify();
if(!IsDefined($(autoCompId)))
{
InputField2ComboBox_Build (inputCtrl);
}
if(IsDefined($(autoCompId)))
{
$(autoCompId).hide();
if((inputCtrl.identify() != g_InputField2ComboBox_curHideId) || ("" == g_InputField2ComboBox_curHideId))
{
InputField2ComboBox_Show (inputCtrl);
g_InputField2ComboBox_curHideId = inputCtrl.identify();
}
else
{
}
}
return false;
}
else
{
return true;
}
}
function InputField2ComboBox_OnArrowBlur (oThis)
{
oThis = $(oThis);
inputCtrl = oThis.previous("input");
InputField2ComboBox_CheckValid (inputCtrl);
if("" != g_InputField2ComboBox_curHideId)
{
g_InputField2ComboBox_curHideId = inputCtrl.id;
new PeriodicalExecuter(function(pe) {pe.stop();InputField2ComboBox_Hide();}, 0.5);
}
return true;
}
function InputField2ComboBox_CreateArrow (inputCtrl)
{
var choiseHandle = GetClientCtrlHandleHtml (inputCtrl, "<span class='comboHandle' onclick='InputField2ComboBox_ComboHandleClick(this)' onblur='InputField2ComboBox_OnArrowBlur(this)'></span>")
inputCtrl.insert ({after: choiseHandle});
newId = inputCtrl.next("span.clientCtrl").identify()
$(newId).insert ({top: inputCtrl});
}
function InputField2ComboBox_Create (inputCtrl)
{
g_InputField2ComboBox_curId = inputCtrl.identify();
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (inputCtrl));
autoCompId += inputCtrl.identify();
if(!IsDefined($(autoCompId)))
{
InputField2ComboBox_Build (inputCtrl);
}
}
function fnAfterShow (autoCompId)
{
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (g_InputField2ComboBox_curId));
if(IsDefined($(autoCompId)))
{
IsVisible = $(autoCompId).visible();
}
}
function InputField2ComboBox_Show (inputCtrl)
{
var curComboId = g_InputField2ComboBox_curId;
var curHideId  = g_InputField2ComboBox_curHideId;
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (inputCtrl));
var IsVisible = false;
autoCompId += inputCtrl.identify();
if(!IsDefined($(autoCompId)))
{
InputField2ComboBox_Create (inputCtrl);
}
else
{
IsVisible = $(autoCompId).visible();
}
InputField2ComboBox_Hide ();
g_InputField2ComboBox_curId = inputCtrl.identify();
new PeriodicalExecuter(function(pe)
{
curCombo = $(g_InputField2ComboBox_curId);
if(curCombo)
{
InputField2ComboBox_RePositon (curCombo);
}
else
{
pe.stop();
}
}, 0.3);
if(!IsVisible)
{
new Effect.Appear($(autoCompId), { duration: 0.15, afterFinish:fnAfterShow });
}
}
function fnAfterHide (autoCompId)
{
g_InputField2ComboBox_curHideId = "";
}
function InputField2ComboBox_Hide (mode)
{
try
{
if(g_InputField2ComboBox_curHideId.length > 0)
{
inputCtrl = $(g_InputField2ComboBox_curHideId);
if(inputCtrl)
{
var autoCompId = InputField2ComboBox_AutoCompId(InputField2ComboBox_GetDataListName (inputCtrl));
autoCompId += inputCtrl.identify();
if(IsDefined($(autoCompId)))
{
if("immediately" == mode)
{
$(autoCompId).hide();
}
else
{
$(autoCompId).hide();
}
fnAfterHide (autoCompId);
}
}
}
}
catch (e)
{
alert ("ERR: InputField2ComboBox_Hide: " + e + ")");
}
}
function InputField2ComboBox_GetDataListName (inputCtrl)
{
var dataListName = "";
try
{
$w(inputCtrl.className).each(function(className)
{
var posList = className.indexOf("_List");
if(posList > 0)
{
var checkName = className.substr (0, posList);
dataList = InputField2ComboBoxGetListDataByName (checkName);
if(dataList && "string" == typeof dataList && dataList.length > 0)
{
dataListName = checkName;
inputCtrl.identify();
}
else
{
}
}
})
}
catch (e)
{
alert ("ERR: InputField2ComboBox_GetDataListName: " + e + ")");
}
return dataListName;
}
function ComboBox_Create_Data_Control (inputCtrl, comboData)
{
InputField2ComboBox_CreateArrow (inputCtrl);
if(!inputCtrl.value || ("" == inputCtrl.value))
{
}
inputCtrl.onfocus = function()
{
if("" != g_InputField2ComboBox_curHideId)
{
new PeriodicalExecuter(function(pe) {pe.stop();InputField2ComboBox_Hide();}, 0.3);
}
return true;
}
inputCtrl.onblur = function()
{
InputField2ComboBox_CheckValid (this);
if("" != g_InputField2ComboBox_curHideId)
{
g_InputField2ComboBox_curHideId = this.id;
new PeriodicalExecuter(function(pe) {pe.stop();InputField2ComboBox_Hide();}, 0.3);
}
return true;
}
}
function comboBox_Behaviour_Selector_Init (selector)
{
try
{
$$(selector).each(function(inputCtrl)
{
dataListName = InputField2ComboBox_GetDataListName (inputCtrl);
if(dataListName && "" != dataListName)
{
var classListName = dataListName + "_List";
var comboData = eval(classListName);
if(comboData && comboData.length > 0)
{
if(!inputCtrl.hasClassName("_isInitialized_"))
{
inputCtrl.addClassName("_isInitialized_");
InputField2ComboBox_CreateArrow (inputCtrl);
if(!inputCtrl.value || ("" == inputCtrl.value))
{
inputCtrl.value = comboData.split(',')[0].trim().split(':')[0];
}
inputCtrl.onfocus = function()
{
if("" != g_InputField2ComboBox_curHideId)
{
new PeriodicalExecuter(function(pe) {pe.stop();InputField2ComboBox_Hide();}, 0.3);
}
return true;
}
inputCtrl.onblur = function()
{
InputField2ComboBox_CheckValid (this);
if("" != g_InputField2ComboBox_curHideId)
{
g_InputField2ComboBox_curHideId = this.id;
new PeriodicalExecuter(function(pe) {pe.stop();InputField2ComboBox_Hide();}, 0.3);
}
return true;
}
}
else
{
}
}
}
})
}
catch (e)
{
debug_out ("ERR: InputField2ComboBox Init: " + e + ")", 1000, "A")
}
}
function comboBox_Behaviour_Init ()
{
comboBox_Behaviour_Selector_Init ("input.comboBox");
}
function addClassNameToNaviPath(oThis, cls)
{
var li = $(oThis).up("li");
while (li && "string" == typeof (li.tagName) && "LI" == li.tagName.toUpperCase())
{
li.addClassName(cls);
li = li.up("li");
}
}
function NavigationCollapsibleBodyClassToggle ()
{
toggleBodyClasses("u_NaviCollapsed");
oNavi = $$('.nav').first();
oNavi.show();
if("function" == typeof (sync_footer_with_bodyClass)) {sync_footer_with_bodyClass ();}
return false;
}
function saved()
{
new Effect.Scale(element, 100, {
scaleContent: false,
scaleX: false,
scaleFrom: 10,
scaleMode: {originalHeight: 192, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
afterFinish:NavigationCollapsibleBodyClassToggle
})
new Effect.Scale(element, 10, {
scaleContent: false,
scaleX: false,
scaleMode: 'box',
scaleFrom: 100,
scaleMode: {originalHeight: 192, originalWidth: elementDimensions.width},
restoreAfterFinish: true,
afterFinish:NavigationCollapsibleBodyClassToggle
})
}
function NavigationCollapsibleBehaviour (oThis)
{
if(useScript ())
{
oNavi = $$('.nav').first();
element = $(oNavi).cleanWhitespace();
var oldInnerBottom = element.down().getStyle('bottom');
var elementDimensions = element.getDimensions();
if(hasBodyClass("u_NaviCollapsed"))
{
new Effect.SlideDown(element, { duration: 0.3, scaleFrom: 10, scaleMode: {originalHeight: 192},  afterFinish:NavigationCollapsibleBodyClassToggle });
}
else
{
new Effect.SlideUp(element, { duration: 0.3,  scaleTo: 10, afterFinish:NavigationCollapsibleBodyClassToggle });
}
return false;
}
else
{
return NavigationCollapsibleBodyClassToggle ();
}
}
function NavigationBehaviourInit ()
{
$$('#naviToggler a').each(function(el)
{
el.title = "Toggle-Navigation";
el.onclick = function()
{
return NavigationCollapsibleBehaviour (this);
}
})
}
function navigation_get_anker(oThis)
{
if("string" == typeof (oThis))
{
var oHref = navigation_find_href_item(oThis);
if(IsDefined (oHref))
{
oThis = oHref;
}
else
{
debug_out ("ERR: navigation_get_anker not Found: " + oThis);
}
}
return oThis;
}
function navigation_set_eot (oThis, clientItemId)
{
oThis = navigation_get_anker (oThis);
if(!IsDefined (oThis))
{
oThis = $(clientItemId);
}
if(IsDefined (oThis))
{
var li = $(oThis).up("li");
li.addClassName("eot");
}
}
function navigation_open_click (oThis, clientItemId)
{
oThis = navigation_get_anker (oThis);
if(!IsDefined (oThis))
{
oThis = $(clientItemId);
}
if(IsDefined (oThis))
{
var li = $(oThis).up("li");
if(hasBodyClass("u_treeViewNavi"))
{
if(li.hasClassName("close"))
{
li.removeClassName("close");
li.addClassName("open");
}
else if(li.hasClassName("open") && li.hasClassName("active"))
{
li.removeClassName("open");
li.addClassName("close");
}
else
{
li.addClassName("open");
}
}
$$('.nav li.active').invoke("removeClassName", "active");
var ul = li.down("ul");
if(!IsDefined (ul) && !li.hasClassName("eot"))
{
var aId = oThis.identify();
get_ajaxContent (oThis, "subNavi:", 'get', {naviArea:'navi_1',clientItemId:aId});
}
while (li && "LI" == li.tagName.toUpperCase())
{
li.addClassName("active");
li = li.up("li");
}
}
return false;
}
function navigation_open_click_behaviour_init ()
{
removeBodyClass ("locationLoading");
if("function" == typeof (navigation_ajax_init)) {navigation_ajax_init ();}
$$('.nav li a[rel=openClick], .nav li.openClick > a').each(function(el)
{
el.up("li").addClassName("activateOnClick");
if("function" != typeof (el.onclick))
{
el.onclick = function()
{
if(hasBodyClasses("u_denyajax u_cmseditmode", 1)){return true;}
if("function" == typeof (fire_href)) {fire_href (this.href);}
return navigation_open_click (this);
}
}
})
}
function navigation_find_href_item (href)
{
href = getHRefRelPath (href);
return $$('.nav li a[href*='+href+']').first();
}
function HeadlineBehaviourToggleClick ()
{
toggleBodyClasses("u_HeadCollapsed");
if("function" == typeof (sync_footer_with_bodyClass)) {sync_footer_with_bodyClass ();}
return false;
}
function HeadlineBehaviourInit ()
{
$$('#areaHeader h1.head a').each(function(el)
{
el.onclick = function()
{
if(useScript ()) {return HeadlineBehaviourToggleClick (this)};
}
})
}
function select_list_box_behaviour_init ()
{
$$('select.setBodyClass').each(function(sel)
{
addBodyClasses ($F(sel));
sel.onchange = function()
{
var deSel = "";
$(this).select ('option').each(function(opt)
{
deSel += opt.value + " ";
})
removeBodyClasses (deSel);
addBodyClasses ($F(this));
var ul = $(this).up("ul");
var hasFocus = false;
ul.select("li.value").each(function(li)
{
if(!hasFocus && IsVisibleElement(li))
{
var inp = li.down("input[value='']")
if(inp && IsVisibleElement(inp) && !hasFocus)
{
hasFocus = true;
inp.focus();
}
}
});
}
})
}
function footer_prepare ()
{
$$('.footer').each(function(foot)
{
if(!foot.hasClassName('initialized'))
{
foot.addClassName('initialized');
userSettingsBehaviour ();
foot.select('li a').each(function(lia)
{
if(hasBodyClass ("grp_appManagement"))
{
ajax_getSubNavi(lia.up("li"), 'areaFooter');
}
else
{
lia.onmouseover = function()
{
return ajax_getSubNavi($(this).up("li"), 'areaFooter');
}
}
})
}
})
}
function footer_init_prepare ()
{
$$('.footer').each(function(foot)
{
foot.onmouseover = function()
{
footer_prepare ();
}
})
}
function Footer_Behaviour_Init ()
{
sync_footer_with_bodyClass();
footer_init_prepare ();
}
function sync_footer_with_bodyClass()
{
$$('.footer input[type=radio],.footer input[type=checkbox]').each(function(inp)
{
if(inp.hasClassName("invers"))
{
inp.checked = !hasBodyClass(inp.value);
}
else
{
inp.checked = hasBodyClass(inp.value);
}
})
}
function set_modal(mode)
{
if(mode)
{
addBodyClasses ('mode_Modal');
removeBodyClasses("loadingCanceled");
}
else
{
removeBodyClasses ('mode_Modal sys_submit u_wndModal');
addBodyClasses("loadingCanceled");
}
}
function is_modal()
{
return hasBodyClass ("mode_Modal");
}
function toggle_modal()
{
toggleBodyClasses ("mode_Modal");
return false;
}
function set_modal_submit()
{
set_modal(true);
addBodyClasses('sys_submit');
}
function submit_cancel()
{
if(self.stop)
{
stop();
}
else
{
if(document.execCommand)
{
document.execCommand('Stop');
}
}
set_modal(false);
return false;
}
function modal_Behaviour_Init ()
{
if(!$("areaModal"))
{
getBody().insert({bottom: '<div id="areaModal"></div><div id="loadingCancel"><p>Die Seite wird geladen...</p><a href="#" class="cancelSubmit" onclick="return submit_cancel()">Abbrechen</a></div>'});
var loadingCancel = $('areaModal').next('#loadingCancel');
if("function" == typeof (Draggable))
{
new Draggable(loadingCancel);
}
}
}
function SpinnerCtrl_CreateHandle (inpCtrl)
{
var choiseHandle = GetClientCtrlHandleHtml (inpCtrl, "<span class='spinnerCtrlUp' onclick='SpinnerCtrl_Up(this)'></span><span class='spinnerCtrlDown' onclick='SpinnerCtrl_Down(this)'></span>")
inpCtrl.insert ({after: choiseHandle});
newId = inpCtrl.next("span.clientCtrl").identify()
$(newId).insert ({top: inpCtrl});
$(newId).select(".spinnerCtrlUp, .spinnerCtrlDown").each(function(el)
{
el.observe('keydown', function (e) {return SpinnerCtrl_OnKeyDown (this, e);});
})
}
function SpinnerCtrl_Up (oThis)
{
var inp = $(oThis).previous("input");
if(!inp)
{
inp = $(oThis).up().down("input");
}
if(!inp)
{
alert ("spinnerCtrl input not found");
return true;
}
else
{
if(inp.hasClassName("comboBox"))
{
if(inp.hasClassName("numeric"))
{
inp.value = InputField2ComboBox_Next(inp);
}
else
{
inp.value = InputField2ComboBox_Prev(inp);
}
}
else
{
var format = inp.className.replace('spinnerCtrl','');
format = format.replace('required','');
format = format.trim();
var val = $F(inp);
if(!IsNumeric(val))
{
val = "0";
}
inp.value = 1 * val + 1;
}
if("function" == typeof (notifySpinnerCtrl)) {notifySpinnerCtrl (oThis, "up");}
return false;
}
}
function SpinnerCtrl_Down (oThis)
{
var inp = $(oThis).previous("input");
if(!inp)
{
inp = $(oThis).up().down("input");
}
if(!inp)
{
alert ("spinnerCtrl input not found");
return true;
}
else
{
if(inp.hasClassName("comboBox"))
{
if(inp.hasClassName("numeric"))
{
inp.value = InputField2ComboBox_Prev(inp);
}
else
{
inp.value = InputField2ComboBox_Next(inp);
}
}
else
{
var format = inp.className.replace('spinnerCtrl','');
format = format.replace('required','');
format = format.trim();
var val = $F(inp);
if(!IsNumeric(val) || val < 2)
{
val = "2";
}
inp.value = 1 * val - 1;
}
if("function" == typeof (notifySpinnerCtrl)) {notifySpinnerCtrl (oThis, "down");}
return false;
}
}
function SpinnerCtrl_OnKeyDown (oThis, evt)
{
retval = false;
keyCode = evt.keyCode
if(keyCode == 0 || keyCode == null) {
keyCode = evt.charCode;
}
switch (keyCode)
{
case Event.KEY_PLUS:
case Event.KEY_UP:
SpinnerCtrl_Up (oThis);
break;
case Event.KEY_MINUS:
case Event.KEY_DOWN:
SpinnerCtrl_Down (oThis);
break;
default:
if((16 != keyCode) && (17 != keyCode))
{
}
retval = true;
break;
}
return retval;
}
function omClientControl_BuildCounter (inpCtrl)
{
if(!inpCtrl.hasClassName("hasCounter_"))
{
inpCtrl.addClassName ('hasCounter_');
inpCtrl.addClassName ('clientCtrl');
SpinnerCtrl_CreateHandle (inpCtrl);
}
}
function omClientControls ()
{
var selector = "input.counterCtrl";
if((Prototype.Browser.IE) && (Prototype.Browser.Version < 7))
{
selector = ".basket " + selector;
}
$$(selector).each
(
function(el)
{
omClientControl_BuildCounter(el);
}
)
}
var __divTableSelector        = "table";
var __divTablePageEndDistance = 58;
var __divTableMinScrollHeight = 120;
var __divTableDivBorderSize   = 0;
var __divTableWidth           = 100;
var __divTableHeight          = 300;
var __divTableDivBorderWidth  = 0;
function appendTableRowColumn(oTable)
{
var rows = oTable.getElementsByTagName('TR');
var trBgCol = $$(__divTableSelector + " thead tr th")[0].getStyle('background-color');
for (var i=0; i < rows.length;i++)
{
var cell = rows[i].insertCell(-1);
cell.style.width = '13px';
cell.style.marginLeft = '22px';
cell.width = '13';
if(0 == i)
{
cell.className = "expand";
cell.innerHTML = '&#160;&#160;&#160;&#160;';
cell.innerHTML = '&#160;_&#160;';
cell.style.color = "#a00000";
cell.style.backgroundColor = trBgCol;
cell.onclick=divTableExpand;
}
else
{
cell.innerHTML = '';
}
}
}
function appendTableActionColumn(oTable)
{
var tHead = oTable.parentNode.getElementsByTagName('THEAD')[0];
var trHead = tHead.getElementsByTagName('TR')[0];
var cols = trHead.getElementsByTagName('TH');
for (var i=0; i < cols.length;i++)
{
var column = cols[i];
column.innerHTML += " <a href='#' onclick='appendTableInput(this)'>v</a>";
}
}
function appendTableInput(oThis)
{
var oTable = oThis.parentNode.parentNode.parentNode.parentNode;
var tHead = oTable.parentNode.getElementsByTagName('THEAD')[0];
var trHead = tHead.getElementsByTagName('TR')[0];
var cols = trHead.getElementsByTagName('TH');
colHtml = cols[0].innerHTML.toLowerCase();
if(colHtml.indexOf('<br') >=0)
{
for (var i=0; i < cols.length;i++)
{
var column = cols[i];
var testHtml = column.innerHTML.toLowerCase();
var posBr = testHtml.indexOf('<br');
column.innerHTML = column.innerHTML.substring (0, posBr);
}
}
else
{
for (var i=0; i < cols.length;i++)
{
var column = cols[i];
column.innerHTML += "<br /><input type='text' value='' />";
}
}
}
function divTableExpand ()
{
var oTable = this.parentNode.parentNode.parentNode;
var tBody = oTable.parentNode.getElementsByTagName('TBODY')[0];
var oDivTable = oTable.parentNode;
var tHead = oTable.parentNode.getElementsByTagName('THEAD')[0];
var trHead = tHead.getElementsByTagName('TR')[0];
this.style.color = "#a00000";
var stylePos = "relative";
if(oDivTable.Mode != "auto")
{
tBody.style.height = "auto";
oDivTable.style.height = "auto";
oDivTable.Mode = "auto";
this.innerHTML = '&#160;_&#160;';
trHead.style.position = "static";
trHead.style.position = "relative";
trHead.style.top = "0px";
trHead.style.left = "0px";
}
else
{
trHead.style.position = "relative";
this.innerHTML = '&#160;X&#160;';
oDivTable.Mode = "scroll";
applyTableDimensions (oTable, __divTableWidth, __divTableHeight);
tableEventOnResize ();
}
}
function adjustTableHeader (oTable)
{
if(navigator.userAgent.indexOf('Opera')>=0) return;
if(document.all && Prototype.Browser.IE && oTable)
{ // IE6 bugfix against "jumping" thead
var oDivTable = oTable.parentNode;
if(oDivTable)
{
var trHead = oDivTable.getElementsByTagName('TR')[0];
trHead.className = trHead.className; // ohne diese "seltsame Zeile" funktioniert es im ie6 nicht!!
trHead.style.top = oDivTable.scrollTop + 'px';
}
}
}
function setTableWidth (oTable)
{
if(navigator.userAgent.indexOf('Opera')>=0) return;
if(document.all && Prototype.Browser.IE && oTable)
{ // IE bugfix against clipping table
var oDivTable = oTable.parentNode;
if(oDivTable)
{
if(oDivTable.Mode == "auto") {return;}
var winW = getWindowWidth ();
var trHead = oDivTable.getElementsByTagName('TR')[0];
var tableW = $(trHead).getStyle('width').replace(/px/g, "");
if(winW >= tableW)
{
tableW = __divTableWidth;
if("100%" == __divTableWidth)
{
tableW = winW - 2* __divTableDivBorderWidth - 2 * __divTableBodyMargin - 22;
}
}
else
{
if(Prototype.Browser.IE6)
{ // IE6 bugfix against "endless" loop
tableW -= 3;
}
}
tableW = getStyleUnit (tableW);
$(oDivTable).setStyle({
width: tableW
});
if(0)
{
var tableW = $(trHead).getStyle('width').replace(/px/g, "");
tableW -= 2;
tableW = getStyleUnit (tableW);
$(oDivTable).setStyle({
width: tableW
});
}
}
}
}
function expandTableToPageBottom (oTable)
{
var oDivTable = oTable.parentNode;
var oDivTableDivPosY = Position.cumulativeOffset(oDivTable)[1];
if(oDivTable.Mode == "auto") {return;}
var bodyH = getWindowHeight();
var minTableHeight = __divTableMinScrollHeight + __divTablePageEndDistance;
var newdivH = bodyH - oDivTableDivPosY;
if(newdivH < minTableHeight)
{
newdivH = minTableHeight;
}
newdivH -= __divTablePageEndDistance;
if(0 < __divTableDivBorderSize)
{
newdivH -= 2 * __divTableDivBorderSize - 1;
}
var winW = getWindowWidth ();
var tabW = oTable.style.width.replace(/px/g, "");
if(winW <= tabW)
{
newdivH -= 13; // substract height of horizontal scroller
}
try
{
$(oDivTable).setStyle({
height: newdivH + 'px'
});
}
catch (e)
{
alert ("oDivTable.setStyle (" + newdivH + ")");
}
if(!document.all)
{
var tHead = oTable.parentNode.getElementsByTagName('THEAD')[0];
var tBody = oTable.parentNode.getElementsByTagName('TBODY')[0];
tBody.style.height = (oTable.parentNode.clientHeight-tHead.offsetHeight) + 'px';
}
}
function tableEventOnResize ()
{
var theDivTable = $$(__divTableSelector)[0];
$$(__divTableSelector).each(function(theDivTable)
{
if("TABLE" == theDivTable.tagName)
{
expandTableToPageBottom (theDivTable);
adjustTableHeader (theDivTable);
setTableWidth (theDivTable);
}
})
}
function tableHeaderEventOnMouseOver ()
{
var oTable = this;
if("TABLE" == oTable.tagName)
{
adjustTableHeader (oTable);
}
else
{
alert (oTable.tagName);
}
}
function initExpandTableToPageBottom (oTable)
{
if("TABLE" == oTable.tagName)
{
var tHead = oTable.parentNode.getElementsByTagName('THEAD')[0];
oTable.onmouseover = tableHeaderEventOnMouseOver;
tableEventOnResize ();
}
Event.observe(window, 'resize', tableEventOnResize, false);
}
function applyTableDimensions (oTable, width, height)
{
if(oTable && oTable.style)
{
if(width)
{
width = getStyleUnit (width);
oTable.style.width = width;
oTable.parentNode.style.width = width;
}
if(height)
{
height = getStyleUnit (height);
oTable.style.height = height;
oTable.parentNode.style.height = height;
}
}
else
{
alert ("applyTableDimensions (" + oTable + ")");
}
}
function initDivTable(tableSelector,width,height)
{
__divTableSelector = tableSelector;
$$(__divTableSelector).each(function(theDivTable)
{
if("TABLE" == theDivTable.tagName )
{
var trHead = theDivTable.parentNode.getElementsByTagName('THEAD')[0].firstChild;
var tHead = theDivTable.parentNode.getElementsByTagName('THEAD')[0];
var trHead = tHead.getElementsByTagName('TR')[0];
trHead.style.position = "relative";
appendTableActionColumn (theDivTable);
{
appendTableRowColumn(theDivTable);
}
__divTableWidth = width;
__divTableHeight = height;
applyTableDimensions (theDivTable, __divTableWidth, __divTableHeight);
__divTableDivBorderWidth = $(theDivTable.parentNode).getStyle('border-width').replace(/px/g, "");
if("" == __divTableDivBorderWidth) {__divTableDivBorderWidth = 0;}
__divTableBodyMargin = $$("body")[0].getStyle('margin').replace(/px/g, "");
if("" == __divTableBodyMargin) {__divTableBodyMargin = 0;}
initExpandTableToPageBottom (theDivTable);
}
})
}
function omTabCellEditInputBlur(oThis)
{
return;
var thisTd = $(oThis.parentNode);
var newVal = oThis.value;
thisTd.innerHTML = newVal;
if("function" != typeof (thisTd.onclick))
{
thisTd.onclick = function()
{
return omTabCellEdit(this);
}
}
}
function omTableCreateInputClientControl (theInput, theType, tabKey)
{
theInput = $(theInput)
if("COMBO" == theType)
{
var curTable = theInput.up("table");
listClass = tabKey + "_List_Options";
comboData = $F(curTable.select("span#ComboBoxOptionListsValues input." + listClass).first());
theClass = tabKey + "_List comboBox";
ComboBox_Create_Data_Control (theInput, comboData);
}
else if("NUMBER" == theType)
{
SpinnerCtrl_CreateHandle (theInput);
}
else if("DATE" == theType)
{
calendar_create_handle (theInput);
}
else
{
theInput.onclick = function(){return true;}
}
}
function omSetTabCellEditInput(oThis)
{
if("TD" == oThis.tagName)
{
var clickedTd = $(oThis);
if(clickedTd.hasClassName("controlIsInitalized"))
{
return true;
}
var thisText = oThis.innerHTML.replace(/'/g, "&#39;");
if((thisText.indexOf('__omAppendTableRow-Item__') >=0) || (thisText.indexOf('omNewText:') >=0))
{
thisText = "";
}
thisText = thisText.replace(/<\/B>/g, "");
thisText = thisText.replace(/<B>/g, "");
thisText = thisText.replace(/<\/b>/g, "");
thisText = thisText.replace(/<b>/g, "");
var curTr = clickedTd.up("tr");
var curTable = curTr.up("table");
var id = curTr.identify();
var curTd = clickedTd;
var index = -1;
do
{
curTd = curTd.previous("td");
index++;
} while (IsDefined(curTd) && "TD" == curTd.tagName);
var curTh = curTable.select("thead tr.headlines th")[index];
var classNames = curTh.className;
var theId = id.substr(1);
var tabKey = getClassValue(classNames, "key_");
var theType = getClassValue(classNames, "type_");
if(("id_" == tabKey) || ("IMGLINK" == theType))
{
alert ("Hinweis: \nDieses Feld kann aus konsitenzbedenken \nnicht direkt in der Tabelle geaendert werden.");
return true;
}
var tabId = getClassValue(curTable.className, "tabId_");
var tabDsn = getClassValue(curTable.className, "dsn_");
var cellId = theId + ":" + tabKey;
var theClass = theType;
if("COMBO" == theType)
{
theClass = tabKey + "_List comboBox";
}
else if("DATE" == theType)
{
theClass = "calendar Format_MM-JJ";
}
else if("NUMBER" == theType)
{
}
else if(("RICHEDIT" == theType) || ("TEXTAREA" == theType))
{
if(!is_modal())
{
set_modal(true);
ajaxContentPost ('GetTableCellEditWindow', {tabId: tabId, id_: theId, tabKey: tabKey, tabType: theType});
}
return false;
}
var thisInput = "<input type='text' class='"+theClass+"' name='omNewText:"+cellId+"' size='28' value='"+thisText+"' onblur='omTabCellEditInputBlur(this)'/>";
oThis.innerHTML = thisInput;
var theInput = $(oThis.getElementsByTagName('input')[0]);
omTableCreateInputClientControl (theInput, theType, tabKey);
theInput.focus();
clickedTd.addClassName("controlIsInitalized");
}
}
function _omCreateTabCellCheckBox(oThis, setChecked)
{
var thisText = oThis.innerHTML;
var thisId = "cellIdCb" + thisText;
var thisInput = "<input id='"+thisId+"' type='checkbox' "+setChecked+" name='omNewCheckbox[]' value='"+thisText+"' /> <label for='"+thisId+"'> "+thisText+" </label>";
oThis.innerHTML = thisInput;
oThis.onclick = function(){return true;}
}
function omDivTableCheckBoxToggle(oThis)
{
var chkBox = $(oThis).down("input[type=checkbox]");
if(chkBox)
{
chkBox.checked = !chkBox.checked;
}
return false;
return true;
}
function omSetTabCellCheckBox(oThis)
{
_omCreateTabCellCheckBox(oThis, " checked='checked'");
}
function omDivTableCreateCheckbox(oThis)
{
if("TD" == oThis.tagName)
{
_omCreateTabCellCheckBox(oThis, "");
}
}
function omDivTableCreateRadioButton(oThis)
{
if("TD" == oThis.tagName)
{
var cellId = oThis.innerHTML;
var thisId = "rowRadioId" + cellId;
var thisInput = "<input id='"+thisId+"' type='radio' name='omSelectedRow' value='"+cellId+"' /> <label for='"+thisId+"'> "+cellId+" </label>";
oThis.innerHTML = thisInput;
oThis.onclick = function(){return true;}
}
}
function omTabCellEdit(oThis)
{
if("TD" == oThis.tagName)
{
omSetTabCellEditInput(oThis);
return;
var thisTr = $(oThis.parentNode);
var i=0;
$A(thisTr.getElementsByTagName('TD')).each(function(el)
{
omSetTabCellEditInput(el);
i++;
})
}
}
function omDivTableRowAppend(selector)
{
var thisText = "";
var tRow = " <tr class='__omAppend__'>\n";
var selector = "table.sort";
rowAppendCount = $$(selector + " tbody tr.__omAppend__").length;
thisText = rowAppendCount;
focusName = "";
idx=0;
$$(selector + " thead tr.headlines th").each(function(el)
{
var thisInput = "";
var thisTitle = "";
var inp = el.down('input');
if(inp)
{
var action = inp.name.split("/sort/")[1];
thisText = action;
thisTitle = "__omAppendTableRow-Item__:"+rowAppendCount+":"+action;
if("id_" == action)
{
thisInput = "new<input type='hidden' name='"+thisTitle+"' value='-1000' />";
}
else
{
thisInput = "<input type='text' name='"+thisTitle+"' title='"+thisTitle+"' size='28' value='' />";
if("" == focusName)
{
focusName = thisTitle;
}
}
}
else
{
thisInput = "?<input type='hidden' name='__omAppendTableRow__[]' value='"+rowAppendCount + ":" + idx+"' />";
idx++;
}
tRow += "  <td>"+thisInput+"</td>\n";
})
tRow += " </tr>\n";
$$(selector + " tbody").first().insert({bottom: tRow});
if("" != focusName)
{
$$(selector + " tbody input[name='"+focusName+"']").first().focus();
}
}
function omApplyDivTableCellEditEvent(selector, editCassName)
{
idx = 0;
idy = 0;
if(!editCassName)
{
editCassName = "edit";
}
if("edit" == editCassName)
{
headCols = $$(selector + " thead tr.headlines th").length;
$$(selector + " tbody tr td").each(function(el)
{
if(idx >= headCols)
{
idx = 0;
idy++;
}
el.idx = idx;
el.idy = idy;
el.title = idx + "," + idy;
idx++;
el.className = editCassName;
el.onclick = function()
{
return omTabCellEdit(this);
}
})
}
else if("radio" == editCassName)
{
$$(selector).each(function(el)
{
omDivTableCreateRadioButton(el);
})
}
else if("createCheckbox" == editCassName)
{
$$(selector).each(function(el)
{
omDivTableCreateCheckbox(el);
})
}
else
{
$$(selector).each(function(el)
{
el.className = editCassName;
el.onclick = function()
{
return omSetTabCellCheckBox(this);
}
})
}
}
function omDivTableGetComboBoxOptionLists (oThis)
{
if(!$("ComboBoxOptionListsValues"))
{
var curTable = $(oThis).up("table");
var tabList = "";
curTable.select("thead tr.headlines th").each(function(el)
{
if(el.hasClassName ("type_COMBO"))
{
var tabKey = getClassValue(el.className, "key_");
if("" != tabList)
{
tabList += ",";
}
tabList += tabKey;
}
})
if("" != tabList)
{
var tabId = getClassValue(curTable.className, "tabId_");
var tabDsn = getClassValue(curTable.className, "dsn_");
curTable.insert ("<span id='ComboBoxOptionListsValues'></span>");
ajaxContentPost ('TableComboBoxOptionLists:ComboBoxOptionListsValues', {dsnTab: tabDsn, tabList: tabList});
}
}
}
function omDivTableCellEdit (oThis)
{
omApplyDivTableCellEditEvent('table.sort', 'edit');
omApplyDivTableCellEditEvent('table.sort tbody tr td:first-child', 'checkbox');
omHideDivTableSettings (oThis);
omDivTableGetComboBoxOptionLists (oThis);
addBodyClasses('divTableCellEdit');
return false;
}
function omPerformTabRowEdit(oThis)
{
if("TR" == oThis.tagName)
{
var input = oThis.down("input");
input.checked = true;
}
}
function omDivTableRowEdit(oThis)
{
$$("table.sort tbody tr").each(function(el)
{
el.className = "editRow";
el.onclick = function()
{
return omPerformTabRowEdit(this);
}
el.ondblclick = function()
{
omPerformTabRowEdit(this);
return omSubmit ($("divTableRefresh").name);
}
})
omApplyDivTableCellEditEvent('table.sort tbody tr td:first-child', 'radio');
omHideDivTableSettings (oThis);
return false;
}
function omDivTableDeleteRows(oThis)
{
$$("table.sort tbody tr").each(function(el)
{
el.className = "editRow";
el.onclick = function()
{
return omDivTableCheckBoxToggle(this);
}
})
omApplyDivTableCellEditEvent('table.sort tbody tr td:first-child', 'createCheckbox');
omHideDivTableSettings (oThis);
return false;
}
function omShowDivTableAddModal ()
{
set_modal(true);
}
function omShowDivTableRemoveModal ()
{
set_modal(false);
}
function omShowDivTableSettings (oThis)
{
Effect.Appear('idDlgTableSettings', {duration: 0.4, afterFinish:omShowDivTableAddModal});
return false;
}
function omHideDivTableSettings (oThis)
{
Effect.Fade('idDlgTableSettings', {duration: 0.4, afterFinish:omShowDivTableRemoveModal});
return false;
}
function omApplyDivTableHandleChanged(oThis)
{
if(HasValue("tab_useAjax"))
{
var tBodyId = $$("table.sort tbody")[0].identify();
var tHeadInfoId = $$("table.sort thead tr.tableCtrl th.info")[0].identify();
var tFootInfoId = $$("table.sort tfoot tr.tableCtrl .info")[0].identify();
ajaxContentPost ('TableBodyUpdate:'+tBodyId + ',TableHeadInfoUpdate:'+tHeadInfoId + ',TableFootInfoUpdate:'+tFootInfoId + ',backforward:pager');
return false;
}
else
{
return true;
}
}
function omApplyAjaxSubmit(oThis)
{
if(HasValue("tab_useAjax"))
{
var pInfo = oThis.name.substr (4);
var tableId = $$("table.sort")[0].up().identify();
ajaxContentPost ('TableUpdate:'+tableId, {ajaxPathInfo: pInfo, backforward:''});
return false;
}
else
{
return true;
}
}
function omToggleDivTableSettingsColumns(oThis)
{
var isChecked = false;
if("all_" == $F(oThis))
{
isChecked = true;
}
$$("#idTableHeadSelector input[name^=selKey]").each(function(el)
{
el.checked = isChecked;
})
return true;
}
function fnJoinSortedTableHeadlines()
{
var content="";
var selHeadKeyName = $('idTableHeadSelector').previous('.selAllChoise').down('span').className;
$$("ul#idTableHeadSelector li").each(function(elem)
{
content += elem.identify() + ",";
})
$("tab_csvPositions"+selHeadKeyName).value = content;
return true;
}
function omApplyDivTableSettings()
{
if($("idDlgTableSettings"))
{
$("idDlgTableSettings").setStyle({
left: '100px', top:'100px', display: 'none'
})
}
if("undefined" != typeof (Sortable))
{
$$('#idDlgTableSettings ul.sortable').each(function(el)
{
Sortable.create($(el).identify(),{onUpdate:fnJoinSortedTableHeadlines});
})
}
$$("table.sort thead tr th.settings").each(function(el)
{
el.addClassName("cursorHelp");
el.onclick = function()
{
return omShowDivTableSettings(this);
}
})
$$("#tabSelAllChoise_").each(function(el)
{
el.onclick = function()
{
return omToggleDivTableSettingsColumns($(this));
}
})
}
function omApplyDivTableFilterClientControls (oThis)
{
var curElem = $(oThis);
if(!curElem.hasClassName("hasFilterClientControls"))
{
if(!$("ComboBoxOptionListsValues"))
{
omDivTableGetComboBoxOptionLists (oThis);
}
else
{
var curTable = $(oThis).up("table");
var aTabHeadlines = curTable.select("thead tr.headlines th");
var idx = 0;
curTable.select("thead tr.filter th input").each(function(theInput)
{
idx++;
var clsNames = aTabHeadlines[idx].className;
if(aTabHeadlines[idx].hasClassName("type_COMBO"))
{
var tabKey = getClassValue(aTabHeadlines[idx].className, "key_");
var theType = getClassValue(aTabHeadlines[idx].className, "type_");
theClass = tabKey + "_List comboBox";
addClassNames (theInput, theClass);
omTableCreateInputClientControl (theInput, theType, tabKey);
}
})
curElem.addClassName("hasFilterClientControls");
}
}
return true;
}
function omApplyDivTableFilterBehaviour ()
{
$$("table.sort thead tr.filter th input, table.sort tfoot input[name=tab_lineFltrRows]").each(function(el)
{
el.onkeyup = function()
{
return omApplyDivTableHandleChanged(this);
}
})
$$("#tab_rowsPerPage,#tab_markMatched").each(function(el)
{
el.onchange = function()
{
return omApplyDivTableHandleChanged(this);
}
})
$$("table.sort tfoot .info input[type=submit],table.sort thead .headlines input[type=submit]").each(function(el)
{
el.onclick = function()
{
$(this).addClassName("firedBtn_");
return omApplyAjaxSubmit(this);
}
})
$$("table.sort thead tr.filter").each(function(el)
{
omDivTableGetComboBoxOptionLists (el);
el.onclick = function()
{
return omApplyDivTableFilterClientControls(this);
}
})
}
function omApplyDivTableBehaviour ()
{
omApplyDivTableFilterBehaviour ();
omApplyDivTableSettings();
}
function getMessageName (id)
{
var Name = id.substr(3);
Name = Name.replace(/Area/, "");
return Name;
}
function buildMessageContainer (id)
{
var Name = getMessageName (id);
var msgContainer = '<div class="dlg area'+Name+'"><fieldset><legend>'+Name+'</legend><div id="'+id+'"></div></fieldset></div>';
$("areaContent").insert({top: msgContainer});
}
function buildContainer (id, cls)
{
switch (id)
{
case "msgErrorArea":
case "msgInfoArea":
case "msgWarningArea":
case "msgDebugMsgArea":
buildMessageContainer (id);
break;
case "AJAXSCRIPT":
getBody().insert({bottom: "<div id='"+id+"'></div>"});
break;
case "newDragWindow":
getForm().insert({top: "<div id='"+id+"'></div>"});
break;
default:
if(!$(id))
{
if(cls && cls.length > 0)
{
getBody().insert({bottom: "<div id='"+id+"' class='"+cls+"'></div>"});
}
else
{
getBody().insert({top: "<div id='"+id+"'></div>"});
}
}
break;
}
return $(id);
}
function updateContainer (id, value)
{
if($(id))
{
switch (id)
{
case "headlineCart":
$(id).replace (value);
break;
case "msgErrorArea":
case "msgInfoArea":
case "msgWarningArea":
case "msgDebugMsgArea":
if("" == value)
{
Name = getMessageName (id);
try
{
var removeArea = "div.area"+Name;
var removeId = $$(removeArea).first();
if(removeId)
{
removeId = removeId.identify();
$(removeId).remove();
}
}
catch (e)
{
alert (e);
}
return;
}
$(id).update (value);
break;
default:
$(id).update (value);
break;
}
}
}
function ajaxJsonUpdate(response)
{
if("" != response)
{
var jsonRes = "";
try
{
jsonRes = $H(response.evalJSON ());
}
catch (e)
{
debug_out (response);
alert (response);
jsonRes = $H();
}
jsonRes.each (function(pair)
{
switch (pair.key)
{
case "syncBodyClass":
SyncBodyClass (pair.value);
break;
case "setBodyClass":
ReplaceBodyClasses (pair.value);
break;
default:
if(!pair.key || "" == pair.key)
{
$("areaContent").insert({top: pair.value});
}
else
{
if(!$(pair.key))
{
if("" != pair.value)
{
buildContainer (pair.key);
}
}
if($(pair.key))
{
updateContainer (pair.key, pair.value);
$(pair.key).removeClassName("ajaxLoading");
}
}
break;
}
})
if("function" == typeof (omAjaxReinit)) {omAjaxReinit ();}
}
else
{
}
}
function ajaxSerialize(action, theParams, callMethod)
{
var serializedForm = $H();
if('get' != callMethod)
{
serializedForm = $H(getForm().serialize(true));
}
if(theParams)
{
try
{
serializedForm.update($H(theParams));
}
catch (e)
{
alert (e);
alert ($H(theParams).inspect());
}
}
serializedForm.set('ajaxLanguage',  getLanguage());
serializedForm.set('ajaxAction', action);
return serializedForm;
}
function ajaxDecode (response)
{
var r = response.replace(/&Acirc;&sect;/g, "§");
return r
}
function ajaxLoadingFinished()
{
delayed_behaviour_init()
removeBodyClasses("performLoading_");
set_modal(false);
$$("input[type=submit].firedBtn_").each(function(el)
{
el.disabled=false;
el.removeClassName ("firedBtn_");
})
if("function" == typeof (omAjaxReinit)) {omAjaxReinit ();}
}
function ajaxLoadContent(action, theParams, callMethod)
{
if(hasBodyClasses("performLoading_"))
{
}
if(!g_js_ajax_enabled)
{
return true;
}
if(theParams)
{
var hParms = eval(theParams);
if(hParms)
{
var ajaxPathInfo = hParms.ajaxPathInfo;
if(ajaxPathInfo && ajaxPathInfo.length > 10)
{
if(ajaxPathInfo.indexOf("/secure:ssl") > 0)
{
var loc = "" + document.location;
if(loc.indexOf("https://") != 0)
{
return true;
}
}
}
}
}
var serializedForm = ajaxSerialize(action, theParams, callMethod);
new Ajax.Request(g_js_httpRoot + "ajPerform/" + getLanguage() +"-" + g_js_version,
{
method:callMethod,
parameters: serializedForm,
contentType: 'application/x-www-form-urlencoded; charset=ISO-8859-1',
evalScripts: true,
onSuccess: function(transport)
{
if(!$("divQfPreview"))
{
getBody().insert('<div id="divQfPreview"> </div>\n');
}
else
{
$("divQfPreview").show();
}
var response = ajaxDecode (transport.responseText || "");
ajaxJsonUpdate(response);
},
onComplete: function()
{
ajaxLoadingFinished();
},
onCreate: function()
{
removeBodyClasses("loadingComplete loadingCanceled");
if(!this.parameters.denyMessages)
{
addBodyClasses("performLoading_");
}
if(this.parameters.sysSubmit)
{
addBodyClasses("sys_submit");
}
if(this.parameters.modal)
{
addBodyClasses("mode_Modal");
}
},
onFailure: function()
{
ajaxLoadingFinished();
}
});
return false;
}
function ajaxContentGet(action, theParams)
{
return ajaxLoadContent(action, theParams, "get")
}
function ajaxContentPost(action, theParams)
{
return ajaxLoadContent(action, theParams, "post")
}
function ajaxContent(action, theParams, callMethod)
{
if('get' == callMethod)
{
return ajaxContentGet(action, theParams);
}
else
{
return ajaxContentPost(action, theParams);
}
}
function omAjaxPerform(oThis, theActionId)
{
theAction = theActionId.split(":")[0];
theId = theActionId.split(":")[1];
if(!$(theId) && theId && theId.length > 0)
{
$("areaContent").insert({top: '<div id="'+theId+'"></div>'});
}
switch (theAction)
{
case "ArticleQuery":
if($F(oThis).length > 0)
{
ajaxContentPost(theActionId, {ajaxClass: "quickFind"});
}
else
{
$(theId).update("");
}
break;
case "CityQuery":
if($F(oThis).length > 0)
{
ajaxContentPost(theActionId, {ajaxQuickFind: escape($F(oThis)), ajaxClass: "quickFind"});
}
else
{
$(theId).update("");
}
break;
default:
return true;
break;
}
return false;
}
function ajaxUpdateResponseValues(theValues)
{
if(theValues && theValues.length > 0)
{
var pairs = "";
$A(theValues.split("|")).each (function(elem)
{
pairs = elem.split(":");
if($(pairs[0]))
{
$(pairs[0]).value = pairs[1]
}
})
}
}
function ajaxSubmitAction (oThis)
{
var theParams = "";
var action = oThis.action;
alert (action);
return ajaxContentPost(action, theParams);
}
function escapedFormValue (val)
{
return val;
}
function ajaxDisplayTicker ()
{
var teaserId = $$('#periodicalAjajContent p').first().identify();
ajaxContentGet("ticker:periodicalAjajContent", {TeaserId: teaserId});
}
function omAjax ()
{
if($("periodicalAjajContent"))
{
new PeriodicalExecuter(function(pe)
{
ajaxDisplayTicker ();
}, 2);
}
if(!$("divQfPreview"))
{
$("dyn_cart").insert({top: '<div id="divQfPreview"> x </div>\n'});
alert ("creating divQfPreview")
}
Event.observe ('qfValue', 'keypress', function (event)
{
switch (event.keyCode)
{
case Event.KEY_RETURN:
Event.stop (event);
omSubmit ("query/"+escapedFormValue($F(this)));
break;
}
}, false);
Event.observe ('qfValue', 'keyup', function (event)
{
switch (event.keyCode)
{
case Event.KEY_HOME:
case Event.KEY_END:
case Event.KEY_UP:
case Event.KEY_DOWN:
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
return true;
case Event.KEY_PAGEUP:
case Event.KEY_PAGEDOWN:
return false;
default:
return omAjaxPerform(this, "ArticleQuery:divQfPreview");
}
}, false);
}
function ajax_pageContentAsUlli(li)
{
var ul = li.down("ul");
if(((!IsDefined(ul) && !li.hasClassName("loading")) || li.hasClassName ("noCache")) && !li.hasClassName("empty"))
{
li.addClassName("loading");
var a = li.down("a");
if(IsDefined(a))
{
var store = ":insert";
if(IsDefined(ul))
{
store = ":update";
}
debug_out ("actionPath=" + getCurrendPage());
debug_out ("ajaxPathInfo=" + getRawRelPath(a.href));
ajaxContentGet ("naviPageContent:" + li.identify() + ":insert", {naviArea:'areaFooter', actionPath:getCurrendPage(),ajaxPathInfo:getRawRelPath(a.href),denyMessages:true});
}
}
}
function ajax_getSubNavi(li)
{
var ul = li.down("ul");
if(!IsDefined(ul) && !li.hasClassName("loading"))
{
li.addClassName("loading");
var a = li.down("a");
if(IsDefined(a))
{
var href = a.readAttribute("href");
if(href && !href.startsWith("#"))
{
var mode = ":insert";
aRel = a.readAttribute("rel");
if(aRel && aRel.indexOf("contextMenu") >= 0)
{
href = getCurrendPage();
mode = ":replace";
}
else
{
href = getRawRelPath(a.href);
}
ajaxContentGet ("getSubNavi:"+li.identify() + mode, {naviArea:'areaFooter', rel:aRel, ajaxPathInfo:href,denyMessages:false});
}
else
{
a.addClassName("eot");
}
}
else
{
var inp = li.down("input[type=submit]");
if(IsDefined(inp))
{
ajaxContentGet ("getSubNavi:"+li.identify() +":insert", {naviArea:'areaFooter', ajaxPathInfo:inp.name.substr(4),denyMessages:true});
}
}
}
}
function ajax_getAreaMenu(oThis, naviArea)
{
return ajaxContentGet ("contextMenu:" + naviArea, {bodyClass:'xmodalWin',renderMode:'dragWindow'});
}
function ajax_getPullupMenu(oThis, areaName)
{
var li = oThis.up("li");
var ul = li.down("ul");
if(!IsDefined(ul))
{
li.addClassName("pullup");
li.insert("<ul></ul>");
var ulId = li.down("ul").identify();
ajaxContentGet ("naviArea:"+ulId, {naviArea:areaName});
}
return false;
}
function getRawRelPath(href)
{
var raw = "" + href.split(g_js_appExec + "/")[1];
if(raw || raw.length == 0)
{
raw = href;
}
return raw.split(".htm")[0];
}
function getRawBaseRelPath(href)
{
var pos, raw = getRawRelPath(href),
pQuery = raw.split("/-/")[1];
raw = raw.split("/-/")[0];
var pos = raw.lastIndexOf("/");
if(pos >= 0)
{
raw = raw.substr(pos+1);
}
if(pQuery)
{
raw += "/-/" +  pQuery;
}
return raw;
}
function ajaxContent_Init ()
{
navigation_ajax_content_behaviour_init ();
$$("#areaContent ul.previewList>li span a,#pager a").each(function(el)
{
el.onclick = function()
{
if(hasBodyClasses("u_denyajax u_cmseditmode", 1)){return true;}
return get_ajaxContent (this);
}
})
$$("#areaContent ul.dirContent a, #bct .bct a").each(function(el)
{
el.onclick = function()
{
if(hasBodyClasses("u_denyajax u_cmseditmode", 1)){return true;}
return get_ajaxPage (navigation_find_href_item (this.href));
}
})
if("function" == typeof (collapsible_Behaviour_Init)) {collapsible_Behaviour_Init();}
if("function" == typeof (select_list_box_behaviour_init)) {select_list_box_behaviour_init();}
if("function" == typeof (omAjaxReinit)) {omAjaxReinit ();}
}
function ajaxNaviInplaceTranslation (oThis)
{
new Ajax.InPlaceEditor($(oThis).identify(), '/demoajaxreturn.html');
return false;
}
function setPageRef (pRef)
{
var loc = "" + document.location;
loc = loc.split('#')[0];
document.location = loc + pRef;
}
function get_ajaxContent (oThis, action, method, options)
{
var ajaxPathInfo = getRawRelPath(oThis.href);
var optHash = $H({ajaxPathInfo:ajaxPathInfo,reInitBodyClasses:'1',xxnaviArea:'mainNavi'});
if(!action || "string" != typeof (action) || "" == action)
{
action = "ajaxContent:areaContent:replace";
}
else if(hasRelName (oThis, "dragWindow"))
{
optHash.update ({bodyClass:'modalWin',renderMode:'dragWindow'});
}
if(!hasRelName (oThis, "dragWindow"))
{
if($("bct"))
{
var idBct = $("bct").down(".bct").identify();
action += ',pager:pager,pageReference,bct:'+idBct;
}
}
else
{
action = "ajaxInnerContent:newDragWindow";
optHash.update ({bodyClass:'modalWin',renderMode:'dragWindow'});
}
var pagePath = "" + oThis.href;
debug_out (ajaxPathInfo);
debug_out (pagePath);
pagePath = pagePath.split("/-/pagePath:")[1];
if(pagePath && "" != pagePath)
{
ajaxPathInfo += "/-/pagePath:" + pagePath;
}
if(options)
{
optHash.update(options);
}
if(hasBodyClass ("inplaceNaviArrange"))
{
action += ",inplaceNaviArrange,inplaceContentArrange";
ajaxContent (action, {ajaxPathInfo:ajaxPathInfo, reInitBodyClasses:"1",bodyClass:'inplaceNaviArrange inplaceContent',denyMessages:true}, method);
}
else
{
debug_out ("** get_ajaxContent: calling ajaxContent: " + action + "; optHash.pathInfo: " + optHash["ajaxPathInfo"]);
ajaxContent (action, optHash, method);
}
return false;
}
function get_ajaxHrefContent (href)
{
var action = "ajaxContent:areaContent:replace";
if($("bct"))
{
action += ',pager:pager,bct:'+$("bct").down(".bct").identify();
}
return ajaxContentGet (action, $H({ajaxPathInfo:href,reInitBodyClasses:'1'}));
}
function get_ajaxHrefTransitionContent (href, action)
{
var oTemp, tmp, oCachedPager, id="areaTransitionContent",
relPath = getRawBaseRelPath(href),
oObj = $("areaContent").down("*[data-src='"+relPath+"']");
if(!action)
{
action = "ajaxTransitionContent";
}
action += ":areaTransitionContent:update";
if(oObj && relPath == oObj.getAttribute("data-src"))
{
if(action.startsWith ("ajaxTransitionContent"))
{
doContentTransitionPrepareObject (oObj);
prepareTransitionEffect ();
}
if($("pager"))
{
oCachedPager = oObj.down(".cachedPager");
if(oCachedPager && $("bct").down("h1"))
{
$("bct").down("h1").innerHTML = oCachedPager.getAttribute("title");
}
$("pager").innerHTML = oCachedPager.innerHTML;
pager_ajax_init ();
}
if(action.startsWith ("ajaxTransitionContent"))
{
getAjaxPreloadContent ();
}
return false;
}
else
{
if(hasBodyClasses("performLoading_"))
{
return false;
}
if(!$(id))
{
buildContainer (id, "areaContent hidden");
}
if($("bct"))
{
if(action.startsWith ("ajaxPreloadContent"))
{
action += ',pager:preloadPager,bct:preloadBcc';
}
else
{
action += ',pager:pager,bct:'+$("bct").down(".bct").identify();
}
}
oObj = $("areaContent").down("div[data-src]");
if(!oObj)
{
$("areaContent").innerHTML = "<div>" + $("areaContent").innerHTML + "</div>";
oObj = $("areaContent").down("div");
if($("pager") && $("pager").down("li.active strong"))
{
tmp = $("pager").down("li.active strong").getAttribute("data-src");
tmp = getRawBaseRelPath(tmp);
oTemp = $('bct').down("h1");
if(oTemp)
{
oObj.insert({bottom: "<div title='"+oTemp.innerHTML+"' class='hidden cachedPager'>"+$('pager').innerHTML+"</div>"});
}
}
else
{
tmp = getRawBaseRelPath(getCurrendPage ());
}
oObj.setAttribute ("data-src", tmp);
oObj.addClassName ("deactivate");
}
return ajaxContentGet (action, $H({ajaxPathInfo:getRawRelPath(href),reInitBodyClasses:'1'}));
}
}
function get_ajaxPage (oThis)
{
if(IsDefined (oThis))
{
oThis = $(oThis);
var action = "ajaxContent:areaContent:replace";
var oUl = oThis.next("ul");
if(!IsDefined (oUl))
{
if(!(oThis.up("li").hasClassName("eot")))
{
action = "ajaxContent:areaContent:replace,subNavi";
}
}
method = '';
if(hasRelName (oThis, "dragWindow"))
{
method = 'get';
}
get_ajaxContent (oThis, action, method);
if(IsDefined (oUl) || oThis.up("li").hasClassName("eot"))
{
navigation_open_click (oThis);
}
}
else
{
return true;
}
return false;
}
function navigation_ajax_content_behaviour_init ()
{
$$('#container .ajax li.ajaxContent > a').each(function(el)
{
el.onclick = function()
{
if(hasBodyClasses("u_denyajax u_cmseditmode", 1)){return true;}
if(hasRelName (this, "dragWindow"))
{
get_ajaxContent (this, '', 'get');
return false;
}
else
{
get_ajaxContent (this);
return navigation_open_click (this);
}
}
})
$$('#container .ajax li.ajaxPages a').each(function(el)
{
el.onclick = function()
{
if(hasBodyClasses("u_denyajax u_cmseditmode", 1)){return true;}
if(hasBodyClass("u_naviTranslation"))
{
return ajaxNaviInplaceTranslation (this);
}
else
{
return get_ajaxPage (this);
}
}
})
}
function append_sub_navi (relPath, subNav, clientItemId)
{
var oThis = navigation_find_href_item(relPath);
if(!IsDefined (oThis))
{
oThis = $(clientItemId);
}
if(!IsDefined (oThis))
{
debug_out ("ERR: append_sub_navi ("+relPath+"), id = ("+clientItemId+") not Found!");
}
else
{
debug_out ("append_sub_navi ("+relPath+"), id = ("+clientItemId+")...");
var oUl = $(oThis).next("ul");
if(!IsDefined (oUl))
{
oThis.insert({after:"<ul>"+subNav+"</ul>"});
navigation_open_click (oThis);
navigation_ajax_content_behaviour_init ();
debug_out ("OK! append_sub_navi ("+relPath+")");
}
}
}
function Html2BBCode(c)
{
c = c.replace(/</g,'[');
c = c.replace(/>/g,']');
return c;
}
function picMngtSelectNavPath(oThis)
{
$$('#picMngNavi li.active').invoke("removeClassName", "active");
addClassNameToNaviPath(oThis, "active")
}
function picMngtSelectorInit(selector)
{
$$(selector + " ul li a").each(function(el)
{
el.onclick = function()
{
if($("picMngContent"))
{
$("picMngContent").addClassName("ajaxLoading");
ajaxContentPost ('picMngtImageContent:picMngContent', {imagePath:this.href});
}
picMngtSelectNavPath(this);
return false;
}
})
}
function picMngtPrepareContent()
{
$$("#picMngContent .sekPicPreview a").each(function(el)
{
el.onclick = function()
{
$(this).up(".sekPicPreview").toggleClassName("selected");
return false;
}
})
}
function omAdminInit()
{
picMngtSelectorInit("#picMngNavi");
}
function imageChooser(oThis,fldId)
{
var oWnd = dragWindow ("dragWndSelImg", "", "dragWndSelImg", "", "askAction u_picSel",oThis);
var oContent = oWnd.down(".content");
oContent.addClassName("imageChooser ajaxLoading");
var baseDir ="omUploads,album";
ajaxContentPost ('imageChooser:'+oContent.identify(), {connectedField:fldId,baseDir:baseDir,context:'image'});
return false;
}
function imageChooserTreeview(oThis,idImgDirTree,idTreePreview,idImgDetail, fldId)
{
var baseDir ="omUploads,album";
ajaxContentPost ('imageChooserTreeview:'+idImgDirTree,
{
connectedField:fldId,
baseDir:baseDir,
imgDirTree:idImgDirTree,
treePreview:idTreePreview,
imgDetail:idImgDetail,
context:'image'
});
return false;
}
function imageChooserDirContent_init()
{
$$(".imageChooserDirContent a").each(function(el)
{
el.onclick = function()
{
var file = fileFromHref (this.href);
var oImg = $(this).down("img");
if(oImg)
{
var imgSrc = $(this).down("img").src;
var dc = $(this).up(".imageChooserDirContent");
var imgId = getClassValue (dc.className, 'connectedImage_');
if($(imgId))
{
$(imgId).src = imgSrc;
}
var imgDetail = getClassValue (dc.className, 'imgDetail_');
if($(imgDetail))
{
var img = "<img src='"+imgSrc+"' />";
$(imgDetail).update(img);
}
var conId = getClassValue (dc.className, 'connectedField_');
if($(conId))
{
if("imageName" == getClassValue (dc.className, 'fieldFormat_'))
{
imgSrc = fileFromPath(imgSrc);
}
$(conId).value = imgSrc;
}
}
else
{
return imageChooserTreeview_click(this);
}
return false;
}
})
return false;
}
function picMngtPerformSelectedItems(oThis,mode)
{
var selList = "<ul>";
var idx=0;
id = "sel" + ++idx;
var pathFile = "";
$$("#picMngContent .sekPicPreview.selected, #picMngContent .galeryBody").each(function(el)
{
var name = "";
var img = el.down("img");
if(el.hasClassName("selected"))
{
pathFile = img.src.split("/c/")[1];
pathFile = pathFile.replace('/icon/','/');
}
else
{
pathFile = img.src;
pathFile = pathFile.substr (pathFile.indexOf(g_js_httpRoot) + g_js_httpRoot.length);
}
var aSec = pathFile.split("/");
var name = aSec[aSec.length-1];
var suffix = name.substr(name.length-3);
name = name.substr(0,name.length-4);
var item = "<li><input type='checkbox' name='selImgList[]' value='item"+idx+":"+pathFile+"' id='"+id+"' checked='checked' />";
item += "<label for='"+id+"' title='"+pathFile+"' >" +img.up().innerHTML + "</label> <input type='text' name='item"+idx+":name' value='"+name+"' />";
item += "<span class='suffix'>."+suffix+"</span><input type='hidden' name='item"+idx+":suffix' value='"+suffix+"' />";
item += "</li>";
selList += item;
id = "sel" + ++idx;
})
selList += "</ul>";
var baseDir = pathFile.substr (0,pathFile.lastIndexOf("/"));
var moveData = "<li class='moveData'>";
moveData += "<input type='submit' name='btn_targetDir/pic' value='Zielverzeichnis' onclick='return getDirectoryChooser(this,\"moveDirectory\",\"album\");' id='moveData' /><input type='text' name='moveDirectory' id='moveDirectory' value='"+baseDir+"'/>";
moveData += "</li>";
var imgAction = "<li>";
id = "sel" + ++idx;
imgAction += "<label for='"+id+"'><input type='radio' name='selImgAction' value='delete' id='"+id+"' /><span>L&ouml;schen</span></label> ";
id = "sel" + ++idx;
imgAction += "<label for='"+id+"'><input type='radio' name='selImgAction' value='trash' id='"+id+"' /><span>Papierkorb</span></label> " ;
id = "sel" + ++idx;
imgAction += "<label for='"+id+"'><input type='radio' name='selImgAction' value='rename' id='"+id+"' /><span>Umbenennen</span></label> ";
id = "sel" + ++idx;
imgAction += "<label for='"+id+"'><input type='radio' name='selImgAction' value='move' id='"+id+"' /><span>verschieben</span></label> ";
id = "sel" + ++idx;
imgAction += "<label for='"+id+"'><input type='radio' name='selImgAction' value='copy' id='"+id+"' /><span>kopieren</span></label> ";
imgAction += "</li>";
var footer = "<ul>" + moveData + imgAction + "</ul><input type='submit' class='action' name='btn_webSiteAdministration/action/picturemanagement/-/perform:list' onclick='return picMngtPerformList(this);' value='Ausfuehren' />";
dragWindow ("dragWndSel", selList, "" + mode+"Action", footer, "askAction u_picSel");
$$("#dragWndSel .foot input[type=radio]").each(function(el)
{
el.onclick = function()
{
var id = $(this).identify();
var txt = $(this).up("li").down("label[for="+id+"] span").innerHTML;
var foot = $(this).up(".foot");
var btn = foot.down("input[type=submit].action");
btn.value=txt;
var oWin = $(this).up("#dragWndSel");
foot.select("input[type=radio]").each(function(el)
{
oWin.removeClassName(el.value +"Action");
})
oWin.addClassName($(this).value +"Action");
return true;
}
})
$$("#dragWndSel .foot input[value="+mode+"]").each(function(el)
{
el.click();
})
}
function picMngtPerformList (oThis)
{
var oWin = $(oThis).up(".dragWindow");
var ctId = oWin.down("div.body.content").identify();
var ajaxPathInfo = oThis.name.substr(4);
ajaxContentPost ('picMngtPerformList:'+ctId,
{
dragWinId:oWin.identify(),
ajaxPathInfo:ajaxPathInfo,
context:'image'
});
return false;
}
function imageSorter_OnUpdate(list)
{
var sortType = getClassValue (list.className, 'sortType_');
var pathFile = "";
var theList = "";
var sortAction = "picMngtSortOrder";
if("dirContent" == sortType)
{
list.select("li a").each(function(el)
{
pathFile = el.href.split(".htm")[0];
pathFile = getHRefPathInfo(pathFile);
theList += pathFile.substr (1+pathFile.lastIndexOf("/"))  + ",";
})
sortAction = "picMngtSortDirectoryOrder";
}
else
{
$$("#picMngContent .sekPicPreview img").each(function(el)
{
pathFile = el.src.split("/c/")[1];
pathFile = pathFile.replace('/icon/','/');
theList += pathFile.substr (1+pathFile.lastIndexOf("/"))  + ",";
})
}
var path = pathFile.substr (0, pathFile.lastIndexOf("/"));
ajaxContentPost (sortAction, {path:path,dirList:theList,sortAction:sortAction});
}
function imageNaviSorter_Init(oThis)
{
var sType = "sortType_dirContent";
if($("picMngContent"))
{
var ul = $("picMngContent").down(".subNaviSort ul");
var id = 0;
if(ul)
{
ul.select("li").each(function(el)
{
el.identify();
var a = el.down("a");
if(a)
{
a.onclick = function()
{
return false;
}
}
})
id = ul.identify();
ul.addClassName("picSortActive " + sType);
Sortable.create(id,{onUpdate:imageSorter_OnUpdate});
}
}
return false;
}
function imageSorter_Init(oThis)
{
imageNaviSorter_Init(oThis);
var sType = "sortType_";
var ul = $("picMngContent").down("ul.previewList");
var id = 0;
if(ul)
{
sType += "previewList";
}
else
{
ul = $("picMngContent").down("ul.dirContent");
sType += "dirContent";
}
ul.select("li").each(function(el)
{
el.identify();
var a = el.down("a");
if(a)
{
a.onclick = function()
{
return false;
}
}
})
id = ul.identify();
ul.addClassName("picSortActive " + sType);
Sortable.create(id,{onUpdate:imageSorter_OnUpdate});
return false;
}
function getUploadDragIFrameForm(relPath,upType,modalWnd)
{
var upLoadId = "iFrameWndUploadId_";
var oUploadDiv = $(upLoadId);
if(!oUploadDiv)
{
getBody().insert ('\n<div id="'+upLoadId+'"></div>\n');
oUploadDiv = $(upLoadId);
}
oUploadDiv.addClassName("ajaxLoading");
ajaxContentPost ('getUploadDragIFrame:'+upLoadId, {relPath:relPath,uploadType:upType,modalWnd:modalWnd});
}
function getUploadDragIFrame(oThis,upType,modalWnd)
{
getUploadDragIFrameForm(oThis.title,upType,modalWnd)
}
function inplacePicUpload(pInfo,oThis)
{
getUploadDragIFrameForm(getHRefPathInfo(pInfo),'image','modal');
}
function inplacePicEdit(pInfo,oThis)
{
ajaxContentPost ('picMngtImageContent:picMngContent', {imagePath:pInfo,bodyClass:'inplacePicEdit'});
}
function getDirectoryChooser(oThis, fldId, baseDir)
{
var oBase = getBody();
if($(fldId))
{
oBase = $(fldId).up(".dragWindow");
}
var oWnd = getContainer ("dirChooser", oBase);
oWnd.setStyle({display:'none'});
ajaxContentPost ('directoryChooser:'+oWnd.identify(), {connectedField:fldId,baseDir:baseDir,context:'image'});
return false;
}
function directoryFromHref(href)
{
var dir = href.split('.htm')[0];
dir = dir.split(g_js_appExec)[1];
return dir;
}
function fileFromPath(path)
{
return path.substr (path.lastIndexOf("/")+1);
}
function fileFromHref(href)
{
return fileFromPath(href.split(g_js_appExec)[1]);
}
function directoryChooserBtnClick(oThis)
{
var conId = getClassValue (oThis.className, 'connectedField_');
$(conId).value = $(oThis).up("ul").down("li input.preview").value;
var dc = $(oThis).up(".dirChooser");
new Effect.SlideUp(dc, {duration: 0.2, transition: Effect.Transitions.linear});
return false;
}
function directoryChooser_init()
{
$$("div.dirChooser .dirNavi ul li a").each(function(el)
{
el.onclick = function()
{
var dirNav = $(this).up(".dirNavi");
dirNav.select("a.selected").invoke("removeClassName", "selected");
$(this).addClassName("selected");
dirNav.select("li.active").invoke("removeClassName", "active");
addClassNameToNaviPath(this, "active");
var dir = directoryFromHref(this.href);
dirNav.up(".dirChooser").down(".foot .preview").value=dir;
return false;
}
})
$$("div.dirChooser .abort").each(function(el)
{
el.onclick = function()
{
var dc = $(this).up(".dirChooser");
new Effect.SlideUp(dc, {duration: 0.2, transition: Effect.Transitions.linear});
return false;
}
})
return false;
}
function imageChooserNavi_init()
{
$$("div.imageChooser .dirNavi ul li a").each(function(el)
{
el.onclick = function()
{
var dirNav = $(this).up(".dirNavi");
var oPreview = $(getClassValue (dirNav.className, 'treePreview_'));
if(!oPreview)
{
var imageChooser = dirNav.up(".imageChooser");
oPreview = imageChooser.down(".imgPreview");
}
dirNav.select("a.selected").invoke("removeClassName", "selected");
$(this).addClassName("selected");
dirNav.select("li.active").invoke("removeClassName", "active");
addClassNameToNaviPath(this, "active");
var dir = directoryFromHref(this.href);
oPreview.addClassName("ajaxLoading");
ajaxContentGet ('renderImageContent:'+oPreview.identify(),
{
directory:dir,
connectedField:getClassValue (dirNav.className, 'connectedField_'),
imgDetail:getClassValue (dirNav.className, 'imgDetail_')
});
return false;
}
})
$$("div.imageChooser .abort").each(function(el)
{
el.onclick = function()
{
var dc = $(this).up(".imageChooser");
new Effect.SlideUp(dc, {duration: 0.2, transition: Effect.Transitions.linear});
return false;
}
})
return false;
}
function imageChooserTreeview_click(oThis)
{
var oPreview = null;
var dirNav = $(oThis).up(".dirNavi");
if(dirNav)
{
oPreview = $(getClassValue (dirNav.className, 'treePreview_'));
}
else
{
oPreview = $(oThis).up('.imageChooserDirContent');
dirNav = oPreview;
}
dirNav.select("a.selected").invoke("removeClassName", "selected");
$(oThis).addClassName("selected");
dirNav.select("li.active").invoke("removeClassName", "active");
addClassNameToNaviPath(oThis, "active");
var dir = directoryFromHref(oThis.href);
oPreview.addClassName("ajaxLoading");
ajaxContentGet ('renderImageContent:'+oPreview.identify(),
{
directory:dir,
connectedField:getClassValue (dirNav.className, 'connectedField_'),
imgDetail:getClassValue (dirNav.className, 'imgDetail_')
});
return false;
}
function imageChooserTreeview_init()
{
$$("div.imageChooserTreeview a").each(function(el)
{
el.onclick = function()
{
return imageChooserTreeview_click(this);
}
})
}
function imageChooserLoadLastContent()
{
$$("div.dirNavi").each(function(dirNav)
{
var oPreview = null;
if(dirNav)
{
oPreview = $(getClassValue (dirNav.className, 'treePreview_'));
}
else
{
oPreview = $(oThis).up('.imageChooserDirContent');
dirNav = oPreview;
}
ajaxContentGet ('renderImageContent:'+oPreview.identify(),
{
directory:"",
connectedField:getClassValue (dirNav.className, 'connectedField_'),
imgDetail:getClassValue (dirNav.className, 'imgDetail_')
});
})
}
function imageChooserContent_init()
{
$$("div.imageChooser .imgPreview a").each(function(el)
{
el.onclick = function()
{
var file = fileFromHref (this.href);
var imgSrc = $(this).down("img").src;
if($('previewImgContainer'))
{
var img = "<img src='"+imgSrc+"' />";
$('previewImgContainer').update(img);
}
var oWin = $(this).up(".dragWindow");
var okBtn = oWin.down(".foot input[class^=connectedField_]");
if(okBtn)
{
var conId = getClassValue (okBtn.className, 'connectedField_');
if($(conId))
{
$(conId).value = imgSrc;
}
}
oWin.down(".dragHandle").innerHTML = file;
return false;
}
})
return false;
}
function tabControl_hideTabContents (oThis)
{
oTabCtrl = oThis.up("ul");
oTabCtrlLi = oThis.up("li");
var hideHead = !oTabCtrlLi.hasClassName ("toggle");
oAnker = oTabCtrl.previous("a");
if(IsDefined(oAnker))
{
var oTabBody = $$('a[name="'+oAnker.rel+'"]').first().up("div");
oTabCtrl.select('li a').each(function(el)
{
el.up("li").removeClassName ("active");
if(el.rel)
{
$w(el.rel).each(function(relName)
{
tabControl_hideRelElement (oTabBody, relName, hideHead)
})
}
else
{
if(el.href && "" != el.href)
{
var relName = el.href.split("#")[1];
tabControl_hideRelElement (oTabBody, relName, hideHead);
}
}
})
return false;
}
return true;
}
function TabControl_relBehaviour_Init (selector)
{
$$(selector).each(function(el)
{
el.onclick = function()
{
return tabControl_showByRel (this);
}
})
firstElem = $$(selector).first();
if(firstElem)
{
var oCtrlBlock = firstElem.up(".tabControl");
var targetName = window.location.href.split("/-/tabBlock:")[1];
if(IsDefined(targetName))
{
targetName = targetName.split(".htm")[0];
}
else
{
var targetName = window.location.href.split("#")[1];
if(IsDefined(targetName))
{
window.location.href = window.location.href.split("#")[0] + "#refTop";
}
else
{
aAct = oCtrlBlock.select(".active").first();
if(IsDefined(aAct))
{
targetName = aAct.href;
}
else
{
targetName = firstElem.href.split("#")[1];
}
}
}
if(IsDefined(targetName))
{
oCtrlBlock.select("a[href=#"+targetName+"]").each(function(el)
{
tabControl_showByRel (el);
})
}
}
}
function tabControl_hideRelElement (oTabBody, relName, hideHead)
{
oTabBody.select('a[name="'+relName+'"]').each(function(el)
{
var oCtrlBlock = el.up();
var uPersit = getClassValue(oCtrlBlock.className, "u_");
if(uPersit.length > 2)
{
removeBodyClasses("u_" + uPersit);
}
oCtrlBlock.removeClassName ("active");
oCtrlBlock.removeClassName ("selected");
if(hideHead)
{
oCtrlBlock.hide();
}
else
{
oCtrlBlock.show();
}
oCtrlBlock.select (".head").each (function(elHead)
{
elHead.addClassName ("closed");
if(!hideHead)
{
}
else
{
}
})
oCtrlBlock.select (".body").each (function(elBody)
{
elBody.hide();
})
})
}
function tabControl_showRelElement (oTabBody, relName, clsName)
{
oTabBody.select('a[name="'+relName+'"]').each(function(el)
{
var oCtrlBlock = el.up();
var uPersit = getClassValue(oCtrlBlock.className, "u_");
if(uPersit.length > 2)
{
addBodyClasses("u_" + uPersit);
}
oCtrlBlock.addClassName ("active");
if(clsName)
{
oCtrlBlock.addClassName (clsName);
}
oCtrlBlock.show();
oCtrlBlock.select (".head").each (function(elHead)
{
elHead.removeClassName ("closed");
})
oCtrlBlock.select (".body").each (function(elBody)
{
elBody.show();
})
})
}
function tabControl_hideAll (oTabCtrl)
{
oAnker = oTabCtrl.previous("a");
if(IsDefined(oAnker))
{
var oTabBody = $$('a[name="'+oAnker.rel+'"]').first().up("div");
oTabCtrl.select('li a').each(function(el)
{
el.up("li").removeClassName ("active");
if(el.rel)
{
$w(el.rel).each(function(relName)
{
tabControl_hideRelElement (oTabBody, relName, true)
})
}
else
{
if(el.href && "" != el.href)
{
var relName = el.href.split("#")[1];
tabControl_hideRelElement (oTabBody, relName, true);
}
}
})
return false;
}
return true;
}
function tabControl_showAll (oTabCtrl)
{
oAnker = oTabCtrl.previous("a");
if(IsDefined(oAnker))
{
var oTabBody = $$('a[name="'+oAnker.rel+'"]').first().up("div");
oTabCtrl.select('li a').each(function(el)
{
el.up("li").removeClassName ("active");
if(el.rel)
{
$w(el.rel).each(function(relName)
{
tabControl_showRelElement (oTabBody, relName)
})
}
else
{
if(el.href && "" != el.href)
{
var relName = el.href.split("#")[1];
tabControl_showRelElement (oTabBody, relName);
}
}
})
return false;
}
return true;
}
function tabControl_showByRel (oThis)
{
oTabCtrl = oThis.up("ul");
oTabCtrlLi = oThis.up("li");
oTabCtrlLi.addClassName ("active");
var isToggle = oTabCtrlLi.hasClassName ("toggle");
var canOpen = (!isToggle || !oTabCtrl.hasClassName ("allOpen"))
clsSelected = "";
oAnker = oTabCtrl.previous("a");
if(IsDefined(oAnker))
{
var oTabBody = $$('a[name="'+oAnker.rel+'"]').first().up("div");
if(canOpen)
{
tabControl_hideAll (oTabCtrl);
}
else
{
tabControl_hideTabContents(oThis);
}
if($(oThis).hasClassName ("selection_behaviourShowAll"))
{
if(canOpen)
{
tabControl_showAll (oTabCtrl);
}
}
else
{
if(oThis.rel && "" != oThis.rel)
{
var clsSelected = "selected";
var aRels = $w(oThis.rel);
if(aRels.length > 1)
{
clsSelected = "";
}
if(canOpen)
{
aRels.each(function(relName)
{
tabControl_showRelElement (oTabBody, relName, clsSelected);
})
}
}
else
{
if(canOpen)
{
if(oThis.href && "" != oThis.href)
{
var relName = oThis.href.split("#")[1];
tabControl_showRelElement (oTabBody, relName, "selected");
}
}
}
}
if(isToggle)
{
oTabCtrl.toggleClassName ("allOpen");
}
else
{
oTabCtrl.removeClassName ("allOpen");
}
oTabCtrlLi.addClassName ("active");
}
return false;
}
function tabControl_init ()
{
TabControl_relBehaviour_Init ("div.tabCtrlHead .tabControl li a[href^=#]");
}
g_curErrorMessageId = "";
function fnAfterErrorMessageHighlight ()
{
if(IsDefined(g_curErrorMessageId))
{
if("function" == typeof (validatorApply))
{
validatorApply($(g_curErrorMessageId));
}
SetFocus(g_curErrorMessageId);
}
g_curErrorMessageId = "";
}
function fnAfterErrorMessageScroll ()
{
if(IsDefined(g_curErrorMessageId))
{
$(g_curErrorMessageId).removeClassName("invalid");
if(!$(g_curErrorMessageId).hasClassName ("readonly"))
{
SetFocus(g_curErrorMessageId);
}
}
}
function errorMessagesScrollTo (oElem, scrollDuration)
{
oElem = $(oElem);
g_curErrorMessageId = oElem.identify();
new Effect.ScrollTo(oElem,{offset:-4, duration:scrollDuration, afterFinish:fnAfterErrorMessageScroll});
return false;
}
function errorMessagesInit ()
{
$$('.areaError li label[for]').each(function(el)
{
var theId = el.readAttribute('for');
if(theId && "" != theId && IsDefined($(theId)))
{
el.onclick = function()
{
var theId = $(this).readAttribute('for');
return errorMessagesScrollTo (theId, g_scrollDuration);
}
}
else
{
el.addClassName("missingId");
}
})
}
function IsApplicableFocusEle (el)
{
return "submit" != el.type && "radio" != el.type && "checkbox" != el.type && !el.disabled && !el.readonly;
}
function CanSetFirstFocus (csfEl)
{
return (!hasFirstFocus() && IsApplicableFocusEle (csfEl) && !hasClassNames(csfEl, 'readonly hidden disabled invisible', 1) && IsVisibleElement(csfEl));
}
function hasFirstFocus ()
{
return hasBodyClass ("hasFirstFocus") || (hasBodyClass ("hasAutoFocus") && !hasBodyClass ("sys_hasErrors"));
}
function reportNoFocusElemFound ()
{
return false;
if(hasFirstFocus ())
{
debug_error ("Sehr komisch:", "hat angeblich focus aber trotzem kommt *** reportNoFocusElemFound *** ");
}
else
{
debug_out("*** reportNoFocusElemFound *** ");
}
return false;
}
function doSetFirstFocus (el)
{
var hasFocus = false;
if(IsApplicableFocusEle (el))
{
if(IsValid (el))
{
hasFocus = SetFocus(el);
}
else
{
el.activate();
hasFocus = true;
}
if(hasFocus)
{
addBodyClass ("hasFirstFocus");
el.addClassName ("isFirstFocusElement");
}
}
return hasFocus;
}
function setFirstElementFocus()
{
if(!IsBrowserVersion("IE_6-7"))
{
var hasFocusEle = false;
$$('#areaContent input, #areaContent textarea, #areaContent select').each(function(el)
{
if(!hasFirstFocus ())
{
if(doSetFirstFocus(el))
{
debug_out ("setFirstElementFocus: "+el.identify());
return true;
}
}
})
}
return reportNoFocusElemFound ();
}
function mustSetFirstFocus()
{
return !(hasFirstFocus () || hasBodyClass ("doEditPageContent"));
}
function setFirstVisibleFocus()
{
if(!mustSetFirstFocus())
{
return false;
}
var hasFocus = false;
$$('#areaContent input[type=text]').each(function(el)
{
if(CanSetFirstFocus(el))
{
if(doSetFirstFocus (el))
{
hasFocus = true;
return hasFocus;
}
}
else if(IsBrowserVersion("IE_6-7"))
{
hasFocus = true;
return hasFocus;
}
})
if(!hasFocus)
{
hasFocus = setFirstElementFocus();
}
return hasFocus;
}
function setFirstRequiredInvalidFocus()
{
if(!hasFirstFocus() && !IsBrowserVersion("IE_6-7"))
{
$$('#areaContent input.required, #areaContent textarea.required').each(function(el)
{
if(CanSetFirstFocus(el) && (!IsEmpty() && !IsValid (el)))
{
if(doSetFirstFocus (el))
{
debug_out("setFirstRequiredInvalidFocus: "+el.identify());
return true;
}
}
})
}
return setFirstVisibleFocus();
}
function setMarkedFocus()
{
$$('#areaContent input.firstFocus,#areaContent textarea.firstFocus').each(function(el)
{
if(CanSetFirstFocus(el))
{
if(doSetFirstFocus (el))
{
debug_out("setMarkedFocus: "+el.identify());
return true;
}
}
})
return setFirstRequiredInvalidFocus();
}
function first_focus_behaviour ()
{
if(!mustSetFirstFocus())
{
return false;
}
return setMarkedFocus();
}
function emptyTitleValue_init ()
{
$$(".nav2 input.emptyTitleValue").each(function(el)
{
el.onblur = function(evt)
{
if("" == this.value)
{
$(this).addClassName("fieldDescription");
}
return false;
}
el.onfocus = function(evt)
{
$(this).removeClassName("fieldDescription");
return false;
}
if("" == el.value)
{
el.addClassName("fieldDescription");
}
el.setAttribute("autocomplete", "off");
})
}
function browserSettings ()
{
$$('#areaContent input.noBrowserComplete').each(function(inp)
{
inp.setAttribute("autocomplete", "off");
})
}
function baseBehaviour_init ()
{
if("function" == typeof (errorMessagesInit)) {errorMessagesInit ();}
if("function" == typeof (userBehaviourCookie_Init))  {userBehaviourCookie_Init ();}
if("function" == typeof (first_focus_behaviour)) {first_focus_behaviour();}
browserSettings ();
}
function perfomDeliveryForm(oThis)
{
if((oThis) && (oThis.checked))
{
if("object" == typeof (Effect))
{
new Effect.SlideDown('divIdDeliveryAddr', { duration: 0.4 });
}
else
{
$('divIdDeliveryAddr').show();
}
}
else
{
if("object" == typeof (Effect))
{
new Effect.SlideUp('divIdDeliveryAddr', {duration: 0.4 });
}
else
{
$('divIdDeliveryAddr').hide();
}
}
}
function deliveryAddr_behaviour_init ()
{
choiseDifferentDeliveryAddr = $('choiseDifferentDeliveryAddr')
if(choiseDifferentDeliveryAddr)
{
choiseDifferentDeliveryAddr.onclick = function()
{
perfomDeliveryForm (this);
}
if($('choiseDifferentDeliveryAddr') && ($('choiseDifferentDeliveryAddr').checked))
{
$('divIdDeliveryAddr').show();
}
else
{
$('divIdDeliveryAddr').hide();
}
}
}
function previewPic_show(oThis)
{
var oImg = oThis.up(".img").down("img");
var dst = "" + oImg.src;
var src = "" + oThis.down("img").src;
var path= dst.substr(0, dst.lastIndexOf("/"));
var file= src.substr(src.lastIndexOf("/"));
oImg.src = path + file;
}
function previewPics_behaviour()
{
$$(".previewPics a").each(function(el)
{
el.onmouseover=function()
{
previewPic_show($(this));
}
el.onclick=function()
{
previewPic_show($(this));
}
})
}
function call_function_by_string (funcName, oThis, keyCode)
{
if(("string" == typeof (funcName)) && funcName.length > 0)
{
try
{
if("function" == typeof (eval(funcName)))
{
return eval(funcName +"($(oThis), keyCode)");
}
}
catch(e)
{
}
}
return false;
}
function $fnCall (funcName, oThis, keyCode)
{
return call_function_by_string (funcName, oThis, keyCode);
}
function special_page_behaviour_init_by_form_class()
{
var oForm = getForm();
var ret = false;
if(oForm)
{
var allFunctions = oForm.className;
var initFunc = getClassValue (allFunctions, 'special_');
while (initFunc.length > 0)
{
ret =  call_function_by_string (initFunc, oForm, 0);
allFunctions = allFunctions.replace('special_' + initFunc,'');
initFunc = getClassValue (allFunctions, 'special_');
}
}
return ret;
}
g_js_ajax_enabled = false;
function omAjaxReinit()
{
delayedBehaviour()
if("function" == typeof (ajax4Details_Init)) {ajax4Details_Init ();}
if("function" == typeof (ajax4Basket_Init)) {ajax4Basket_Init ();}
if("function" == typeof (omClientControls)) {omClientControls ();}
if("function" == typeof (fnInputRange)) {fnInputRange ();}
if("function" == typeof (onBodyKeyDown_init)) {onBodyKeyDown_init ();}
if("function" == typeof (slideshow_init)) {slideshow_init ();}
}
function returnFalse(oThis)
{
return false;
}
function delayedBehaviour()
{
if("function" == typeof (delayed_behaviour_init)) {delayed_behaviour_init ();}
}
function omOnloadBehaviour ()
{
if(useScript ())
{
if(navigator.cookieEnabled)
{
g_js_ajax_enabled = true;
}
if("function" == typeof (browser_detect_Init)) {browser_detect_Init();}
var scrollValues = getScrollValues ();
if(hasBodyClass ("u_showDevelopDebugWin"))
{
developDebugWinShow (true);
debug_out ("DebugWin is enabled");
}
if("function" == typeof (collapsible_Behaviour_Init)) {collapsible_Behaviour_Init();}
if("function" == typeof (select_list_box_behaviour_init)) {select_list_box_behaviour_init();}
if("function" == typeof (NavigationBehaviourInit)) {NavigationBehaviourInit ();}
if("function" == typeof (navigation_open_click_behaviour_init)) {navigation_open_click_behaviour_init ();}
if("function" == typeof (navigation_ajax_content_behaviour_init)) {navigation_ajax_content_behaviour_init ();}
if("function" == typeof (HeadlineBehaviourInit)) {HeadlineBehaviourInit ();}
if("function" == typeof (dragWindow_init)) {dragWindow_init ();}
if("function" == typeof (fieldValidatorInit)) {fieldValidatorInit ();}
if("function" == typeof (Footer_Behaviour_Init)) {Footer_Behaviour_Init ();}
if("function" == typeof (omApplyDivTableBehaviour)) {omApplyDivTableBehaviour ();}
if("function" == typeof (omAjaxReinit)) {omAjaxReinit ();}
if("function" == typeof (omAdminInit)) {omAdminInit ();}
if("function" == typeof (baseBehaviour_init)) {baseBehaviour_init ();}
if("function" == typeof (calendar_behaviour_init)) {calendar_behaviour_init ();}
if("function" == typeof (imageChooser_behaviour_init)) {imageChooser_behaviour_init ();}
if("function" == typeof (contextMenu_init)) {contextMenu_init();}
if("function" == typeof (emptyTitleValue_init)) {emptyTitleValue_init();}
if("function" == typeof (dsnTabColArrange_Init)) {dsnTabColArrange_Init();}
if("function" == typeof (dsnTabIRowInplaceArrange_Init)) {dsnTabIRowInplaceArrange_Init();}
if("function" == typeof (deliveryAddr_behaviour_init)) {deliveryAddr_behaviour_init();}
if("function" == typeof (previewPics_behaviour)) {previewPics_behaviour();}
if("function" == typeof (bodyClassInput_init)) {bodyClassInput_init();}
if("function" == typeof (specialPageBehaviour))
{
specialPageBehaviour ();
}
if("function" == typeof (handleScrolling)) { handleScrolling(scrollValues); }
window.setTimeout(delayedBehaviour, 50);
}
}
function omOnUnloadBehaviour()
{
if("function" == typeof (set_modal_submit)) {set_modal_submit();}
return true;
}
document.observe('dom:loaded', omOnloadBehaviour);
Event.observe(window, 'beforeunload', omOnUnloadBehaviour);
function lazyInit()
{
omOnloadBehaviour ();
}
<!-- DEFAULT: en 102298    v= -->



