
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


// place any jQuery/helper plugins in here, instead of separate, slower script files.

// ----------------------------------------------------------------------------
// Vegas - jQuery plugin 
// Add awesome fullscreen backgrounds to your webpages.
// v 1.1 beta
// Dual licensed under the MIT and GPL licenses.
// http://vegas.jaysalvat.com/
// ----------------------------------------------------------------------------
( function( $ ){
    var $background = $( '<img />' ).addClass( 'vegas-background' ),
        $overlay    = $( '<div />' ).addClass( 'vegas-overlay' ),
        $loading    = $( '<div />' ).addClass( 'vegas-loading' ),
        $current    = $(),
        paused = null,
        backgrounds = [],
        step = 0,
        timer,
        methods = {

        // Init plugin
        init : function( settings ) {

            var options = {
                src: getBackground(),
                align: 'center',
                valign: 'center',
                fade: 0,
                loading: true,
                load: function() {},
                complete: function() {}
            }
            $.extend( options, $.vegas.defaults.background, settings );

            if ( options.loading ) {
                loading();
            }

            $new = $background.clone();
            $new.css( {
                'position': 'fixed',
                'left': '0px',
                'top': '0px'
            })
            .load( function() {
                $( window ).bind( 'resize.vegas', function( e ) {
                    resize( $new, options );
                });

                if ( $current.is( 'img' ) ) {

                    $current.stop();

                    $new.hide()
                        .insertAfter( $current )
                        .fadeIn( options.fade, function() {
                            $('.vegas-background')
                                .not(this)
                                    .remove();
                            $( 'body' ).trigger( 'vegascomplete', [ this, step - 1 ] );
                            options.complete.apply( $new, [ step - 1 ] );
                        });
                } else {
                    $new.hide()
                        .prependTo( 'body' )
                        .fadeIn( options.fade, function() {
                            $( 'body' ).trigger( 'vegascomplete', [ this, step - 1 ] );
                            options.complete.apply( this, [ step - 1 ] );    
                        });
                }

                $current = $new;

                resize( $current, options );

                if ( options.loading ) {
                    loaded();
                }

                $( 'body' ).trigger( 'vegasload', [ $current.get(0), step - 1 ] );
                options.load.apply( $current.get(0), [ step - 1 ] );

                if ( step ) {
                    $( 'body' ).trigger( 'vegaswalk', [ $current.get(0), step - 1 ] );
                    options.walk.apply( $current.get(0), [ step - 1 ] );
                }
            })
            .attr( 'src', options.src );

            return $.vegas;
        },

        // Destroy background and/or overlay
        destroy: function( what ) {
            if ( !what || what == 'background') {
                $( '.vegas-background, .vegas-loading' ).remove();
                $( window ).unbind( 'resize.vegas' );
                $current = null;
            }

            if ( what == 'overlay') {
                $( '.vegas-overlay' ).remove();
            }

            return $.vegas;
        },

        // Display the pattern overlay
        overlay: function( settings ) {
            var options = {
                src: null,
                opacity: null
            };
            $.extend( options, $.vegas.defaults.overlay, settings );

            $overlay.remove();

            $overlay
                .css( {
                    'margin': '0',
                    'padding': '0',
                    'position': 'fixed',
                    'left': '0px',
                    'top': '0px',
                    'width': '100%',
                    'height': '100%'
            });

            if ( options.src ) {
                $overlay.css( 'backgroundImage', 'url(' + options.src + ')' );
            }

            if ( options.opacity ) {
                $overlay.css( 'opacity', options.opacity );
            }

            $overlay.prependTo( 'body' );

            return $.vegas;
        },

        // Start/restart slideshow
        slideshow: function( settings, keepPause ) {
            var options = {
                step: step,
                delay: 5000,
                preload: false,
                backgrounds: backgrounds,
                walk: function() {}
            };
            options = $.extend( {}, $.vegas.defaults.slideshow, options, settings );

            if ( options.backgrounds != backgrounds ) {
                if ( !settings.step ) {
                    options.step = 0;
                }

                if ( options.preload ) {
                    $.vegas( 'preload', options.backgrounds )
                }
            }

            backgrounds = options.backgrounds;
            step = options.step;

            clearInterval( timer );

            if ( !backgrounds.length ) {
                return $.vegas;
            }

            var doSlideshow = function() {
                if ( step < 0 ) {
                    step = backgrounds.length - 1;
                }

                if ( step >= backgrounds.length || !backgrounds[ step - 1 ] ) {
                    step = 0;
                }

                var settings = backgrounds[ step++ ];
                settings.walk = options.walk;

                $.vegas( settings );
            }
            doSlideshow();

            if ( !keepPause ) {
                paused = false;
                
                $( 'body' ).trigger( 'vegasstart', [ $current.get(0), step - 1 ] );
            }

            if ( !paused ) {
                timer = setInterval( doSlideshow, options.delay );
            }

            return $.vegas;
        },

        // Jump to the next background in the current slideshow
        next: function() {
            var from = step;

            if ( step ) {
                $.vegas( 'slideshow', { step: step }, true );

                $( 'body' ).trigger( 'vegasnext', [ $current.get(0), step - 1, from - 1 ] );
            }

            return $.vegas;
        },

        // Jump to the previous background in the current slideshow
        previous: function() {
            var from = step;

            if ( step ) {
                $.vegas( 'slideshow', { step: step - 2 }, true );

                $( 'body' ).trigger( 'vegasprevious', [ $current.get(0), step - 1, from - 1 ] );
            }

            return $.vegas;
        },

        // Jump to a specific background in the current slideshow
        jump: function( s ) {
            var from = step;

            if ( step ) {
                $.vegas( 'slideshow', { step: s }, true );

                $( 'body' ).trigger( 'vegasjump', [ $current.get(0), step - 1, from - 1 ] );
            }

            return $.vegas;
        },

        // Stop slideshow
        stop: function() {
            var from = step;
            step = 0;
            paused = null;
            clearInterval( timer );

            $( 'body' ).trigger( 'vegasstop', [ $current.get(0), from - 1 ] );

            return $.vegas;
        },

        // Pause slideShow
        pause: function() {
            paused = true;
            clearInterval( timer );

            $( 'body' ).trigger( 'vegaspause', [ $current.get(0), step - 1 ] );

            return $.vegas;
        },

        // Get some useful values or objects
        get: function( what ) {
            if ( what == null || what == 'background' ) {
                return $current.get(0);
            }

            if ( what == 'overlay' ) {
                return $overlay.get(0);
            }

            if ( what == 'step' ) {
                return step - 1;
            }

            if ( what == 'paused' ) {
                return paused;
            }
        },
        
        // Preload an array of backgrounds
        preload: function( backgrounds ) {
            for( var i in backgrounds ) {
                if ( backgrounds[ i ].src ) {
                    $('<img src="' + backgrounds[ i ].src + '">');
                }
            }

            return $.vegas;
        }
    }

    // Resize the background
    function resize( $img, settings ) {
        var options =  {
            align: 'center',
            valign: 'center'
        }
        $.extend( options, settings );

        var ww = $( window ).width(),
            wh = $( window ).height(),
            iw = $img.width(),
            ih = $img.height(),
            rw = wh / ww,
            ri = ih / iw,
            newWidth, newHeight,
            newLeft, newTop,
            properties;

        if ( rw > ri ) {
            newWidth = wh / ri;
            newHeight = wh;
        } else {
            newWidth = ww;
            newHeight = ww * ri;
        }

        properties = {
            'width': newWidth + 'px',
            'height': newHeight + 'px',
			'top': 'auto',
			'bottom': 'auto',
			'left': 'auto',
			'right': 'auto'			
        }

        if ( !isNaN( parseInt( options.valign ) ) ) {
            properties[ 'top' ] = ( 0 - ( newHeight - wh ) / 100 * parseInt( options.valign ) ) + 'px';
        } else if ( options.valign == 'top' ) {
            properties[ 'top' ] = 0;
        } else if ( options.valign == 'bottom' ) {
            properties[ 'bottom' ] = 0;
        } else {
            properties[ 'top' ] = ( wh - newHeight ) / 2;
        } 

        if ( !isNaN( parseInt( options.align ) ) ) {
            properties[ 'left' ] = ( 0 - ( newWidth - ww ) / 100 * parseInt( options.align ) ) + 'px';
        } else if ( options.align == 'left' ) {
            properties[ 'left' ] = 0;
        } else if ( options.align == 'right' ) {
            properties[ 'right' ] = 0;
        } else {
            properties[ 'left' ] = ( ww - newWidth ) / 2 ;
        }

        $img.css( properties );
    }

    // Display the loading indicator
    function loading() {
        $loading.prependTo( 'body' ).fadeIn();
    }

    // Hide the loading indicator
    function loaded() {
        $loading.fadeOut( 'fast', function() {
            $( this ).remove();
        });
    }

    // Get the background image from the body
    function getBackground() {
        if ( $( 'body' ).css( 'backgroundImage' ) ) {
            return $( 'body' ).css( 'backgroundImage' ).replace( /url\("?(.*?)"?\)/i, '$1' );
        }
    }

    // The plugin
    $.vegas = function( method ) {
        if ( methods[ method ] ) {
            return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
        } else if ( typeof method === 'object' || !method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' +  method + ' does not exist' );
        }
    };

    // Global parameters
    $.vegas.defaults = {
        background: {
            // src:         string
            // align:       string/int
            // valign:      string/int
            // fade:        int
            // loading      bool
            // load:        function
            // complete:    function
        },
        slideshow: {
            // step:        int
            // delay:       int
            // backgrounds: array
            // preload:     bool
            // walk:        function
        },
        overlay: {
            // src:         string
            // opacity:     float
        }
    }
})( jQuery );



/** Paginator plugin.  Reworked for jQuery 1.4.2 support **/
(function($) {
    var UT = {
        /**
         * Attaches the click handler for the 'prev' link.
         **/
        bindPrevClick: function(container, link) {
            link.data('container', container);
            link.click(UT.onPrevClick);
        },

        /**
         * Attaches the click handler for the 'next' link.
         **/
        bindNextClick: function(container, link) {
            link.data('container', container);
            link.click(UT.onNextClick);
        },

        /**
         * Attaches the click handler to the given numbered page link.
         **/
        bindPageClick: function(container, link, i) {
            link.data('container', container);
            link.data('i', i);
            link.click(UT.onPageClick);
        },

        /**
         * Returns a newly created DOM element representing the 'prev' link.
         **/
        createPrevLink: function() {
            var link = $('<input type="button" value="Previous"></input>')
                .addClass($.fn.paginate.defaults.nextLinkCss);

            return link;
        },

        /**
         * Returns a newly created DOM element representing the 'next' link.
         **/
        createNextLink: function() {
            var link = $('<input type="button" value="Next"></input>')
                .addClass($.fn.paginate.defaults.nextLinkCss);
            return link;
        },

        /**
         * Returns a newly created DOM element representing a numbered page link.
         **/
        createPageLink: function(i) {
            var link = $('<input type="button" value="' + (i+1) + '"/>')
                .addClass($.fn.paginate.defaults.pageLinkCss);

            return link;
        },

        /**
         * Returns a newly created DOM element representing a 'page' of content.
         **/
        createPage: function() {
            return $('<div class="' + $.fn.paginate.defaults.pageCss + '"></div>');
        },

        /**
         * Returns a newly created "marker" element containing the given text.  The marker is used for detecting the
         * offset of text within a page container.
         **/
        createHeightMarker: function(word) {
            return $('<span class="' + $.fn.paginate.defaults.markerCss + '">' + word + '</span>');
        },

        /**
         * Based on jQuery's nextAll method, except *all* node types are returned (including text nodes)
         **/
        nextAll: function(node) {
            var contents = node.parent().contents();
            var sibs = [];
            var found = false;
            for(var i=0; i<contents.length; ++i) {
                if(found) {
                    sibs.push(contents[i]);
                } else {
                    found = (node[0] == contents[i]);
                }
            }

            return $(sibs);
        },

        /**
         * The given node marks the start of a new page.  All the content that follows the node (including the node itself)
         * is added to a new page.  This is done by drilling upwards through the DOM hierarchy from the given node until the
         * page container is reached, then on the way back up (and starting with the page element itself), each successive parent
         * element is forked, and all the siblings of that element are moved to the new page.
         **/
        breakPage: function(node) {
            if(node.hasClass($.fn.paginate.defaults.pageCss)) {
                // create the new page
                var page = UT.createPage();
                var pageable = node.parents('.' + $.fn.paginate.defaults.pageableCss + ':first');
                pageable.append(page);

                return page;

            } else {
                // go straight up the the tree until the containing page is reached
                var newNode = UT.breakPage(node.parent());

                // on the way back down, fork each node until the page break marker is hit
                if(node.hasClass($.fn.paginate.defaults.markerCss)) {
                    newNode.prepend(UT.nextAll(node));
                    newNode.prepend(node);

                    return null;  // done
                } else {
                    // fork the node and add-after all the node's subsequent siblings to the newly forked container
                    var newChild = $('<' + node[0].tagName + '></' + node[0].tagName +'>');
                    newNode.append(newChild);
                    newChild.after(UT.nextAll(node));
                    return newChild;
                }
            }
        },

        /**
         * Traverses the entire DOM tree of the given element and runs the given handler on each text node found.
         **/
        eachTextNode: function(parent, onTextNode) {

            parent.contents().each(function() {

                if(this.nodeType==3) {
                    onTextNode(this);
                } else {
                    UT.eachTextNode($(this), onTextNode);
                }
            });
        },

        /**
         * Takes a page with content inside and, based on the given height, subdivides the page into smaller pages.
         **/
        subdivide: function(page, height) {

            // recursively look at every text node in the pageable content node tree
            UT.eachTextNode(page, function(node) {
                // find all the words and split the text node accordingly
                var reg = /(\w+)(([^\w]+)(\w))?/i;
                var cur = node;
                var m = cur.data.match(reg);
                // initialize the page offset by finding the page that contains the current node
                var pageOff = UT.findParentPage($(node)).offset().top;
                
                while(m) {
                    var split = m[2]? m.index+m[0].length-1 : m.index+m[0].length;
                    var next = cur.splitText(split);

                    var marker = UT.createHeightMarker(cur.data);
                    var p = cur.parentNode;
                    p.replaceChild(marker[0], cur);
                    var off = marker.offset().top;

                    // page break test
                    if(off - pageOff > height) {
                        // fork the current page starting with the marker
                        UT.breakPage(marker);
                        // update the relative page offset now that it's a new page.  use the marker to find the current page
                        pageOff = UT.findParentPage(marker).offset().top;

                    } else {
                        p.replaceChild(cur, marker[0]);
                    }

                    cur = next;
                    m = cur.data.match(reg);
                }
            });
        },
        
        /**
         * If pages have been explicitly defined in the html, they are found and initialized. Otherwise, this method will
         * look for a container of "pageable" content, and auto-generate & initialize pages based on the given height from that content.
         **/
        renderPages: function(container, height) {
            // If pre-defined pages exist, ensure that all pages but the first are not shown and return.
            // TODO: what is the actual appropriate pattern for this situation?  ie jQuery object chaining?
            var pages = container.find('.' + $.fn.paginate.defaults.pageCss);
            if(pages.length > 0) {
                UT.showPage(container, 0);
                return;
            }

            // When no pre-defined pages exist, automatically generate pages from content based on the given height.
            // for now, gonna use an explicit content div
            var pageable = container.find('.' + $.fn.paginate.defaults.pageableCss);

            // get a list of *all* the child nodes of the pageable container
            var pageableNodes = pageable.contents();

            // create the default page and add it to the pageable container
            var page = UT.createPage();
            pageable.append(page);

            // add the nodes to the default page
            page.append(pageableNodes);

            // the approach I took was to create a default page and put all the pageable content inside that, then
            // bisect the default page into smaller pages according to the given height.
            UT.subdivide(page, height);

            // show the first page, hide the rest
            UT.showPage(container, 0);
        },

        /**
         * Handles the wireup and/or creation of the prev, next and page number links.
         **/
        renderLinks: function(container) {
            UT.renderPrevNext(container);
            UT.renderPageNumbers(container);
        },

        /**
         * If a container marked with "prevNext" is found in the html, prev and next links are automatically created and wired up.
         * Elements marked with explicit "prev" and "next" are assumed to be links that already exist (so they don't need to be
         * generated automatically), so only the event wireup is performed.
         **/
        renderPrevNext: function(container) {
            // find the prev/next element container and/or any prev/next links
            var prevNext = container.find('.' + $.fn.paginate.defaults.prevNextCss);
            var prevLink = container.find('.' + $.fn.paginate.defaults.prevLinkCss);
            var nextLink = container.find('.' + $.fn.paginate.defaults.nextLinkCss);

            // if none of these elements exist, then the assumption is that the designer doesn't need the prev/next interface
            if(prevNext.length==0 && prevLink.length==0 && nextLink.length==0) {
                return;
            }

            // if no page links are available, generate some in the container, if applicable
            if(prevLink.length == 0) {
                prevLink = UT.createPrevLink();
                prevNext.append(prevLink);
            }
            if(nextLink.length == 0) {
                nextLink = UT.createNextLink();
                prevNext.append(nextLink);
            }

            // do wireup
            UT.bindPrevClick(container, prevLink);
            UT.bindNextClick(container, nextLink);
        },

        /**
         * If an element marked with "pageNumbers" is found, numbered page links corresponding to any the pages
         * are automatically created inside as children of that element.
         **/
        renderPageNumbers: function(container) {
            var pageNumbers = container.find('.' + $.fn.paginate.defaults.pageNumbersCss);
            // if a 'pageNumbers' element exists, then check for existing links to wire up, or create page number links if none exist
            if(!pageNumbers || (pageNumbers.length==0)) {
                return;
            }

            // find all the child pages and create a number link for each
            container.find('.' + $.fn.paginate.defaults.pageCss).each(function(i) {
                var link = UT.createPageLink(i);
                UT.bindPageClick(container, link, i);
                pageNumbers.append(link);
            });
            // init the first page and page link to have the "currentPage" class
            pageNumbers.find('.' + $.fn.paginate.defaults.pageLinkCss + ':first')
                .addClass($.fn.paginate.defaults.currentPageCss);            
        },

        /**
         * If an element marked with "location" is found, set the current location (current page of total page count) as its content.
         **/
        renderLocation: function(container) {
            var location = container.find('.' + $.fn.paginate.defaults.locationCss);
            location.text((UT.getCurrentPage(container)+1) + ' / ' + UT.getPageCount(container));
        },

        /**
         * Returns the page at the given (0-based) page index.
         **/
        getPage: function(container, i) {
            return $(container.find('.' + $.fn.paginate.defaults.pageCss)[i]);
        },

        /**
         * Returns a jQuery-wrapped page element representing the currently shown page.
         **/
        getCurrentPage: function(container) {
            var pages = container.find('.' + $.fn.paginate.defaults.pageCss);
            for(var i=0; i<pages.length; ++i) {
                if($(pages[i]).hasClass($.fn.paginate.defaults.currentPageCss)) {
                    return i;
                }
            }
            return -1;
        },

        /**
         * Returns the total number of pages.
         **/
        getPageCount: function(container) {
            return container.find('.' + $.fn.paginate.defaults.pageCss).length;
        },

        /**
         * Finds the page that contains the given child node.
         **/
        findParentPage: function(child) {
            return child.parents('.' + $.fn.paginate.defaults.pageCss + ':first');
        },

        /**
         * Hides all pages and removes the 'currentPage' css class.
         **/
        hidePages: function(container) {
            // hide all pages and remove the css class representing the 'current' page
            container.find('.' + $.fn.paginate.defaults.pageCss)
                .hide()
                .removeClass($.fn.paginate.defaults.currentPageCss);
        },

        /**
         * Shows the page at the given (0-based) index and tags it with the 'currentPage' css class.
         * NOTE: calls hidePages() first.
         **/
        showPage: function(container, i) {
            var page = UT.getPage(container, i);
            if(page && page.length > 0) {
                UT.hidePages(container);
                page.show().addClass($.fn.paginate.defaults.currentPageCss);
            }
        },

        /**
         * Given the (0-based) index representing the current page, marks the appropriate numbered page link
         * with the 'currentPage' class, and clears this class on all other links.
         **/
        setLinkCurrent: function(container, i) {
            // reset all page links back to default
            container.find('.' + $.fn.paginate.defaults.pageLinkCss)
                .removeClass($.fn.paginate.defaults.currentPageCss);
            // set the current page link as current
            container.find('.' + $.fn.paginate.defaults.pageLinkCss + '[value="' + (i+1) + '"]')
                .addClass($.fn.paginate.defaults.currentPageCss);
        },

        /**
         * Click handler for the 'prev' link.  Decreases the current page index by 1, if applicable.
         **/
        onPrevClick: function(evt) {
            var container = $(this).data().container;
            var current = UT.getCurrentPage(container);

            if(current == 0) {
                return;
            }
            UT.showPage(container, current-1);
            UT.setLinkCurrent(container, current-1);

            UT.renderLocation(container);
        },

        /**
         * Click handler for the 'next' link.  Increases the current page index by 1, if applicable.
         **/
        onNextClick: function(evt) {
            var container = $(this).data().container;
            var current = UT.getCurrentPage(container);
            var count = UT.getPageCount(container);

            if(current == count-1) {
                return;
            }
            UT.showPage(container, current+1);
            UT.setLinkCurrent(container, current+1);
            
            UT.renderLocation(container);
        },

        /**
         * Click handler for the numbered page links.  Sets the current page index to given value (passed in via jQuery's event data object).
         **/
        onPageClick: function(evt) {
            var container = $(this).data().container;
            var i = $(this).data().i;
            var current = UT.getCurrentPage(container);
            
            if(i == current) {
                return;
            }

            UT.showPage(container, i);
            UT.setLinkCurrent(container, i);
            
            UT.renderLocation(container);
        }
    };

    $.fn.extend({
        /**
         *  The main entry point for the plugin.  Takes a set of jQuery-selected elements and, for each one, paginates the content based on
         *  the given height, and initializes pager navigation controls based on certain sensible conventions.
         **/
        paginate: function(height, options) {
            // paginate() is designed to handle one jQuery element at a time
            if(this.length > 1) {
                this.each(function() {
                    $(this).paginate(height, options);
                });
                return this;
            }

            $.fn.paginate.defaults = {
                pageableCss: 'pageable',          // css class that explicitly marks content to be paged
                pageContentCss: 'pageContent',          // css class representing
                pageNumbersCss: 'pageNumbers',          // css class for numbered page links container.
                prevNextCss: 'prevNext',                // css class for prev/next links container
                locationCss: 'location',                    // css class that indicates where the "location" goes (eg "page 1/4")
                prevLinkCss: 'prevLink',                        // css class for 'previous' link
                nextLinkCss: 'nextLink',                        // css class for 'next' link
                prevNextSepCss: "prevNextSep",           // css class for the separator between the prev & next links, if applicable. shown when both are visible
                pageLinkCss: 'pageLink',                    // css class for the page links
                currentPageCss: 'currentPage',          // css class that marks the link and page representing the current page
                pageCss: 'page',                        // css class for page container
                markerCss: 'marker'
            };
            options = $.extend($.fn.paginate.defaults, options);

            // ensure any pageable content is broken up into "page" elements.
            UT.renderPages(this, height);

            // create the pager links in the appropriate style
            UT.renderLinks(this);

            // render the location (eg "page 1/4")
            UT.renderLocation(this);

            return this;
        }
    });
})(jQuery);


/*
* Placeholder plugin for jQuery
* ---
* Copyright 2010, Daniel Stocks (http://webcloud.se)
* Released under the MIT, BSD, and GPL Licenses.
*/
(function($) {
    function Placeholder(input) {
        this.input = input;
        if (input.attr('type') == 'password') {
            this.handlePassword();
        }
        // Prevent placeholder values from submitting
        $(input[0].form).submit(function() {
            if (input.hasClass('placeholder') && input[0].value == input.attr('placeholder')) {
                input[0].value = '';
            }
        });
    }
    Placeholder.prototype = {
        show : function(loading) {
            // FF and IE saves values when you refresh the page. If the user refreshes the page with
            // the placeholders showing they will be the default values and the input fields won't be empty.
            if (this.input[0].value === '' || (loading && this.valueIsPlaceholder())) {
                if (this.isPassword) {
                    try {
                        this.input[0].setAttribute('type', 'text');
                    } catch (e) {
                        this.input.before(this.fakePassword.show()).hide();
                    }
                }
                this.input.addClass('placeholder');
                this.input[0].value = this.input.attr('placeholder');
            }
        },
        hide : function() {
            if (this.valueIsPlaceholder() && this.input.hasClass('placeholder')) {
                this.input.removeClass('placeholder');
                this.input[0].value = '';
                if (this.isPassword) {
                    try {
                        this.input[0].setAttribute('type', 'password');
                    } catch (e) { }
                    // Restore focus for Opera and IE
                    this.input.show();
                    this.input[0].focus();
                }
            }
        },
        valueIsPlaceholder : function() {
            return this.input[0].value == this.input.attr('placeholder');
        },
        handlePassword: function() {
            var input = this.input;
            input.attr('realType', 'password');
            this.isPassword = true;
            // IE < 9 doesn't allow changing the type of password inputs
            if ($.browser.msie && input[0].outerHTML) {
                var fakeHTML = $(input[0].outerHTML.replace(/type=(['"])?password\1/gi, 'type=$1text$1'));
                this.fakePassword = fakeHTML.val(input.attr('placeholder')).addClass('placeholder').focus(function() {
                    input.trigger('focus');
                    $(this).hide();
                });
                $(input[0].form).submit(function() {
                    fakeHTML.remove();
                    input.show()
                });
            }
        }
    };
    var NATIVE_SUPPORT = !!("placeholder" in document.createElement( "input" ));
    $.fn.placeholder = function() {
        return NATIVE_SUPPORT ? this : this.each(function() {
            var input = $(this);
            var placeholder = new Placeholder(input);
            placeholder.show(true);
            input.focus(function() {
                placeholder.hide();
            });
            input.blur(function() {
                placeholder.show(false);
            });

            // On page refresh, IE doesn't re-populate user input
            // until the window.onload event is fired.
            if ($.browser.msie) {
                $(window).load(function() {
                    if(input.val()) {
                        input.removeClass("placeholder");
                    }
                    placeholder.show(true);
                });
                // What's even worse, the text cursor disappears
                // when tabbing between text inputs, here's a fix
                input.focus(function() {
                    if(this.value == "") {
                        var range = this.createTextRange();
                        range.collapse(true);
                        range.moveStart('character', 0);
                        range.select();
                    }
                });
            }
        });
    }
})(jQuery);

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

/*
 * jQuery resize event - v1.1 - 3/14/2010
 * http://benalman.com/projects/jquery-resize-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
