/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, 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;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) 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;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, 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 + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

/* jquery.swfobject.license.txt */
(function(C){ var E=document,B="object",D=window,A="";C.flashPlayerVersion=(function(){ var H,F,K,J,M=false,L="ShockwaveFlash.ShockwaveFlash";if(!(H=navigator.plugins["Shockwave Flash"])){ try{ F=new ActiveXObject(L+".7")}catch(K){ try{ F=new ActiveXObject(L+".6");H=[6,0,21];F.AllowScriptAccess="always"}catch(J){ if(H&&H[0]===6){M=true}}if(!M){ try{ F=new ActiveXObject(L)}catch(I){ H="X 0,0,0"}}}if(!M&&F){ try{H=F.GetVariable("$version")}catch(G){}}}else{H=H.description}H=H.match(/^[A-Za-z\s]*?(\d+)(\.|,)(\d+)(\s+r|,)(\d+)/);return[H[1]*1,H[3]*1,H[5]*1]}());C.flashExpressInstaller="expressInstall.swf";C.hasFlashPlayer=(C.flashPlayerVersion[0]!==0);C.hasFlashPlayerVersion=function(G){ var F=C.flashPlayerVersion;G=(/string|number/.test(typeof G))?G.toString().split("."):G;G=[G.major||G[0]||F[0],G.minor||G[1]||F[1],G.release||G[2]||F[2]];return(C.hasFlashPlayer&&(G[0]>F[0]||(G[0]===F[0]&&(G[1]>F[1]||(G[1]===F[1]&&G[2]>=F[2])))))};C.flash=function(Q){ if(!C.hasFlashPlayer){ return false}var G=Q.swf||A,O=Q.params||{ },I=E.createElement("body"),F,P,L,H,N,M,K,J;Q.height=Q.height||180;Q.width=Q.width||320;if(Q.hasVersion&&!C.hasFlashPlayerVersion(Q.hasVersion)){ C.extend(Q,{id:"SWFObjectExprInst",height:Math.max(Q.height,137),width:Math.max(Q.width,214)});G=Q.expressInstaller||C.flashExpressInstaller;O={ flashvars:{ MMredirectURL:location.href,MMplayerType:(C.browser.msie&&C.browser.win)?"ActiveX":"PlugIn",MMdoctitle:E.title.slice(0,47)+" - Flash Player Installation"}}}if(typeof O===B){ if(Q.flashvars){O.flashvars=Q.flashvars}if(Q.wmode){O.wmode=Q.wmode}}for(N in (M=["expressInstall","flashvars","hasVersion","params","swf","wmode"])){ delete Q[M[N]]}F=[];for(N in Q){ if(typeof Q[N]===B){ P=[];for(M in Q[N]){P.push(M.replace(/([A-Z])/,"-$1").toLowerCase()+":"+Q[N][M]+";")}Q[N]=P.join(A)}F.push(N+'="'+Q[N]+'"')}Q=F.join(" ");if(typeof O===B){ F=[];for(N in O){ if(typeof O[N]===B){ P=[];for(M in O[N]){ if(typeof O[N][M]===B){ L=[];for(K in O[N][M]){ if(typeof O[N][M][K]===B){ H=[];for(J in O[N][M][K]){H.push([J.replace(/([A-Z])/,"-$1").toLowerCase(),":",O[N][M][K][J],";"].join(A))}O[N][M][K]=H.join(A)}L.push([K,"{",O[N][M][K],"}"].join(A))}O[N][M]=L.join(A)}P.push([M,"=",D.escape(O[N][M])].join(A))}O[N]=P.join("&amp;")}F.push(['<PARAM NAME="',N,'" VALUE="',O[N],'">'].join(A))}O=F.join(A)}if(!(/style=/.test(Q))){ Q+=' style="vertical-align:text-top;"'}if(!(/style=(.*?)vertical-align/.test(Q))){Q=Q.replace(/style="/,'style="vertical-align:text-top;')}if(C.browser.msie){ Q+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';O='<PARAM NAME="movie" VALUE="'+G+'">'+O}else{ Q+=' type="application/x-shockwave-flash" data="'+G+'"'}I.innerHTML=["<OBJECT ",Q,">",O,"</OBJECT>"].join(A);return C(I.firstChild)};C.fn.flash=function(G){ if(!C.hasFlashPlayer){ return this}var F=0,H;while((H=this.eq(F++))[0]){H.html(C.flash(C.extend({},G)));if(E.getElementById("SWFObjectExprInst")){F=this.length}}return this}}(jQuery));

/**
* DUI: The Digg User Interface Library
*
* Copyright (c) 2008-2009, Digg, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the Digg, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @module DUI
* @author Micah Snyder <micah@digg.com>
* @description The Digg User Interface Library
* @version 0.0.4
* @link http://code.google.com/p/digg
*
*/

/* Add Array.prototype.indexOf -- Guess which major browser doesn't support it natively yet? */
[ ].indexOf || (Array.prototype.indexOf = function(v, n) {
    n = (n == null) ? 0 : n; var m = this.length;

    for (var i = n; i < m; i++) {
        if (this[i] == v) return i;
    }

    return -1;
});

(function($) {

    /* Create our top-level namespace */
    DUI = {
        version: "0.0.4"
    };

    /**
    * @class Class Class creation and management for use with jQuery. Class is a singleton that handles static and dynamic classes, as well as namespaces
    */
    DUI.Class = {
        /**
        * @var {Array} _dontEnum Internal array of keys to omit when looking through a class' properties. Once the real DontEnum bit is writable we won't have to deal with this.
        */
        _dontEnum: ['_ident', '_dontEnum', 'create', 'namespace', 'ns', 'supers', 'sup', 'init', 'each'],

        /**
        * @function create Make a class! Do work son, do work
        * @param {optional Object} methods Any number of objects can be passed in as arguments to be added to the class upon creation
        * @param {optional Boolean} static If the last argument is Boolean, it will be treated as the static flag. Defaults to false (dynamic)
        */
        create: function() {
            //Set _this to DUI.Class
            var _this = this;

            //Figure out if we're creating a static or dynamic class
            var s = (arguments.length > 0 && //if we have arguments...
                arguments[arguments.length - 1].constructor == Boolean) ? //...and the last one is Boolean...
                    arguments[arguments.length - 1] : //...then it's the static flag...
                    false; //...otherwise default to a dynamic class

            //Static: Object, dynamic: Function
            var c = s ? {} : function() {
                this.init.apply(this, arguments);
            }

            //All of our classes have these in common
            var methods = {
                _ident: {
                    library: "DUI.Class",
                    version: "0.0.4",
                    dynamic: true
                },

                //_dontEnum should exist in our classes as well
                _dontEnum: this._dontEnum,

                //A basic namespace container to pass objects through
                ns: [],

                //A container to hold one level of overwritten methods
                supers: {},

                //A constructor
                init: function() { },

                //Our namespace function
                namespace: function(ns) {
                    //Don't add nothing
                    if (!ns) return null;

                    //Set _this to the current class, not the DUI.Class lib itself
                    var _this = this;

                    //Handle ['ns1', 'ns2'... 'nsN'] format
                    if (ns.constructor == Array) {
                        //Call namespace normally for each array item...
                        $.each(ns, function() {
                            _this.namespace.apply(_this, [this]);
                        });

                        //...then get out of this call to namespace
                        return;

                        //Handle {'ns': contents} format
                    } else if (ns.constructor == Object) {
                        //Loop through the object passed to namespace
                        for (var key in ns) {
                            //Only operate on Objects and Functions
                            if ([Object, Function].indexOf(ns[key].constructor) > -1) {
                                //In case this.ns has been deleted
                                if (!this.ns) this.ns = [];

                                //Copy the namespace into an array holder
                                this.ns[key] = ns[key];

                                //Apply namespace, this will be caught by the ['ns1', 'ns2'... 'nsN'] format above
                                this.namespace.apply(this, [key]);
                            }
                        }

                        //We're done with namespace for now
                        return;
                    }

                    //Note: [{'ns': contents}, {'ns2': contents2}... {'nsN': contentsN}] is inherently handled by the above two cases

                    var levels = ns.split(".");

                    /* Dynamic classes are Functions, so we'll extend their prototype.
                    Static classes are Objects, so we'll extend them directly */
                    var nsobj = this.prototype ? this.prototype : this;

                    $.each(levels, function() {
                        /* When adding a namespace check to see, in order:
                        * 1) Does the ns exist in our ns passthrough object?
                        * 2) Does the ns already exist in our class
                        * 3) Does the ns exist as a global var?
                        * NOTE: Support for this was added so that you can namespace classes
                        * into other classes, i.e. MyContainer.namespace('MyUtilClass'). this
                        * behaviour is dangerously greedy though, so it may be removed.
                        * 4) If none of the above, make a new static class
                        */
                        nsobj[this] = _this.ns[this] || nsobj[this] || window[this] || DUI.Class.create(true);

                        /* If our parent and child are both dynamic classes, copy the child out of Parent.prototype and into Parent.
                        * It seems weird at first, but this allows you to instantiate a dynamic sub-class without instantiating
                        * its parent, e.g. var baz = new Foo.Bar();
                        */
                        if (_this.prototype && DUI.isClass(nsobj[this]) && nsobj[this].prototype) {
                            _this[this] = nsobj[this];
                        }

                        //Remove our temp passthrough if it exists
                        delete _this.ns[this];

                        //Move one level deeper for the next iteration
                        nsobj = nsobj[this];
                    });

                    //TODO: Do we really need to return this? It's not that useful anymore
                    return nsobj;
                },

                /* Create exists inside classes too. neat huh?
                * Usage differs slightly: MyClass.create('MySubClass', { myMethod: function() }); */
                create: function() {
                    //Turn arguments into a regular Array
                    var args = Array.prototype.slice.call(arguments);

                    //Pull the name of the new class out
                    var name = args.shift();

                    //Create a new class with the rest of the arguments
                    var temp = DUI.Class.create.apply(DUI.Class, args);

                    //Load our new class into the {name: class} format to pass it into namespace()
                    var ns = {};
                    ns[name] = temp;

                    //Put the new class into the current one
                    this.namespace(ns);
                },

                //Iterate over a class' members, omitting built-ins
                each: function(cb) {
                    if (!$.isFunction(cb)) {
                        throw new Error('DUI.Class.each must be called with a function as its first argument.');
                    }

                    //Set _this to the current class, not the DUI.Class lib itself
                    var _this = this;

                    $.each(this, function(key) {
                        if (_this._dontEnum.indexOf(key) != -1) return;

                        cb.apply(this, [key, this]);
                    });
                },

                //Call the super of a method
                sup: function() {
                    try {
                        var caller = this.sup.caller.name;
                        this.supers[caller].apply(this, arguments);
                    } catch (noSuper) {
                        return false;
                    }
                }
            }

            //Static classes don't need a constructor
            s ? delete methods.init : null;

            //...nor should they be identified as dynamic classes
            s ? methods._ident.dynamic = false : null;

            /* Put default methods into the class before anything else,
            * so that they'll be overwritten by the user-specified ones */
            $.extend(c, methods);

            /* Second copy of methods for dynamic classes: They get our
            * common utils in their class definition AND their prototype */
            if (!s) $.extend(c.prototype, methods);

            //Static: extend the Object, Dynamic: extend the prototype
            var extendee = s ? c : c.prototype;

            //Loop through arguments. If they're the right type, tack them on
            $.each(arguments, function() {
                //Either we're passing in an object full of methods, or the prototype of an existing class
                if (this.constructor == Object || typeof this.init != undefined) {
                    /* Here we're going per-property instead of doing $.extend(extendee, this) so that
                    * we overwrite each property instead of the whole namespace. Also: we omit the 'namespace'
                    * helper method that DUI.Class tacks on, as there's no point in storing it as a super */
                    for (i in this) {
                        /* If a property is a function (other than our built-in helpers) and it already exists
                        * in the class, save it as a super. note that this only saves the last occurrence */
                        if ($.isFunction(extendee[i]) && _this._dontEnum.indexOf(i) == -1) {
                            //since Function.name is almost never set for us, do it manually
                            this[i].name = extendee[i].name = i;

                            //throw the existing function into this.supers before it's overwritten
                            extendee.supers[i] = extendee[i];
                        }

                        //Special case! If 'dontEnum' is passed in as an array, add its contents to DUI.Class._dontEnum
                        if (i == 'dontEnum' && this[i].constructor == Array) {
                            extendee._dontEnum = $.merge(extendee._dontEnum, this[i]);
                        }

                        //extend the current property into our class
                        extendee[i] = this[i];
                    }
                }
            });

            //Shiny new class, ready to go
            return c;
        }
    };

})(jQuery);

//Simple check so see if the object passed in is a DUI Class
DUI.isClass = function(check, type) {
    type = type || false;

    try {
        if (check._ident.library == 'DUI.Class') {
            if ((type == 'dynamic' && !check._ident.dynamic)
               || (type == 'static' && check._ident.dynamic)) {
                return false;
            }

            return true;
        }
    } catch (noIdentUhOh) {
        return false;
    }

    return false;
}

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){ if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){ if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))

var mousecoords = null;
var current = '';
var locked = false;
var headlineText1 = '';
var headlineText2 = '';
var menu_hold = '';


var campaignIndex;
var campaignLocked;
var campaignLoader;
var campaignImageSequence;
var campaignSpeed;
var campaignTime;
var campaignVideo;

var ExternalFile = DUI.Class.create({
	init: function(filename, type) {
		this.filename = filename;
		if(type == null || type == "") {
			if(filename.indexOf('css') != -1)
				this.type = "css";
			else
				this.type="js";
		} else
			this.type = type;
		this.load();
	},
	load: function() {
		if(this.type == "css") {
			var fileref = document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", this.filename);
		} else {
			var fileref = document.createElement("script");
			fileref.setAttribute("type", "text/javascript");
			fileref.setAttribute("src", this.filename);
		}
		if (typeof fileref!="undefined")
			document.getElementsByTagName("head")[0].appendChild(fileref)
	}
});
var FileLoader = DUI.Class.create({
	init: function() {
		this.files = [];
	},
	load: function(filename) {
		if(!this.find(filename))
			this.files.push(new ExternalFile(filename));
	},
	find: function(filename) {
		for(var i=0; i<this.files.length; i++)
			if(this.files[i].filename == filename)
				return true;
		return false;
	}
});

var fileloader = new FileLoader();

var Loader = DUI.Class.create({
	init: function() {
		this.queue = [];
		this.loading = false;
		this.timeout = 0;
	},
	add: function(name) {
		if(this.queue.length == 0) {
			clearTimeout(this.timeout);
			this.timeout = setTimeout(this.show, 1000);
		}
		this.queue = [];
		this.queue.push(name);
	},
	remove: function(name) {
		if(this.queue.length == 0) { clearTimeout(this.timeout); return; }
		for(var i=0; i<this.queue.length; i++)
			if(this.queue[i] == name)
				this.queue.splice(i, 1);
		if(this.queue.length == 0) {
			clearTimeout(this.timeout);
			this.hide();
		}
	},
	show: function() {
		clearTimeout(this.timeout);
		if(!$.browser.msie || $.browser.version.substr(0,1)>7)
			$("#blackout").stop().css({ display : 'block' }).animate({ opacity : 1 }, { queue : false,  duration : 250 });
		$("#loader").stop().css({ display : 'block' }).animate({ opacity : 1 }, { queue : false,  duration : 500 });
	},
	hide: function() {
		if(!$.browser.msie || $.browser.version.substr(0,1)>7)
			$("#blackout").stop().animate({ opacity : 0 }, { queue : false,  duration : 250, complete : function() { $(this).css({ display : 'none' }); } });
		$("#loader").stop().animate({ opacity : 0 }, { queue : false,  duration : 250, complete : function() { $(this).css({ display : 'none' }); } });
	}
});

var phbRequirement = "";

$(function() {
  document.write = function(evil) {
    phbRequirement += evil;
$('#mailchimpdiv').html(phbRequirement);
  }
});


var loader = new Loader();
/*
 *	JQuery Image Sequences
 *	Developed at Noble Studios
 */
(function($) {
	$.fx.step['imageSequence'] = function(fx) {
		var index = Math.min(parseInt(Math.round(fx.end.frames.length * fx.pos)), fx.end.frames.length - 1);
		if($(fx.elem).data('is_index') != index) {
			fx.elem.innerHTML = '<img src="'+fx.end.frames[Math.max(index - 1, 0)].src+'" \>';
			fx.elem.style.background = 'url('+fx.end.frames[index].src+') 0 0 no-repeat';
			$(fx.elem).data('is_index', index);
		} else if(index == fx.end.frames.length - 1)
			fx.elem.innerHTML = '';
		$(fx.elem).pngFix();
	}
	$.ImageSequence = DUI.Class.create({
		init: function(options) {
			var defaults = jQuery.extend({
				frames : [],
				load : null,
				loadStep : null
			}, options);
			
			jQuery.extend(this, defaults);
			this.numloaded = 0;
			this.loaded = false;
			this.reversed = false;
			
			var parent = this;
			
			$.each(this.frames, function(i, frame) {
				parent.frames[i] = new Image();
				parent.frames[i].src = frame;
				if(parent.frames[i].complete)
					parent.loadImage(parent);
				else
					parent.frames[i].onload = function() {parent.loadImage(parent);}
			});
		},
		loadImage: function(is) {
			is.numloaded++;
			if(is.loadStep) is.loadStep(is.numloaded / is.frames.length, is);
			if(is.numloaded == is.frames.length) {
				this.loaded = true;
				if(is.load) is.runLoad(is);
			}
		},
		addLoad: function(func) {
			if(this.load == null)
				this.load = func;
			else if(typeof this.load == 'function')
				this.load = new Array(this.load, func);
			else
				this.load.push(func);
				
		},
		runLoad:function(is) {
			if(this.load != null) {
				if(typeof this.load == 'function')
					this.load(is);
				else
					for(var i=0; i<this.load.length; i++)
						this.load[i](is);
			}
			this.load = null;
		},
		waitLoad: function(callback) {
			this.addLoad(callback);
			if(this.loaded) this.runLoad();
		},
		addFrames: function(obj) {
			var parent = this;
			if(typeof obj == "object")
				$.each(obj, function(i, frame) {addFrame(frame);});
			else
				addFrame(obj);

			this.loaded = false;

			function addFrame(frame) {
				parent.frames.push(new Image());
				parent.frames[parent.frames.length-1].src = frame;
				if(parent.frames[parent.frames.length-1].complete)
					parent.loadImage(parent);
				else
					parent.frames[parent.frames.length-1].onload = function() {parent.loadImage(parent);}
			}
		},
		setForward: function() {
			if(this.reversed) this.reverseFrames();
		},
		setBackward: function() {
			if(!this.reversed) this.reverseFrames();
		},
		reverseFrames: function() {
			this.reversed = !this.reversed;
			this.frames.reverse();
		}
	});
})(jQuery);
var ImageLoader = DUI.Class.create({
	init: function() {
		this.imageObj = new Image();
		this.callback = null;
	},
	load: function(src, callback) {
		this.callback = callback;
                if($.browser.msie && $.browser.version.substr(0,1)>=9)
		  this.imageObj.onload = callback;
		this.imageObj.onerror = function() {
			alert('Connection lost.  Please refresh the page once the connection has been reestablished.');
		};
		this.imageObj.src = src;
		if(this.imageObj.complete) {
			this.imageObj.onload = function() {};
			this.callback.call(this.imageObj);
		}
	}
});

$(document).ready(function() {
  jQuery.queue.def = false;
  jQuery.easing.def = "easeOutQuad";
  $('body').css({ position : 'static' }).css({ position : 'relative' });

  $.scrollTo('0', 500);

  headlineText1 = $('#header h1').html();
  headlineText2 = $('#header h2').html();
  if($.browser.msie) {
    $('#header h1').html("");
    $('#header h2').html("");
 }

  


  // Main menu hover
  $('#menu a').hover(menuHoverOn, menuHoverOff);
  function menuHoverOn(){
    $(this).find('img.on').stop()
	  .css({ opacity : 0, display : 'inline' })
	  .animate({ opacity : 1 } , { duration : 250 });
	$(this).find('img.caption').stop()
	  .css({ opacity : 0, display : 'inline', marginLeft : -10 })
	  .animate({ opacity : 1, marginLeft : 0 }, { duration : 250 });
  }
  function menuHoverOff(){
    $(this).find('img.on').stop()
      .animate({ opacity : 0 } , { duration : 250, complete:function(){ $(this).css({ display: 'none' }); } });
    $(this).find('img.caption').stop()
      .animate({ opacity : 0, marginLeft : -10 }, { duration : 250, complete:function(){ $(this).css({ display: 'none' }); } });
  }

  // Footer social hover
  $('#social a').hover(socialOn, socialOff);
  function socialOn(){
    $(this).find('img.on').stop()
	  .css({ opacity : 0, display: 'block' })
	  .animate({ opacity : 1 } , { duration : 200 });
  }
  function socialOff(){
    $(this).find('img.on').stop()
	  .animate({ opacity : 0 } , { duration : 300, complete:function(){ $(this).css({ display: 'none' }); } });
  }

  
});


// AJAX page request getURL(url#hash)
String.prototype.capitalize = function(){ //v1.0
    return this.replace(/\w+/g, function(a){
        if(a == "and" || a == "of") return a;
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};


function convertHash(hash) {
  hash = hash.replace(new RegExp( "_", "g" ), " ");
  if(hash.lastIndexOf("/") == hash.length - 1)
    hash = hash.substring(0, hash.lastIndexOf("/"));
  return hash.replace(new RegExp( "/", "g" ), " > ").capitalize();
}

function getURL(hash, linkObj) {
	hash = hash.substring(hash.lastIndexOf('#') + 1);
	if(!locked && current!=hash ) {
		loader.add("page");
		locked = true;
                pageTracker._trackPageview("/"+hash+".html" );
		var hash_ref = hash.split("/");
		if( hash_ref[0] != 'about' && hash_ref[0] != 'showcase' && hash_ref[0] != 'clients' && hash_ref[0] != 'news' && hash_ref[0] != 'contact' && hash_ref[0] != 'videos')
			hash='';

		//animate content out
		if($.browser.msie) {
		    $('body').css({ position : 'static' }).css({ position : 'relative' });
		    $('#body, #body #showcase, #body div#projects, #body div#showcase_pagination .buttons, #body .clientswrapper, #body .campaign_wrapper, #body #news_wrapper .pagination, #body #map_wrapper').animate({ opacity : 0 }, { duration : 200, queue : false });
		} else
		    $('#body').animate({ opacity : 0 }, { duration : 200, queue : false });

		$('#hidden').load('http://www.noblestudios.com/' + hash + '/content/ajax/', function (responseText, textStatus, XMLHttpRequest) {
			loader.remove("page");
			if(responseText != '') {
				//update title
				if(document.title) document.title = convertHash('Noble Studios, Inc.'+((hash != "") ? ' > '+hash : ' - Marketing and Web Development'));  //$('#content .page_title:first').html();
				//call pngFix() for new content if needed

			  if(!$.browser.msie && (hash_ref[0] == "index" || hash_ref[0] == ""))
				headTextOn();
			  else
				headTextOff();
				//after fade content out is finished:
				setTimeout(function() {
					if ( hash == '' ) hash = 'index';
					current = hash;
					//update url
					window.location.hash = hash;
					//save hash for ie
					$('#hiddenFrame').attr('src', 'http://www.noblestudios.com/incl/store_hash?hash='+hash);
					//determine height of new content
					var h = $('#hidden').height();
					//animate in header
					//if( hash == 'index' && $.browser.msie) headTextOn();
					$('#header').animate({height : '110px'}, { duration : 250, queue : false });
					//animate in body
					$('#body .inner').animate({ height : (h > 121) ? h : 121 },{ duration : 500, complete : function(){$('#body .inner').css({height:'auto', overflow:'visible'});} });

					var tempname = current.split("/")[0];
					var temppath = "http://www.noblestudios.com/index.php/";
					switch(tempname) {
						case "index":
							break;
						default:
//							fileloader.load(temppath+tempname+"/css_"+tempname);
							break;
					}
					//after animate in
					setTimeout(function() {
						//move content from div#hidden to div.inner
						$('#body .inner').html($('#hidden').html());
						$('#hidden').html('');
						
						
						//call initialize functions after new content is loaded
						var current_ref = current.split("/")
						var path = "http://www.noblestudios.com/index.php/";

						if ( current_ref[0] == 'index' )
							initHome();
						else if ( current_ref[0] == 'about' ) {
							var aboutPath = path + 'about/';
							
							if(!fileloader.find(aboutPath+"js_about"))
								fileloader.load(aboutPath+"js_about");
							else
								initAbout();
						} else if ( current_ref[0] == 'showcase' ) {
							var showcasePath = path + 'showcase/';
							if(!fileloader.find(showcasePath+"js_showcase"))
								fileloader.load(showcasePath+"js_showcase");
							else
								initShowcase();
						} else if ( current_ref[0] == 'clients' ) {
							var clientsPath = path + 'clients/';
							if(!fileloader.find(clientsPath+"js_clients"))
								fileloader.load(clientsPath+"js_clients");
							else
								initClients();
						} else if ( current_ref[0] == 'news' ) {
							var newsPath = path + 'news/';
							if(!fileloader.find(newsPath+"js_news"))
								fileloader.load(newsPath+"js_news");
							else
								initNews();
						} else if ( current_ref[0] == 'contact' ) {
							var contactPath = path + 'contact/';
							if(!fileloader.find(contactPath+"js_contact"))
								fileloader.load(contactPath+"js_contact");
							else
								initContact();
						} else if (current_ref[0] == 'videos')
							$('#sub_wrapper h1').each( h1Replace );

						//$('#body').animate({ opacity : 1 }, { duration : 500, complete : function() { if(jQuery.browser.msie) this.style.removeAttribute("filter"); } });
						if($.browser.msie) {
						    $('body').css({ position : 'static' }).css({ position : 'relative' });
						    $('#body, #body #showcase, #body div#projects, #body div#showcase_pagination .buttons, #body .clientswrapper, #body #news_wrapper .pagination, #body #map_wrapper').animate({ opacity : 1 }, { duration : 200, queue : false, complete : function() { if(jQuery.browser.msie) this.style.removeAttribute("filter"); } });
						} else
						    $('#body').animate({ opacity : 1 }, { duration : 200, queue : false, complete : function() { if(jQuery.browser.msie) this.style.removeAttribute("filter"); } });
						$('#pagewrapper').css({'position':'static'}).css({'position':'relative'});
						$('body').css({'position':'static'}).css({'position':'relative'});
						locked = false;
						if (current_ref.length=2)
						  $(linkObj).mouseout();
					}, 500);
				}, 200);
			} else
				locked = false;
		});
	}
}

function checkURL() {
  if(!locked) {
    var hash_page = window.location.hash.substring(window.location.hash.lastIndexOf('#') + 1);
    if(document.frames && document.frames['hiddenFrame'] && document.frames['hiddenFrame'].getHash && current != document.frames['hiddenFrame'].getHash()) window.location.hash = document.frames['hiddenFrame'].getHash();
    if(current != hash_page ) getURL(hash_page);
  }
}

// flash text replace
function h1Replace(index, element){
    $(this).css({
        width: $(this).width(),
        height:$(this).height()
      }).flash({
      swf: 'http://www.noblestudios.com/images/uploads/fonts/humanist777_light_replace.swf',
      flashvars: { text : encodeURIComponent($(this).html()),  color : '#ffffff',  width : $(this).width(),  height : $(this).height(), size : 35, align : 'left', line : 12,  spacing : -0.5 },
      height: $(this).height(), width: $(this).width(), bgcolor: '#080809', wmode: 'transparent'
      });
}

function h2Replace(index, element){
    $(this).css({
        width: $(this).width(),
        height:$(this).height()
      }).flash({
      swf: 'http://www.noblestudios.com/images/uploads/fonts/humanist777_light_replace.swf',
      flashvars: { text : encodeURIComponent($(this).html()),  color : '#939598',  width : $(this).width(),  height : $(this).height(), size : 20, align : 'left', line : 14,  spacing : 0 },
      height: $(this).height(), width: $(this).width(), bgcolor: '#080809', wmode: 'transparent'
      });
}

function h3Replace(index, element){
    $(this).css({
        width: $(this).width(),
        height:$(this).height()
      }).flash({
      swf: 'http://www.noblestudios.com/images/uploads/fonts/humanist777_light_replace.swf',
      flashvars: { text : encodeURIComponent($(this).html()),  color : '#ffffff',  width : $(this).width(),  height : $(this).height(), size : 28, align : 'left', line : 8,  spacing : -0.5 },
      height: $(this).height(), width: $(this).width(), bgcolor: '#080809', wmode: 'transparent'
      });
}

function headTextOn(){
   $('#header h1').html(headlineText1).flash({
      swf: 'http://www.noblestudios.com/images/uploads/fonts/humanist777_light_replace.swf',
      flashvars: { text : headlineText1,  color : '#ffffff',  width : 976,  height : 44, size : 35, align : 'center', line : 0,  spacing : -0.5 },
      height: 44, width: 976, bgcolor: '#080809', wmode: 'transparent'
      });
   $('#header h2').html(headlineText2).flash({
      swf: 'http://www.noblestudios.com/images/uploads/fonts/humanist777_light_replace.swf',
      flashvars: { text : headlineText2,  color : '#939598',  width : 976,  height : 120, size : 20, align : 'center', line : 14,  spacing : 0 },
      height: 120, width: 976, bgcolor: '#080809', wmode: 'transparent'
      });
}
function headTextOff(){
      $('#header h1').html('');
      $('#header h2').html('');
}

function sizeFlash() {
  var screenWidth = $(this).width();
  var screenHeight = $(this).height();
  $('#fourthWard').width( screenWidth );
  $('#fourthWard').height( screenHeight );
  $('#fourthWard object').width( screenWidth );
  $('#fourthWard object').height( screenHeight );
}

$(document).mousemove(function(e) {
	mousecoords = { x : e.pageX, y : e.pageY };
});

$(document).ready(function() {
	$('#blackout').css('opacity', 0).click(hideVideo);
	$('#lightbox').click(function(e){e.stopPropagation()});});
function showVideo(src) {
	$('#lightbox').animate({width:800,height: 600,marginTop:-310,marginLeft:-410},{queue:false,duration:500}).html('').flash({
		swf: 'http://www.noblestudios.com/images/uploads/template/swf/flv_player_big.swf',
		flashvars: { file : src },
		height: '100%', width: '100%', wmode: 'opaque'
	});//.append('<a href="javascript:void(0)" onclick="hideVideo()">Close</a>');
	$('#blackout').css('display','block').animate({opacity:1},{queue:false,duration:500});}
function hideVideo() {
	$('#lightbox').animate({width:0,height: 0,marginTop:-10,marginLeft:-10},{queue:false,duration:500});
	$('#blackout').animate({opacity:0},{queue:false,duration:250,complete:function() {
		$(this).css('display','none');
		$('#lightbox').html();
	}});
}

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

var campaigns = [

{
  description: "",
  source: "http://noblestudios.com/images/uploads/campaign/ArtWallCampaign_v1.jpg",
  link: "http://www.noblestudios.com/news/page/artists"},
{
  description: "You can follow us... wherever we may go.  There isn't an ocean too deep. A mountain so high it can keep. Keep us away. ",
  source: "http://noblestudios.com/images/uploads/campaign/2010_0112_CampaignImage_social.jpg",
  link: "http://noblestudios.com/news/page/social_noble"},
{
  description: "Noble Studios wishes everyone a very happy holidays!",
  source: "http://noblestudios.com/images/uploads/campaign/2010_HolidayCard.jpg",
  link: "http://noblestudios.com/happy_holidays/"},
{
  description: "Noble Studios received four 2010 Awards of Excellence (Gold) and three Awards of Distinction (Silver) from the Communicator Awards, the leading international awards program honoring creative excellence.",
  source: "http://noblestudios.com/images/uploads/campaign/20100607_CommunicatorAwards_v4.jpg",
  link: "http://www.noblestudios.com/news/page/communicator_awards"},
{
  description: "The Nevada District office of the U. S. Small Business Administration has selected its small business award honorees for 2010. Jarrod Lopiccolo, co-owner of Noble Studios in Carson City, has been named Young Entrepreneur of the Year for the State of Nevada. Jarrod and the other honorees will be recognized at an after-hours awards reception the week of May 3rd in Las Vegas.  ",
  source: "http://noblestudios.com/images/uploads/campaign/Campaign_EntrepreneurAward.jpg",
  link: "http://www.noblestudios.com/news/page/entrepreneur_of_the_year"},
{
  description: "",
  source: "http://noblestudios.com/images/uploads/campaign/20100129_CampaignImage_dave.jpg",
  link: "http://www.noblestudios.com/about/awards/"},
{
  description: "Microsoft Photosynth - Noble Studios is working on a project using the new Microsoft Photosynth software released in 2009.",
  source: "http://noblestudios.com/images/uploads/campaign/synth.jpg",
  link: "http://www.noblestudios.com/contact/"},
{
  description: "Congratulations Nevada Magazine Wins First Place in 2008 National Headliner Awards",
  source: "http://noblestudios.com/images/uploads/campaign/20090825_CampaignImage_nevm.jpg",
  link: "http://www.noblestudios.com/about/awards/"},
{
  description: "Here's to happy memories in 2009!",
  source: "http://noblestudios.com/images/uploads/campaign/karma.jpg",
  link: "javascript:addFlvPlayer('http://www.noblestudios.com/images/uploads/flv_player/video.flv')"},
{
  description: "Congratulations Holland Project Wins in the 2008 Communicator Awards",
  source: "http://noblestudios.com/images/uploads/campaign/20090825_CampaignImage_holl.jpg",
  link: "http://www.noblestudios.com/about/awards/"},
{
  description: "From our desk to Autodesk.",
  source: "http://noblestudios.com/images/uploads/campaign/fromourdesk.jpg",
  link: "http://www.noblestudios.com/showcase/"},
{
  description: "Nice work Michelangelo! We'll see you soon at the 2009 Noble Retreat.",
  source: "http://noblestudios.com/images/uploads/campaign/europe.jpg",
  link: "http://www.noblestudios.com/news/page/we_made_our_goal2"},
{
  description: "Autodesk Dragonfly is alive!",
  source: "http://noblestudios.com/images/uploads/campaign/dragonfly.jpg",
  link: "http://www.noblestudios.com/news/page/autodesk_project_dragonfly"},
{
  description: "Happy Birthday Noble!",
  source: "http://noblestudios.com/images/uploads/campaign/bday.jpg",
  link: "http://www.noblestudios.com/about/"}
];

$(document).ready(function() {
for(var i=0; i<campaigns.length; i++) {jQuery.preLoadImages(campaigns[i]['source']);}
});

function initHome(){
  if($('#header h1').css('display') == 'none') {
    $('#header h1').css('display', 'block');
    $('#header h2').css('display', 'block');
  }
  
  $('#home_wrapper h3').each( h3Replace );
}

var introTimeout = null;
function introAnimation() {
  $('*').stop( true );
  clearTimeout(introTimeout);
  $('#header').css({ height : 110});
  //$('#header .content').css({ opacity : 0, visibility : 'visible' });
  //$('#header-overlay').css({ opacity : 1, visibility : 'visible' });
  $('.module').css({ opacity : 0, visibility : 'visible', marginTop : 0 });
  $('.campaign').css({ opacity : 0, visibility : 'visible' });
if($.browser.msie)
  $('.campaign_wrapper').css({ opacity : 0, visibility : 'visible' });
  $('#header').animate({ height : 340 }, { duration : 1000, complete : function() { if($.browser.msie) headTextOn(); } });
  introTimeout = setTimeout(function() {
    //$('#header .content').animate({ opacity : 1 }, { duration : 1000 });
    //$('#header-overlay').animate({ opacity : 0 }, { duration : 1000 });
    $('.module:first').animate({ opacity : 1, marginTop : 20 }, { duration : 300, complete : animateModule });
    introTimeout = setTimeout(function() {
      $('.campaign').animate({ opacity : 1 }, { duration : 1000, complete : initCampaign });
if($.browser.msie)
  $('.campaign_wrapper').animate({ opacity : 1 }, { duration : 1000 });
      //$('#header-overlay').css({ visibility : 'hidden' });
    }, 1000);
  }, 700);
}

function animateModule() {
  $(this).find('+.module').animate({ opacity : 1, marginTop : 20 }, { duration : 300, complete : animateModule });
}

function initCampaign() {
        var directory = "http://www.noblestudios.com/images/uploads/loader/";
	$('.campaign').css({opacity:'none'});
	campaignIndex = 0;
	campaignVideo = false;
	campaignLoader = new ImageLoader();
	campaignLoaderLocked = false;
	campaignTime = 0;
	campaignSpeed = 750;
	$('#campaign_loader').css({ opacity : 0 });
	for(var i=0; i<campaigns.length; i++)
		$('.pagination').append('<span></span>');
	$('.pagination span:eq(0)').addClass('active');
	
	campaignImageSequence = new $.ImageSequence({
		frames: new Array(directory+'_0000.png',directory+'_0001.png',directory+'_0002.png',directory+'_0003.png',directory+'_0004.png',directory+'_0005.png',directory+'_0006.png',directory+'_0007.png'),
		load: function() {
			$('.pagination span').click(function(e) {
				var index = $('.pagination span').index(this);
				if(index != campaignIndex)
					campaignGoto(index);
			});
			$('.left_arrow').click(function(e) { campaignGoto(null, 'left') });
			$('.right_arrow').click(function(e) { campaignGoto(null, 'right') });
		}
	});
}

function addFlvPlayer(flv) {
	campaignVideo = true;
	if(flv == '' || flv == null) flv = 'http://www.noblestudios.com/images/uploads/flv_player/video.flv';
	$('#campaign_container').empty().flash({swf:'http://www.noblestudios.com/images/uploads/flv_player/flv_player.swf', flashvars:{video:flv}, height:352, width:907, wmode: 'transparent' });	
}
function removeFlvPlayer() {
	campaignVideo = false;
	$('#campaign_container').empty().html('<a href="'+campaigns[campaignIndex].link+'"><img src="'+campaigns[campaignIndex].source+'" width="907" height="352" alt="'+campaigns[campaignIndex].description+'" /></a>');
}
function updatePagination(i) {
	$('.campaign .pagination span').removeClass('active');
	$('.campaign .pagination span:eq('+i+')').addClass('active');
}
function campaignPaginate() {
	$('.pagination span').removeClass('active');
	$('.pagination span:eq('+campaignIndex+')').addClass('active');
}
function campaignSpeedUpdate() {
	var current = new Date();
	campaignSpeed = Math.min(750, current.getTime() - campaignTime);
	campaignTime = current.getTime();
}
function campaignGoto(index, direction) {
	var directory = "http://www.noblestudios.com/images/uploads/loader/";
	if(index == null && direction == null)
		return;
	if(index == null)
		index = ((direction == 'left') ? ((campaignIndex == 0) ? campaigns.length - 1 : campaignIndex-1) : ((campaignIndex == campaigns.length - 1) ? 0 : campaignIndex+1));
	if(direction == null) {
		if(index != campaignIndex) {
			if(index < campaignIndex)
				direction = 'left';
			else
				direction = 'right';
		} else
			return;
	}
	campaignSpeedUpdate();
	if($.browser.msie && $.browser.version.substr(0,1)<7)
		$('#campaign_loader').html('<img src="'+directory+'loader.gif" width="34" height="34" />');
	else if(!campaignLoaderLocked)
		animateLoader();
	$('#campaign_loader').css('display', 'block').animate({ opacity : 1 }, { duration : 500, queue: false });
	$('#campaign_container').stop(true, true).animate({ opacity : .5 }, { duration : 500, queue: false });
	if(campaignVideo)
		removeFlvPlayer();
	campaignIndex = index;
	campaignPaginate();
	campaignLoader.load(campaigns[index].source, function() {
		campaigns[index].source = this.src;
		$('#campaign_loader').stop().animate({ opacity : 0 }, { duration : 500, queue: false });
		$('#campaign_container').stop().animate({ opacity : 1 }, { duration : 500, queue: false });
		campaignLoaderLocked = false;
		var insert = '<a href="'+campaigns[index].link+'"><img src="'+this.src+'" width="907" height="352" alt="'+campaigns[index].description+'" /></a>';
		if(direction == 'left')
			$('#campaign_container').prepend(insert);
		else
			$('#campaign_container').append(insert);
		$('#campaign_container')
			.css('left', ((direction == 'left') ? -907 : 0))
			.animate({ left : ((direction == 'left') ? 0 : -907) }, { duration : campaignSpeed, queue: false, easing: 'easeOutQuad', complete:
			((direction == 'left')
			? function() {
					$('#campaign_container a:eq(1)').remove();
				}
			: function() {
					$('#campaign_container a:eq(0)').remove();
					$('#campaign_container').css('left', 0);
				}
			)
		});
	});
	function animateLoader() {
		campaignLoaderLocked = true;
		$('#campaign_loader').animate({ imageSequence: campaignImageSequence }, { duration: 1000, queue: false, easing: 'linear', complete: animateLoader });
	}
}


