﻿/*jslint bitwise: true, browser: true, eqeqeq: true, immed: true, newcap: true, nomen: true, onevar: true, plusplus: true, undef: true, white: true, indent: 4 */

/*Analogue 1.09.9, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved.*/
var analogue = (function (window, root) {
    var build = new Date('October 04 2009 21:10:02'), detect = (function () {
        var a, div = document.createElement('div');
        root.className = 'hasJs';
        div.innerHTML = '<a href="/a" style="color:red;float:left;opacity:.5">a</a><input />';
        div.getElementsByTagName('input')[0].setAttribute('name', 'nameAttribute');
        a = div.getElementsByTagName('a')[0];
        if (!window.HTMLElement) {
            if (window.Element && window.Element.prototype) {
                window.HTMLElement = window.Element;
            } else {
                if (window['[[DOMElement.prototype]]']) {
                    window.HTMLElement = function () {};
                    window.HTMLElement.prototype = window['[[DOMElement.prototype]]'];
                }
            }
        }
        return {
            cssFloat: !!a.style.cssFloat ? 'cssFloat' : 'styleFloat',
            getElementById: (function () {
                var div = document.createElement('div'), id = 'id' + new Date().getTime(), value = true;
                div.innerHTML = '<a name="' + id + '"></a>';
                root.insertBefore(div, root.firstChild);
                value = !div.ownerDocument.getElementById(id);
                root.removeChild(div);
                return value;
            }()),
            href: a.getAttribute('href') === '/a',
            style: (/red/).test(a.getAttribute('style')),
            setAttribute: (/nameAttribute/).test(div.innerHTML),
            arraySlice: (function () {
                try {
                    return !!Array.prototype.slice.call(root.childNodes)[0];
                } catch (e) {
                    return false;
                }
            }()),
            opacity: a.style.opacity === '0.5',
            textContent: a.textContent === 'a' ? 'textContent' : 'innerText'
        };
    }()), events = (function () {
        var cancelBubble, fixEvent = function (element, event) {
            event.metaKey = event.ctrlKey;
            event.pageX = event.clientX + Math.max(root.scrollLeft, document.body.scrollLeft) - (root.clientLeft || 0);
            event.pageY = event.clientY + Math.max(root.scrollTop, document.body.scrollTop) - (root.clientTop || 0);
            event.preventDefault = function () {
                this.returnValue = false;
            };
            event.relatedTarget = event.type === 'mouseover' ? event.fromElement : event.type === 'mouseout' ? event.toElement : undefined;
            event.stopPropagation = function () {
                this.cancelBubble = true;
            };
            event.target = event.srcElement || element;
            event.timeStamp = new Date().getTime();
            event.which = event.charCode = event.keyCode;
            if (!event.which && event.button) {
                event.which = (event.button === 1 ? 1 : (event.button === 4 ? 2 : (event.button === 2 ? 3 : 0)));
            }
            return event;
        }, guid = 0, meta = null, returnValue, handleEvent = function (event) {
            event = event || fixEvent(this, window.event);
            var i, listeners = this.events[event.type];
            for (i in listeners) {
                if (listeners.hasOwnProperty(i)) {
                    meta.pseudoEvent = {'listener': listeners[i], 'target': this, 'event': event};
                    if (returnValue === false) {
                        event.preventDefault();
                    }
                    if (cancelBubble === true) {
                        event.stopPropagation();
                    }
                }
            }
        };
        if (root.attachEvent) {
            meta = document.createElement('meta');
            meta.pseudoEvent = null;
            meta.attachEvent('onpropertychange', function (event) {
                if (event.propertyName === 'pseudoEvent') {
                    meta.pseudoEvent.listener.call(meta.pseudoEvent.target, meta.pseudoEvent.event);
                    returnValue = meta.pseudoEvent.event.returnValue;
                    cancelBubble = meta.pseudoEvent.event.cancelBubble;
                }
            });
            document.getElementsByTagName('head')[0].appendChild(meta);
        }
        return {
            addEvent: root.addEventListener ? function (type, listener) {
                this.addEventListener(type, listener, false);
                return this;
            } : function (type, listener) {
                listener.guid = listener.guid || (guid += 1);
                this.events = this.events || {};
                if (!this.events[type]) {
                    this.events[type] = {};
                    if (this['on' + type]) {
                        this.events[type][0] = this['on' + type];
                    }
                    this['on' + type] = handleEvent;
                }
                this.events[type][listener.guid] = listener;
                return this;
            },
            removeEvent: root.removeEventListener ? function (type, listener) {
                this.removeEventListener(type, listener, false);
                return this;
            } : function (type, listener) {
                if (this.events && this.events[type] && listener.guid) {
                    delete this.events[type][listener.guid];
                }
                return this;
            },
            triggerEvent: root.dispatchEvent ? function (type, which) {
                var charCode = 0, event = null, keyCode = 0;
                if (/mouse|click/.test(type)) {
                    event = document.createEvent('MouseEvents');
                    if (event.initMouseEvent) {
                        event.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, which || 0, null);
                    } else {
                        event = document.createEvent('UIEvents');
                        event.initEvent(type, true, true);
                        event.button = which || 0;
                    }
                } else if (/key(down|press|up)/.test(type)) {
                    if (which) {
                        which = typeof which === 'number' ? which : which.charCodeAt(0);
                        if (type === 'keypress') {
                            if ((which > 64 && which < 91) || (which > 96 && which < 123)) {
                                charCode = which;
                            } else {
                                keyCode = which;
                            }
                        } else {
                            keyCode = which;
                        }
                    }
                    try {
                        event = document.createEvent('KeyEvents');
                        event.initKeyEvent(type, true, true, window, false, false, false, false, keyCode, charCode);
                    } catch (e) {
                        try {
                            event = document.createEvent('Events');
                        } catch (er) {
                            event = document.createEvent('UIEvents');
                        } finally {
                            event.initEvent(type, true, true);
                            event.keyCode = keyCode;
                            event.charCode = charCode;
                            event.which = which || 0;
                        }
                    }
                } else {
                    event = document.createEvent('HTMLEvents');
                    event.initEvent(type, true, true);
                }
                return this.dispatchEvent(event);
            } : function (type, which) {
                var event = document.createEventObject();
                if (/mouse|click/.test(type)) {
                    event.button = (which === 0 ? 1 : (which === 1 ? 4 : (which === 2 ? 2 : 0)));
                } else if (/key(down|press|up)/.test(type)) {
                    event.keyCode = which ? (typeof which === 'number' ? which : which.charCodeAt(0)) : 0;
                }
                event.type = type;
                return this.fireEvent('on' + type, fixEvent(this, event));
            }
        };
    }()), extend = function (object, source) {
        if (!source) {
            source = object;
            object = this;
        }
        for (var i in source) {
            if (source.hasOwnProperty(i) && !object[i]) {
                object[i] = source[i];
            }
        }
        return object;
    }, methods = (function () {
        var booleans = {
            'checked': 'checked',
            'disabled': 'disabled',
            'multiple': 'multiple',
            'readonly': 'readOnly',
            'selected': 'selected'
        }, getOpacity = function (element) {
            if (detect.opacity) {
                return window.getComputedStyle(element, null).opacity || 1;
            }
            try {
                return element.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
            } catch (e) {
                try {
                    return element.filters.alpha.opacity / 100;
                } catch (er) {}
            }
            return 1;
        }, i, properties = {
            'accesskey': 'accessKey',
            'class': 'className',
            'float': detect.cssFloat,
            'for': 'htmlFor',
            'html': 'innerHTML',
            'maxlength': 'maxLength',
            'tabindex': 'tabIndex',
            'text': detect.textContent,
            'title': 'title'
        };
        for (i in booleans) {
            if (booleans.hasOwnProperty(i)) {
                properties[i] = booleans[i];
            }
        }
        return {
            addClass: function (value) {
                var classes = this.className.split(' ');
                if (!this.hasClass(value)) {
                    classes.push(value);
                    this.className = classes.join(' ');
                }
                return this;
            },
            getProperty: function (attribute) {
                if (attribute === 'style' && !detect.style) {
                    return this.style.cssText.toLowerCase();
                }
                if (attribute === 'opacity') {
                    return getOpacity(this);
                }
                if ((/^(href|src|type|value)$/i).test(attribute) && !detect.href) {
                    return this.getAttribute(attribute, 2);
                }
                if (booleans[attribute]) {
                    return !!this[properties[attribute]];
                }
                return properties[attribute] ? this[properties[attribute]] : this.getAttribute(attribute);
            },
            hasClass: function (value) {
                return this.className && new RegExp('(^|\\s)' + value + '($|\\s)').test(this.className);
            },
            removeClass: function (value) {
                var classes = this.className.split(' '), i, ii;
                for (i = 0, ii = classes.length; i < ii; i += 1) {
                    if (classes[i] === value) {
                        classes.splice(i, 1);
                    }
                }
                this.className = classes.join(' ');
                return this;
            },
            setProperty: function (attribute, value) {
                if (attribute === 'style' && !detect.style) {
                    this.style.cssText = value;
                } else if (attribute === 'opacity') {
                    if (detect.opacity) {
                        this.style.opacity = value;
                    } else if (this.style.filter !== undefined) {
                        this.style.filter = 'alpha(opacity=' + value * 100 + ')';
                    }
                } else if (attribute.match(/^on(\w+)$/i) && typeof value === 'function') {
                    this.addEvent(RegExp.$1, value);
                } else if (properties[attribute]) {
                    if (booleans[attribute] && typeof value !== 'boolean') {
                        value = (typeof value !== 'undefined') ? true : false;
                    }
                    this[properties[attribute]] = value;
                } else {
                    this.setAttribute(attribute, value);
                }
                return this;
            },
            toggleClass: function (value) {
                if (this.hasClass(value)) {
                    this.removeClass(value);
                } else {
                    this.addClass(value);
                }
                return this;
            }
        };
    }()), path = document.getElementsByTagName('script')[0].src.replace(/((\/)*[\w\.]+)$/, '/').replace(new RegExp('^' + document.location.protocol + '//' + document.domain), ''), selectors = (function () {
        var clean = function (string) {
            return string.replace(/^\s+|\s+$/g, '');
        }, getElementById = detect.getElementById ? function (id) {
            return document.getElementById(id);
        } : function (id) {
            var element = document.getElementById(id), elements, i;
            if (element) {
                if (element.id === id) {
                    return element;
                } else {
                    elements = document.all[id];
                    for (i = 1; (element = elements[i]); i += 1) {
                        if (element.id === id) {
                            return element;
                        }
                    }
                }
            }
            return null;
        }, getElements = function (context, tag, combinator) {
            tag = (tag ? tag : '*').toLowerCase();
            var child, children, collection = [], element, elements, i, ii, j;
            for (i = 0, ii = context.length; i < ii; i += 1) {
                switch (combinator) {
                case '>':
                    children = context[i].childNodes;
                    for (j = 0; (child = children[j]); j += 1) {
                        if (child.nodeType === 1 && child.nodeName !== '!') {
                            if (tag === '*' || child.nodeName.toLowerCase() === tag) {
                                collection.push(child);
                            }
                        }
                    }
                    break;
                case '+':
                    element = context[i].nextSibling;
                    while (element) {
                        if (element.nodeType === 1 && element.nodeName !== '!') {
                            if (tag !== '*' && element.nodeName.toLowerCase() !== tag) {
                                break;
                            }
                            collection.push(element);
                            break;
                        } else {
                            element = element.nextSibling;
                        }
                    }
                    break;
                default:
                    elements = context[i].getElementsByTagName(tag);
                    for (j = 0; (element = elements[j]); j += 1) {
                        collection.push(element);
                    }
                }
            }
            return collection;
        }, getPrevious = function (element) {
            while ((element = element.previousSibling) && element.nodeType !== 1) {}
            return element;
        }, parse = function (context, selector) {
            context = [context];
            selector = clean(selector.replace(/\s*(>|\+)\s*/g, ' $1'));
            var combinator, element, elements, i, ii, j, k, kk, match, parts, property, token, tokens = selector.split(' ');
            for (i = 0, ii = tokens.length; i < ii; i += 1) {
                token = clean(tokens[i]);
                if ((match = (/^(>|\+)/i).exec(token))) {
                    combinator = match[1];
                    token = token.replace(combinator, '');
                }
                if (token.indexOf('#') > -1) {
                    parts = token.split('#');
                    element = getElementById(parts[1]);
                    if (!element || (parts[0] && element.nodeName.toLowerCase() !== parts[0])) {
                        return [];
                    }
                    context = [element];
                } else if (token.indexOf('.') > -1) {
                    parts = token.split('.');
                    elements = getElements(context, parts[0], combinator);
                    context = [];
                    for (j = 0; (element = elements[j]); j += 1) {
                        match = true;
                        for (k = 1, kk = parts.length; k < kk; k += 1) {
                            if (!element.className || !new RegExp('(^|\\s)' + parts[k] + '(\\s|$)').test(element.className)) {
                                match = false;
                                break;
                            }
                        }
                        if (match) {
                            context.push(element);
                        }
                    }
                } else if ((match = (/^(\w*):first\-child$/i).exec(token))) {
                    elements = getElements(context, match[1], combinator);
                    context = [];
                    for (j = 0; (element = elements[j]); j += 1) {
                        if (!getPrevious(element)) {
                            context.push(element);
                        }
                    }
                } else if ((match = (/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/i).exec(token))) {
                    elements = getElements(context, match[1], combinator);
                    context = [];
                    for (j = 0; (element = elements[j]); j += 1) {
                        if ((property = element.getProperty(match[2]))) {
                            if (!match[3]) {
                                context.push(element);
                            } else if (match[3] === '=' && property === match[4]) {
                                context.push(element);
                            } else if (match[3] === '~' && new RegExp('(^|\\s)' + match[4] + '(\\s|$)').test(property)) {
                                context.push(element);
                            } else if (match[3] === '^' && property.indexOf(match[4]) === 0) {
                                context.push(element);
                            } else if (match[3] === '$' && property.lastIndexOf(match[4]) === (property.length - match[4].length)) {
                                context.push(element);
                            } else if (match[3] === '*' && (property.indexOf(match[4]) + 1)) {
                                context.push(element);
                            } else if (match[3] === '|' && new RegExp('^' + match[4] + '-').test(property)) {
                                context.push(element);
                            }
                        }
                    }
                } else {
                    context = getElements(context, token, combinator);
                }
            }
            return context;
        }, unique = function (collection) {
            var element, filtered = [], i;
            for (i = 0; (element = collection[i]); i += 1) {
                if (!element.included && element.nodeName !== '!') {
                    element.included = true;
                    filtered.push(element);
                }
            }
            for (i = 0; (element = filtered[i]); i += 1) {
                element.included = null;
            }
            return filtered;
        };
        return {
            match: document.querySelectorAll ? function (context, selector) {
                var collection = [], elements = context.querySelectorAll(selector), i = 0;
                if (detect.arraySlice) {
                    return Array.prototype.slice.call(elements);
                }
                while (elements[i]) {
                    collection.push(elements[i]);
                    i += 1;
                }
                return collection;
            } : function (context, selector) {
                var collection = [], i, ii, groups = selector.split(',');
                for (i = 0, ii = groups.length; i < ii; i += 1) {
                    collection = collection.concat(parse(context, groups[i]));
                }
                return unique(collection);
            }
        };
    }()), versioning = [1, build.getFullYear().toString().slice(2), build.getMonth().toString()];
    extend(methods, extend(events, {
        getElementsByAttribute: function (name, value, tag) {
            return selectors.match(this, (tag ? tag : '') + '[' + name + (value ? '~="' + value + '"' : '') + ']');
        },
        getElementsByClassName: function (value) {
            return selectors.match(this, '.' + value.replace(' ', '.'));
        },
        getElementsBySelector: function (selector) {
            return selectors.match(this, selector);
        }
    }));
    extend(Array.prototype, {
        forEach: function (iterator) {
            var array = this, i = 0, ii = array.length, object = arguments[1];
            while (i < ii) {
                if (i in array) {
                    iterator.call(object, array[i], i, array);
                }
                i += 1;
            }
        }
    });
    extend(Function.prototype, {
        bind: function (object) {
            var method = this;
            return function () {
                return method.apply(object, arguments);
            };
        },
        extend: extend,
        inherit: function (object) {
            this.prototype = object;
            return this;
        },
        inherits: function (Parent, inheritance) {
            this.constructor = Parent;
            this.prototype = new Parent();
            if (inheritance) {
                this.extend(this.prototype, inheritance);
            }
            return this;
        }
    });
    extend(window, {
        addEvent: function () {
            return events.addEvent.apply(window, arguments);
        },
        removeEvent: function () {
            return events.removeEvent.apply(window, arguments);
        },
        triggerEvent: function () {
            return events.triggerEvent.apply(window, arguments);
        }
    });
    extend(document, {
        addEvent: function (type, listener) {
            if ((/^(dom|ready)+(contentloaded)*$/i).test(type)) {
                if (!this.ready.fired) {
                    events.addEvent.call(this, 'dataavailable', listener);
                } else {
                    listener.apply(this, arguments);
                }
                return this;
            } else {
                return events.addEvent.call(this, type, listener);
            }
        },
        get: function (query) {
            var attempt = 'getElementById,getElementsByTagName,getElementsByClassName,getElementsBySelector'.split(','), i, ii, result;
            for (i = 0, ii = attempt.length; i < ii; i += 1) {
                try {
                    result = this[attempt[i]](query);
                    if (result !== null && (result.length === undefined || result.length !== 0)) {
                        return result;
                    }
                } catch (e) {}
            }
            return null;
        },
        head: document.getElementsByTagName('head')[0],
        loadScript: function (source) {
            if (/*@cc_on!@*/false && !this.ready.fired) {
                this.write(decodeURI('%3Cscript src="' + source + '" type="text/javascript"%3E%3C/script%3E'));
            } else {
                var script = this.createElement('script');
                script.setAttribute('type', 'text/javascript');
                script.setAttribute('src', source);
                this.head.appendChild(script);
            }
            return this;
        },
        loadStyleSheet: function (source, media) {
            var sheet = this.createElement('link');
            sheet.setAttribute('href', source);
            sheet.setAttribute('media', media || 'screen');
            sheet.setAttribute('rel', 'stylesheet');
            sheet.setAttribute('type', 'text/css');
            this.head.appendChild(sheet);
            return this;
        },
        ready: function () {
            if (!document.ready.fired) {
                document.ready.fired = true;
                document.ready.fire();
                if (document.removeEventListener) {
                    document.removeEventListener('DOMContentLoaded', document.ready, false);
                }
                window.removeEvent('load', document.ready);
            }
        }.extend({
            fire: root.dispatchEvent ? function () {
                var event = document.createEvent('HTMLEvents');
                event.initEvent('dataavailable', true, true);
                document.dispatchEvent(event);
            } : function () {
                var event = document.createEventObject();
                event.type = 'dataavailable';
                document.fireEvent('on' + event.type, event);
            },
            fired: false
        }),
        set: function (tag, attributes, content) {
            var element, i, ii;
            if (attributes && !detect.setAttribute) {
                for (i in attributes) {
                    if (i.match(/^(checked|multiple|name|readonly|type)$/i)) {
                        tag += ' ' + i + '="' + attributes[i] + '"';
                        delete attributes[i];
                    }
                }
                tag = '<' + tag + '>';
            }
            element = document.createElement(tag);
            if (attributes) {
                for (i in attributes) {
                    if (attributes.hasOwnProperty(i)) {
                        element.setProperty(i, attributes[i]);
                    }
                }
            }
            if (content) {
                if (typeof content === 'string') {
                    element.appendChild(document.createTextNode(content));
                } else {
                    for (i = 0, ii = content.length; i < ii; i += 1) {
                        if (typeof content[i] === 'string') {
                            content[i] = document.createTextNode(content[i]);
                        }
                        element.appendChild(content[i]);
                    }
                }
            }
            return element;
        }
    });
    extend(document, events);
    if (window.HTMLElement) {
        extend(window.HTMLElement.prototype, methods);
    } else {
        document.create = document.createElement;
        document.createElement = function (tag) {
            return extend(document.create(tag), methods);
        };
        document.addEvent('ready', function () {
            var elements = document.getElementsByTagName('*'), i, ii;
            for (i = 0, ii = elements.length; i < ii; i += 1) {
                extend(elements[i], methods);
            }
        });
    }
    if (document.addEventListener) {
        document.addEventListener('DOMContentLoaded', document.ready, false);
        if (document.readyState) {
            (function () {
                if ((/loaded|complete/).test(document.readyState)) {
                    return document.ready();
                }
                setTimeout(arguments.callee, 10);
            }());
        }
    }
    /*@cc_on document.loadScript(path + 'Analogue.MSIE.js.ashx').write(decodeURI('%3Cscript defer src="//:" onreadystatechange="if(this.readyState===\'complete\'){document.ready();}"%3E%3C/script%3E')); @*/
    window.addEvent('load', document.ready);
    return {
        path: path,
        version: versioning.join('.') + ' (' + build.valueOf() + ')'
    };
}(this, document.documentElement));

/*Analogue.Forms 1.09.7, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved.*/
analogue.forms = (function (window) {
    var build = new Date('August 04 2009 04:04:56'), check = {
        alpha: function (value) {
            return !(/[^a-zA-Z]/g).test(value);
        },
        alphaNumeric: function (value) {
            return !(/[^a-zA-Z\d]/g).test(value);
        },
        creditCard: (function () {
            var cards = [ // http://en.wikipedia.org/wiki/Credit_card_number
                {length: '15', name: 'American Express', prefix: /^3[4|7]{1}/},
                {length: '16', name: 'Discover', prefix: /^(6011|622|(64[4-9]{1})|65)/},
                {length: '16', name: 'MasterCard', prefix: /^5[1-5]{1}/},
                {length: '13,16', name: 'Visa', prefix: /^4/}
            ];
            return {
                length: function (element) {
                    var i, ii, lengths = cards[element.cardType].length.split(','), value = element.value;
                    for (i = 0, ii = lengths.length; i < ii; i += 1) {
                        if (value.length === parseInt(lengths[i], 10)) {
                            return true;
                        }
                    }
                    return false;           
                },
                luhn: function (value) { 
                    var calc, checksum = 0, i, j = 1;
                    for (i = value.length - 1; i >= 0; i -= 1) {
                        calc = Number(value.charAt(i)) * j;
                        if (calc > 9) {
                            checksum = checksum + 1;
                            calc = calc - 10;
                        }
                        checksum = checksum + calc;
                        j = j === 1 ? 2 : 1;
                    } 
                    return (checksum % 10 === 0);
                },
                prefix: function (element) {
                    var i, ii, value = element.value;
                    element.cardName = element.cardType = null;
                    if (value.length > 1) {
                        for (i = 0, ii = cards.length; i < ii; i += 1) {
                            if (cards[i].prefix.test(value)) {
                                element.cardType = i;
                                element.cardName = cards[i].name;
                                return true;
                            }
                        }
                    }     
                    return false;
                }
            };
        }()),
        date: function (value) {
            var day, days, month, year;
            if (!(/^(\d{1,2})[\s\.\/\-](\d{1,2})[\s\.\/\-](\d{4})$/).test(value)) {
                return false;
            }
            month = parseInt(RegExp.$1, 10);
            day = parseInt(RegExp.$2, 10);
            year = parseInt(RegExp.$3, 10);
            if (month < 1 || month > 12 || year < 1900 || year > 2100) {
                return false;
            }
            switch (month) {
            case 2:
                days = ((year % 4) === 0) ? 29 : 28;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                days = 30;
                break;
            default:
                days = 31;
            }
            return (day >= 1 && day <= days);
        },
        email: function (value) {
            if ((/^([\w\-]+(?:\.[\w\-]+)*)@((?:[\w\-]+\.)*\w[\w\-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/).test(value)) {
                var path = analogue.path + 'mx/lookup.ashx', request = new XMLHttpRequest();
                if (!request) {
                    return true;
                } else {
                    request.open('GET', path + '?email=' + value.split('@')[1] + '&nocache=' + new Date().getTime(), false);
                    request.send(null);
                    if (request.status === 200) {
                        if (request.responseText.indexOf('ERROR')) {
                            return true;
                        }
                        return false;
                    }
                    return true;
                }
            }
            return false;
        },
        empty: function (value) {
            return !(value === null || value.length === 0 || (/^\s+$/).test(value));
        },
        group: function (node) {
            var count = 0, i, ii, valid = null;
            if (node.nodeType !== 1) {
                return 0;
            }
            if (node.nodeName.toLowerCase() === 'input') {
                switch (node.type.toLowerCase()) {
                case 'checkbox':
                case 'radio':
                    valid = node.checked;
                    break;
                default: 
                    valid = node.value;
                }
            } else {
                valid = node.value;
            }
            if (valid && this.empty(valid)) {
                count += 1;
            }
            for (i = 0, ii = node.childNodes.length; i < ii; i += 1) {
                count += this.group(node.childNodes[i]);
            }
            return count;
        },
        match: function (element) {
            var verify = document.getElementById(element.id.split('-')[1]);
            if (verify && element.value !== verify.value) {
                return false;
            }
            return true;
        },
        numeric: function (value) {
            return !(/[^\d\.\-]/g).test(value);
        },
        phone: function (value) {
            return (/^([1]?[\s\.\-]?\(?[2-9]\d{2}\)?)?[\s\.\-]?(\d{3}[\s\.\-]?\d{4})$/).test(value);
        },
        url: function (value) {
            return (/^(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?\^=%&amp;:\/~\+#]*[\w\-\@?\^=%&amp;\/~\+#])?/).test(value);
        }
    }, getLabel = function (element, form) {
        if (element.parentNode.nodeName.toLowerCase() === 'label') {
            return element.parentNode;
        }
        var i, label, labels = form.getElementsByTagName('label');
        for (i = 0; (label = labels[i]); i += 1) {
            if (label.htmlFor && label.htmlFor === element.id) {
                return label;
            }
        }
        return false;
    }, serialize = function () {
        var element, elements = this.elements, i, j, jj, parameters = [], push = function (name, value) {
            parameters.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
        };
        for (i = 0; (element = elements[i]); i += 1) {
            if (!element.disabled) {
                switch (element.type) {
                case 'text':
                case 'password':
                case 'hidden':
                case 'textarea': 
                    push(element.name, element.value);
                    break;
                case 'select-one':
                    if (element.selectedIndex >= 0) {
                        push(element.name, element.options[element.selectedIndex].value);
                    }
                    break;
                case 'select-multiple':
                    for (j = 0, jj = element.options.length; j < jj; j += 1) {
                        if (element.options[j].selected) {
                            push(element.name, element.options[j].value);
                        }
                    }
                    break;
                case 'checkbox':
                case 'radio':
                    if (element.checked) {
                        push(element.name, element.value);
                    }
                    break;
                }
            }
        }
        return parameters.join('&');
    }, validate = function (event) {
        var count, element, elements = this.getElementsByClassName('isRequired'), error, errors = [], i, j, jj, match, message, span, tag, title, valid, value;
        for (i = 0; (element = elements[i]); i += 1) {
            element.removeClass('isInvalid');
            if (element.label) {
                element.label.removeClass('isInvalid');
            }
            if (element.nextSibling && element.nextSibling.nodeName.toLowerCase() === 'span') {
                element.parentNode.removeChild(element.nextSibling);
            } else if (element.lastChild && element.lastChild.nodeName.toLowerCase() === 'span') {
                element.removeChild(element.lastChild);
            }
            tag = element.nodeName.toLowerCase();
            title = element.title;
            valid = true;
            value = element.value;
            switch (tag) {
            case 'div':
            case 'fieldset':
                if ((/atLeast-(\d+)/).test(element.className)) {
                    if (!(valid = (count = parseInt(RegExp.$1, 10)) <= check.group(element))) {
                        errors.push('Please select at least ' + count + ' options in the ' + title + ' group.');
                    }
                } else if (!(valid = check.group(element))) {
                    errors.push('Please select an option in the ' + title + ' group.');
                } 
                if (valid && (/atMost-(\d+)/).test(element.className)) {
                    if (!(valid = (count = parseInt(RegExp.$1, 10)) >= check.group(element))) {
                        errors.push('Please select no more than ' + count + ' options in the ' + title + ' group.');
                    }
                }
                break;
            case 'input':
                switch (element.type.toLowerCase()) {
                case 'checkbox':
                case 'radio':
                    if (!(valid = element.checked)) {
                        errors.push('You must ' + title + '.');
                    }
                    break;
                default:
                    if (!(valid = check.empty(value))) {
                        errors.push('The ' + title + ' field is required.');
                    } else if (element.hasClass('checkAlpha') && (!(valid = check.alpha(value)))) {
                        errors.push('The ' + title + ' field may contain letters only, no numbers or other characters.');
                    } else if (element.hasClass('checkAlphaNumeric') && (!(valid = check.alphaNumeric(value)))) {
                        errors.push('The ' + title + ' field may contain letters and numbers only.');
                    } else if (element.hasClass('checkCreditCard')) { 
                        value = element.value = element.value.replace(/\W/gi, '');
                        if ((!(valid = check.numeric(value)))) {
                            errors.push('The Credit Card number may contain numbers only, no letters or other characters.');
                        } else if (!(valid = check.creditCard.prefix(element))) {
                            errors.push('The Credit Card number you entered is an unknown or unsupported card type.');
                        } else if (!(valid = check.creditCard.length(element))) {
                            errors.push('Your ' + element.cardName + ' card number has too many or too few digits.');
                        } else if (!(valid = check.creditCard.luhn(value))) {
                            errors.push('Your ' + element.cardName + ' card number is invalid.');
                        }
                    } else if (element.hasClass('checkDate') && (!(valid = check.date(value)))) {
                        errors.push(value + ' does not appear to be a valid date.');
                    } else if (element.hasClass('checkEmail') && (!(valid = check.email(value)))) {
                        errors.push(value + ' does not appear to be a valid e-mail address.');
                    } else if (element.hasClass('checkMatch') && (!(valid = check.match(element)))) {
                        match = document.getElementById(element.id.split('-')[1]);
                        errors.push('The ' + title + ' field does not match the ' + match.title + ' field.');
                    } else if (element.hasClass('checkNumeric') && (!(valid = check.numeric(value)))) {
                        errors.push('The ' + title + ' field may contain numbers only, no letters or other characters.');
                    } else if (element.hasClass('checkPhone') && (!(valid = check.phone(value)))) {
                        errors.push(value + ' does not appear to be a valid phone number.');
                    } else if (element.hasClass('checkUrl') && (!(valid = check.url(value)))) {
                        errors.push(value + ' does not appear to be a valid URL.');
                    }
                }
                break;
            case 'select':
                if (element.hasClass('checkIndex')) {
                    valid = element.selectedIndex !== 0;
                } else {
                    valid = check.empty(element.options[element.selectedIndex].value);
                }
                if (!valid) {
                    errors.push('Please select an option from the ' + title + ' list.');
                }
                break;
            case 'textarea':
                if (!(valid = check.empty(value))) {
                    errors.push('The ' + title + ' field is required.');
                }
                break;
            }
            if (!valid) {
                element.addClass('isInvalid');
                if (element.label) { 
                    element.label.addClass('isInvalid');
                }
                if (!this.hasClass('useConfirm') && !this.hasClass('useAlert')) {
                    span = document.set('span', { 'class': 'errorDetail' },  [errors[0], document.set('span')]);
                    if (tag === 'fieldset' || tag === 'div') {
                        element.appendChild(span);
                    } else {
                        element.parentNode.insertBefore(span, element.nextSibling);
                    }
                    if (element.focus) {
                        element.focus();
                    }
                    event.preventDefault();
                    return false;
                }
                if (errors.length === 1) {
                    error = element;
                }
            }
        }
        if (errors.length === 0) {
            if (this.hasClass('disableSubmit')) {
                this.getElementsBySelector('[type="submit"]')[0].disabled = true;
            }
            return true;
        }
        message = 'The following form ' + (errors.length > 1 ? 'fields were' : 'field is') + ' incomplete or incorrect:\n\n';
        for (j = 0, jj = errors.length; j < jj; j += 1) {
            message += (j + 1) + '. ' + errors[j] + '\n';
        }
        if (this.hasClass('useConfirm') && confirm(message + '\nYour form has not been submitted.\nClick \"OK\" to continue submitting the form; or\nClick \"Cancel\" to check the information that you provided and try again.')) {
            return true;
        } else if (this.hasClass('useAlert')) {
            alert(message + '\nYour form has not been submitted.\nPlease check the information that you provided and submit the form again.');
        }
        if (error.focus) {
            error.focus();
        }
        event.preventDefault();
        return false;
    }, versioning = [1, build.getFullYear().toString().slice(2), build.getMonth().toString()];
    document.addEvent('ready', function () {
        var element, elements, form, forms = document.getElementsByTagName('form'), i, j, setFocus = false;
        for (i = 0; (form = forms[i]); i += 1) {
            form.serialize = serialize;
            if (!setFocus && form.hasClass('setFocus')) {
                setFocus = form;
            }
            elements = form.getElementsByClassName('isRequired');
            if (elements.length > 0) {
                form.addEvent('submit', validate);
                for (j = 0; (element = elements[j]); j += 1) {
                    element.label = getLabel(element, form);
                }
            }
        }
        if (setFocus) {
            window.addEvent('load', function () {
                var element, elements = this.elements, i;
                for (i = 0; (element = elements[i]); i += 1) {
                    if (element.nodeName.toLowerCase() !== 'fieldset' && element.type.toLowerCase() !== 'hidden' && !element.disabled) {
                        element.focus();
                        break;
                    }
                }
            }.bind(setFocus));
        }
    });    
    return {
        validate: function (method, parameters) {
            return check[method](parameters);
        },
        version: versioning.join('.') + ' (' + build.valueOf() + ')' 
    };
}(this));

/*Animate 1.09.6, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved. Easing Equations v1.5, Copyright (c) 2003 Robert Penner, all rights reserved. Open Source BSD License.*/
var Animate = function (object, property, transition, begin, finish, duration, suffix) {
    this.initialize(object, property, transition, begin, finish, duration, suffix);
}.inherit({
    addEvent: function (listener) {
        this.removeEvent(listener);
        return this.listeners.push(listener);
    },
    callEvent: function () {
        var i, ii, listener, listeners = this.listeners, properties = [];
        for (i = 0, ii = arguments.length; i < ii; i += 1) {
            properties.push(arguments[i]);
        }
        listener = properties.shift();
        for (i = 0, ii = listeners.length; i < ii; i += 1) {
            if (listeners[i][listener]) {
                listeners[i][listener].apply(listeners[i], properties);
            }
        }
    },
    change: 0,
    continueTo: function (finish, duration) {
        this.begin = this.position;
        this.setFinish(finish);
        if (this.duration !== undefined) {
            this.setDuration(duration);
        }
        this.start();
    },
    delegate: function (object, method) {
        var array = [], i, ii;
        for (i = 2, ii = arguments.length; i < ii; i += 1) {
            array[i - 2] = arguments[i];
        }
        return function () {
            method.apply(object, [].concat(arguments, array));
        };
    },
    fforward: function () {
        this.time = this.duration;
        this.fixTime();
        this.update();
    },
    fixTime: function () {
        this.startTime = this.getTimer() - this.time * 1000;
    },
    getPosition: function (time) {
        if (time === undefined) {
            time = this.time;
        }
        return this.transition(time, this.begin, this.change, this.duration);
    },
    getTimer: function () {
        return new Date().getTime() - this.time;
    },
    initialize: function (object, property, transition, begin, finish, duration, suffix) {
        if (!arguments.length) {
            return;
        }
        this.listeners = [];
        this.addEvent(this);
        this.object = object;
        this.property = property;
        if (transition !== null && transition !== '') {
            this.transition = transition;
        }
        if (property === 'opacity') {
            if (begin < 0) {
                begin = 0;
            }
            if (finish > 100) {
                finish = 100;
            }
        }
        this.begin = begin;
        this.position = begin;
        this.setFinish(finish);
        this.setDuration(duration);
        this.suffix = suffix || '';
    },
    listeners: [],
    looping: false,
    nextFrame: function () {
        this.setTime((this.getTimer() - this.startTime) / 1000);
    },
    onEnterFrame: function () {
        if (this.isPlaying) {
            this.nextFrame();
            setTimeout(this.delegate(this, this.onEnterFrame), 0);
        }
    },
    position: 0,
    prevPosition: 0,
    prevTime: 0,
    removeEvent: function (listener) {
        var i, ii, listeners = this.listeners;
        for (i = 0, ii = listeners.length; i < ii; i += 1) {
            if (listeners[i] === listener) {
                listeners.splice(i, 1);
                return true;
            }
        }
        return false;
    },
    resume: function () {
        this.fixTime();
        this.startEnterFrame();
        this.callEvent('onresume', { target: this, type: 'onresume' });
    },
    rewind: function (time) {
        this.stop();
        this.time = (time === undefined) ? 0 : time;
        this.fixTime();
        this.update();
    },
    setDuration: function (duration) {
        this.duration = (duration === null || duration <= 0) ? 100000 : duration;
    },
    setFinish: function (finish) {
        this.change = finish - this.begin;
    },
    setPosition: function (position) {
        this.prevPosition = this.position;
        if (this.property === 'opacity') {
            this.object.style.opacity = Math.round(position) / 100; 
            this.object.style.MozOpacity = Math.round(position) / 100;
            this.object.style.KhtmlOpacity = Math.round(position) / 100;
            this.object.style.filter = 'alpha(opacity=' + Math.round(position) + ')';
        } else {
            this.object[this.property] = Math.round(position) + this.suffix;
        }
        this.position = position;
        this.callEvent('onchange', { target: this, type: 'onchange' });
    },
    setTime: function (time) {
        this.prevTime = this.time;
        if (time > this.duration) {
            if (this.looping) {
                this.rewind(time - this.duration);
                this.update();
                this.callEvent('onloop', { target: this, type: 'onloop' });
            } else {
                this.time = this.duration;
                this.update();
                this.stop();
                this.callEvent('onfinish', { target: this, type: 'onfinish' });
            }
        } else if (time < 0) {
            this.rewind();
            this.update();
        } else {
            this.time = time;
            this.update();
        }
    },
    start: function () {
        this.rewind();
        this.startEnterFrame();
        this.callEvent('onstart', { target: this, type: 'onstart' });
    },
    startEnterFrame: function () {
        this.stopEnterFrame();
        this.isPlaying = true;
        this.onEnterFrame();
    },
    startTime: 0,
    stop: function () {
        this.stopEnterFrame();
        this.callEvent('onstop', { target: this, type: 'onstop' });
    },
    stopEnterFrame: function () {
        this.isPlaying = false;
    },
    time: 0,
    // simple linear tweening - no easing
    transition: function (t, b, c, d) {
        return c * t / d + b;
    },
    update: function () {
        this.setPosition(this.getPosition(this.time));
    },
    yoyo: function () {
        this.continueTo(this.begin, this.time);
    }
}).extend({
    // BACK EASING: overshooting cubic easing: (s+1)*t^3 - s*t^2
    backIn: function (t, b, c, d, s) {
        s = s || 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    backOut: function (t, b, c, d, s) {
        s = s || 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    backInOut: function (t, b, c, d, s) {
        s = s || 1.70158;
        if ((t /= d / 2) < 1) {
            return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        }
        return c / 2 * ((t -= 2) * t * (((s  = (1.525)) + 1) * t + s) + 2) + b;
    },
    // BOUNCE EASING: exponentially decaying parabolic bounce
    bounceIn: function (t, b, c, d) {
        return c - Animate.bounceOut(d - t, 0, c, d) + b;
    },
    bounceOut: function (t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
        }
    },
    bounceInOut: function (t, b, c, d) {
        if (t < d / 2) {
            return Animate.bounceIn(t * 2, 0, c, d) * 0.5 + b;
        }
        return Animate.bounceOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
    },
    // QUADRATIC EASING: t^2
    easeIn: function (t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOut: function (t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOut: function (t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t + b;
        }
        return -c / 2 * ((t -= 1) * (t - 2) - 1) + b;
    },
    // QUINTIC EASING: t^5
    snapIn: function (t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    snapOut: function (t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    snapInOut: function (t, b, c, d) {
        if ((t /= d / 2) < 1) {
            return c / 2 * t * t * t * t * t + b;
        }
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    version: (function () {
        var build = new Date('July 06 2009 01:53:53'), versioning = [1, build.getFullYear().toString().slice(2), build.getMonth().toString()];
        return versioning.join('.') + ' (' + build.valueOf() + ')';
    }())
});

/*getPageScroll and getPageSize, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved.*/
function getPageScroll() {
    return [
        this.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
        this.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
    ];
}
function getPageSize() {
    var pageHeight, pageWidth, windowHeight, windowWidth, xScroll, yScroll;
    if (this.innerHeight && this.scrollMaxY) {
        xScroll = this.innerWidth + this.scrollMaxX;
        yScroll = this.innerHeight + this.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    if (this.innerHeight) {
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth; 
        } else {
            windowWidth = this.innerWidth;
        }
        windowHeight = this.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {	
        pageWidth = xScroll;		
    } else {
        pageWidth = windowWidth;
    }
    return [pageWidth, pageHeight, windowWidth, windowHeight];
}

/*Lightbox for Forms, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved.*/
var contact = (function () {
    var build = new Date(2009, 6, 24), versioning = [2, build.getFullYear().toString().slice(2), build.getMonth().toString()];
    return {
        end: function () {
            document.onkeydown = function () {};
            this.contactEffect = new Animate(this.contact, 'opacity', Animate.easeIn, 100, 0, this.effectDuration / 2, '');
            this.contactEffect.start();
            this.contactEffect.onfinish = function () {
                this.contact.style.display = 'none';
            }.bind(this);
        },
        getLinks: function () {
            var anchor, anchors = document.get('a[rel^="contact"]') || [], click = function (event) {
                contact.start();
                event.preventDefault();
            }, i;
            for (i = 0; (anchor = anchors[i]); i += 1) {
                anchor.addEvent('click', click);
            }
        },
        initialize: function (effectSpeed, formHeight) {
            this.getLinks();
            this.effectSpeed = effectSpeed || 8;
            if (this.effectSpeed > 10) {
                this.effectSpeed = 10;
            } else if (this.effectSpeed < 1) {
                this.effectSpeed = 1;
            }
            this.effectDuration = (11 - this.effectSpeed) * 0.15;
            this.contact = document.get('contact');
            this.formHeight = formHeight || 509;
            document.get('#inquiry a')[0].addEvent('click', function (event) {
                this.end();
                event.preventDefault();
            }.bind(this));
        },
        onkeydown: function () {
            document.onkeydown = function (e) {
                var escape, keycode;
                if (!e) {
                    keycode = event.keyCode;
                    escape = 27;
                } else {
                    keycode = e.which;
                    escape = e.DOM_VK_ESCAPE;
                }
                if (keycode === escape) {
                    this.end();
                }
            }.bind(this);
        },
        start: function () {
            var pageScroll = getPageScroll(), pageSize = getPageSize(), top = (pageScroll[1] + ((pageSize[3] - this.formHeight) / 2));
            this.contact.setProperty('style', 'display:block; top:' + (top < 0 ? 0 : top) + 'px; left:' + pageScroll[0] + 'px;');
            this.contactEffect = new Animate(this.contact, 'opacity', Animate.easeIn, 0, 100, this.effectDuration, '');
            this.contactEffect.start();
            this.onkeydown();
        },
        version: versioning.join('.') + ' (' + build.valueOf() + ')'
    };
}());

/*Lightbox 3.09.11, Copyright (c) 2009 Analogue Web Design LLC, all rights reserved. Based upon Lightbox v2.04 by Lokesh Dhakar. Licensed under the Creative Commons Attribution 2.5 License <http://creativecommons.org/licenses/by/2.5/>.*/
var lightbox = (function (window) {
    var bind = function (object, method) {
        return function () {
            return method.apply(object, arguments);
        };
    }, build = new Date('December 21 2009 04:49:22'), versioning = [2, build.getFullYear().toString().slice(2), build.getMonth().toString()], getPageScroll = function () {
        return [
            window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
            window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
        ];
    }, getPageSize = window.innerWidth ? function () {
        var windowHeight = window.innerHeight, windowWidth = window.innerWidth, xScroll = window.innerWidth + window.scrollMaxX, yScroll = window.innerHeight + window.scrollMaxY;
        return [xScroll < windowWidth ? xScroll : windowWidth, yScroll < windowHeight ? windowHeight : yScroll, window.innerWidth, window.innerHeight];
    } : function () {
        var windowHeight, windowWidth, xScroll, yScroll;
        if (document.documentElement.clientWidth !== 0) {
            windowHeight = document.documentElement.clientHeight;
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowHeight = document.body.clientHeight;
            windowWidth = document.body.clientWidth;
        }
        if (document.body.scrollHeight > document.body.offsetHeight) {
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else {
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        return [xScroll < windowWidth ? xScroll : windowWidth, yScroll < windowHeight ? windowHeight : yScroll, windowWidth, windowHeight];
    }, pause = function (milliseconds) {
        var current, date = new Date();
        do {
            current = new Date();
        }
        while (current - date < milliseconds);
    };
    return {
        changeImage: function (imageNumber) {
            this.slideShowPause();
            this.imageCurrent = imageNumber;
            this.lightboxHeader.style.visibility = 'hidden';
            this.lightboxImage.style.display = 'none';
            this.lightboxFooter.style.display = 'none';
            this.lightboxPrevLink.style.display = 'none';
            this.lightboxNextLink.style.display = 'none';
            var imgPreloader = new Image();
            imgPreloader.onload = function () {
                this.lightboxImage.src = this.imageArray[this.imageCurrent][0];
                this.resizeContainer(imgPreloader.width, imgPreloader.height);
            }.bind(this);
            imgPreloader.src = this.imageArray[this.imageCurrent][0];
        },
        end: function () {
            document.onkeydown = function () {};
            this.slideShowPause();
            this.lightbox.style.display = 'none';
            if (this.imageArray.length === 1) {
                this.lightboxFrame.setProperty('style', 'height: 250px; width: 250px');
            }
            this.lightboxImage.style.display = 'none';
            this.overlayEffect = new Animate(this.overlay, 'opacity', Animate.easeIn, this.overlayOpacity, 0, this.resizeDuration / 2, '');
            this.overlayEffect.start();
            this.overlayEffect.onfinish = function () {
                this.overlay.style.display = 'none';
            }.bind(this);
        },
        getImages: function () {
            var anchor, anchors = document.get('a[rel^="lightbox"]') || [], i;
            for (i = 0; (anchor = anchors[i]); i += 1) {
                anchor.addEvent('click', bind(this, function (anchor) {
                    return function (event) {
                        this.start(anchor);
                        event.preventDefault();
                    };
                }(anchor)));
            }
        },
        initialize: function (borderWidth, overlayOpacity, resizeSpeed, slideShow, slideShowSpeed) {
            var i, id, ids = 'overlay,lightbox,lightboxHeader,lightboxCaption,lightboxCloseLink,lightboxFrame,lightboxImage,lightboxFooter,lightboxControls,lightboxNextLink,lightboxPlayLink,lightboxPauseLink,lightboxPrevLink,lightboxImageSet'.split(',');
            this.getImages();
            this.borderWidth = borderWidth || 0;
            this.overlayOpacity = overlayOpacity || 80;
            if (this.overlayOpacity > 100) {
                this.overlayOpacity = 100;
            } else if (this.overlayOpacity < 0) {
                this.overlayOpacity = 0;
            }
            this.resizeSpeed = resizeSpeed || 8;
            if (this.resizeSpeed > 10) {
                this.resizeSpeed = 10;
            } else if (this.resizeSpeed < 1) {
                this.resizeSpeed = 1;
            }
            this.resizeDuration = (11 - this.resizeSpeed) * 0.15;
            this.slideShow = slideShow || false;
            this.slideShowSpeed = slideShowSpeed || 5000;
            this.slideShowPlaying = this.slideShow;
            document.body.appendChild(document.set('div', {'id': 'overlay', 'style': 'filter: alpha(opacity=80); -moz-opacity: 0.8; opacity: 0.8;', 'onclick': function (event) {
                this.end();
                event.preventDefault();
            }.bind(this)}));
            document.body.appendChild(document.set('div', {'id': 'lightbox'}, [
                document.set('div', {'class': 'clear', 'id': 'lightboxHeader'}, [
                    document.set('div', {'id': 'lightboxCaption'}),
                    document.set('a', {'id': 'lightboxCloseLink', 'href': '#', 'onclick': function (event) {
                        this.end();
                        event.preventDefault();
                    }.bind(this), 'title': 'Close'})
                ]),
                document.set('div', {'id': 'lightboxFrame'}, [
                    document.set('img', {'id': 'lightboxImage'})
                ]),
                document.set('div', {'class': 'clear', 'id': 'lightboxFooter'}, [
                    document.set('div', {'id': 'lightboxControls'}, [
                        document.set('a', {'id': 'lightboxNextLink', 'href': '#', 'title': 'Next'}),
                        document.set('a', {'id': 'lightboxPlayLink', 'href': '#', 'onclick': function (event) {
                            this.slideShowPlay();
                            event.preventDefault();
                        }.bind(this), 'title': 'Play'}),
                        document.set('a', {'id': 'lightboxPauseLink', 'href': '#', 'onclick': function (event) {
                            this.slideShowStop();
                            event.preventDefault();
                        }.bind(this), 'title': 'Pause'}),
                        document.set('a', {'id': 'lightboxPrevLink', 'href': '#', 'title': 'Previous'})
                    ]),
                    document.set('span', {'id': 'lightboxImageSet'})
                ])
            ]));
            for (i = 0; (id = ids[i]); i += 1) {
                this[id] = document.get([id]);
            }
            this.lightboxImageEffect = new Animate(this.lightboxImage, 'opacity', Animate.snapOut, 0, 100, this.resizeDuration, '');
            this.lightboxImageEffect.onfinish = function () {
                this.lightboxHeader.style.visibility = 'visible';
                this.lightboxHeaderEffect = new Animate(this.lightboxHeader, 'opacity', Animate.snapOut, 0, 100, this.resizeDuration * 2, '');
                this.lightboxHeaderEffect.start();
                if (this.imageArray.length > 1) {
                    this.lightboxFooter.style.display = 'block';
                    this.lightboxFooterEffect = new Animate(this.lightboxFooter, 'opacity', Animate.snapOut, 0, 100, this.resizeDuration * 2, '');
                    this.lightboxFooterEffect.onfinish = function () {
                        this.overlay.style.height = getPageSize()[1] + 'px';
                    }.bind(this);
                    this.lightboxFooterEffect.start();
                }
            }.bind(this);
            this.lightboxImage.oncontextmenu = function () {
                return false;
            };
        },
        onkeydown: function () {
            document.onkeydown = function (e) {
                var escape, key, keycode;
                if (!e) {
                    keycode = event.keyCode;
                    escape = 27;
                } else {
                    keycode = e.which;
                    escape = e.DOM_VK_ESCAPE;
                }
                key = String.fromCharCode(keycode).toLowerCase();
                if (key === 'x' || key === 'o' || key === 'c' || keycode === escape) {
                    this.end();
                } else if (key === 'p' || keycode === 37) {
                    if (this.imageCurrent !== 0) {
                        document.onkeydown = function () {};
                        this.changeImage(this.imageCurrent - 1);
                    }
                } else if (key === 'n' || keycode === 39) {
                    if (this.imageCurrent !== (this.imageArray.length - 1)) {
                        document.onkeydown = function () {};
                        this.changeImage(this.imageCurrent + 1);
                    }
                } else if (key === 's') {
                    this.slideShowToggle();
                }
            }.bind(this);
        },
        preloadImages: function () {
            var preloadNextImage, preloadPrevImage;
            if ((this.imageArray.length - 1) > this.imageCurrent) {
                preloadNextImage = new Image();
                preloadNextImage.src = this.imageArray[this.imageCurrent + 1][0];
            }
            if (this.imageCurrent > 0) {
                preloadPrevImage = new Image();
                preloadPrevImage.src = this.imageArray[this.imageCurrent - 1][0];
            }
        },
        resizeContainer: function (width, height) {
            var heightDifference = (this.lightboxFrame.offsetHeight - this.borderWidth * 2) - height, widthDifference = (this.lightboxFrame.offsetWidth - this.borderWidth * 2) - width;
            this.lightboxImageWidth = new Animate(this.lightboxFrame.style, 'width', Animate.easeIn, this.lightboxFrame.offsetWidth - this.borderWidth * 2, width, this.resizeDuration, 'px');
            this.lightboxImageWidth.onfinish = function () {
                this.lightboxImage.style.display = 'block';
                this.lightboxImageEffect.start();
            }.bind(this);
            this.lightboxImageHeight = new Animate(this.lightboxFrame.style, 'height', Animate.easeIn, this.lightboxFrame.offsetHeight - this.borderWidth * 2, height, this.resizeDuration, 'px');
            this.lightboxImageHeight.start();
            this.lightboxImageHeight.onfinish = function () {
                this.lightboxImageWidth.start();
            }.bind(this);
            if ((heightDifference === 0) && (widthDifference === 0)) {
                if (window.msie) {
                    pause(500);
                } else {
                    pause(100);
                }
            }
            this.lightboxHeader.style.width = width + (this.borderWidth * 2) + 'px';
            this.lightboxFooter.style.width = width + (this.borderWidth * 2) + 'px';
            this.updateDetails();
            this.preloadImages();
        },
        slideShowPlay: function () {
            var lightbox = this;
            this.lightboxPlayLink.style.display = 'none';
            this.lightboxPauseLink.style.display = 'block';
            this.slideShowPlaying = true;
            this.slideShowTimer = setInterval(function () {
                lightbox.changeImage(this.imageCurrent !== (this.imageArray.length - 1) ? this.imageCurrent + 1 : 0);
            }.bind(lightbox), 6000);
        },
        slideShowPause: function () {
            this.lightboxPlayLink.style.display = 'block';
            this.lightboxPauseLink.style.display = 'none';
            if (this.slideShowTimer) {
                clearInterval(this.slideShowTimer);
            }
        },
        slideShowStop: function () {
            this.slideShowPlaying = false;
            this.lightboxPlayLink.style.display = 'block';
            this.lightboxPauseLink.style.display = 'none';
            if (this.slideShowTimer) {
                clearInterval(this.slideShowTimer);
            }
        },
        slideShowToggle: function () {
            if (this.slideShowPlaying) {
                this.slideShowStop();
            } else {
                this.slideShowPlay();
            }
        },
        start: function (link) {
            var anchor, anchors, i, imageNumber = 0, pageScroll = getPageScroll(), pageSize = getPageSize();
            this.overlay.setProperty('style', 'display:block; height:' + pageSize[1] + 'px;');
            this.overlayEffect = new Animate(this.overlay, 'opacity', Animate.easeOut, 0, this.overlayOpacity, this.resizeDuration, '');
            this.overlayEffect.start();
            this.imageArray = [];
            if ((link.getProperty('rel') === 'lightbox')) {
                this.imageArray.push([link.getProperty('href'), link.getProperty('title')]);
            } else {
                anchors = document.get('a[rel="' + link.getProperty('rel') + '"]') || [];
                for (i = 0; (anchor = anchors[i]); i += 1) {
                    this.imageArray.push([anchor.getProperty('href'), anchor.getProperty('title')]);
                }
                while (this.imageArray[imageNumber][0] !== link.getProperty('href')) {
                    imageNumber += 1;
                }
            }
            this.lightbox.setProperty('style', 'display:block; top:' + (pageScroll[1] + (pageSize[3] / 15)) + 'px; left:' + pageScroll[0] + 'px;');
            this.changeImage(imageNumber);
        },
        updateDetails: function () {
            this.lightboxCaption.innerHTML = this.imageArray[this.imageCurrent][1];
            if (this.imageArray.length > 1) {
                this.lightboxImageSet.style.display = 'block';
                this.lightboxImageSet.innerHTML = 'Image ' + (this.imageCurrent + 1) + ' of ' + this.imageArray.length;
            }
            if (this.imageCurrent !== 0) {
                this.lightboxPrevLink.style.display = 'block';
                this.lightboxPrevLink.onclick = function () {
                    this.changeImage(this.imageCurrent - 1);
                    if (window.msie) {
                        window.event.returnValue = false;
                    }
                    return false;
                }.bind(this);
            }
            if (this.imageCurrent !== (this.imageArray.length - 1)) {
                this.lightboxNextLink.style.display = 'block';
                this.lightboxNextLink.onclick = function () {
                    this.changeImage(this.imageCurrent + 1);
                    if (window.msie) {
                        window.event.returnValue = false;
                    }
                    return false;
                }.bind(this);
            }
            this.onkeydown();
            if (this.slideShow && this.imageArray.length > 1) {
                if (this.slideShowPlaying) {
                    this.slideShowPlay();
                } else {
                    this.slideShowStop();
                }
            }
        },
        version: versioning.join('.') + ' (' + build.valueOf() + ')'
    };
}(this));

/*Google Anayltics*/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12490342-1'], ['_trackPageview']);