window.labels = new Object(); window.labels["main"] = new Object(); window.labels["main"]["loading"] = "loading..."; window.labels["autocomplete"] = new Object(); window.labels["autocomplete"]["cancel"] = "Annuleer"; window.labels["sortable"] = new Object(); window.labels["lightbox"] = new Object(); window.labels["lightbox"]["cancel"] = "Annuleer"; window.labels["lightbox"]["save"] = "OK"; window.labels["editatonce"] = new Object(); window.labels["editatonce"]["saving"] = "gegevens bewaren"; window.labels["editinplace"] = new Object(); window.labels["editinplace"]["cancel"] = "Annuleer"; window.labels["editinplace"]["save"] = "OK"; window.labels["editinplace"]["onempty"] = "Add value"; window.labels["editinplace"]["saving"] = "gegevens bewaren"; window.labels["editinplace"]["fetching"] = "gegevens ophalen"; window.labels["editinplace"]["validate"] = new Object(); window.labels["editinplace"]["validate"]["msg"] = "Type een geldige waarde"; window.labels["editinplace"]["validate"]["out"] = "Type een geldige waarde"; window.labels["editinplace"]["validate"]["integer"] = "Type alleen nummers tussen 0-9"; window.labels["editinplace"]["validate"]["float"] = "Type alleen nummers tussen 0-9"; window.labels["unlink"] = new Object(); window.labels["unlink"]["cancel"] = "Nee"; window.labels["unlink"]["yes"] = "Ja"; window.labels["unlink"]["confirm"] = "Verwijder"; window.labels["unlink"]["title"] = "Verwijder dit item"; window.labels["unlink"] = new Object(); window.labels["unlink"]["cancel"] = "Nee"; window.labels["unlink"]["yes"] = "Ja"; window.labels["unlink"]["confirm"] = "Verwijder"; window.labels["unlink"]["title"] = "Verwijder dit item"; window.labels['shoutbox'] = new Object(); window.labels['shoutbox']['away'] = "You seem to be away from this window. Shutting down shoutbox."; window.labels['shoutbox']['changed'] = "The default conversation for this page has changed. Refreshing in a few seconds."; window.labels['shoutbox']['noconv'] = "No conversation exists for this thing yet."; window.labels['shoutbox']['emptytext'] = "Text is empty. You need to type something"; window.labels['shoutbox']['votedthis'] = "Voted this:"; window.labels['shoutbox']['showsms'] = "Show SMS"; window.labels['shoutbox']['hidesms'] = "Hide SMS"; (function(){ /* * jQuery 1.2.2 - New Wave Javascript * * Copyright (c) 2007 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Date: 2008-01-14 17:56:07 -0500 (Mon, 14 Jan 2008) * Rev: 4454 */ if ( window.jQuery ) var _jQuery = window.jQuery; var jQuery = window.jQuery = function( selector, context ) { return new jQuery.prototype.init( selector, context ); }; if ( window.$ ) var _$ = window.$; window.$ = jQuery; var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; var isSimple = /^.[^:#\[\.]*$/; jQuery.fn = jQuery.prototype = { init: function( selector, context ) { selector = selector || document; if ( selector.nodeType ) { this[0] = selector; this.length = 1; return this; } else if ( typeof selector == "string" ) { var match = quickExpr.exec( selector ); if ( match && (match[1] || !context) ) { if ( match[1] ) selector = jQuery.clean( [ match[1] ], context ); else { var elem = document.getElementById( match[3] ); if ( elem ) if ( elem.id != match[3] ) return jQuery().find( selector ); else { this[0] = elem; this.length = 1; return this; } else selector = []; } } else return new jQuery( context ).find( selector ); } else if ( jQuery.isFunction( selector ) ) return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); return this.setArray( selector.constructor == Array && selector || (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || [ selector ] ); }, jquery: "1.2.2", size: function() { return this.length; }, length: 0, get: function( num ) { return num == undefined ? jQuery.makeArray( this ) : this[ num ]; }, pushStack: function( elems ) { var ret = jQuery( elems ); ret.prevObject = this; return ret; }, setArray: function( elems ) { this.length = 0; Array.prototype.push.apply( this, elems ); return this; }, each: function( callback, args ) { return jQuery.each( this, callback, args ); }, index: function( elem ) { var ret = -1; this.each(function(i){ if ( this == elem ) ret = i; }); return ret; }, attr: function( name, value, type ) { var options = name; if ( name.constructor == String ) if ( value == undefined ) return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined; else { options = {}; options[ name ] = value; } return this.each(function(i){ for ( name in options ) jQuery.attr( type ? this.style : this, name, jQuery.prop( this, options[ name ], type, i, name ) ); }); }, css: function( key, value ) { if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) value = undefined; return this.attr( key, value, "curCSS" ); }, text: function( text ) { if ( typeof text != "object" && text != null ) return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); var ret = ""; jQuery.each( text || this, function(){ jQuery.each( this.childNodes, function(){ if ( this.nodeType != 8 ) ret += this.nodeType != 1 ? this.nodeValue : jQuery.fn.text( [ this ] ); }); }); return ret; }, wrapAll: function( html ) { if ( this[0] ) jQuery( html, this[0].ownerDocument ) .clone() .insertBefore( this[0] ) .map(function(){ var elem = this; while ( elem.firstChild ) elem = elem.firstChild; return elem; }) .append(this); return this; }, wrapInner: function( html ) { return this.each(function(){ jQuery( this ).contents().wrapAll( html ); }); }, wrap: function( html ) { return this.each(function(){ jQuery( this ).wrapAll( html ); }); }, append: function() { return this.domManip(arguments, true, false, function(elem){ if (this.nodeType == 1) this.appendChild( elem ); }); }, prepend: function() { return this.domManip(arguments, true, true, function(elem){ if (this.nodeType == 1) this.insertBefore( elem, this.firstChild ); }); }, before: function() { return this.domManip(arguments, false, false, function(elem){ this.parentNode.insertBefore( elem, this ); }); }, after: function() { return this.domManip(arguments, false, true, function(elem){ this.parentNode.insertBefore( elem, this.nextSibling ); }); }, end: function() { return this.prevObject || jQuery( [] ); }, find: function( selector ) { var elems = jQuery.map(this, function(elem){ return jQuery.find( selector, elem ); }); return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? jQuery.unique( elems ) : elems ); }, clone: function( events ) { var ret = this.map(function(){ if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { var clone = this.cloneNode(true), container = document.createElement("div"), container2 = document.createElement("div"); container.appendChild(clone); container2.innerHTML = container.innerHTML; return container2.firstChild; } else return this.cloneNode(true); }); var clone = ret.find("*").andSelf().each(function(){ if ( this[ expando ] != undefined ) this[ expando ] = null; }); if ( events === true ) this.find("*").andSelf().each(function(i){ if (this.nodeType == 3) return; var events = jQuery.data( this, "events" ); for ( var type in events ) for ( var handler in events[ type ] ) jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); }); return ret; }, filter: function( selector ) { return this.pushStack( jQuery.isFunction( selector ) && jQuery.grep(this, function(elem, i){ return selector.call( elem, i ); }) || jQuery.multiFilter( selector, this ) ); }, not: function( selector ) { if ( selector.constructor == String ) if ( isSimple.test( selector ) ) return this.pushStack( jQuery.multiFilter( selector, this, true ) ); else selector = jQuery.multiFilter( selector, this ); var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; return this.filter(function() { return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; }); }, add: function( selector ) { return !selector ? this : this.pushStack( jQuery.merge( this.get(), selector.constructor == String ? jQuery( selector ).get() : selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ? selector : [selector] ) ); }, is: function( selector ) { return selector ? jQuery.multiFilter( selector, this ).length > 0 : false; }, hasClass: function( selector ) { return this.is( "." + selector ); }, val: function( value ) { if ( value == undefined ) { if ( this.length ) { var elem = this[0]; if ( jQuery.nodeName( elem, "select" ) ) { var index = elem.selectedIndex, values = [], options = elem.options, one = elem.type == "select-one"; if ( index < 0 ) return null; for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { var option = options[ i ]; if ( option.selected ) { value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; if ( one ) return value; values.push( value ); } } return values; } else return (this[0].value || "").replace(/\r/g, ""); } return undefined; } return this.each(function(){ if ( this.nodeType != 1 ) return; if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) this.checked = (jQuery.inArray(this.value, value) >= 0 || jQuery.inArray(this.name, value) >= 0); else if ( jQuery.nodeName( this, "select" ) ) { var values = value.constructor == Array ? value : [ value ]; jQuery( "option", this ).each(function(){ this.selected = (jQuery.inArray( this.value, values ) >= 0 || jQuery.inArray( this.text, values ) >= 0); }); if ( !values.length ) this.selectedIndex = -1; } else this.value = value; }); }, html: function( value ) { return value == undefined ? (this.length ? this[0].innerHTML : null) : this.empty().append( value ); }, replaceWith: function( value ) { return this.after( value ).remove(); }, eq: function( i ) { return this.slice( i, i + 1 ); }, slice: function() { return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); }, map: function( callback ) { return this.pushStack( jQuery.map(this, function(elem, i){ return callback.call( elem, i, elem ); })); }, andSelf: function() { return this.add( this.prevObject ); }, domManip: function( args, table, reverse, callback ) { var clone = this.length > 1, elems; return this.each(function(){ if ( !elems ) { elems = jQuery.clean( args, this.ownerDocument ); if ( reverse ) elems.reverse(); } var obj = this; if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); var scripts = jQuery( [] ); jQuery.each(elems, function(){ var elem = clone ? jQuery( this ).clone( true )[0] : this; if ( jQuery.nodeName( elem, "script" ) ) { scripts = scripts.add( elem ); } else { if ( elem.nodeType == 1 ) scripts = scripts.add( jQuery( "script", elem ).remove() ); callback.call( obj, elem ); } }); scripts.each( evalScript ); }); } }; jQuery.prototype.init.prototype = jQuery.prototype; function evalScript( i, elem ) { if ( elem.src ) jQuery.ajax({ url: elem.src, async: false, dataType: "script" }); else jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); if ( elem.parentNode ) elem.parentNode.removeChild( elem ); } jQuery.extend = jQuery.fn.extend = function() { var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; if ( target.constructor == Boolean ) { deep = target; target = arguments[1] || {}; i = 2; } if ( typeof target != "object" && typeof target != "function" ) target = {}; if ( length == 1 ) { target = this; i = 0; } for ( ; i < length; i++ ) if ( (options = arguments[ i ]) != null ) for ( var name in options ) { if ( target === options[ name ] ) continue; if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType ) target[ name ] = jQuery.extend( target[ name ], options[ name ] ); else if ( options[ name ] != undefined ) target[ name ] = options[ name ]; } return target; }; var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {}; var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; jQuery.extend({ noConflict: function( deep ) { window.$ = _$; if ( deep ) window.jQuery = _jQuery; return jQuery; }, isFunction: function( fn ) { return !!fn && typeof fn != "string" && !fn.nodeName && fn.constructor != Array && /function/i.test( fn + "" ); }, isXMLDoc: function( elem ) { return elem.documentElement && !elem.body || elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; }, globalEval: function( data ) { data = jQuery.trim( data ); if ( data ) { var head = document.getElementsByTagName("head")[0] || document.documentElement, script = document.createElement("script"); script.type = "text/javascript"; if ( jQuery.browser.msie ) script.text = data; else script.appendChild( document.createTextNode( data ) ); head.appendChild( script ); head.removeChild( script ); } }, nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); }, cache: {}, data: function( elem, name, data ) { elem = elem == window ? windowData : elem; var id = elem[ expando ]; if ( !id ) id = elem[ expando ] = ++uuid; if ( name && !jQuery.cache[ id ] ) jQuery.cache[ id ] = {}; if ( data != undefined ) jQuery.cache[ id ][ name ] = data; return name ? jQuery.cache[ id ][ name ] : id; }, removeData: function( elem, name ) { elem = elem == window ? windowData : elem; var id = elem[ expando ]; if ( name ) { if ( jQuery.cache[ id ] ) { delete jQuery.cache[ id ][ name ]; name = ""; for ( name in jQuery.cache[ id ] ) break; if ( !name ) jQuery.removeData( elem ); } } else { try { delete elem[ expando ]; } catch(e){ if ( elem.removeAttribute ) elem.removeAttribute( expando ); } delete jQuery.cache[ id ]; } }, each: function( object, callback, args ) { if ( args ) { if ( object.length == undefined ) { for ( var name in object ) if ( callback.apply( object[ name ], args ) === false ) break; } else for ( var i = 0, length = object.length; i < length; i++ ) if ( callback.apply( object[ i ], args ) === false ) break; } else { if ( object.length == undefined ) { for ( var name in object ) if ( callback.call( object[ name ], name, object[ name ] ) === false ) break; } else for ( var i = 0, length = object.length, value = object[0]; i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} } return object; }, prop: function( elem, value, type, i, name ) { if ( jQuery.isFunction( value ) ) value = value.call( elem, i ); return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? value + "px" : value; }, className: { add: function( elem, classNames ) { jQuery.each((classNames || "").split(/\s+/), function(i, className){ if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) elem.className += (elem.className ? " " : "") + className; }); }, remove: function( elem, classNames ) { if (elem.nodeType == 1) elem.className = classNames != undefined ? jQuery.grep(elem.className.split(/\s+/), function(className){ return !jQuery.className.has( classNames, className ); }).join(" ") : ""; }, has: function( elem, className ) { return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; } }, swap: function( elem, options, callback ) { var old = {}; for ( var name in options ) { old[ name ] = elem.style[ name ]; elem.style[ name ] = options[ name ]; } callback.call( elem ); for ( var name in options ) elem.style[ name ] = old[ name ]; }, css: function( elem, name, force ) { if ( name == "width" || name == "height" ) { var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; function getWH() { val = name == "width" ? elem.offsetWidth : elem.offsetHeight; var padding = 0, border = 0; jQuery.each( which, function() { padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; }); val -= Math.round(padding + border); } if ( jQuery(elem).is(":visible") ) getWH(); else jQuery.swap( elem, props, getWH ); return Math.max(0, val); } return jQuery.curCSS( elem, name, force ); }, curCSS: function( elem, name, force ) { var ret; function color( elem ) { if ( !jQuery.browser.safari ) return false; var ret = document.defaultView.getComputedStyle( elem, null ); return !ret || ret.getPropertyValue("color") == ""; } if ( name == "opacity" && jQuery.browser.msie ) { ret = jQuery.attr( elem.style, "opacity" ); return ret == "" ? "1" : ret; } if ( jQuery.browser.opera && name == "display" ) { var save = elem.style.display; elem.style.display = "block"; elem.style.display = save; } if ( name.match( /float/i ) ) name = styleFloat; if ( !force && elem.style && elem.style[ name ] ) ret = elem.style[ name ]; else if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( name.match( /float/i ) ) name = "float"; name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); var getComputedStyle = document.defaultView.getComputedStyle( elem, null ); if ( getComputedStyle && !color( elem ) ) ret = getComputedStyle.getPropertyValue( name ); else { var swap = [], stack = []; for ( var a = elem; a && color(a); a = a.parentNode ) stack.unshift(a); for ( var i = 0; i < stack.length; i++ ) if ( color( stack[ i ] ) ) { swap[ i ] = stack[ i ].style.display; stack[ i ].style.display = "block"; } ret = name == "display" && swap[ stack.length - 1 ] != null ? "none" : ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || ""; for ( var i = 0; i < swap.length; i++ ) if ( swap[ i ] != null ) stack[ i ].style.display = swap[ i ]; } if ( name == "opacity" && ret == "" ) ret = "1"; } else if ( elem.currentStyle ) { var camelCase = name.replace(/\-(\w)/g, function(all, letter){ return letter.toUpperCase(); }); ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left; elem.runtimeStyle.left = elem.currentStyle.left; elem.style.left = ret || 0; ret = elem.style.pixelLeft + "px"; elem.style.left = style; elem.runtimeStyle.left = runtimeStyle; } } return ret; }, clean: function( elems, context ) { var ret = []; context = context || document; if (typeof context.createElement == 'undefined') context = context.ownerDocument || context[0] && context[0].ownerDocument || document; jQuery.each(elems, function(i, elem){ if ( !elem ) return; if ( elem.constructor == Number ) elem = elem.toString(); if ( typeof elem == "string" ) { elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? all : front + ">"; }); var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); var wrap = !tags.indexOf("", "" ] || !tags.indexOf("", "" ] || tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && [ 1, "", "
" ] || !tags.indexOf("", "" ] || (!tags.indexOf("", "" ] || !tags.indexOf("", "" ] || jQuery.browser.msie && [ 1, "div
", "
" ] || [ 0, "", "" ]; div.innerHTML = wrap[1] + elem + wrap[2]; while ( wrap[0]-- ) div = div.lastChild; if ( jQuery.browser.msie ) { var tbody = !tags.indexOf("" && tags.indexOf("= 0 ; --j ) if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) tbody[ j ].parentNode.removeChild( tbody[ j ] ); if ( /^\s/.test( elem ) ) div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); } elem = jQuery.makeArray( div.childNodes ); } if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) ) return; if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options ) ret.push( elem ); else ret = jQuery.merge( ret, elem ); }); return ret; }, attr: function( elem, name, value ) { if (!elem || elem.nodeType == 3 || elem.nodeType == 8) return undefined; var fix = jQuery.isXMLDoc( elem ) ? {} : jQuery.props; if ( name == "selected" && jQuery.browser.safari ) elem.parentNode.selectedIndex; if ( fix[ name ] ) { if ( value != undefined ) elem[ fix[ name ] ] = value; return elem[ fix[ name ] ]; } else if ( jQuery.browser.msie && name == "style" ) return jQuery.attr( elem.style, "cssText", value ); else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") ) return elem.getAttributeNode( name ).nodeValue; else if ( elem.tagName ) { if ( value != undefined ) { if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) throw "type property can't be changed"; elem.setAttribute( name, "" + value ); } if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) return elem.getAttribute( name, 2 ); return elem.getAttribute( name ); } else { if ( name == "opacity" && jQuery.browser.msie ) { if ( value != undefined ) { elem.zoom = 1; elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); } return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : ""; } name = name.replace(/-([a-z])/ig, function(all, letter){ return letter.toUpperCase(); }); if ( value != undefined ) elem[ name ] = value; return elem[ name ]; } }, trim: function( text ) { return (text || "").replace( /^\s+|\s+$/g, "" ); }, makeArray: function( array ) { var ret = []; if ( typeof array != "array" ) for ( var i = 0, length = array.length; i < length; i++ ) ret.push( array[ i ] ); else ret = array.slice( 0 ); return ret; }, inArray: function( elem, array ) { for ( var i = 0, length = array.length; i < length; i++ ) if ( array[ i ] == elem ) return i; return -1; }, merge: function( first, second ) { if ( jQuery.browser.msie ) { for ( var i = 0; second[ i ]; i++ ) if ( second[ i ].nodeType != 8 ) first.push( second[ i ] ); } else for ( var i = 0; second[ i ]; i++ ) first.push( second[ i ] ); return first; }, unique: function( array ) { var ret = [], done = {}; try { for ( var i = 0, length = array.length; i < length; i++ ) { var id = jQuery.data( array[ i ] ); if ( !done[ id ] ) { done[ id ] = true; ret.push( array[ i ] ); } } } catch( e ) { ret = array; } return ret; }, grep: function( elems, callback, inv ) { if ( typeof callback == "string" ) callback = eval("false||function(a,i){return " + callback + "}"); var ret = []; for ( var i = 0, length = elems.length; i < length; i++ ) if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) ) ret.push( elems[ i ] ); return ret; }, map: function( elems, callback ) { var ret = []; for ( var i = 0, length = elems.length; i < length; i++ ) { var value = callback( elems[ i ], i ); if ( value !== null && value != undefined ) { if ( value.constructor != Array ) value = [ value ]; ret = ret.concat( value ); } } return ret; } }); var userAgent = navigator.userAgent.toLowerCase(); jQuery.browser = { version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], safari: /webkit/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) }; var styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat"; jQuery.extend({ boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat", props: { "for": "htmlFor", "class": "className", "float": styleFloat, cssFloat: styleFloat, styleFloat: styleFloat, innerHTML: "innerHTML", className: "className", value: "value", disabled: "disabled", checked: "checked", readonly: "readOnly", selected: "selected", maxlength: "maxLength", selectedIndex: "selectedIndex", defaultValue: "defaultValue", tagName: "tagName", nodeName: "nodeName" } }); jQuery.each({ parent: "elem.parentNode", parents: "jQuery.dir(elem,'parentNode')", next: "jQuery.nth(elem,2,'nextSibling')", prev: "jQuery.nth(elem,2,'previousSibling')", nextAll: "jQuery.dir(elem,'nextSibling')", prevAll: "jQuery.dir(elem,'previousSibling')", siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)", children: "jQuery.sibling(elem.firstChild)", contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)" }, function(name, fn){ fn = eval("false||function(elem){return " + fn + "}"); jQuery.fn[ name ] = function( selector ) { var ret = jQuery.map( this, fn ); if ( selector && typeof selector == "string" ) ret = jQuery.multiFilter( selector, ret ); return this.pushStack( jQuery.unique( ret ) ); }; }); jQuery.each({ appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after", replaceAll: "replaceWith" }, function(name, original){ jQuery.fn[ name ] = function() { var args = arguments; return this.each(function(){ for ( var i = 0, length = args.length; i < length; i++ ) jQuery( args[ i ] )[ original ]( this ); }); }; }); jQuery.each({ removeAttr: function( name ) { jQuery.attr( this, name, "" ); if (this.nodeType == 1) this.removeAttribute( name ); }, addClass: function( classNames ) { jQuery.className.add( this, classNames ); }, removeClass: function( classNames ) { jQuery.className.remove( this, classNames ); }, toggleClass: function( classNames ) { jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames ); }, remove: function( selector ) { if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) { jQuery( "*", this ).add(this).each(function(){ jQuery.event.remove(this); jQuery.removeData(this); }); if (this.parentNode) this.parentNode.removeChild( this ); } }, empty: function() { jQuery( ">*", this ).remove(); while ( this.firstChild ) this.removeChild( this.firstChild ); } }, function(name, fn){ jQuery.fn[ name ] = function(){ return this.each( fn, arguments ); }; }); jQuery.each([ "Height", "Width" ], function(i, name){ var type = name.toLowerCase(); jQuery.fn[ type ] = function( size ) { return this[0] == window ? jQuery.browser.opera && document.body[ "client" + name ] || jQuery.browser.safari && window[ "inner" + name ] || document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] : this[0] == document ? Math.max( Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]), Math.max(document.body["offset" + name], document.documentElement["offset" + name]) ) : size == undefined ? (this.length ? jQuery.css( this[0], type ) : null) : this.css( type, size.constructor == String ? size : size + "px" ); }; }); var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ? "(?:[\\w*_-]|\\\\.)" : "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)", quickChild = new RegExp("^>\\s*(" + chars + "+)"), quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"), quickClass = new RegExp("^([#.]?)(" + chars + "*)"); jQuery.extend({ expr: { "": "m[2]=='*'||jQuery.nodeName(a,m[2])", "#": "a.getAttribute('id')==m[2]", ":": { lt: "im[3]-0", nth: "m[3]-0==i", eq: "m[3]-0==i", first: "i==0", last: "i==r.length-1", even: "i%2==0", odd: "i%2", "first-child": "a.parentNode.getElementsByTagName('*')[0]==a", "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a", "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')", parent: "a.firstChild", empty: "!a.firstChild", contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0", visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"', hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"', enabled: "!a.disabled", disabled: "a.disabled", checked: "a.checked", selected: "a.selected||jQuery.attr(a,'selected')", text: "'text'==a.type", radio: "'radio'==a.type", checkbox: "'checkbox'==a.type", file: "'file'==a.type", password: "'password'==a.type", submit: "'submit'==a.type", image: "'image'==a.type", reset: "'reset'==a.type", button: '"button"==a.type||jQuery.nodeName(a,"button")', input: "/input|select|textarea|button/i.test(a.nodeName)", has: "jQuery.find(m[3],a).length", header: "/h\\d/i.test(a.nodeName)", animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length" } }, parse: [ /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/, new RegExp("^([:.#]*)(" + chars + "+)") ], multiFilter: function( expr, elems, not ) { var old, cur = []; while ( expr && expr != old ) { old = expr; var f = jQuery.filter( expr, elems, not ); expr = f.t.replace(/^\s*,\s*/, "" ); cur = not ? elems = f.r : jQuery.merge( cur, f.r ); } return cur; }, find: function( t, context ) { if ( typeof t != "string" ) return [ t ]; if ( context && context.nodeType != 1 && context.nodeType != 9) return [ ]; context = context || document; var ret = [context], done = [], last, nodeName; while ( t && last != t ) { var r = []; last = t; t = jQuery.trim(t); var foundToken = false; var re = quickChild; var m = re.exec(t); if ( m ) { nodeName = m[1].toUpperCase(); for ( var i = 0; ret[i]; i++ ) for ( var c = ret[i].firstChild; c; c = c.nextSibling ) if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) ) r.push( c ); ret = r; t = t.replace( re, "" ); if ( t.indexOf(" ") == 0 ) continue; foundToken = true; } else { re = /^([>+~])\s*(\w*)/i; if ( (m = re.exec(t)) != null ) { r = []; var merge = {}; nodeName = m[2].toUpperCase(); m = m[1]; for ( var j = 0, rl = ret.length; j < rl; j++ ) { var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; for ( ; n; n = n.nextSibling ) if ( n.nodeType == 1 ) { var id = jQuery.data(n); if ( m == "~" && merge[id] ) break; if (!nodeName || n.nodeName.toUpperCase() == nodeName ) { if ( m == "~" ) merge[id] = true; r.push( n ); } if ( m == "+" ) break; } } ret = r; t = jQuery.trim( t.replace( re, "" ) ); foundToken = true; } } if ( t && !foundToken ) { if ( !t.indexOf(",") ) { if ( context == ret[0] ) ret.shift(); done = jQuery.merge( done, ret ); r = ret = [context]; t = " " + t.substr(1,t.length); } else { var re2 = quickID; var m = re2.exec(t); if ( m ) { m = [ 0, m[2], m[3], m[1] ]; } else { re2 = quickClass; m = re2.exec(t); } m[2] = m[2].replace(/\\/g, ""); var elem = ret[ret.length-1]; if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) { var oid = elem.getElementById(m[2]); if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] ) oid = jQuery('[@id="'+m[2]+'"]', elem)[0]; ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : []; } else { for ( var i = 0; ret[i]; i++ ) { var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2]; if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" ) tag = "param"; r = jQuery.merge( r, ret[i].getElementsByTagName( tag )); } if ( m[1] == "." ) r = jQuery.classFilter( r, m[2] ); if ( m[1] == "#" ) { var tmp = []; for ( var i = 0; r[i]; i++ ) if ( r[i].getAttribute("id") == m[2] ) { tmp = [ r[i] ]; break; } r = tmp; } ret = r; } t = t.replace( re2, "" ); } } if ( t ) { var val = jQuery.filter(t,r); ret = r = val.r; t = jQuery.trim(val.t); } } if ( t ) ret = []; if ( ret && context == ret[0] ) ret.shift(); done = jQuery.merge( done, ret ); return done; }, classFilter: function(r,m,not){ m = " " + m + " "; var tmp = []; for ( var i = 0; r[i]; i++ ) { var pass = (" " + r[i].className + " ").indexOf( m ) >= 0; if ( !not && pass || not && !pass ) tmp.push( r[i] ); } return tmp; }, filter: function(t,r,not) { var last; while ( t && t != last ) { last = t; var p = jQuery.parse, m; for ( var i = 0; p[i]; i++ ) { m = p[i].exec( t ); if ( m ) { t = t.substring( m[0].length ); m[2] = m[2].replace(/\\/g, ""); break; } } if ( !m ) break; if ( m[1] == ":" && m[2] == "not" ) r = isSimple.test( m[3] ) ? jQuery.filter(m[3], r, true).r : jQuery( r ).not( m[3] ); else if ( m[1] == "." ) r = jQuery.classFilter(r, m[2], not); else if ( m[1] == "[" ) { var tmp = [], type = m[3]; for ( var i = 0, rl = r.length; i < rl; i++ ) { var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ]; if ( z == null || /href|src|selected/.test(m[2]) ) z = jQuery.attr(a,m[2]) || ''; if ( (type == "" && !!z || type == "=" && z == m[5] || type == "!=" && z != m[5] || type == "^=" && z && !z.indexOf(m[5]) || type == "$=" && z.substr(z.length - m[5].length) == m[5] || (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not ) tmp.push( a ); } r = tmp; } else if ( m[1] == ":" && m[2] == "nth-child" ) { var merge = {}, tmp = [], test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" || !/\D/.test(m[3]) && "0n+" + m[3] || m[3]), first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0; for ( var i = 0, rl = r.length; i < rl; i++ ) { var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode); if ( !merge[id] ) { var c = 1; for ( var n = parentNode.firstChild; n; n = n.nextSibling ) if ( n.nodeType == 1 ) n.nodeIndex = c++; merge[id] = true; } var add = false; if ( first == 0 ) { if ( node.nodeIndex == last ) add = true; } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 ) add = true; if ( add ^ not ) tmp.push( node ); } r = tmp; } else { var f = jQuery.expr[m[1]]; if ( typeof f != "string" ) f = jQuery.expr[m[1]][m[2]]; f = eval("false||function(a,i){return " + f + "}"); r = jQuery.grep( r, f, not ); } } return { r: r, t: t }; }, dir: function( elem, dir ){ var matched = []; var cur = elem[dir]; while ( cur && cur != document ) { if ( cur.nodeType == 1 ) matched.push( cur ); cur = cur[dir]; } return matched; }, nth: function(cur,result,dir,elem){ result = result || 1; var num = 0; for ( ; cur; cur = cur[dir] ) if ( cur.nodeType == 1 && ++num == result ) break; return cur; }, sibling: function( n, elem ) { var r = []; for ( ; n; n = n.nextSibling ) { if ( n.nodeType == 1 && (!elem || n != elem) ) r.push( n ); } return r; } }); /* * A number of helper functions used for managing events. * Many of the ideas behind this code orignated from * Dean Edwards' addEvent library. */ jQuery.event = { add: function(elem, types, handler, data) { if ( elem.nodeType == 3 || elem.nodeType == 8 ) return; if ( jQuery.browser.msie && elem.setInterval != undefined ) elem = window; if ( !handler.guid ) handler.guid = this.guid++; if( data != undefined ) { var fn = handler; handler = function() { return fn.apply(this, arguments); }; handler.data = data; handler.guid = fn.guid; } var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ var val; if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return val; val = jQuery.event.handle.apply(arguments.callee.elem, arguments); return val; }); handle.elem = elem; jQuery.each(types.split(/\s+/), function(index, type) { var parts = type.split("."); type = parts[0]; handler.type = parts[1]; var handlers = events[type]; if (!handlers) { handlers = events[type] = {}; if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { if (elem.addEventListener) elem.addEventListener(type, handle, false); else if (elem.attachEvent) elem.attachEvent("on" + type, handle); } } handlers[handler.guid] = handler; jQuery.event.global[type] = true; }); elem = null; }, guid: 1, global: {}, remove: function(elem, types, handler) { if ( elem.nodeType == 3 || elem.nodeType == 8 ) return; var events = jQuery.data(elem, "events"), ret, index; if ( events ) { if ( types == undefined ) for ( var type in events ) this.remove( elem, type ); else { if ( types.type ) { handler = types.handler; types = types.type; } jQuery.each(types.split(/\s+/), function(index, type){ var parts = type.split("."); type = parts[0]; if ( events[type] ) { if ( handler ) delete events[type][handler.guid]; else for ( handler in events[type] ) if ( !parts[1] || events[type][handler].type == parts[1] ) delete events[type][handler]; for ( ret in events[type] ) break; if ( !ret ) { if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) { if (elem.removeEventListener) elem.removeEventListener(type, jQuery.data(elem, "handle"), false); else if (elem.detachEvent) elem.detachEvent("on" + type, jQuery.data(elem, "handle")); } ret = null; delete events[type]; } } }); } for ( ret in events ) break; if ( !ret ) { var handle = jQuery.data( elem, "handle" ); if ( handle ) handle.elem = null; jQuery.removeData( elem, "events" ); jQuery.removeData( elem, "handle" ); } } }, trigger: function(type, data, elem, donative, extra) { data = jQuery.makeArray(data || []); if ( !elem ) { if ( this.global[type] ) jQuery("*").add([window, document]).trigger(type, data); } else { if ( elem.nodeType == 3 || elem.nodeType == 8 ) return undefined; var val, ret, fn = jQuery.isFunction( elem[ type ] || null ), event = !data[0] || !data[0].preventDefault; if ( event ) data.unshift( this.fix({ type: type, target: elem }) ); data[0].type = type; if ( jQuery.isFunction( jQuery.data(elem, "handle") ) ) val = jQuery.data(elem, "handle").apply( elem, data ); if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) val = false; if ( event ) data.shift(); if ( extra && jQuery.isFunction( extra ) ) { ret = extra.apply( elem, val == null ? data : data.concat( val ) ); if (ret !== undefined) val = ret; } if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) { this.triggered = true; try { elem[ type ](); } catch (e) {} } this.triggered = false; } return val; }, handle: function(event) { var val; event = jQuery.event.fix( event || window.event || {} ); var parts = event.type.split("."); event.type = parts[0]; var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 ); args.unshift( event ); for ( var j in handlers ) { var handler = handlers[j]; args[0].handler = handler; args[0].data = handler.data; if ( !parts[1] || handler.type == parts[1] ) { var ret = handler.apply( this, args ); if ( val !== false ) val = ret; if ( ret === false ) { event.preventDefault(); event.stopPropagation(); } } } if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null; return val; }, fix: function(event) { var originalEvent = event; event = jQuery.extend({}, originalEvent); event.preventDefault = function() { if (originalEvent.preventDefault) originalEvent.preventDefault(); originalEvent.returnValue = false; }; event.stopPropagation = function() { if (originalEvent.stopPropagation) originalEvent.stopPropagation(); originalEvent.cancelBubble = true; }; if ( !event.target ) event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either if ( event.target.nodeType == 3 ) event.target = originalEvent.target.parentNode; if ( !event.relatedTarget && event.fromElement ) event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; if ( event.pageX == null && event.clientX != null ) { var doc = document.documentElement, body = document.body; event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); } if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) event.which = event.charCode || event.keyCode; if ( !event.metaKey && event.ctrlKey ) event.metaKey = event.ctrlKey; if ( !event.which && event.button ) event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); return event; }, special: { ready: { setup: function() { bindReady(); return; }, teardown: function() { return; } }, mouseenter: { setup: function() { if ( jQuery.browser.msie ) return false; jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler); return true; }, teardown: function() { if ( jQuery.browser.msie ) return false; jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler); return true; }, handler: function(event) { if ( withinElement(event, this) ) return true; arguments[0].type = "mouseenter"; return jQuery.event.handle.apply(this, arguments); } }, mouseleave: { setup: function() { if ( jQuery.browser.msie ) return false; jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler); return true; }, teardown: function() { if ( jQuery.browser.msie ) return false; jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler); return true; }, handler: function(event) { if ( withinElement(event, this) ) return true; arguments[0].type = "mouseleave"; return jQuery.event.handle.apply(this, arguments); } } } }; jQuery.fn.extend({ bind: function( type, data, fn ) { return type == "unload" ? this.one(type, data, fn) : this.each(function(){ jQuery.event.add( this, type, fn || data, fn && data ); }); }, one: function( type, data, fn ) { return this.each(function(){ jQuery.event.add( this, type, function(event) { jQuery(this).unbind(event); return (fn || data).apply( this, arguments); }, fn && data); }); }, unbind: function( type, fn ) { return this.each(function(){ jQuery.event.remove( this, type, fn ); }); }, trigger: function( type, data, fn ) { return this.each(function(){ jQuery.event.trigger( type, data, this, true, fn ); }); }, triggerHandler: function( type, data, fn ) { if ( this[0] ) return jQuery.event.trigger( type, data, this[0], false, fn ); return undefined; }, toggle: function() { var args = arguments; return this.click(function(event) { this.lastToggle = 0 == this.lastToggle ? 1 : 0; event.preventDefault(); return args[this.lastToggle].apply( this, arguments ) || false; }); }, hover: function(fnOver, fnOut) { return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut); }, ready: function(fn) { bindReady(); if ( jQuery.isReady ) fn.call( document, jQuery ); else jQuery.readyList.push( function() { return fn.call(this, jQuery); } ); return this; } }); jQuery.extend({ isReady: false, readyList: [], ready: function() { if ( !jQuery.isReady ) { jQuery.isReady = true; if ( jQuery.readyList ) { jQuery.each( jQuery.readyList, function(){ this.apply( document ); }); jQuery.readyList = null; } jQuery(document).triggerHandler("ready"); } } }); var readyBound = false; function bindReady(){ if ( readyBound ) return; readyBound = true; if ( document.addEventListener && !jQuery.browser.opera) document.addEventListener( "DOMContentLoaded", jQuery.ready, false ); if ( jQuery.browser.msie && window == top ) (function(){ if (jQuery.isReady) return; try { document.documentElement.doScroll("left"); } catch( error ) { setTimeout( arguments.callee, 0 ); return; } jQuery.ready(); })(); if ( jQuery.browser.opera ) document.addEventListener( "DOMContentLoaded", function () { if (jQuery.isReady) return; for (var i = 0; i < document.styleSheets.length; i++) if (document.styleSheets[i].disabled) { setTimeout( arguments.callee, 0 ); return; } jQuery.ready(); }, false); if ( jQuery.browser.safari ) { var numStyles; (function(){ if (jQuery.isReady) return; if ( document.readyState != "loaded" && document.readyState != "complete" ) { setTimeout( arguments.callee, 0 ); return; } if ( numStyles === undefined ) numStyles = jQuery("style, link[rel=stylesheet]").length; if ( document.styleSheets.length != numStyles ) { setTimeout( arguments.callee, 0 ); return; } jQuery.ready(); })(); } jQuery.event.add( window, "load", jQuery.ready ); } jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + "submit,keydown,keypress,keyup,error").split(","), function(i, name){ jQuery.fn[name] = function(fn){ return fn ? this.bind(name, fn) : this.trigger(name); }; }); var withinElement = function(event, elem) { var parent = event.relatedTarget; while ( parent && parent != elem ) try { parent = parent.parentNode; } catch(error) { parent = elem; } return parent == elem; }; jQuery(window).bind("unload", function() { jQuery("*").add(document).unbind(); }); jQuery.fn.extend({ load: function( url, params, callback ) { if ( jQuery.isFunction( url ) ) return this.bind("load", url); var off = url.indexOf(" "); if ( off >= 0 ) { var selector = url.slice(off, url.length); url = url.slice(0, off); } callback = callback || function(){}; var type = "GET"; if ( params ) if ( jQuery.isFunction( params ) ) { callback = params; params = null; } else { params = jQuery.param( params ); type = "POST"; } var self = this; jQuery.ajax({ url: url, type: type, dataType: "html", data: params, complete: function(res, status){ if ( status == "success" || status == "notmodified" ) self.html( selector ? jQuery("
") .append(res.responseText.replace(//g, "")) .find(selector) : res.responseText ); self.each( callback, [res.responseText, status, res] ); } }); return this; }, serialize: function() { return jQuery.param(this.serializeArray()); }, serializeArray: function() { return this.map(function(){ return jQuery.nodeName(this, "form") ? jQuery.makeArray(this.elements) : this; }) .filter(function(){ return this.name && !this.disabled && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type)); }) .map(function(i, elem){ var val = jQuery(this).val(); return val == null ? null : val.constructor == Array ? jQuery.map( val, function(val, i){ return {name: elem.name, value: val}; }) : {name: elem.name, value: val}; }).get(); } }); jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ jQuery.fn[o] = function(f){ return this.bind(o, f); }; }); var jsc = (new Date).getTime(); jQuery.extend({ get: function( url, data, callback, type ) { if ( jQuery.isFunction( data ) ) { callback = data; data = null; } return jQuery.ajax({ type: "GET", url: url, data: data, success: callback, dataType: type }); }, getScript: function( url, callback ) { return jQuery.get(url, null, callback, "script"); }, getJSON: function( url, data, callback ) { return jQuery.get(url, data, callback, "json"); }, post: function( url, data, callback, type ) { if ( jQuery.isFunction( data ) ) { callback = data; data = {}; } return jQuery.ajax({ type: "POST", url: url, data: data, success: callback, dataType: type }); }, ajaxSetup: function( settings ) { jQuery.extend( jQuery.ajaxSettings, settings ); }, ajaxSettings: { global: true, type: "GET", timeout: 0, contentType: "application/x-www-form-urlencoded", processData: true, async: true, data: null, username: null, password: null, accepts: { xml: "application/xml, text/xml", html: "text/html", script: "text/javascript, application/javascript", json: "application/json, text/javascript", text: "text/plain", _default: "*/*" } }, lastModified: {}, ajax: function( s ) { var jsonp, jsre = /=\?(&|$)/g, status, data; s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); if ( s.data && s.processData && typeof s.data != "string" ) s.data = jQuery.param(s.data); if ( s.dataType == "jsonp" ) { if ( s.type.toLowerCase() == "get" ) { if ( !s.url.match(jsre) ) s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; } else if ( !s.data || !s.data.match(jsre) ) s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; s.dataType = "json"; } if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { jsonp = "jsonp" + jsc++; if ( s.data ) s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); s.url = s.url.replace(jsre, "=" + jsonp + "$1"); s.dataType = "script"; window[ jsonp ] = function(tmp){ data = tmp; success(); complete(); window[ jsonp ] = undefined; try{ delete window[ jsonp ]; } catch(e){} if ( head ) head.removeChild( script ); }; } if ( s.dataType == "script" && s.cache == null ) s.cache = false; if ( s.cache === false && s.type.toLowerCase() == "get" ) { var ts = (new Date()).getTime(); var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); } if ( s.data && s.type.toLowerCase() == "get" ) { s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; s.data = null; } if ( s.global && ! jQuery.active++ ) jQuery.event.trigger( "ajaxStart" ); if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.src = s.url; if (s.scriptCharset) script.charset = s.scriptCharset; if ( !jsonp ) { var done = false; script.onload = script.onreadystatechange = function(){ if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) { done = true; success(); complete(); head.removeChild( script ); } }; } head.appendChild(script); return undefined; } var requestDone = false; var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); xml.open(s.type, s.url, s.async, s.username, s.password); try { if ( s.data ) xml.setRequestHeader("Content-Type", s.contentType); if ( s.ifModified ) xml.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xml.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? s.accepts[ s.dataType ] + ", */*" : s.accepts._default ); } catch(e){} if ( s.beforeSend ) s.beforeSend(xml); if ( s.global ) jQuery.event.trigger("ajaxSend", [xml, s]); var onreadystatechange = function(isTimeout){ if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { requestDone = true; if (ival) { clearInterval(ival); ival = null; } status = isTimeout == "timeout" && "timeout" || !jQuery.httpSuccess( xml ) && "error" || s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || "success"; if ( status == "success" ) { try { data = jQuery.httpData( xml, s.dataType ); } catch(e) { status = "parsererror"; } } if ( status == "success" ) { var modRes; try { modRes = xml.getResponseHeader("Last-Modified"); } catch(e) {} // swallow exception thrown by FF if header is not available if ( s.ifModified && modRes ) jQuery.lastModified[s.url] = modRes; if ( !jsonp ) success(); } else jQuery.handleError(s, xml, status); complete(); if ( s.async ) xml = null; } }; if ( s.async ) { var ival = setInterval(onreadystatechange, 13); if ( s.timeout > 0 ) setTimeout(function(){ if ( xml ) { xml.abort(); if( !requestDone ) onreadystatechange( "timeout" ); } }, s.timeout); } try { xml.send(s.data); } catch(e) { jQuery.handleError(s, xml, null, e); } if ( !s.async ) onreadystatechange(); function success(){ if ( s.success ) s.success( data, status ); if ( s.global ) jQuery.event.trigger( "ajaxSuccess", [xml, s] ); } function complete(){ if ( s.complete ) s.complete(xml, status); if ( s.global ) jQuery.event.trigger( "ajaxComplete", [xml, s] ); if ( s.global && ! --jQuery.active ) jQuery.event.trigger( "ajaxStop" ); } return xml; }, handleError: function( s, xml, status, e ) { if ( s.error ) s.error( xml, status, e ); if ( s.global ) jQuery.event.trigger( "ajaxError", [xml, s, e] ); }, active: 0, httpSuccess: function( r ) { try { return !r.status && location.protocol == "file:" || ( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 || jQuery.browser.safari && r.status == undefined; } catch(e){} return false; }, httpNotModified: function( xml, url ) { try { var xmlRes = xml.getResponseHeader("Last-Modified"); return xml.status == 304 || xmlRes == jQuery.lastModified[url] || jQuery.browser.safari && xml.status == undefined; } catch(e){} return false; }, httpData: function( r, type ) { var ct = r.getResponseHeader("content-type"); var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; var data = xml ? r.responseXML : r.responseText; if ( xml && data.documentElement.tagName == "parsererror" ) throw "parsererror"; if ( type == "script" ) jQuery.globalEval( data ); if ( type == "json" ) data = eval("(" + data + ")"); return data; }, param: function( a ) { var s = []; if ( a.constructor == Array || a.jquery ) jQuery.each( a, function(){ s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) ); }); else for ( var j in a ) if ( a[j] && a[j].constructor == Array ) jQuery.each( a[j], function(){ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) ); }); else s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) ); return s.join("&").replace(/%20/g, "+"); } }); jQuery.fn.extend({ show: function(speed,callback){ return speed ? this.animate({ height: "show", width: "show", opacity: "show" }, speed, callback) : this.filter(":hidden").each(function(){ this.style.display = this.oldblock || ""; if ( jQuery.css(this,"display") == "none" ) { var elem = jQuery("<" + this.tagName + " />").appendTo("body"); this.style.display = elem.css("display"); if (this.style.display == "none") this.style.display = "block"; elem.remove(); } }).end(); }, hide: function(speed,callback){ return speed ? this.animate({ height: "hide", width: "hide", opacity: "hide" }, speed, callback) : this.filter(":visible").each(function(){ this.oldblock = this.oldblock || jQuery.css(this,"display"); this.style.display = "none"; }).end(); }, _toggle: jQuery.fn.toggle, toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : fn ? this.animate({ height: "toggle", width: "toggle", opacity: "toggle" }, fn, fn2) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); }); }, slideDown: function(speed,callback){ return this.animate({height: "show"}, speed, callback); }, slideUp: function(speed,callback){ return this.animate({height: "hide"}, speed, callback); }, slideToggle: function(speed, callback){ return this.animate({height: "toggle"}, speed, callback); }, fadeIn: function(speed, callback){ return this.animate({opacity: "show"}, speed, callback); }, fadeOut: function(speed, callback){ return this.animate({opacity: "hide"}, speed, callback); }, fadeTo: function(speed,to,callback){ return this.animate({opacity: to}, speed, callback); }, animate: function( prop, speed, easing, callback ) { var optall = jQuery.speed(speed, easing, callback); return this[ optall.queue === false ? "each" : "queue" ](function(){ if ( this.nodeType != 1) return false; var opt = jQuery.extend({}, optall); var hidden = jQuery(this).is(":hidden"), self = this; for ( var p in prop ) { if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) return jQuery.isFunction(opt.complete) && opt.complete.apply(this); if ( p == "height" || p == "width" ) { opt.display = jQuery.css(this, "display"); opt.overflow = this.style.overflow; } } if ( opt.overflow != null ) this.style.overflow = "hidden"; opt.curAnim = jQuery.extend({}, prop); jQuery.each( prop, function(name, val){ var e = new jQuery.fx( self, opt, name ); if ( /toggle|show|hide/.test(val) ) e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); else { var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), start = e.cur(true) || 0; if ( parts ) { var end = parseFloat(parts[2]), unit = parts[3] || "px"; if ( unit != "px" ) { self.style[ name ] = (end || 1) + unit; start = ((end || 1) / e.cur(true)) * start; self.style[ name ] = start + unit; } if ( parts[1] ) end = ((parts[1] == "-=" ? -1 : 1) * end) + start; e.custom( start, end, unit ); } else e.custom( start, val, "" ); } }); return true; }); }, queue: function(type, fn){ if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) { fn = type; type = "fx"; } if ( !type || (typeof type == "string" && !fn) ) return queue( this[0], type ); return this.each(function(){ if ( fn.constructor == Array ) queue(this, type, fn); else { queue(this, type).push( fn ); if ( queue(this, type).length == 1 ) fn.apply(this); } }); }, stop: function(clearQueue, gotoEnd){ var timers = jQuery.timers; if (clearQueue) this.queue([]); this.each(function(){ for ( var i = timers.length - 1; i >= 0; i-- ) if ( timers[i].elem == this ) { if (gotoEnd) timers[i](true); timers.splice(i, 1); } }); if (!gotoEnd) this.dequeue(); return this; } }); var queue = function( elem, type, array ) { if ( !elem ) return undefined; type = type || "fx"; var q = jQuery.data( elem, type + "queue" ); if ( !q || array ) q = jQuery.data( elem, type + "queue", array ? jQuery.makeArray(array) : [] ); return q; }; jQuery.fn.dequeue = function(type){ type = type || "fx"; return this.each(function(){ var q = queue(this, type); q.shift(); if ( q.length ) q[0].apply( this ); }); }; jQuery.extend({ speed: function(speed, easing, fn) { var opt = speed && speed.constructor == Object ? speed : { complete: fn || !fn && easing || jQuery.isFunction( speed ) && speed, duration: speed, easing: fn && easing || easing && easing.constructor != Function && easing }; opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : { slow: 600, fast: 200 }[opt.duration]) || 400; opt.old = opt.complete; opt.complete = function(){ if ( opt.queue !== false ) jQuery(this).dequeue(); if ( jQuery.isFunction( opt.old ) ) opt.old.apply( this ); }; return opt; }, easing: { linear: function( p, n, firstNum, diff ) { return firstNum + diff * p; }, swing: function( p, n, firstNum, diff ) { return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; } }, timers: [], timerId: null, fx: function( elem, options, prop ){ this.options = options; this.elem = elem; this.prop = prop; if ( !options.orig ) options.orig = {}; } }); jQuery.fx.prototype = { update: function(){ if ( this.options.step ) this.options.step.apply( this.elem, [ this.now, this ] ); (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); if ( this.prop == "height" || this.prop == "width" ) this.elem.style.display = "block"; }, cur: function(force){ if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null ) return this.elem[ this.prop ]; var r = parseFloat(jQuery.css(this.elem, this.prop, force)); return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; }, custom: function(from, to, unit){ this.startTime = (new Date()).getTime(); this.start = from; this.end = to; this.unit = unit || this.unit || "px"; this.now = this.start; this.pos = this.state = 0; this.update(); var self = this; function t(gotoEnd){ return self.step(gotoEnd); } t.elem = this.elem; jQuery.timers.push(t); if ( jQuery.timerId == null ) { jQuery.timerId = setInterval(function(){ var timers = jQuery.timers; for ( var i = 0; i < timers.length; i++ ) if ( !timers[i]() ) timers.splice(i--, 1); if ( !timers.length ) { clearInterval( jQuery.timerId ); jQuery.timerId = null; } }, 13); } }, show: function(){ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); this.options.show = true; this.custom(0, this.cur()); if ( this.prop == "width" || this.prop == "height" ) this.elem.style[this.prop] = "1px"; jQuery(this.elem).show(); }, hide: function(){ this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); this.options.hide = true; this.custom(this.cur(), 0); }, step: function(gotoEnd){ var t = (new Date()).getTime(); if ( gotoEnd || t > this.options.duration + this.startTime ) { this.now = this.end; this.pos = this.state = 1; this.update(); this.options.curAnim[ this.prop ] = true; var done = true; for ( var i in this.options.curAnim ) if ( this.options.curAnim[i] !== true ) done = false; if ( done ) { if ( this.options.display != null ) { this.elem.style.overflow = this.options.overflow; this.elem.style.display = this.options.display; if ( jQuery.css(this.elem, "display") == "none" ) this.elem.style.display = "block"; } if ( this.options.hide ) this.elem.style.display = "none"; if ( this.options.hide || this.options.show ) for ( var p in this.options.curAnim ) jQuery.attr(this.elem.style, p, this.options.orig[p]); } if ( done && jQuery.isFunction( this.options.complete ) ) this.options.complete.apply( this.elem ); return false; } else { var n = t - this.startTime; this.state = n / this.options.duration; this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); this.now = this.start + ((this.end - this.start) * this.pos); this.update(); } return true; } }; jQuery.fx.step = { scrollLeft: function(fx){ fx.elem.scrollLeft = fx.now; }, scrollTop: function(fx){ fx.elem.scrollTop = fx.now; }, opacity: function(fx){ jQuery.attr(fx.elem.style, "opacity", fx.now); }, _default: function(fx){ fx.elem.style[ fx.prop ] = fx.now + fx.unit; } }; jQuery.fn.offset = function() { var left = 0, top = 0, elem = this[0], results; if ( elem ) with ( jQuery.browser ) { var parent = elem.parentNode, offsetChild = elem, offsetParent = elem.offsetParent, doc = elem.ownerDocument, safari2 = safari && parseInt(version) < 522, fixed = jQuery.css(elem, "position") == "fixed"; if ( elem.getBoundingClientRect ) { var box = elem.getBoundingClientRect(); add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)); add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop ); } else { add( elem.offsetLeft, elem.offsetTop ); while ( offsetParent ) { add( offsetParent.offsetLeft, offsetParent.offsetTop ); if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 ) border( offsetParent ); if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" ) fixed = true; offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent; offsetParent = offsetParent.offsetParent; } while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) { if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) ) add( -parent.scrollLeft, -parent.scrollTop ); if ( mozilla && jQuery.css(parent, "overflow") != "visible" ) border( parent ); parent = parent.parentNode; } if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) || (mozilla && jQuery.css(offsetChild, "position") != "absolute") ) add( -doc.body.offsetLeft, -doc.body.offsetTop ); if ( fixed ) add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)); } results = { top: top, left: left }; } function border(elem) { add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) ); } function add(l, t) { left += parseInt(l) || 0; top += parseInt(t) || 0; } return results; }; })(); window.widget_manager = null; $(document).ready( function () { window.widget_manager = new WidgetManager( window.widget_names ); if ( window.widget_roots && window.widget_roots.length > 0 ) { for ( var i in window.widget_roots ) { init_widgets( window.widget_roots[i] ); } } else { init_widgets( document.body ); } $( window ).unload( function () { window.widget_manager.stopAll(); } ); } ); function widget_save_redir( url ) { var n = window.widget_manager.stopAll(); var t = n > 0 ? 2000 : 1; setTimeout( function () { location.href = url; }, t ); } function init_widgets( context ) { var x = $( context ).get(0); x && window.widget_manager.startWidgets( x ); } function WidgetManager( widget_names ) { this.widgetNames = widget_names; this.currentWidgets = {}; this.allWidgets = {}; } WidgetManager.prototype.widgets = function ( name ) { return this.allWidgets[name]; }; WidgetManager.prototype.add = function ( name, w ) { this.allWidgets[name] = this.allWidgets[name] || []; this.allWidgets[name].push( w ); }; WidgetManager.prototype.find_all = function ( f, ws ) { ws = ws || ['editinplace','editatonce']; var rt = []; for ( var i in ws ) { var a = this.allWidgets[ws[i]] || []; for ( var j in a ) { if ( f( a[j] ) ) { rt.push( a[j] ); } } } return rt; }; WidgetManager.prototype.find = function ( f, ws ) { ws = ws || ['editinplace','editatonce']; for ( var i in ws ) { var a = this.allWidgets[ws[i]] || []; for ( var j in a ) { if ( f( a[j] ) ) { return a[j]; } } } return null; }; WidgetManager.prototype.current = function ( name ) { return this.currentWidgets[name]; }; WidgetManager.prototype.stopAll = function () { var count = 0; for ( var name in this.currentWidgets ) { var w = this.currentWidgets[name]; if ( w ) { if ( w.widgetBlur( name, null ) ) { count += 1; } } } return count; }; WidgetManager.prototype.stop = function ( name ) { var w = this.currentWidgets[name]; w && w.widgetBlur( name, null ); }; WidgetManager.prototype.widgetFocus = function ( name, obj ) { for ( i in this.currentWidgets ) { var w = this.currentWidgets[i]; w.widgetBlur && w.widgetBlur( name, obj ); } this.currentWidgets[name] = obj; }; WidgetManager.prototype.startWidgets = function ( root ) { var stack = [root]; var names = this.widgetNames; var names_do = {}; for ( var i in names ) { names_do['do_' + names[i]] = names[i]; } while ( stack.length > 0 ) { var e = stack.pop(); if ( e.className && e.className.match( /do_[a-z_]+/ ) ) { var clsss = e.className.match( /do_[a-z_]+/g ); for ( var i = 0; i < clsss.length; i++ ) { var w = names_do[clsss[i]]; if ( w ) { eval("init_" + w + "( e )"); } } } if ( e.childNodes ) { for ( var i = 0 ; i < e.childNodes.length ; i++ ) { if ( e.childNodes[i].nodeType != 3 ) { stack.unshift( e.childNodes[i] ); } } } } var ends = ['editinplace','editatonce']; for ( var i in ends ) { if ( jQuery.inArray( names, ends[i] ) > -1) { eval( 'end_' + ends[i] + '()' ); } } }; function validate_field2id ( name ) { name = name.replace( /\./g, "_" ); return 'required_fields_li_' + name; } function validate_cmpfield ( l ) { return function ( x ) { return jQuery.inArray( l, x.options.ajax.field ) > -1; } } function validate_goto ( i ) { var e = window.widget_manager.find( validate_cmpfield( [i] ) ); if ( e ) { var p = jQuery.getPosition( e.container ); scroll( 0, p.y - 100 ); } } function validate_update () { if ( jQuery.isEmptyObject( window.required_fields ) ) { $( "#required_fields_main" ).hide(); $( "#required_fields_other" ).show(); return; } $( "#required_fields_main" ).show(); $( "#required_fields_other" ).hide(); var fs = window.required_fields; var ul = $( "#required_fields_list" ).get( 0 ); ul.innerHTML = ''; var bind_click = function ( li, i ) { var fu = function ( x ) { return x.options.ajax.field == i; }; var e = window.widget_manager.find( fu ); if ( e && e.options ) { var c = e.options.callback; c = c || function () {}; var fc = function ( d ) { delete( window.required_fields[i] ); validate_update(); c && c( d ); } e.options.callback = fc; $( li ).bind( "click", function () { validate_goto( i ); return false; } ); } }; var gs = jQuery.objKeys( fs ); var fu = validate_cmpfield( gs ); var ws = window.widget_manager.find_all( fu ); for ( var i in ws ) { ws[i].addRequiredClass(); } for ( var i in fs ) { var li = document.createElement( "li" ); var an = document.createElement( "a" ); li.id = validate_field2id( i ); li.className = "required_field_title"; an.href='#'; $( an ).html( fs[i] ); $( li ).append( an ); $( ul ).append( li ); bind_click( an, i ); } } function apply_options( docs, o ) { for ( var i in docs ) { var d = docs[i]; var ds = d[0].split('.'); if ( ds.length > 1 ) { o[ds[0]][ds[1]] = o[ds[0]][ds[1]] || d[1]; } else { o[d[0]] = o[d[0]] || d[1]; } } return o; } function identity ( x ) { return x; } jQuery.fn.opacity = function ( v ) { this.css('opacity', v ); if ( jQuery.browser.msie ) { this.css('filter', 'alpha(opacity=' + v * 100 + ')'); } } jQuery.extend( { objKeys: function ( obj ) { var ret = []; for ( var i in obj ) { ret.push( i ); } return ret; }, label: function ( path, def ) { var names = path.split('.'); var tmp = window.labels; while ( names.length > 0 && tmp ) { tmp = tmp[names.shift()]; } return tmp || def; }, createCookie: function ( name, value, days ) { if ( days ) { var date = new Date(); date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) ); var expires = "; expires=" + date.toGMTString(); } else { var expires = ""; } document.cookie = name + "=" + value+expires + "; path=/"; }, readCookie: function ( name ) { var nameEQ = name + "="; var ca = document.cookie.split( ';' ); for ( var i = 0 ; i < ca.length ; i++ ) { var c = ca[i]; while ( c.charAt(0) == ' ' ) { c = c.substring( 1, c.length ); } if ( c.indexOf( nameEQ ) == 0 ) { return c.substring( nameEQ.length, c.length ); } } return null; }, eraseCookie: function( name ) { jQuery.createCookie( name, "", -1 ); }, log: function () { if ( window.console && window.console.log && window.console.assert ) { window.console.log( arguments ); } }, warn: function( where , what ) { if ( !what ) { what = "You cannot edit this now."; } alert( where + ': ' + what ); jQuery.log( arguments ); }, error: function ( msg , url , line ) { alert( msg + " @ " + url + " @ " + line ); return false; }, xparam: function ( params ) { var res = []; for ( var i in params ) { if ( params[i].constructor == Array ) { for ( var j = 0 ; j < params[i].length ; j++ ) { res.push( i + '[' + j + ']=' + encodeURIComponent( params[i][j] ) ); } } else if ( params[i].constructor == Object ) { for ( var j in params[i] ) { res.push( i + '[' + j + ']=' + encodeURIComponent( params[i][j] ) ); } } else { res.push( i + '=' + encodeURIComponent( params[i] ) ); } } return res.join( '&' ); }, windowSize: function () { var p = { w: 0, h: 0 }; var e = document.documentElement; var b = document.body; if ( typeof( window.innerWidth ) == 'number' ) { p.w = window.innerWidth; p.h = window.innerHeight; } else if( e && ( e.clientWidth || e.clientHeight ) ) { p.w = e.clientWidth; p.h = e.clientHeight; } else if( b && ( b.clientWidth || b.clientHeight ) ) { p.w = b.clientWidth; p.h = b.clientHeight; } return p; }, mousePosition: function ( ev ) { ev = ev || window.event; var x = 0, y = 0; if ( ev.pageX || ev.pageY ) { x = ev.pageX; y = ev.pageY; } else if ( ev.clientX || ev.clientY ) { x = ev.clientX + document.body.scrollLeft; y = ev.clientY + jQuery.pageScrollTop(); //document.body.scrollTop; } return { "x": x, "y": y }; }, mouseInWindow: function ( e ) { var ret = {}; if ( !e ) { var e = window.event; } if ( e.clientX || e.clientY ) { ret.x = e.clientX - Math.max( 0 , document.body.scrollLeft ); ret.y = e.clientY - Math.max( 0 , document.body.scrollTop ); // document.body.scrollTop*/ + document.documentElement.scrollTop; } return ret; }, assocMergeInto: function ( r , a ) { if ( a ) { for( var i in a ) { r[i] = a[i]; } } return r; }, assocMerge: function ( a , b ) { return jQuery.assocMergeInto( jQuery.assocMergeInto( {}, a ), b ); }, dateFormat: function ( format , date ) { format = format.replace( /\%Y/ , date.getFullYear() ); format = format.replace( /\%m/ , date.getMonth() + 1 ); format = format.replace( /\%d/ , date.getDate() ); format = format.replace( /\%H/ , date.getHours() ); format = format.replace( /\%M/ , date.getMinutes() ); return format; }, remFromQuery: function ( url , name ) { var reg = new RegExp( '&?' + name + '=[^&]*' ); url = url.replace( reg, '' ); return url; }, addToQuery: function ( url , data ) { return url + ( url.match( /\?/ ) ? '&' : '?' ) + data; }, attrOptions: function ( e , name ) { var a = e.getAttribute( name ) || ''; a = a.replace( /,\s*$/ , '' ); eval( "var tmp = {" + a + "}" ); return tmp; }, pageScrollTop: function () { var pos = jQuery.getScroll(); return pos.y; }, getScroll: function () { var p = {x: 0, y: 0}; var e = document.documentElement; var b = document.body; if ( e && ( e.scrollLeft || e.scrollTop ) ) { p.x = e.scrollLeft; p.y = e.scrollTop; } else if ( b && ( b.scrollLeft || b.scrollTop ) ) { p.x = b.scrollLeft; p.y = b.scrollTop; } else if ( window.pageXOffset || window.pageYOffset ) { p.x = window.pageXOffset; p.y = window.pageYOffset; } else if( window.scrollX || window.scrollY ) { p.x = window.scrollX; p.y = window.scrollY; } return p; }, getPosition: function ( obj, ignoreRelative ) { ignoreRelative = ignoreRelative || false; var curleft = curtop = 0; if ( false && jQuery.browser.msie ) { var childImg = false; for ( var i in obj.childNodes ) { childImg = childImg || obj.childNodes[i].tagName == 'IMG'; } if ( childImg ) { curleft -= obj.offsetLeft; } } while ( obj ) { if ( !ignoreRelative || jQuery( obj ).css('position') != "relative" ) { curleft += obj.offsetLeft; curtop += obj.offsetTop; } obj = obj.offsetParent; } return { x: curleft, y: curtop }; }, getSize : function(e) { var w = jQuery.css(e,'width'); var h = jQuery.css(e,'height'); var wb = 0; var hb = 0; es = e.style; if ( jQuery(e).css('display') != 'none' ) { wb = e.offsetWidth; hb = e.offsetHeight; } else { oldVisibility = es.visibility; oldPosition = es.position; es.visibility = 'hidden'; es.display = 'block'; es.position = 'absolute'; wb = e.offsetWidth; hb = e.offsetHeight; es.display = 'none'; es.position = oldPosition; es.visibility = oldVisibility; } return { w:w, h:h, wb:wb, hb:hb }; }, elemInWindow: function ( o ) { var oLeft = o.offsetLeft; var oTop = o.offsetTop; while( o.offsetParent != null ) { oParent = o.offsetParent; // Get parent object reference oLeft += oParent.offsetLeft; // Add parent left position oTop += oParent.offsetTop; // Add parent top position o = oParent; } return { l: oLeft , t: oTop }; }, validateForm: function ( frm , alrt ) { if ( document.getElementById( frm ) ) { var f = document.getElementById( frm ); } else if ( document.forms[ frm ] ) { var f = document.forms[ frm ]; } else { f = frm; } if ( alrt == 'null' ) { alrt = 'All fields are required'; } var isValid = true; var vFormElems = new Array(); for ( i = 0 ; i < f.elements.length ; i++ ) { elem = f.elements[i]; vCode = ( elem['alt'] ) ? elem['alt'] : elem.getAttribute('alt'); if ( !( typeof vCode == 'undefined' || vCode == null || vCode == "" ) ) { if ( jQuery.inArray( vFormElems, elem.name ) > -1) { break; } else { v = jQuery.getValue( f.elements[elem.name] ); if ( vCode == 'required' && v.length < 1 ) { isValid = false; } vFormElems[i] = elem.name; } } } if (!isValid) { alert( alrt ); } return isValid }, getValue: function ( ffield , def ) { v = ''; t = ffield.type; if( !t ) { t = ffield[0].type; } if( t == 'checkbox' ) { if( ffield.length ) { for( gv_i=0 ; gv_i < ffield.length ; gv_i++ ) { if ( ffield[gv_i].checked ) { v = ffield[gv_i].value; } } } else { if ( ffield.checked ) { v = ffield.value; } } } else if ( t == 'file' ) v = ffield.value; else if ( t == 'hidden' ) v = ffield.value; else if ( t == 'password' ) v = ffield.value; else if ( t == 'radio' ) { if ( ffield.length ) { for ( gv_i=0 ; gv_i < ffield.length ; gv_i++) { if ( ffield[gv_i].checked ) v = ffield[gv_i].value; } } else { if ( ffield.checked ) v = ffield.value; } } else if (t == 'select-multiple' ) v = ffield.options[ffield.selectedIndex].value; else if (t == 'select-one' ) v = ffield.options[ffield.selectedIndex].value; else if (t == 'text' ) v = ffield.value; else if (t == 'textarea' ) v = ffield.value; if (def != null && v == '') { return def; } return v; }, byId: function ( id , doc ) { if ( typeof id == "string" || id instanceof String ) { if ( !doc ) { doc = document; } return doc.getElementById ( id ); } return id; }, textContent: function ( node ) { var _result = ""; if (node == null) { return _result; } for (var i = 0; i < node.childNodes.length; i++) { switch (node.childNodes[i].nodeType) { case 1: // ELEMENT_NODE case 5: // ENTITY_REFERENCE_NODE _result += jQuery.textContent(node.childNodes[i]); break; case 3: // TEXT_NODE case 2: // ATTRIBUTE_NODE case 4: // CDATA_SECTION_NODE _result += node.childNodes[i].nodeValue; break; default: break; } } return _result; }, isEmailAddress: function ( v ) { mailvalid = true; if ( v.indexOf ( '@' ) < 1 ) { mailvalid = false; } else if ( v.lastIndexOf ( '.' ) < v.indexOf ( '@' ) ) { isvalid = false; } aapje = v.indexOf( '@' ); puntje = v.indexOf( '.' ); if ( puntje - aapje == 1 ) { mailvalid = false; } return mailvalid; }, isSizeSmaller: function ( v , size ) { if ( v.length < size ) { return true; } else { return false; } }, isSizeGreater: function ( v , size ) { if ( v.length > size ) { return true; } else { return false; } }, showHide: function (str) { a = str.split(','); for ( var i = 0 ; i < a.length ; i++ ) { s = a[i]; c = s.charAt(0); v = 'block'; if (c == '-') { v = 'none'; s = s.substr( 1 , s.length-1); } else if ( c == '+') { s = s.substr( 1 , s.length - 1 ); } if ( $( "#" + s ) ) { $("#" + s).css( 'display', v ); } } }, hideAllBut: function ( a, b ) { if ( jQuery.isObject( a ) ) { for ( var p in a ) { $( "#" + a[p] ).hide(); } } else if ( jQuery.isArray(a) ) { for ( i = 0 ; i < a.length ; i++ ) { $( "#" + a[i] ).hide(); } } else if ( jQuery.isString( a ) ) { var d = document.getElementsByTagName( 'div' ); for( i = 0 ; i < d.length ; i++ ) { var l = a.length; var id = d[i].id; if ( id.substring( 0 , l ) == a ) { $( "#" + d[i].id ).hide(); } } } if ( jQuery.isArray( b ) ) { for ( i = 0 ; i < a.length ; i++) { $( "#" + b[i] ).show(); } } else if ( jQuery.isString( b ) ) { $( "#" + b ).show(); } }, popup: function ( thg_id, o, l, t, w, h ) { if ( l == null ) l = 100; if ( t == null ) t = 100; if ( w == null ) w = 400; if ( h == null ) h = 400; var aPopupWin = window.open( '', 'PopupWin', 'scrollbars=yes,menubar=no,location=no,directories=no,statusbar=no,toolbar=no,resizable=yes,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l ); aPopupWin.document.open(); aPopupWin.document.close(); order = ''; if ( o != null ) order = '&order='+o; var p = 'popup.php?id=' + thg_id + order; aPopupWin.document.location.href = p; if( aPopupWin && !aPopupWin.closed ) { aPopupWin.focus(); } }, resizePopup: function() { var mw = 400; if ( parseInt( navigator.appVersion.charAt( 0 ) ) >= 4 ) { NN = ( navigator.appName=="Netscape" ) ? 1 : 0; } if ( document.images[0] ) { ww = ( screen.width ); wh = ( screen.height ); if (NN) { rw = document.images[0].width + 80; rh = document.images[0].height; if ( ww < rw ) rw = ww; if ( rw < mw ) rw = mw; if ( wh < rh ) rh = wh; if ( rh < wh - 140 ) rh = rh + 160; window.top.innerWidth = rw; window.top.innerHeight = rh; } else { rw = document.images[0].width + 80; rh = document.images[0].height; if ( ww < rw ) rw = ww; if ( rw < mw ) rw = mw; if ( wh < rh ) rh = wh; if ( rh < wh - 140 ) rh = rh + 160; window.top.resizeTo( rw, rh ); } parent.window.moveTo( ( screen.width - rw ) / 2, ( screen.height - rh ) / 2 ); } }, isAlien: function ( a ) { return jQuery.isObject(a) && typeof a.constructor != 'function'; }, isArray: function ( a ) { return jQuery.isObject(a) && a.constructor == Array; }, isBoolean: function ( a ) { return typeof a == 'boolean'; }, isEmptyObject: function ( o ) { for ( var i in o ) { return false; } return true; }, isEmpty: function(o) { var i, v; if (jQuery.isObject(o)) { for (i in o) { v = o[i]; if (jQuery.isUndefined(v) && jQuery.isFunction(v)) { return false; } } } return true; }, isFunction: function ( a ) { return typeof a == 'function'; }, isNull: function ( a ) { return typeof a == 'object' && !a; }, isNumber: function ( a ) { return typeof a == 'number' && isFinite(a); }, isObject: function ( a ) { return (a && typeof a == 'object') || jQuery.isFunction(a); }, isString: function ( a ) { return typeof a == 'string'; }, isUndefined: function ( a ) { return typeof a == 'undefined'; }, isDomElement: function ( a ) { return a && typeof a == 'object' && !jQuery.isUndefined(a.childNodes); } }); function AjaxNotice( sel ) { this.sel = sel; } AjaxNotice.prototype.start = function ( text ) { if ( text == '...' ) { text = ''; } text && notice_corner_show( text ); $( this.sel ).addClass( 'ajax_notice' ); } AjaxNotice.prototype.stop = function () { notice_corner_hide(); $( this.sel ).removeClass( 'ajax_notice' ); } window.notice_corner_count = 0; function notice_corner_show ( text ) { window.notice_corner_count += 1; var x = document.getElementById( 'corner_notice' ); if ( !x ) { x = document.createElement( 'div' ); x.id = 'corner_notice'; $( document.body ).append( x ); } $( x ).html( text ); $( x ).show(); window.notice_corner_time = (new Date()).getTime(); } function notice_corner_hide () { window.notice_corner_count -= 1 if ( window.notice_corner_count > 0 ) { return; } else { window.notice_corner_count = 0; } var now = (new Date()).getTime(); var dif = now - window.notice_corner_time; if ( dif > 1000 ) { $( '#corner_notice' ).hide(); } else { setTimeout( function () { notice_corner_hide(); }, dif ); } } function docs_validate() { var lm = jQuery.label( 'editinplace.validate.msg' , 'Please input a valid value' ); var lo = jQuery.label( 'editinplace.validate.out' , 'Value out of range' ); return { opts: [[ "validate", {}, "Input format validation" ] ,[ "validate.regexp", null, "Regular expression to validate format" ] ,[ "validate.name", null, "Name of predefined regular expression [integer|float]" ] ,[ "validate.msg", lm, "Alert message to be displayed in case of wrong format" ] ,[ "validate.min", null, "Minimum allowed value" ] ,[ "validate.max", null, "Maximum allowed value" ] ,[ "validate.empty", false, "Input value is allowed to be empty" ] ,[ "validate.blank", false, "Input value is allowed to be empty/whitespace" ] ,[ "validate.out", lo, "Alert message to be displayed in case of out of range number" ] ] }; } function Validate( opts ) { this.opts = opts; if ( "integer" == this.opts.name ) { this.opts.msg = jQuery.label( 'editinplace.validate.integer' , 'Please input an integer number' ); this.opts.regexp = /^\s*[-+]?\d+\s*$/; } else if ( "float" == this.opts.name ) { this.opts.msg = jQuery.label( 'editinplace.validate.float' , 'Please input a number' ); this.opts.regexp = /^\s*[-+]?\d+(\.\d+)?\s*$/; } } Validate.prototype.range = function ( value ) { var fs = {'integer': parseInt, 'float': parseFloat}; var f = fs[this.opts.name] || identity; value = f( value ); return !( this.opts.min && this.opts.min > value || this.opts.max && this.opts.max < value ); } Validate.prototype.value = function ( value ) { return ( this.opts.blank && value.match( /^\s*$/ ) ) || ( this.opts.empty && value == '' ) || ( this.opts.regexp && this.opts.regexp.exec( value ) ) || ( !this.opts.regexp ); } window.handlingOnError = false; window.handledErrors = []; function anyOnError( msg , url , line ) { var exclude = [ "uncaught exception: Permission denied to get property HTMLInputElement.parentNode" , "uncaught exception: Permission denied to get property HTMLDivElement.parentNode" ]; for ( var i in exclude ) { if ( exclude[i] == msg ) { jQuery.log( "Error belongs to blacklist, won't report it." ); return true; } } for ( var i in window.handledErrors ) { if ( window.handledErrors[i] == msg ) { jQuery.log( "Error already reported once on this session" ); return true; } } if ( window.handlingOnError ) { jQuery.log( "Trying to report an error while already busy reporting another one" ); return false; } window.handlingOnError = true; jQuery.log( "Reporting error: " + msg ); window.handledErrors.push( msg ); var params = {}; params.msg = msg; params.pageurl = location.href; params.scripturl = url; params.linenumber = line; params.referrer = document.referrer; anyRest.error.log( params , function ( xml ) { jQuery.log( 'Error was reported!' ); window.handlingOnError = false; } ); return false; } function rebuild_scp ( ops, xml ) { var dom_id = ops.dom_id; var file = ops.file; var thg_id = ops.rebuild_scp_thg_id || self.options.id; if ( dom_id == null || file == null || thg_id == null ) { jQuery.log('rebuild_scp - please use all parameters: dom_id, file, thg_id'); } else { var scomp_options = jQuery.assocMerge( ops.extra, { 'name': file, 'thg_id': thg_id } ); anyRest.html.scomp ( scomp_options , function ( xml ) { if (anyRest.aux.error(xml)) { jQuery.log(anyRest.aux.errorMsg(xml)); } else { var ts = xml.getElementsByTagName( 'html' )[0]; x = document.getElementById( dom_id ); if ( ts && x ) { var v = anyRest.aux.concatChildNodes( ts ); $( x ).after ( v ).remove(); y = document.getElementById( dom_id ); init_widgets( y ); } else { jQuery.log('Internal error: did not get a template from the server or no dom id. Sorry...'); } } } ); } } function anyGetComputedStyle( node , cssSelector , inValue ) { var cssSelector = toSelectorCase( cssSelector ); var property = toCamelCase( cssSelector ); if( !node || !node.style ) { return inValue; } else if ( document.defaultView && isDescendantOf( node, node.ownerDocument ) ) { // W3, gecko, KHTML try { var cs = document.defaultView.getComputedStyle( node , "" ); if ( cs ) { return cs.getPropertyValue( cssSelector ); } } catch( e ) { // reports are that Safari can throw an exception above if ( node.style.getPropertyValue ) { // W3 return node.style.getPropertyValue( cssSelector ); } else { return inValue; } } } else if ( node.currentStyle ) { // IE return node.currentStyle[property]; } if ( node.style.getPropertyValue ) { // W3 return node.style.getPropertyValue( cssSelector ); } else { return inValue; } } function toSelectorCase( selector ) { return selector.replace(/([A-Z])/g, "-$1" ).toLowerCase(); } function toCamelCase ( selector ) { var arr = selector.split('-'), cc = arr[0]; for ( var i = 1 ; i < arr.length ; i++ ) { cc += arr[i].charAt( 0 ).toUpperCase() + arr[i].substring( 1 ); } return cc; } function isDescendantOf( node, ancestor, guaranteeDescendant ) { if( guaranteeDescendant && node ) { node = node.parentNode; } while( node ) { if ( node == ancestor ) { return true; } node = node.parentNode; } return false; } function validate_hex( s ) { s = s.replace( /#/, '' ); var h3 = s.match(/[a-fA-F0-9]{3}/); if ( h3 ) { var a = ""; for ( var i = 0; i < 3; i++ ) { var c = s.slice(i,i+1); a += c + c; } s = a; } return s; } function parse_dec_a( elem, stl ) { var stl = stl || 'background-color'; var color = anyGetComputedStyle( elem, stl ); if ( color == 'transparent' ) { color = ''; } else { var ff_fr = ffrgb_s2dec_a( color ); if ( ff_fr || ff_fr == 'transparent' ) { color = ff_fr; } else { color = validate_hex( color ); color = hex_s2dec_a( color ); } } return color; } function ffrgb_s2dec_a( x ) { var a = null; var m = x.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/); if ( m ) { a = []; for ( var i = 1; i < 4 ; i++ ) { a.push( parseInt( m[i] ) ); } } return a; } function throb( selector, color_example ) { var elem = $( selector ).get( 0 ); var exmp = $( color_example ).get( 0 ); if ( !elem || !exmp ) { jQuery.log( 'throb: did not receive the correct arguments' ); return; } var frcolor = parse_dec_a( elem ); var tocolor = parse_dec_a( exmp ); if ( !frcolor || !tocolor ) { jQuery.log( 'throb: color values not parseable' ); return; } var start = (new Date()).getTime(); var total = 5000; var anim = function () { var diff = (new Date()).getTime() - start; if ( diff > total ) { elem.style.backgroundColor = '#' + dec_a2hex_s( frcolor ); } else { var x = []; var f = diff / total; var g = ( Math.cos(6 * Math.PI * f + Math.PI) + 1 ) / 2; for ( var i = 0; i < 3; i++ ) { x[i] = Math.floor( g * tocolor[i] + (1 - g) * frcolor[i] ) } elem.style.backgroundColor = '#' + dec_a2hex_s( x ); } }; setInterval( anim, 20 ); } function mysqlDatetimeToDate ( datetime ) { var regex = /^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/; var parts = datetime.replace( regex, "$1 $2 $3 $4 $5 $6" ).split( ' ' ); return new Date( parts[0], parts[1] - 1, parts[2], parts[3], parts[4], parts[5] ); } function showDateRelative( date, now ) { now = now || new Date(); var prefix = ''; if ( date.getFullYear() != now.getFullYear() || date.getMonth() != now.getMonth() || date.getDay() != now.getDay() ) { prefix = '' + date.getFullYear() + '/' + ( date.getMonth() + 1 ) + '/' + date.getDate() + ' '; } return prefix + lpad( date.getHours(), 2, '0' ) + ':' + lpad( date.getMinutes(), 2, '0' ); } function lpad( s, n, c ) { s = '' + s; while ( s.length < n ) { s = c + s; } return s } function dec_a2hex_s( a ) { var x = ''; for ( var i in a ) { x += lpad( dec2hex( a[i] ), 2, '0' ); } return x; } function hex_s2dec_a( s ) { var r = []; for ( var i = 0; i <= 4; i += 2 ) { r.push( hex2dec( s.slice( i, i + 2 ) ) ); } return r; } function dec2hex( x ) { x = parseInt( x ); var m = 16; var s = ''; while ( x > 0 ) { r = x % m; r = r > 9 ? "abcdef".slice( r-10, r-9 ) : '' + r; s = r + s; x = Math.floor( x / m ); } return s; } function hex2dec( x ) { x = '' + x; x = x.toLowerCase(); s = "0123456789abcdef"; n = 0; for ( var i = 0; i < x.length; i++ ) { n = n * 16 + s.indexOf( x.slice(i,i+1) ); } return n; } function implode( arr, sep ) { var ret = '' for ( var i = 0; i < arr.length; i++ ) { ret += ( i > 0 ? sep : '' ) + arr[i]; } return ret; } function strip( str ) { str = str || ''; str = str.replace( /^\s+/g, "" ); str = str.replace( /\s+$/g, "" ); return str; } var anyRest = { 'aux': { 'items': function ( xml ) { var rsp = xml.getElementsByTagName( 'rsp' )[0]; var rst = []; for ( var i = 0 ; i < rsp.childNodes.length ; i++ ) { if ( rsp.childNodes[i].tagName == 'item' ) { rst.push( rsp.childNodes[i] ); } } return rst; }, 'status': function ( xml ) { var rsp = xml.getElementsByTagName( 'rsp' ); return rsp[0].getAttribute( 'stat' ); }, 'error': function ( xml ) { return ( anyRest.aux.status( xml ) != 'ok' ); }, 'errorMsg': function ( xml ) { var es = xml.getElementsByTagName( 'err' ); return es[0] ? es[0].getAttribute( 'msg' ) : ''; }, 'skeleton': function ( type , params , callback ) { params.format = params.format || "xml"; callback = callback || function ( _ ) {}; var opts = { "type": type, "url": "http://www.mediamatic.nl/services/rest/" }; if ( type == 'GET' ) { opts.url += '?' + jQuery.xparam( params ); } if ( type == 'POST' ) { opts.data = jQuery.xparam( params ); } opts.success = function restSuccess ( data ) { callback( data ); } jQuery.ajax( opts ); } } }; anyRest.aux.concatChildNodes = function ( xmldom ) { var str = ''; for ( var i = 0; i < xmldom.childNodes.length ; i++ ) { str += xmldom.childNodes[i].nodeValue; } return str; }; var batch = [ ['anymeta.','POST', ['edge.attribute.get' ,'edge.attribute.set' ,'edge.add' ,'edge.remove' ,'edge.order' ,'edge.addList' ,'error.log' ,'tags.add' ,'predicates.get' ,'predicates.set' ,'user.check' ]], ['','POST', ['contact.add' ,'contact.change' ,'contact.remove' ]], ['','POST', ['jury.accuse' ]], ['anymeta.','GET', ['html.template' ,'html.scomp' ,'search.live' ]]] for ( var i in batch ) { var prefix = batch[i][0]; var http_method = batch[i][1]; var lis = batch[i][2]; for ( var j in lis ) { var words = lis[j].split('.'); var tmp = anyRest; for ( var k = 0; k < words.length - 1; k++ ) { if ( !tmp[words[k]] ) { tmp[words[k]] = {}; } tmp = tmp[words[k]]; } tmp[words[words.length-1]] = makeRestMethod( http_method, prefix + lis[j] ); } } function makeRestMethod( http_method, rest_method ) { return function ( params, callback ) { params.method = rest_method; anyRest.aux.skeleton( http_method, params, callback ); } } anyRest.service = function ( name, opts, callback ) { opts.method = name; anyRest.aux.skeleton( 'POST' , opts , callback ); }; anyRest.call = function ( opts, callback ) { anyRest.aux.skeleton( 'POST' , opts , callback ); }; anyRest.post = function ( name, opts, callback ) { opts.method = name; anyRest.aux.skeleton( 'POST' , opts , callback ); }; anyRest.get = function ( name, opts, callback ) { opts.method = name; anyRest.aux.skeleton( 'GET' , opts , callback ); }; function init_menu( container, context ) { context = context || document.body; $( container, context ).each( function () { var opts = jQuery.attrOptions( this , "menu" ); new Menu( this, opts ); } ); } function docs_menu() { var a = "Dynamic cascading menu item. Notes: ULs and LIs margin values are set to 0. LIs get display: block."; var e = [ ['
    \n
  • A.root\n\t
      \n\t
    • A.1
    • \n\t
    • A.2
    • \n\t
    \n
  • \n
  • B.root\n\t
      \n\t
    • B.1
    • \n\t
    \n
  • \n
', "Vertical menu"], ['
\n
    \n
  • A.root\n\t
      \n\t
    • A.1
    • \n\t
    • A.2
    • \n\t
    \n
  • '+ '\n
\n
\n
    \n
  • B.root\n\t
      \n\t
    • B.1\n\t\t
        \n\t\t'+ '
      • B.1.1
      • \n\t\t
      • B.1.2
      • \n\t\t
      \n\t
    • \n\t
    \n
  • \n
\n\n
', "Horizontal menu"] ]; var c = []; var o = [[ "width", 130, "Width of menu elements" ] ,[ "orientation", 'down', "If the first menus should go down instead of right [down,right]" ] ,[ "timeout", 500, "Milliseconds until the menu disappears after mouseout" ] ]; return { 'examples': e, 'about': a, 'opts': o, 'classes': c }; } function opts_menu( o ) { return apply_options( docs_menu().opts, o ); } function Menu( container, opts ) { opts = opts_menu( opts ); this.container = container; this.opts = opts; this.zindex = 10; this.timeout_lis = []; $( container ).css("margin-top","0px"); var lis = $( "li" , container ); var self = this; lis.each( function () { self.li( this ); } ); } Menu.prototype.li_show = function ( li, liuls ) { for ( var i = 0; i < this.timeout_lis.length; i++ ) { this.li_hide_now( this.timeout_lis[i] ); } this.timeout_lis = []; li.timeout_hide && clearTimeout( li.timeout_hide ); $( "> ul > li", li ).css({ "display": "block", "margin": "0px" }); $( li ).addClass( 'menu_selected' ); if ( !li.positioned ) { var siz = jQuery.getSize( li ); if ( li.parentNode.style.position == "absolute" ) { var l = siz.w; var t = 0; } else { var pos = jQuery.getPosition( li, true ); if ( this.opts.orientation == 'down' ) { var l = pos.x; var t = pos.y + siz.h; } else { var w = this.opts.width || siz.w; var l = pos.x + w; var t = pos.y; } } liuls.css({ "display": "block", "margin": "0px", "position": "absolute", "width" : this.opts.width + "px", "left": l + "px", "top": t + "px", "z-index": (this.zindex += 10) }); li.positioned = true; } liuls.css( "display", "block" ); }; Menu.prototype.li_hide_now = function ( li ) { $( li ).removeClass( "menu_selected" ); $( "> ul" , li ).hide(); }; Menu.prototype.li_hide = function ( li ) { $( li ).removeClass( "menu_selected" ); this.timeout_lis.push( li ); var self = this; li.timeout_hide = setTimeout( function () { self.li_hide_now( li ); }, this.opts.timeout ); }; Menu.prototype.li = function ( li ) { var liuls = $( "> ul" , li ); liuls.css("display","none"); var self = this; $( li ).hover( function () { self.li_show( this, liuls ); }, function () { self.li_hide( this ); } ); }; window.tooltip_count = 0; window.tooltip_current = null; function init_tooltip ( container, context ) { context = context || document.body; $( container, context ).each( function () { var opts = jQuery.attrOptions( this , 'tooltip' ); new Tooltip( this, opts ); } ); } function docs_tooltip() { var a = 'Mouse-pivoted tooltip that behaves intelligently against screen limits'; var e = [[ '', "simple popup using a custom div id" ] ,[ '', "custom width and timeouts" ] ]; var c = []; var o = [ [ 'html' , '', 'The html to be injected into the tooltip div' ] , [ 'dom_id' , '', 'Id of element (on page) to be injected into the tooltip div' ] , [ 'id' , 'tooltip', 'Id of the tooltip div (existing, or to be created)' ] , [ 'width' , '250px', 'Width of the tooltip' ] , [ 'offx' , 10, 'Horizontal distance from the mouse pointer' ] , [ 'offy' , 5, 'Vertical distance from the mouse pointer' ] , [ 'timeout' , 500, 'Number of milliseconds before tooltip disappears' ] ]; return { 'examples': e, 'about': a, 'opts': o, 'classes': c }; } function opts_tooltip( o ) { return apply_options( docs_tooltip().opts, o ); } function Tooltip( container, options ) { options = opts_tooltip( options ); this.options = options; this.container = container; this.addEvents( container, true ); } Tooltip.prototype.addEvents = function ( dom, isMain ) { var self = isMain ? this : window.tooltip_current; $( dom ).bind( 'mousemove', function ( e ) { self.show( isMain ? e : null ); } ).bind( 'mouseout', function ( e ) { self.hide(); } ); }; Tooltip.prototype.layout = function ( ev ) { var w = jQuery.windowSize(); var p = jQuery.mousePosition( ev ); var sY = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; if ( sY > 0 ) { if ( jQuery.browser.msie ) { if ( p.x + this.tip.clientWidth + 30 > w.w ) { this.tip.style.left = sY + p.x - this.options.offx - this.tip.clientWidth + 'px'; } else { this.tip.style.left = sY + p.x - this.options.offx + 'px'; } } else { if ( p.x < sY + this.tip.clientWidth ) { this.tip.style.left = p.x - this.options.offx + 'px'; } else if ( p.x + this.tip.clientWidth + 30 - sY > w.w ) { this.tip.style.left = p.x - this.options.offx - this.tip.clientWidth - 10 + 'px'; } else { this.tip.style.left = p.x - this.options.offx + 'px'; } } } else if ( p.x + this.tip.clientWidth + 30 > w.w ) { this.tip.style.left = w.w - this.options.offx - this.tip.clientWidth - 10 + 'px'; } else { this.tip.style.left = p.x + this.options.offx + 'px'; } if ( p.y + this.tip.clientHeight + 30 > w.h + jQuery.pageScrollTop() ) { this.tip.style.top = p.y - this.options.offy - this.tip.clientHeight + 'px'; } else { this.tip.style.top = p.y + this.options.offy + 'px';; } }; Tooltip.prototype.show = function ( ev ) { if ( this.options.html || ( this.options.dom_id && document.getElementById( this.options.dom_id ) ) ) { window.tooltip_current && window.tooltip_current.hide(); window.tooltip_current = this; window.tooltip_count += 1; var tip = document.getElementById( this.options.id ); if ( !tip ) { tip = document.createElement( 'div' ); tip.id = this.options.id; $( document.body ).append( tip ); this.addEvents( tip, false ); } $( tip ).addClass( 'tooltip' ); this.tip = tip; if ( ev ) { if ( this.options.dom_id ) { this.tip.innerHTML = document.getElementById( this.options.dom_id ).innerHTML; } else { this.tip.innerHTML = this.options.html; } } this.tip.style.width = this.options.width; this.tip.style.position = "absolute"; this.tip.style.zIndex = 2000000; this.tip.style.display = "block"; ev && this.layout( ev ); this.tip.style.visibility = "visible"; } }; Tooltip.prototype.hide = function () { if ( this.tip && this.options.timeout >= 0 ) { var self = this; var count = window.tooltip_count; this.timeout = setTimeout( function () { if ( window.tooltip_count == count ) { self.tip.style.visibility = 'hidden'; } }, self.options.timeout ); } }; window.lightbox_pointer = null; function lightbox_remove() { window.widget_manager.stop( 'lightbox' ); } function lightbox_bar_add( x ) { $( "#lightbox_bar" ).append( x ); } function lightbox_bar_add_button( value, functionName ) { var str = ""; lightbox_bar_add( str ); } function init_lightbox( container, context ) { context = context || document; $( container, context ).each( function () { var opts = jQuery.attrOptions( this , 'lightbox' ); var ajax = jQuery.attrOptions( this , 'lightbox_ajax' ); opts.ajax = ajax; new Lightbox( this, opts ); } ); } function docs_lightbox() { var a = "A slightly too versatile lightbox implementation..."; var e = []; var c = []; var s = jQuery.label( 'lightbox.cancel', 'Cancel' ); var o = [[ 'url', null, "Url to be loaded. Defaults to the href attribute in the element, and then to null" ] ,[ 'lbl_cancel', s, "Cancel button name" ] ,[ 'width', "60%", "Css width of the lightbox" ] ,[ 'height', "60%", "Css height of the lightbox" ] ,[ 'freeze', false, "Whether the lightbox size should be fixed instead of adapting to content"] ,[ 'ajax', {}, "Parameters to be added to lightbox url" ] ]; return { 'examples': e, 'about': a, 'opts': o, 'classes': c }; } function opts_lightbox( o ) { return apply_options( docs_lightbox().opts, o ); } function Lightbox( container, options ) { options = opts_lightbox( options, container ); options.url = options.url || container.href || null; options.width = ( "" + options.width ).replace( 'px' , '' ); options.height = ( "" + options.height ).replace( 'px' , '' ); this.options = options; container = $( container ).get(0); container.obj_lightbox = this; var self = this; $( container ).click( function () { self.show(); return false; } ); if ( options.showonload ) { if ($.browser.msie) { this.show(container); } else { this.show(); } container.blur(); } } Lightbox.prototype.widgetBlur = function ( name, obj ) { if ( obj == null ) { this.remove(); } return false; }; Lightbox.prototype.domCreate = function ( container ) { var lo = document.createElement( "div" ); var lf = document.createElement( "div" ); var lw = document.createElement( "div" ); var lc = document.createElement( "div" ); var cb = document.createElement( "input" ); lo.id = "lightbox_overlay"; lf.id = "lightbox_frame"; lw.id = "lightbox_window"; lc.id = "lightbox_bar"; cb.id = "lightbox_cancel"; lf.style.position = "absolute"; lw.style.width = "100%"; lw.style.height = "100%"; cb.type = "button"; cb.value = this.options.lbl_cancel; if (container) { $( container ).append( lo ); $( container ).append( lf ); } else { $( "body" ).append( lo ); $( "body" ).append( lf ); } $( lf ).append( lc ); $( lf ).append( lw ); $( lc ).append( cb ); var self = this; $( cb ).click( function () { self.remove(); } ); }; Lightbox.prototype.clearResizeInterval = function() { if ( window.lightbox_pointer && window.lightbox_pointer.interval ) { clearInterval( window.lightbox_pointer.interval ); window.lightbox_pointer.interval = null; } }; Lightbox.prototype.remove = function () { this.clearResizeInterval(); var self = this; setTimeout( function () { $('#lightbox_window,#lightbox_frame,#lightbox_overlay').remove(); self.showFlashObjects(); }, 500 ); }; Lightbox.prototype.size_of_content = function () { var fr = document.getElementById("lightbox_iframeContent").contentWindow; var h1 = 0; var h2 = 0; if ( fr && fr.document ) { if ( fr.document.documentElement && fr.document.documentElement.scrollHeight ) { h1 = fr.document.documentElement.scrollHeight; } if ( fr.document.body && fr.document.body.scrollHeight ) { h2 = fr.document.body.scrollHeight; } } var h = Math.max( h1, h2 ); var s = jQuery.getSize( document.getElementById( 'lightbox_frame' ) ); h = s.h < h ? h + 60 : 0; return h; }; Lightbox.prototype.size = function () { if ( document.getElementById( "lightbox_iframeContent" ) ) { var h = this.size_of_content(); h > 0 && $( "#lightbox_frame" ).css( 'height', h + 'px' ); } }; Lightbox.prototype.pixelizeSize = function ( x, y ) { x = parseInt( x.match( /\d+/ ) ); x = Math.max( x , 0 ); x = Math.min( x , 100 ); x = Math.round( y * x / 100 ); return x; }; Lightbox.prototype.h_position = function () { var l = 0; var w = this.options.width; var d = jQuery.windowSize(); if ( w.match( /\%/ ) ) { w = this.pixelizeSize( w, d.w ); } l = ( d.w - w ) / 2; $( "#lightbox_frame" ).css( 'left', l + 'px' ); $( "#lightbox_window" ).css( 'width', w + 'px' ); this.overlaySize(); }; Lightbox.prototype.v_position = function () { var pagesize = jQuery.windowSize(); var pageScroll = jQuery.pageScrollTop(); var t = 0; var h = this.options.height; var d = jQuery.windowSize(); if ( h.match( /\%/ ) ) { h = this.pixelizeSize( h, d.h ); } t = ( d.h - h ) / 2; t = jQuery.pageScrollTop() + t; $( "#lightbox_frame" ).css({ top: t + 'px', height: h + 'px' }); }; Lightbox.prototype.overlaySize = function () { if ( window.innerHeight && window.scrollMaxY ) { yScroll = window.innerHeight + window.scrollMaxY; } else if ( document.body.scrollHeight > document.body.offsetHeight ) { yScroll = document.body.scrollHeight; } else { yScroll = document.body.offsetHeight; } $( "#lightbox_overlay" ).css( "height" , yScroll + "px" ); }; Lightbox.prototype.setRegularUpdate = function () { var self = this; var fr = document.getElementById("lightbox_iframeContent"); fr.interval = setInterval( function () { self.size() }, 800 ); }; Lightbox.prototype.hideFlashObjects = function () { var self = this; jQuery( 'embed' ).each( function () { this.preLightboxVisibility = jQuery( this ).css( 'visibility' ); this.style.visibility = 'hidden'; } ); }; Lightbox.prototype.showFlashObjects = function () { var self = this; jQuery( 'embed' ).each( function () { this.style.visibility = this.preLightboxVisibility; } ); }; Lightbox.prototype.show = function ( container ) { try { window.widget_manager.widgetFocus( 'lightbox', this ); $( "#lightbox_overlay" ).get( 0 ) || this.domCreate(container); var scroll = jQuery.pageScrollTop(); this.overlaySize(); this.options.before_ajax && this.options.before_ajax( this.options ); this.options.ajax.in_lightbox = '1'; var url = jQuery.addToQuery( this.options.url , jQuery.param( this.options.ajax ) ); var rand = Math.floor( Math.random() * 100000 ); if ( document.getElementById( "lightbox_iframeContent" ) == null ) { $("#lightbox_window").append( "" ); } else { $( "#lightbox_iframeContent").get(0).src = url; } this.v_position(); this.h_position(); $( "#lightbox_window,#lightbox_frame" ).css( 'display' , 'block' ); this.options.freeze || this.setRegularUpdate(); window.lightbox_pointer = window.frames['frame'+rand]; var self = this; $( window ).resize( function () { self.h_position(); self.v_position(); } ); setTimeout( function () { self.hideFlashObjects(); }, 20 ) } catch( e ) { jQuery.warn( "Lightbox" , "An error occurred when opening the lightbox." , e ); } }; window.words_all = []; window.words_pool = new AnimationPool(); function init_words( container, context ) { context = context || document.body; $( container, context ).each( function () { var opts = jQuery.attrOptions( this, 'words' ); new Words( this, opts ); } ); } function docs_words() { var a = 'Flying words'; var e = []; var c = []; var o = [[ "words", "", "Comma-separated word list" ] ,[ "duration_x", 900, "Duration of animation x in milliseconds" ] ,[ "duration_y", 1.4, "Duration of animation y in relation to duration_x (1.0 means same duration)" ] ,[ "spread", 1.8, "Side of the projection area / size of original element"] ,[ "position", "hover", "Placing of the words relative to the container element [hover,left]"] ,[ "max_iterations", 30, "Maximum of iterations for the spring algorithm (> means less colisions and bigger delay)" ] ]; return { 'examples': e, 'about': a, 'opts': o, 'classes': c }; } function opts_words( o ) { window.words_opts = window.words_opts || docs_words().opts; return apply_options( window.words_opts, o ); } function Words( container, options ) { options = opts_words( options ); this.options = options; this.container = container; this.context = 'ctx_' + Math.random(); window.words_all[this.context] = this; ws = options.words.split( "," ); this.words = []; for ( var i = 0; i < ws.length; i++ ) { if ( !ws[i].match( /^\s*$/ ) ) { this.words.push( ws[i] ); } } this.divs = []; this.pos = {}; this.expanded = false; this.expanding = false; this.timeout = null; var self = this; $( this.container ).bind( "mousemove", function ( ev ) { self.start( ev ); } ); $( this.container ).bind( "mouseover", function ( ev ) { self.start( ev ); } ); $( this.container ).bind( "mouseout", function ( ev ) { self.stop(); } ); } Words.prototype.stop = function () { this.newTimeout(); }; Words.prototype.start = function () { this.cancelTimeout(); if ( window.words_pool && window.words_pool.running( this.context ) ) { return; } this.inited || this.init(); window.words_pool.stop(); for ( var i in window.words_all ) { if ( i != this.context ) { window.words_all[i].hide(); } } if ( !this.expanding && !this.expanded ) { this.position(); this.plot(); this.position(); this.animExpand(); } }; Words.prototype.position = function () { if ( this.options.position == 'hover' ) { this.hoverPosition(); } else if ( this.options.position == 'left' ) { this.sidePosition(); } else { jQuery.log( 'Words: unknown position value' ) } }; Words.prototype.init = function () { this.inited = true; var self = this; for ( var i = 0 ; i < this.words.length ; i++ ) { var e = document.createElement( 'div' ); e.style.position = 'absolute'; e.style.visibility = 'hidden'; e.className = 'flying_words'; e.innerHTML = this.words[i]; this.divs[i] = e; document.body.appendChild( e ); $( e ).bind( "mouseover", function ( ev ) { self.start( ev ); } ); } }; Words.prototype.hoverPosition = function () { var w = jQuery.windowSize(); var s = jQuery.getSize( this.container ); var p = jQuery.getPosition( this.container ); var x = this.options.spread; var i = x / 2 - 0.5 this.pos = { x: p.x + s.w / 2, y: p.y + s.h / 2, w: s.w * x, h: s.h * x, l: Math.max( p.x - s.w * i, 0 ), t: Math.max( p.y - s.h * i, 0 ) } }; Words.prototype.sidePosition = function () { var p = findPos( this.container ); var pos = { x: p.x + 10, y: p.y + this.container.clientHeight / 2, w: Math.min( 100 + 10 * this.divs.length , 350 ), h: Math.min( 100 + 5 * this.divs.length , 250 ) }; pos.l = pos.x - 40 - pos.w; pos.t = Math.max( pos.y - pos.h / 2 , 10 ); this.pos = pos; }; Words.prototype.plot = function () { for ( var i = 0; i < this.divs.length; i++ ) { var e = this.divs[i]; e.rX = e.gX = 0; e.rY = e.gY = 0; e.w = e.clientWidth; e.h = e.clientHeight; e.oX = this.pos.x - e.w; e.oY = this.pos.y + Math.floor( Math.random() * 50 - 25 ); e.style.left = e.oX + 'px'; e.style.top = e.oY + 'px'; } }; Words.prototype.contains = function ( a , x , y ) { var pad = 3; return a.gX <= x + pad && a.gX + a.w >= x - pad && a.gY <= y + pad && a.gY + a.h >= y - pad; }; Words.prototype.collisionNew = function( a , b ) { a.xw = a.gX + a.w; a.yh = a.gY + a.h; b.xw = b.gX + b.w; b.yh = b.gY + b.h; return ( ( a.gX > b.gX && a.gX < b.xw || b.gX > a.gX && b.gX < a.xw ) && ( a.gY > b.gY && a.gY < b.yh || b.gY > a.gY && b.gY < a.yh ) ); }; Words.prototype.collision = function( a , b ) { return this.contains( b, a.gX , a.gY ) || this.contains( b, a.gX + a.w , a.gY ) || this.contains( b, a.gX , a.gY + a.h ) || this.contains( b, a.gX + a.w , a.gY + a.h ) || ( this.contains( a, b.gX, b.gY ) && this.contains( a, b.gX + b.w , b.gY ) ) || ( this.contains( a, b.gX, b.gY + b.h ) && this.contains( a, b.gX + b.w , b.gY + b.h ) ); }; Words.prototype.walls = function ( a ) { var x = ( a.gX - this.pos.l ) / this.pos.w; var y = ( a.gY - this.pos.t ) / this.pos.h; var p = {}; p.x = x <= 0.5 ? x : 1 - x ; p.y = y <= 0.5 ? y : 1 - y ; p.x = Math.pow( 1 - p.x , 100 ); p.y = Math.pow( 1 - p.y , 100 ); a.rX += ( x <= 0.5 ? 1 : -1 ) * p.x * 2; a.rY += ( y <= 0.5 ? 1 : -1 ) * p.y * 2; }; Words.prototype.repulsion = function ( a , b ) { var x = a.gX - b.gX; var y = a.gY - b.gY; var d = Math.sqrt( x * x + y * y ); var w = ( 1 - d / this.pos.w ) * ( a.w + b.w ) / this.pos.w ; var h = ( 1 - d / this.pos.h ) * ( a.h + b.h ) / this.pos.h ; return { x: ( x < 0 ? -1 : 1 ) * w * 4 * Math.pow( 1 - Math.abs( x / this.pos.w ) , 6 ) , y: ( y < 0 ? -1 : 1 ) * h * 6 * Math.pow( 1 - Math.abs( y / this.pos.h ) , 6 ) }; }; Words.prototype.repulse = function ( a , b ) { r = this.repulsion( a , b ); a.rX += r.x; a.rY += r.y; b.rX -= r.x; b.rY -= r.y; }; Words.prototype.springs = function () { var cont = false; for ( var i = 0 ; i < this.divs.length ; i++ ) { this.divs[i].rX = 0; this.divs[i].rY = 0; } var a = null; var b = null; for ( var i = 0 ; i < this.divs.length ; i++ ) { a = this.divs[i]; this.walls( a ); for ( var j = i+1 ; j < this.divs.length ; j++ ) { b = this.divs[j]; if ( this.collision( a , b ) ) { cont = true; this.repulse( a , b ); } } } if ( cont ) { for ( var i = 0 ; i < this.divs.length ; i++ ) { var d = this.divs[i]; var l = this.pos.l - d.w; var t = this.pos.t - d.h; d.gX = bound( l , d.gX + d.rX * 10, l + this.pos.w ); d.gY = bound( t , d.gY + d.rY * 10, t + this.pos.h ); } } return cont; }; Words.prototype.stopAndHide = function () { this.cancelTimeout(); window.words_pool.stop( this.context ); this.hide(); } Words.prototype.cancelTimeout = function () { if ( this.timeout ) { clearTimeout( this.timeout ); } this.timeout = null; } Words.prototype.newTimeout = function () { this.cancelTimeout(); var self = this; this.timeout = setTimeout( function () { self.stopAndHide(); }, 2000 ); } Words.prototype.hide = function () { this.expanding = false; this.expanded = false; for ( var i = 0 ; i < this.divs.length ; i++ ) { var e = this.divs[i]; e.style.left = this.pos.x + 'px'; e.style.top = this.pos.y + 'px'; e.style.visibility = 'hidden'; } } Words.prototype.animExpand = function() { this.cancelTimeout(); this.expanding = true; var now = new Date().getTime(); var time = 100; var duraX = this.options.duration_x; var duraY = Math.floor( duraX * this.options.duration_y ); for ( var i = 0; i < this.divs.length; i++, time += 300 ) { var e = this.divs[i]; e.gX = Math.floor( this.pos.w * Math.random() ) + this.pos.l - e.w; e.gY = Math.floor( this.pos.h * Math.random() ) + this.pos.t; window.words_pool.add( e, funX, { start: now + time, evol: 'power', duration: duraX, startf: function ( o ) { o.style.visibility = 'visible'; }, context: this.context }); window.words_pool.add( e , funY , { start: now + time, evol: 'power', duration: duraY, context: this.context }); } var max_spring = this.options.max_iterations; while ( max_spring > 0 && this.springs() ) { max_spring--; } var self = this; window.words_pool.options({ endf: function () { self.expanding = false; self.expanded = true; }}, this.context ); window.words_pool.run( this.context ); } function bound( min , x , max ) { return Math.min( Math.max( x , min ) , max ); } function findPos( obj ) { var curleft = 0; var curtop = 0; if ( obj.offsetParent ) { while( true ) { curleft += obj.offsetLeft curtop += obj.offsetTop if( !obj.offsetParent ) { break; } obj = obj.offsetParent; } } else { if ( obj.x ) curleft += obj.x; if ( obj.y ) curtop += obj.y; } return { x: curleft, y: curtop }; } function funX ( obj , evol ) { obj.cX = Math.floor( evol * ( obj.gX - obj.oX ) + obj.oX ); obj.style.left = obj.cX + 'px'; } function funY ( obj , evol ) { obj.cY = Math.floor( evol * ( obj.gY - obj.oY ) + obj.oY ); obj.style.top = obj.cY + 'px'; } function array_filter_inplace( a , f ) { var i = 0; while ( i < a.length ) { if ( !f( a[i] ) ) { a.splice( i , 1 ); } else { i++; } } } function AnimationContext( name ) { this.name = name; this.objs = []; this.running = false ; this.runme = false ; this.pausenow = null ; this.endf = null; } AnimationContext.prototype.stop = function () { if ( this ) { this.running = false; } }; AnimationContext.prototype.run = function () { this.running = true; var now = new Date().getTime(); if ( this.pausenow ) { for ( var i = 0 ; i < this.objs.length ; i++ ) { var x = this.objs[i]; if ( x ) { if ( x.start > this.pausenow ) { x.start += ( now - this.pausenow ); } x.finish += ( now - this.pausenow ); } } this.pausenow = null; } for ( var i = 0 ; i < this.objs.length ; i++ ) { var x = this.objs[i]; if ( !x || x.start > now ) { continue; } var time_left = Math.max( x.finish - now , 0 ); var evol = 1; if ( x.duration > 0 ) { evol = 1 - time_left / x.duration; if ( x.evol == 'power' && x.evol_pow ) { evol = Math.pow( evol , x.evol_pow ); } else if ( x.evol == 'cosine' ) { evol = ( -Math.cos( Math.PI * evol ) + 1 ) / 2 ; } else if ( x.evol == 'ultrasine' ) { evol = ( -Math.sin( 2 * Math.PI * evol ) / 2 + evol ); } } if ( x.virgin && x.startf ) { x.virgin = false; x.startf( x.obj ); } x.fun( x.obj , evol ); if ( time_left == 0 ) { x.endf && x.endf( x.obj ); delete this.objs[i]; } } array_filter_inplace( this.objs , identity ) if ( this.objs.length == 0 ) { this.endf && this.endf(); this.stop(); } }; AnimationContext.prototype.add = function ( obj ) { this.objs.push( obj ); }; function AnimationPool() { this.pool = []; this._running = false; } AnimationPool.prototype.context = function ( name ) { for ( var i = 0 ; i < this.pool.length ; i++ ) { if ( this.pool[i] && this.pool[i].name == name ) { return this.pool[i]; } } return null; }; AnimationPool.prototype.stop = function ( context ) { if ( context ) { var i; for ( i = 0 ; i < this.pool.length ; i++ ) { if ( this.pool[i] && this.pool[i].name == context ) { break } } if ( this.pool[i] ) { this.pool[i].stop(); delete this.pool[i]; array_filter_inplace( this.pool , identity ); } if ( this.pool.length == 0 ) { this._running = false; } } else { this._running = false; for ( var i = 0 ; i < this.pool.length ; i++ ) { if ( this.pool[i] ) { this.pool[i].stop(); delete this.pool[i]; } } array_filter_inplace( this.pool , identity ); } }; AnimationPool.prototype.running = function ( context ) { if ( context ) { var c = this.context( context ); return c && c.running; } else { for ( var i = 0 ; i < this.pool.length ; i++ ) { if ( this.pool[i] && this.pool[i].running ) { return true; } } return false; } }; AnimationPool.prototype.add = function ( obj , fun , opt ) { opt = opt || {}; opt.context = opt.context || ''; opt.evol = opt.evol || 'power'; opt.evol_pow = opt.evol_pow || 2; opt.virgin = true; opt.obj = obj; opt.fun = fun; if ( !opt.start ) { opt.start = new Date().getTime(); } if ( opt.finish && !opt.duration ) { opt.duration = Math.max( opt.finish - opt.start , 0 ); } else { if ( !opt.duration ) { opt.duration = 1000; } opt.finish = opt.start + opt.duration; } var c = this.context( opt.context ); if ( !c ) { c = new AnimationContext( opt.context ); this.pool.push( c ); } c.add( opt ); }; AnimationPool.prototype.run = function( context ) { if ( context ) { var c = this.context( context ); if ( c ) { c.runme = true; } } if ( !this._running ) { this.play(); } }; AnimationPool.prototype.pause = function ( context ) { var now = new Date().getTime(); if ( context ) { var c = this.context( context ); c.pausenow = now; c.runme = false; } else { this._running = false; for ( var i = 0 ; i < this.pool.length ; i++ ) { var c = this.pool[i] if ( c && c.running ) { c.pausenow = now; c.runme = false; } } } }; AnimationPool.prototype.play = function () { var proceed = false; var before = new Date().getTime(); for ( var i = 0 ; i < this.pool.length ; i++ ) { var c = this.pool[i] if ( c && c.runme ) { this._running = true; c.run(); proceed = proceed || c.running; } } var after = new Date().getTime(); if ( proceed ) { var thiss = this; setTimeout( function () { thiss.play(); } , ( after - before < 1 ? 10 : 2 ) ); } else { this.endf && this.endf(); this._running = false; } }; AnimationPool.prototype.options = function ( opts , context ) { if ( context ) { var c = this.context( context ); if ( c && opts.endf ) { c.endf = opts.endf; } } else if ( opts.endf ) { this.endf = opts.endf; } };