eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(3($){7 m=\'2.12\';7 n=$.2z.2p&&/3z 6.0/.31(2P.2G);3 1t(){4(26.20&&26.20.1t)26.20.1t(\'[y] \'+3v.3p.3j.3b(36,\'\'))};$.B.y=3(l){K 9.1c(3(){l=l||{};4(l.2c==2y){3F(l){28\'3E\':4(9.U)22(9.U);9.U=0;K;28\'29\':9.17=1;K;28\'3w\':9.17=0;K;3u:l={1e:l}}}7 c=$(9);7 d=l.1R?$(l.1R,9):c.3g();7 e=d.38();4(e.C<2){1t(\'33; 30 2X 2V: \'+e.C);K}7 f=$.2O({},$.B.y.2q,l||{},$.2d?c.2d():$.2H?c.2F():{});4(f.1P)f.1O=f.1N||e.C;f.G=f.G?[f.G]:[];f.14=f.14?[f.14]:[];f.14.2x(3(){f.2a=0});4(f.1k)f.14.H(3(){1d(e,f,0,!f.1b)});4(n&&f.1I&&!f.2t)27(d);7 g=9.3D;f.r=1p((g.1G(/w:(\\d+)/)||[])[1])||f.r;f.8=1p((g.1G(/h:(\\d+)/)||[])[1])||f.8;f.N=1p((g.1G(/t:(\\d+)/)||[])[1])||f.N;4(c.A(\'1A\')==\'3s\')c.A(\'1A\',\'3o\');4(f.r)c.r(f.r);4(f.8&&f.8!=\'1D\')c.8(f.8);4(f.1a){f.1i=[];1n(7 i=0;i<e.C;i++)f.1i.H(i);f.1i.3f(3(a,b){K 39.1a()-0.5});f.18=0;f.W=f.1i[0]}13 4(f.W>=e.C)f.W=0;7 h=f.W||0;d.A(\'1A\',\'2f\').1y().1c(3(i){7 z=h?i>=h?e.C-(i-h):h-i:e.C-i;$(9).A(\'z-1B\',z)});$(e[h]).M();4(f.Z&&f.r)d.r(f.r);4(f.Z&&f.8&&f.8!=\'1D\')d.8(f.8);4(f.29)c.2U(3(){9.17=1},3(){9.17=0});7 j=$.B.y.L[f.1e];4($.2k(j))j(c,d,f);13 1t(\'2N 2L: \'+f.1e);d.1c(3(){7 a=$(9);9.V=(f.Z&&f.8)?f.8:a.8();9.S=(f.Z&&f.r)?f.r:a.r()});f.F=f.F||{};f.E=f.E||{};f.I=f.I||{};d.1w(\':1v(\'+h+\')\').A(f.F);4(f.T)$(d[h]).A(f.T);4(f.N){4(f.Q.2c==2y)f.Q={2E:2D,2C:2B}[f.Q]||2A;4(!f.1M)f.Q=f.Q/2;3I((f.N-f.Q)<3H)f.N+=f.Q}4(f.2b)f.1L=f.1K=f.2b;4(!f.1s)f.1s=f.Q;4(!f.1o)f.1o=f.Q;f.2v=e.C;f.11=h;4(f.1a){f.D=f.11;4(++f.18==e.C)f.18=0;f.D=f.1i[f.18]}13 f.D=f.W>=(e.C-1)?0:f.W+1;7 k=d[h];4(f.G.C)f.G[0].1J(k,[k,k,f,2u]);4(f.14.C>1)f.14[1].1J(k,[k,k,f,2u]);4(f.1r&&!f.P)f.P=f.1r;4(f.P)$(f.P).25(\'1r\',3(){K 21(e,f,f.1b?-1:1)});4(f.24)$(f.24).25(\'1r\',3(){K 21(e,f,f.1b?1:-1)});4(f.1q)2s(e,f);4(f.N||f.1k)9.U=23(3(){1d(e,f,0,!f.1b)},f.1k?10:f.N+(f.2r||0));f.3A=3(a){7 b=$(a),s=b[0];4(!f.1N)f.1O++;e.H(s);4(f.R)f.R.H(s);f.2v=e.C;b.A(\'1A\',\'2f\').A(f.F).2o(c);4(n&&f.1I&&!f.2t)27(b);4(f.Z&&f.r)b.r(f.r);4(f.Z&&f.8&&f.8!=\'1D\')d.8(f.8);s.V=(f.Z&&f.8)?f.8:b.8();s.S=(f.Z&&f.r)?f.r:b.r()}})};3 1d(a,b,c,d){4(b.2a)K;7 p=a[0].1H,1j=a[b.11],P=a[b.D];4(p.U===0&&!c)K;4(!c&&!p.17&&((b.1P&&(--b.1O<=0))||(b.1u&&!b.1a&&b.D<b.11))){4(b.1Z)b.1Z(b);K}4(c||!p.17){4(b.G.C)$.1c(b.G,3(i,o){o.1J(P,[1j,P,b,d])});7 e=3(){4($.2z.2p&&b.1I)9.3y.3x(\'1Y\');$.1c(b.14,3(i,o){o.1J(P,[1j,P,b,d])})};4(b.D!=b.11){b.2a=1;4(b.1F)b.1F(1j,P,b,e,d);13 4($.2k($.B.y[b.1e]))$.B.y[b.1e](1j,P,b,e);13 $.B.y.2m(1j,P,b,e)}4(b.1a){b.11=b.D;4(++b.18==a.C)b.18=0;b.D=b.1i[b.18]}13{7 f=(b.D+1)==a.C;b.D=f?0:b.D+1;b.11=f?a.C-1:b.D-1}4(b.1q)$(b.1q).2l(\'a\').3t(\'1W\').1Y(\'a:1v(\'+b.11+\')\').2j(\'1W\')}4(b.N&&!b.1k)p.U=23(3(){1d(a,b,0,!b.1b)},b.N);13 4(b.1k&&p.17)p.U=23(3(){1d(a,b,0,!b.1b)},10)};3 21(a,b,c){7 p=a[0].1H,N=p.U;4(N){22(N);p.U=0}b.D=b.11+c;4(b.D<0){4(b.1u)K 1E;b.D=a.C-1}13 4(b.D>=a.C){4(b.1u)K 1E;b.D=0}4(b.1x&&1U b.1x==\'3\')b.1x(c>0,b.D,a[b.D]);1d(a,b,1,c>=0);K 1E};3 2s(b,c){7 d=$(c.1q);$.1c(b,3(i,o){7 a=(1U c.1T==\'3\')?$(c.1T(i,o)):$(\'<a 3q="#">\'+(i+1)+\'</a>\');4(a.3n(\'3m\').C==0)a.2o(d);a.25(\'1r\',3(){c.D=i;7 p=b[0].1H,N=p.U;4(N){22(N);p.U=0}4(1U c.1S==\'3\')c.1S(c.D,b[c.D]);1d(b,c,1,!c.1b);K 1E})});d.2l(\'a\').1Y(\'a:1v(\'+c.W+\')\').2j(\'1W\')};3 27(b){3 1C(s){7 s=1p(s).3l(16);K s.C<2?\'0\'+s:s};3 2i(e){1n(;e&&e.3k.3i()!=\'3h\';e=e.1H){7 v=$.A(e,\'2h-2g\');4(v.3e(\'3d\')>=0){7 a=v.1G(/\\d+/g);K\'#\'+1C(a[0])+1C(a[1])+1C(a[2])}4(v&&v!=\'3c\')K v}K\'#3a\'};b.1c(3(){$(9).A(\'2h-2g\',2i(9))})};$.B.y.2m=3(a,b,c,d){7 e=$(a),$n=$(b);$n.A(c.F);7 f=3(){$n.1z(c.E,c.1s,c.1L,d)};e.1z(c.I,c.1o,c.1K,3(){4(c.O)e.A(c.O);4(!c.1M)f()});4(c.1M)f()};$.B.y.L={2e:3(a,b,c){b.1w(\':1v(\'+c.W+\')\').A(\'1m\',0);c.G.H(3(){$(9).M()});c.E={1m:1};c.I={1m:0};c.O={Y:\'X\'}}};$.B.y.37=3(){K m};$.B.y.2q={1e:\'2e\',N:35,1k:0,Q:34,1s:J,1o:J,P:J,24:J,1x:J,1q:J,1S:J,1T:J,G:J,14:J,1Z:J,2b:J,1L:J,1K:J,1l:J,E:J,I:J,F:J,O:J,1F:J,8:\'1D\',W:0,1M:1,1a:0,Z:0,29:0,1P:0,1N:0,2r:0,1R:J,1I:0,1u:0}})(q);q.B.y.L.32=3(d,e,f){d.A(\'19\',\'1h\');f.G.H(3(a,b,c){q(9).M();c.F.u=b.1g;c.I.u=0-a.1g});f.T={u:0};f.E={u:0};f.O={Y:\'X\'}};q.B.y.L.2Z=3(d,e,f){d.A(\'19\',\'1h\');f.G.H(3(a,b,c){q(9).M();c.F.u=0-b.1g;c.I.u=a.1g});f.T={u:0};f.E={u:0};f.O={Y:\'X\'}};q.B.y.L.2Y=3(d,e,f){d.A(\'19\',\'1h\');f.G.H(3(a,b,c){q(9).M();c.F.x=b.1f;c.I.x=0-a.1f});f.T={x:0};f.E={x:0}};q.B.y.L.2W=3(d,e,f){d.A(\'19\',\'1h\');f.G.H(3(a,b,c){q(9).M();c.F.x=0-b.1f;c.I.x=a.1f});f.T={x:0};f.E={x:0}};q.B.y.L.3r=3(f,g,h){f.A(\'19\',\'1h\').r();h.G.H(3(a,b,c,d){q(9).M();7 e=a.1f,1X=b.1f;c.F=d?{x:1X}:{x:-1X};c.E.x=0;c.I.x=d?-e:e;g.1w(a).A(c.F)});h.T={x:0};h.O={Y:\'X\'}};q.B.y.L.2T=3(f,g,h){f.A(\'19\',\'1h\');h.G.H(3(a,b,c,d){q(9).M();7 e=a.1g,1V=b.1g;c.F=d?{u:-1V}:{u:1V};c.E.u=0;c.I.u=d?e:-e;g.1w(a).A(c.F)});h.T={u:0};h.O={Y:\'X\'}};q.B.y.L.2S=3(a,b,c){c.E={r:\'M\'};c.I={r:\'1y\'}};q.B.y.L.2R=3(a,b,c){c.E={8:\'M\'};c.I={8:\'1y\'}};q.B.y.L.1l=3(g,h,j){7 w=g.A(\'19\',\'2Q\').r();h.A({x:0,u:0});j.G.H(3(){q(9).M()});j.Q=j.Q/2;j.1a=0;j.1l=j.1l||{x:-w,u:15};j.R=[];1n(7 i=0;i<h.C;i++)j.R.H(h[i]);1n(7 i=0;i<j.W;i++)j.R.H(j.R.2n());j.1F=3(a,b,c,d,e){7 f=e?q(a):q(b);f.1z(c.1l,c.1s,c.1L,3(){e?c.R.H(c.R.2n()):c.R.2x(c.R.2M());4(e)1n(7 i=0,1Q=c.R.C;i<1Q;i++)q(c.R[i]).A(\'z-1B\',1Q-i);13{7 z=q(a).A(\'z-1B\');f.A(\'z-1B\',1p(z)+1)}f.1z({x:0,u:0},c.1o,c.1K,3(){q(e?9:a).1y();4(d)d()})})}};q.B.y.L.3B=3(d,e,f){f.G.H(3(a,b,c){q(9).M();c.F.u=b.V;c.E.8=b.V});f.T={u:0};f.F={8:0};f.E={u:0};f.I={8:0};f.O={Y:\'X\'}};q.B.y.L.3C=3(d,e,f){f.G.H(3(a,b,c){q(9).M();c.E.8=b.V;c.I.u=a.V});f.T={u:0};f.F={u:0,8:0};f.I={8:0};f.O={Y:\'X\'}};q.B.y.L.2K=3(d,e,f){f.G.H(3(a,b,c){q(9).M();c.F.x=b.S;c.E.r=b.S});f.F={r:0};f.E={x:0};f.I={r:0};f.O={Y:\'X\'}};q.B.y.L.2J=3(d,e,f){f.G.H(3(a,b,c){q(9).M();c.E.r=b.S;c.I.x=a.S});f.F={x:0,r:0};f.E={x:0};f.I={r:0};f.O={Y:\'X\'}};q.B.y.L.2I=3(d,e,f){f.T={u:0,x:0};f.O={Y:\'X\'};f.G.H(3(a,b,c){q(9).M();c.F={r:0,8:0,u:b.V/2,x:b.S/2};c.E={u:0,x:0,r:b.S,8:b.V};c.I={r:0,8:0,u:a.V/2,x:a.S/2}})};q.B.y.L.3G=3(d,e,f){f.G.H(3(a,b,c){c.F={r:0,8:0,1m:1,x:b.S/2,u:b.V/2,2w:1};c.E={u:0,x:0,r:b.S,8:b.V}});f.I={1m:0};f.O={2w:0}};',62,231,'|||function|if|||var|height|this|||||||||||||||||jQuery|width|||top|||left|cycle||css|fn|length|nextSlide|animIn|cssBefore|before|push|animOut|null|return|transitions|show|timeout|cssAfter|next|speed|els|cycleW|cssFirst|cycleTimeout|cycleH|startingSlide|none|display|fit||currSlide||else|after|||cyclePause|randomIndex|overflow|random|rev|each|go|fx|offsetWidth|offsetHeight|hidden|randomMap|curr|continuous|shuffle|opacity|for|speedOut|parseInt|pager|click|speedIn|log|nowrap|eq|not|prevNextClick|hide|animate|position|index|hex|auto|false|fxFn|match|parentNode|cleartype|apply|easeOut|easeIn|sync|autostopCount|countdown|autostop|len|slideExpr|pagerClick|pagerAnchorBuilder|typeof|nextH|activeSlide|nextW|filter|end|console|advance|clearTimeout|setTimeout|prev|bind|window|clearTypeFix|case|pause|busy|easing|constructor|metadata|fade|absolute|color|background|getBg|addClass|isFunction|find|custom|shift|appendTo|msie|defaults|delay|buildPager|cleartypeNoBg|true|slideCount|zIndex|unshift|String|browser|400|200|fast|600|slow|data|userAgent|meta|zoom|turnRight|turnLeft|transition|pop|unknown|extend|navigator|visible|slideY|slideX|scrollVert|hover|slides|scrollRight|few|scrollLeft|scrollDown|too|test|scrollUp|terminating|1000|4000|arguments|ver|get|Math|ffffff|call|transparent|rgb|indexOf|sort|children|html|toLowerCase|join|nodeName|toString|body|parents|relative|prototype|href|scrollHorz|static|removeClass|default|Array|resume|removeAttribute|style|MSIE|addSlide|turnUp|turnDown|className|stop|switch|fadeZoom|250|while'.split('|'),0,{}));

/* @minify true */
/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);/* @minify true */
/**
 * jCarousel - Riding carousels with jQuery
 *   http://sorgalla.com/jcarousel/
 *
 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Built on top of the jQuery library
 *   http://jquery.com
 *
 * Inspired by the "Carousel Component" by Bill Scott
 *   http://billwscott.com/carousel/
 */

(function($) {
    /**
     * Creates a carousel for all matched elements.
     *
     * @example $("#mycarousel").jcarousel();
     * @before <ul id="mycarousel" class="jcarousel-skin-name"><li>First item</li><li>Second item</li></ul>
     * @result
     *
     * <div class="jcarousel-skin-name">
     *   <div class="jcarousel-container">
     *     <div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
     *     <div class="jcarousel-next"></div>
     *     <div class="jcarousel-clip">
     *       <ul class="jcarousel-list">
     *         <li class="jcarousel-item-1">First item</li>
     *         <li class="jcarousel-item-2">Second item</li>
     *       </ul>
     *     </div>
     *   </div>
     * </div>
     *
     * @name jcarousel
     * @type jQuery
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/jCarousel
     */
    $.fn.jcarousel = function(o) {
        return this.each(function() {
            new $jc(this, o);
        });
    };

    // Default configuration properties.
    var defaults = {
        vertical: false,
        start: 1,
        offset: 1,
        size: null,
        scroll: 3,
        visible: null,
        animation: 'normal',
        easing: 'swing',
        auto: 0,
        wrap: null,
        initCallback: null,
        reloadCallback: null,
        itemLoadCallback: null,
        itemFirstInCallback: null,
        itemFirstOutCallback: null,
        itemLastInCallback: null,
        itemLastOutCallback: null,
        itemVisibleInCallback: null,
        itemVisibleOutCallback: null,
        buttonNextHTML: '<div></div>',
        buttonPrevHTML: '<div></div>',
        buttonNextEvent: 'click',
        buttonPrevEvent: 'click',
        buttonNextCallback: null,
        buttonPrevCallback: null
    };

    /**
     * The jCarousel object.
     *
     * @constructor
     * @name $.jcarousel
     * @param Object e The element to create the carousel for.
     * @param Hash o A set of key/value pairs to set as configuration properties.
     * @cat Plugins/jCarousel
     */
    $.jcarousel = function(e, o) {
        this.options    = $.extend({}, defaults, o || {});

        this.locked     = false;

        this.container  = null;
        this.clip       = null;
        this.list       = null;
        this.buttonNext = null;
        this.buttonPrev = null;

        this.wh = !this.options.vertical ? 'width' : 'height';
        this.lt = !this.options.vertical ? 'left' : 'top';

        // Extract skin class
        var skin = '', split = e.className.split(' ');

        for (var i = 0; i < split.length; i++) {
            if (split[i].indexOf('jcarousel-skin') != -1) {
                $(e).removeClass(split[i]);
                var skin = split[i];
                break;
            }
        }

        if (e.nodeName == 'UL' || e.nodeName == 'OL') {
            this.list = $(e);
            this.container = this.list.parent();

            if (this.container.hasClass('jcarousel-clip')) {
                if (!this.container.parent().hasClass('jcarousel-container'))
                    this.container = this.container.wrap('<div></div>');

                this.container = this.container.parent();
            } else if (!this.container.hasClass('jcarousel-container'))
                this.container = this.list.wrap('<div></div>').parent();
        } else {
            this.container = $(e);
            this.list = $(e).find('>ul,>ol,div>ul,div>ol');
        }

        if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1)
        	this.container.wrap('<div class=" '+ skin + '"></div>');

        this.clip = this.list.parent();

        if (!this.clip.length || !this.clip.hasClass('jcarousel-clip'))
            this.clip = this.list.wrap('<div></div>').parent();

        this.buttonPrev = $('.jcarousel-prev', this.container);

        if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null)
            this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev();

        this.buttonPrev.addClass(this.className('jcarousel-prev'));

        this.buttonNext = $('.jcarousel-next', this.container);

        if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null)
            this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev();

        this.buttonNext.addClass(this.className('jcarousel-next'));

        this.clip.addClass(this.className('jcarousel-clip'));
        this.list.addClass(this.className('jcarousel-list'));
        this.container.addClass(this.className('jcarousel-container'));

        var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
        var li = this.list.children('li');

        var self = this;

        if (li.size() > 0) {
            var wh = 0, i = this.options.offset;
            li.each(function() {
                self.format(this, i++);
                wh += self.dimension(this, di);
            });

            this.list.css(this.wh, wh + 'px');

            // Only set if not explicitly passed as option
            if (!o || o.size === undefined)
                this.options.size = li.size();
        }

        // For whatever reason, .show() does not work in Safari...
        this.container.css('display', 'block');
        this.buttonNext.css('display', 'block');
        this.buttonPrev.css('display', 'block');

        this.funcNext   = function() { self.next(); };
        this.funcPrev   = function() { self.prev(); };
        this.funcResize = function() { self.reload(); };

        if (this.options.initCallback != null)
            this.options.initCallback(this, 'init');

        if ($.browser.safari) {
            this.buttons(false, false);
            $(window).bind('load', function() { self.setup(); });
        } else
            this.setup();
    };

    // Create shortcut for internal use
    var $jc = $.jcarousel;

    $jc.fn = $jc.prototype = {
        jcarousel: '0.2.3'
    };

    $jc.fn.extend = $jc.extend = $.extend;

    $jc.fn.extend({
        /**
         * Setups the carousel.
         *
         * @name setup
         * @type undefined
         * @cat Plugins/jCarousel
         */
        setup: function() {
            this.first     = null;
            this.last      = null;
            this.prevFirst = null;
            this.prevLast  = null;
            this.animating = false;
            this.timer     = null;
            this.tail      = null;
            this.inTail    = false;

            if (this.locked)
                return;

            this.list.css(this.lt, this.pos(this.options.offset) + 'px');
            var p = this.pos(this.options.start);
            this.prevFirst = this.prevLast = null;
            this.animate(p, false);

            $(window).unbind('resize', this.funcResize).bind('resize', this.funcResize);
        },

        /**
         * Clears the list and resets the carousel.
         *
         * @name reset
         * @type undefined
         * @cat Plugins/jCarousel
         */
        reset: function() {
            this.list.empty();

            this.list.css(this.lt, '0px');
            this.list.css(this.wh, '10px');

            if (this.options.initCallback != null)
                this.options.initCallback(this, 'reset');

            this.setup();
        },

        /**
         * Reloads the carousel and adjusts positions.
         *
         * @name reload
         * @type undefined
         * @cat Plugins/jCarousel
         */
        reload: function() {
            if (this.tail != null && this.inTail)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail);

            this.tail   = null;
            this.inTail = false;

            if (this.options.reloadCallback != null)
                this.options.reloadCallback(this);

            if (this.options.visible != null) {
                var self = this;
                var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0;
                $('li', this.list).each(function(i) {
                    wh += self.dimension(this, di);
                    if (i + 1 < self.first)
                        lt = wh;
                });

                this.list.css(this.wh, wh + 'px');
                this.list.css(this.lt, -lt + 'px');
            }

            this.scroll(this.first, false);
        },

        /**
         * Locks the carousel.
         *
         * @name lock
         * @type undefined
         * @cat Plugins/jCarousel
         */
        lock: function() {
            this.locked = true;
            this.buttons();
        },

        /**
         * Unlocks the carousel.
         *
         * @name unlock
         * @type undefined
         * @cat Plugins/jCarousel
         */
        unlock: function() {
            this.locked = false;
            this.buttons();
        },

        /**
         * Sets the size of the carousel.
         *
         * @name size
         * @type undefined
         * @param Number s The size of the carousel.
         * @cat Plugins/jCarousel
         */
        size: function(s) {
            if (s != undefined) {
                this.options.size = s;
                if (!this.locked)
                    this.buttons();
            }

            return this.options.size;
        },

        /**
         * Checks whether a list element exists for the given index (or index range).
         *
         * @name get
         * @type bool
         * @param Number i The index of the (first) element.
         * @param Number i2 The index of the last element.
         * @cat Plugins/jCarousel
         */
        has: function(i, i2) {
            if (i2 == undefined || !i2)
                i2 = i;

            if (this.options.size !== null && i2 > this.options.size)
            	i2 = this.options.size;

            for (var j = i; j <= i2; j++) {
                var e = this.get(j);
                if (!e.length || e.hasClass('jcarousel-item-placeholder'))
                    return false;
            }

            return true;
        },

        /**
         * Returns a jQuery object with list element for the given index.
         *
         * @name get
         * @type jQuery
         * @param Number i The index of the element.
         * @cat Plugins/jCarousel
         */
        get: function(i) {
            return $('.jcarousel-item-' + i, this.list);
        },

        /**
         * Adds an element for the given index to the list.
         * If the element already exists, it updates the inner html.
         * Returns the created element as jQuery object.
         *
         * @name add
         * @type jQuery
         * @param Number i The index of the element.
         * @param String s The innerHTML of the element.
         * @cat Plugins/jCarousel
         */
        add: function(i, s) {
            var e = this.get(i), old = 0, add = 0;

            if (e.length == 0) {
                var c, e = this.create(i), j = $jc.intval(i);
                while (c = this.get(--j)) {
                    if (j <= 0 || c.length) {
                        j <= 0 ? this.list.prepend(e) : c.after(e);
                        break;
                    }
                }
            } else
                old = this.dimension(e);

            e.removeClass(this.className('jcarousel-item-placeholder'));
            typeof s == 'string' ? e.html(s) : e.empty().append(s);

            var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
            var wh = this.dimension(e, di) - old;

            if (i > 0 && i < this.first)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px');

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px');

            return e;
        },

        /**
         * Removes an element for the given index from the list.
         *
         * @name remove
         * @type undefined
         * @param Number i The index of the element.
         * @cat Plugins/jCarousel
         */
        remove: function(i) {
            var e = this.get(i);

            // Check if item exists and is not currently visible
            if (!e.length || (i >= this.first && i <= this.last))
                return;

            var d = this.dimension(e);

            if (i < this.first)
                this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');

            e.remove();

            this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
        },

        /**
         * Moves the carousel forwards.
         *
         * @name next
         * @type undefined
         * @cat Plugins/jCarousel
         */
        next: function() {
            this.stopAuto();

            if (this.tail != null && !this.inTail)
                this.scrollTail(false);
            else
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
        },

        /**
         * Moves the carousel backwards.
         *
         * @name prev
         * @type undefined
         * @cat Plugins/jCarousel
         */
        prev: function() {
            this.stopAuto();

            if (this.tail != null && this.inTail)
                this.scrollTail(true);
            else
                this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
        },

        /**
         * Scrolls the tail of the carousel.
         *
         * @name scrollTail
         * @type undefined
         * @param Bool b Whether scroll the tail back or forward.
         * @cat Plugins/jCarousel
         */
        scrollTail: function(b) {
            if (this.locked || this.animating || !this.tail)
                return;

            var pos  = $jc.intval(this.list.css(this.lt));

            !b ? pos -= this.tail : pos += this.tail;
            this.inTail = !b;

            // Save for callbacks
            this.prevFirst = this.first;
            this.prevLast  = this.last;

            this.animate(pos);
        },

        /**
         * Scrolls the carousel to a certain position.
         *
         * @name scroll
         * @type undefined
         * @param Number i The index of the element to scoll to.
         * @param Bool a Flag indicating whether to perform animation.
         * @cat Plugins/jCarousel
         */
        scroll: function(i, a) {
            if (this.locked || this.animating)
                return;

            this.animate(this.pos(i), a);
        },

        /**
         * Prepares the carousel and return the position for a certian index.
         *
         * @name pos
         * @type Number
         * @param Number i The index of the element to scoll to.
         * @cat Plugins/jCarousel
         */
        pos: function(i) {
            if (this.locked || this.animating)
                return;

            if (this.options.wrap != 'circular')
                i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);

            var back = this.first > i;
            var pos  = $jc.intval(this.list.css(this.lt));

            // Create placeholders, new list width/height
            // and new list position
            var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
            var c = back ? this.get(f) : this.get(this.last);
            var j = back ? f : f - 1;
            var e = null, l = 0, p = false, d = 0;

            while (back ? --j >= i : ++j < i) {
                e = this.get(j);
                p = !e.length;
                if (e.length == 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    c[back ? 'before' : 'after' ](e);
                }

                c = e;
                d = this.dimension(e);

                if (p)
                    l += d;

                if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
                    pos = back ? pos + d : pos - d;
            }

            // Calculate visible items
            var clipping = this.clipping();
            var cache = [];
            var visible = 0, j = i, v = 0;
            var c = this.get(i - 1);

            while (++visible) {
                e = this.get(j);
                p = !e.length;
                if (e.length == 0) {
                    e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
                    // This should only happen on a next scroll
                    c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
                }

                c = e;
                var d = this.dimension(e);
                if (d == 0) {
                    alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
                    return 0;
                }

                if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
                    cache.push(e);
                else if (p)
                    l += d;

                v += d;

                if (v >= clipping)
                    break;

                j++;
            }

             // Remove out-of-range placeholders
            for (var x = 0; x < cache.length; x++)
                cache[x].remove();

            // Resize list
            if (l > 0) {
                this.list.css(this.wh, this.dimension(this.list) + l + 'px');

                if (back) {
                    pos -= l;
                    this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
                }
            }

            // Calculate first and last item
            var last = i + visible - 1;
            if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
                last = this.options.size;

            if (j > last) {
                visible = 0, j = last, v = 0;
                while (++visible) {
                    var e = this.get(j--);
                    if (!e.length)
                        break;
                    v += this.dimension(e);
                    if (v >= clipping)
                        break;
                }
            }

            var first = last - visible + 1;
            if (this.options.wrap != 'circular' && first < 1)
                first = 1;

            if (this.inTail && back) {
                pos += this.tail;
                this.inTail = false;
            }

            this.tail = null;
            if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
                var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
                if ((v - m) > clipping)
                    this.tail = v - clipping - m;
            }

            // Adjust position
            while (i-- > first)
                pos += this.dimension(this.get(i));

            // Save visible item range
            this.prevFirst = this.first;
            this.prevLast  = this.last;
            this.first     = first;
            this.last      = last;

            return pos;
        },

        /**
         * Animates the carousel to a certain position.
         *
         * @name animate
         * @type undefined
         * @param mixed p Position to scroll to.
         * @param Bool a Flag indicating whether to perform animation.
         * @cat Plugins/jCarousel
         */
        animate: function(p, a) {
            if (this.locked || this.animating)
                return;

            this.animating = true;

            var self = this;
            var scrolled = function() {
                self.animating = false;

                if (p == 0)
                    self.list.css(self.lt,  0);

                if (self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size)
                    self.startAuto();

                self.buttons();
                self.notify('onAfterAnimation');
            };

            this.notify('onBeforeAnimation');

            // Animate
            if (!this.options.animation || a == false) {
                this.list.css(this.lt, p + 'px');
                scrolled();
            } else {
                var o = !this.options.vertical ? {'left': p} : {'top': p};
                this.list.animate(o, this.options.animation, this.options.easing, scrolled);
            }
        },

        /**
         * Starts autoscrolling.
         *
         * @name auto
         * @type undefined
         * @param Number s Seconds to periodically autoscroll the content.
         * @cat Plugins/jCarousel
         */
        startAuto: function(s) {
            if (s != undefined)
                this.options.auto = s;

            if (this.options.auto == 0)
                return this.stopAuto();

            if (this.timer != null)
                return;

            var self = this;
            this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000);
        },

        /**
         * Stops autoscrolling.
         *
         * @name stopAuto
         * @type undefined
         * @cat Plugins/jCarousel
         */
        stopAuto: function() {
            if (this.timer == null)
                return;

            clearTimeout(this.timer);
            this.timer = null;
        },

        /**
         * Sets the states of the prev/next buttons.
         *
         * @name buttons
         * @type undefined
         * @cat Plugins/jCarousel
         */
        buttons: function(n, p) {
            if (n == undefined || n == null) {
                var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size)
                    n = this.tail != null && !this.inTail;
            }

            if (p == undefined || p == null) {
                var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1);
                if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1)
                    p = this.tail != null && this.inTail;
            }

            var self = this;

            this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent, this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true);
            this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent, this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true);

            if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) {
                this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); });
                this.buttonNext[0].jcarouselstate = n;
            }

            if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) {
                this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); });
                this.buttonPrev[0].jcarouselstate = p;
            }
        },

        notify: function(evt) {
            var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');

            // Load items
            this.callback('itemLoadCallback', evt, state);

            if (this.prevFirst !== this.first) {
                this.callback('itemFirstInCallback', evt, state, this.first);
                this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
            }

            if (this.prevLast !== this.last) {
                this.callback('itemLastInCallback', evt, state, this.last);
                this.callback('itemLastOutCallback', evt, state, this.prevLast);
            }

            this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
            this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
        },

        callback: function(cb, evt, state, i1, i2, i3, i4) {
            if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation'))
                return;

            var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb];

            if (!$.isFunction(callback))
                return;

            var self = this;

            if (i1 === undefined)
                callback(self, state, evt);
            else if (i2 === undefined)
                this.get(i1).each(function() { callback(self, this, i1, state, evt); });
            else {
                for (var i = i1; i <= i2; i++)
                    if (i !== null && !(i >= i3 && i <= i4))
                        this.get(i).each(function() { callback(self, this, i, state, evt); });
            }
        },

        create: function(i) {
            return this.format('<li></li>', i);
        },

        format: function(e, i) {
            var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i));
            $e.attr('jcarouselindex', i);
            return $e;
        },

        className: function(c) {
            return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical');
        },

        dimension: function(e, d) {
            var el = e.jquery != undefined ? e[0] : e;

            var old = !this.options.vertical ?
                el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') :
                el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom');

            if (d == undefined || old == d)
                return old;

            var w = !this.options.vertical ?
                d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') :
                d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom');

            $(el).css(this.wh, w + 'px');

            return this.dimension(el);
        },

        clipping: function() {
            return !this.options.vertical ?
                this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) :
                this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth'));
        },

        index: function(i, s) {
            if (s == undefined)
                s = this.options.size;

            return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1;
        }
    });

    $jc.extend({
        /**
         * Gets/Sets the global default configuration properties.
         *
         * @name defaults
         * @descr Gets/Sets the global default configuration properties.
         * @type Hash
         * @param Hash d A set of key/value pairs to set as configuration properties.
         * @cat Plugins/jCarousel
         */
        defaults: function(d) {
            return $.extend(defaults, d || {});
        },

        margin: function(e, p) {
            if (!e)
                return 0;

            var el = e.jquery != undefined ? e[0] : e;

            if (p == 'marginRight' && $.browser.safari) {
                var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;

                $.swap(el, old, function() { oWidth = el.offsetWidth; });

                old['marginRight'] = 0;
                $.swap(el, old, function() { oWidth2 = el.offsetWidth; });

                return oWidth2 - oWidth;
            }

            return $jc.intval($.css(el, p));
        },

        intval: function(v) {
            v = parseInt(v);
            return isNaN(v) ? 0 : v;
        }
    });

})(jQuery);
/*
 * jQuery validation plug-in 1.5.5
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){$.extend($.fn,{validate:function(options){if(!this.length){options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}var validator=$.data(this[0],'validator');if(validator){return validator;}validator=new $.validator(options,this[0]);$.data(this[0],'validator',validator);if(validator.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){validator.cancelSubmit=true;});if(validator.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){validator.submitButton=this;});}this.submit(function(event){if(validator.settings.debug)event.preventDefault();function handle(){if(validator.settings.submitHandler){if(validator.submitButton){var hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);}validator.settings.submitHandler.call(validator,validator.currentForm);if(validator.submitButton){hidden.remove();}return false;}return true;}if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();}if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;}return handle();}else{validator.focusInvalid();return false;}});}return validator;},valid:function(){if($(this[0]).is('form')){return this.validate().form();}else{var valid=true;var validator=$(this[0].form).validate();this.each(function(){valid&=validator.element(this);});return valid;}},removeAttrs:function(attributes){var result={},$element=this;$.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value);$element.removeAttr(value);});return result;},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,'validator').settings;var staticRules=settings.rules;var existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));staticRules[element.name]=existingRules;if(argument.messages)settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;}var filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required;data=$.extend({required:param},data);}return data;}});$.extend($.expr[":"],{blank:function(a){return!$.trim(a.value);},filled:function(a){return!!$.trim(a.value);},unchecked:function(a){return!a.checked;}});$.validator=function(options,form){this.settings=$.extend({},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length==1)return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};if(arguments.length>2&&params.constructor!=Array){params=$.makeArray(arguments).slice(1);}if(params.constructor!=Array){params=[params];}$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n);});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);this.errorsFor(element).hide();}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element){if(element.name in this.submitted||element==this.lastElement){this.element(element);}},onclick:function(element){if(element.name in this.submitted)this.element(element);},highlight:function(element,errorClass,validClass){$(element).addClass(errorClass).removeClass(validClass);},unhighlight:function(element,errorClass,validClass){$(element).removeClass(errorClass).addClass(validClass);}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",dateDE:"Bitte geben Sie ein gültiges Datum ein.",number:"Please enter a valid number.",numberDE:"Bitte geben Sie eine Nummer ein.",digits:"Please enter only digits",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={});$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key;});});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){var validator=$.data(this[0].form,"validator");validator.settings["on"+event.type]&&validator.settings["on"+event.type].call(validator,this[0]);}$(this.currentForm).delegate("focusin focusout keyup",":text, :password, :file, select, textarea",delegate).delegate("click",":radio, :checkbox",delegate);if(this.settings.invalidHandler)$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid())$(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);}return this.valid();},element:function(element){element=this.clean(element);this.lastElement=element;this.prepareElement(element);this.currentElements=$(element);var result=this.check(element);if(result){delete this.invalid[element.name];}else{this.invalid[element.name]=true;}if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}this.showErrors();return result;},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors);this.errorList=[];for(var name in errors){this.errorList.push({message:errors[name],element:this.findByName(name)[0]});}this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm)$(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0;for(var i in obj)count++;return count;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus();}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name==lastActive.name;}).length==1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in rulesCache||!validator.objectLength($(this).rules()))return false;rulesCache[this.name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.formSubmitted=false;this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},check:function(element){element=this.clean(element);if(this.checkable(element)){element=this.findByName(element.name)[0];}var rules=$(element).rules();var dependencyMismatch=false;for(method in rules){var rule={method:method,parameters:rules[method]};try{var result=$.validator.methods[method].call(this,element.value.replace(/\r/g,""),element,rule.parameters);if(result=="dependency-mismatch"){dependencyMismatch=true;continue;}dependencyMismatch=false;if(result=="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;}if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id
+", check the '"+rule.method+"' method");throw e;}}if(dependencyMismatch)return;if(this.objectLength(rules))this.successList.push(element);return true;},customMetaMessage:function(element,method){if(!$.metadata)return;var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method];},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor==String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined)return arguments[i];}return undefined;},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>");},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method);if(typeof message=="function")message=message.call(this,rule.parameters,element);this.errorList.push({message:message,element:element});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper)toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));return toToggle;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);this.showLabel(error.element,error.message);}if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}if(this.settings.unhighlight){for(var i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var label=this.errorsFor(element);if(label.length){label.removeClass().addClass(this.settings.errorClass);label.attr("generated")&&label.html(message);}else{label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:true}).addClass(this.settings.errorClass).html(message||"");if(this.settings.wrapper){label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}if(!this.labelContainer.append(label).length)this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element);}if(!message&&this.settings.success){label.text("");typeof this.settings.success=="string"?label.addClass(this.settings.success):this.settings.success(label);}this.toShow=this.toShow.add(label);},errorsFor:function(element){return this.errors().filter("[for='"+this.idOrName(element)+"']");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},checkable:function(element){return/radio|checkbox/i.test(element.type);},findByName:function(name){var form=this.currentForm;return $(document.getElementsByName(name)).map(function(index,element){return element.form==form&&element.name==name&&element||null;});},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case'select':return $("option:selected",element).length;case'input':if(this.checkable(element))return this.findByName(element.name).filter(':checked').length;}return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param,element){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){return!$.validator.methods.required.call(this,$.trim(element.value),element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[element.name];if(valid&&this.pendingRequest==0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",previous={old:null,valid:true,message:this.defaultMessage(element,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){className.constructor==String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className);},classRules:function(element){var rules={};var classes=$(element).attr('class');classes&&$.each(classes.split(' '),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});return rules;},attributeRules:function(element){var rules={};var $element=$(element);for(method in $.validator.methods){var value=$element.attr(method);if(value){rules[method]=value;}}if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;}return rules;},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,'validator').settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata();},staticRules:function(element){var rules={};var validator=$.data(element.form,'validator');if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};}return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;}if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;}if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter;});$.each(['minlength','maxlength','min','max'],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(['rangelength','range'],function(){if(rules[this]){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}});if($.validator.autoCreateRanges){if(rules.min&&rules.max){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;}if(rules.minlength&&rules.maxlength){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}}if(rules.messages){delete rules.messages}return rules;},normalizeRule:function(data){if(typeof data=="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;}return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message||$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";switch(element.nodeName.toLowerCase()){case'select':var options=$("option:selected",element);return options.length>0&&(element.type=="select-multiple"||($.browser.msie&&!(options[0].attributes['value'].specified)?options[0].text:options[0].value).length>0);case'input':if(this.checkable(element))return this.getLength(value,element)>0;default:return $.trim(value).length>0;}},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(!this.settings.messages[element.name])this.settings.messages[element.name]={};this.settings.messages[element.name].remote=typeof previous.message=="function"?previous.message(value):previous.message;param=typeof param=="string"&&{url:param}||param;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){var valid=response===true;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();}else{var errors={};errors[element.name]=previous.message=response||validator.defaultMessage(element,"remote");validator.showErrors(errors);}previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}else if(this.pending[element.name]){return"pending";}return previous.valid;},minlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)>=param;},maxlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)<=param;},rangelength:function(value,element,param){var length=this.getLength($.trim(value),element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value));},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);},dateDE:function(value,element){return this.optional(element)||/^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);},numberDE:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9-]+/.test(value))return false;var nCheck=0,nDigit=0,bEven=false;value=value.replace(/\D/g,"");for(n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);var nDigit=parseInt(cDigit,10);if(bEven){if((nDigit*=2)>9)nDigit-=9;}nCheck+=nDigit;bEven=!bEven;}return(nCheck%10)==0;},accept:function(value,element,param){param=typeof param=="string"?param.replace(/,/g,'|'):"png|jpe?g|gif";return this.optional(element)||value.match(new RegExp(".("+param+")$","i"));},equalTo:function(value,element,param){return value==$(param).val();}}});$.format=$.validator.format;})(jQuery);;(function($){var ajax=$.ajax;var pendingRequests={};$.ajax=function(settings){settings=$.extend(settings,$.extend({},$.ajaxSettings,settings));var port=settings.port;if(settings.mode=="abort"){if(pendingRequests[port]){pendingRequests[port].abort();}return(pendingRequests[port]=ajax.apply(this,arguments));}return ajax.apply(this,arguments);};})(jQuery);;(function($){$.each({focus:'focusin',blur:'focusout'},function(original,fix){$.event.special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$.event.special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$.event.special[fix].handler,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};});$.extend($.fn,{delegate:function(type,delegate,handler){return this.bind(type,function(event){var target=$(event.target);if(target.is(delegate)){return handler.apply(target,arguments);}});},triggerEvent:function(type,target){return this.triggerHandler(type,[$.event.fix({type:type,target:target})]);}})})(jQuery);/* declare global variables for jslint */
/*global $ */
/* menu.js
 * @author Jason Crane, jcranefwst
 * @minify true
 */
// handles adding/removing of classes that make menu work, uses hoverIntent plugin to delay mouseover/out events 
jQuery(document).ready(function() { 
	var hoverIntentConfig = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
	     interval: 10, // number = milliseconds for onMouseOver polling interval    
	     over: isHover, // function = onMouseOver callback (REQUIRED)    
	     timeout: 350, // number = milliseconds delay before onMouseOut    
	     out: outHover // function = onMouseOut callback (REQUIRED)    
	};
	var _default = $('#nav ul li.default').attr('id'), is_default = '#' + _default;
	function isHover() {
		$('#nav').toggleClass('z99');
		 $(this).addClass('active').removeClass('inactive');	
		 $(this).siblings().removeClass('active').addClass('inactive');
		 $(this).children('.sub_nav').addClass('subnav_active');
	}
	function outHover(){
		var subnav_active = $('li.active').children('sub_nav').hasClass('subnav_active');
		if (subnav_active) {
			// do nothing
		}
		else {	
			$('#nav').toggleClass('z99');
			$(this).removeClass('active').addClass('inactive');
			$(this).children('.sub_nav').removeClass('subnav_active');
			if ($(this).siblings().hasClass('active'))
			{
				// do nothing
			}
			else {
				$(is_default).removeClass('inactive');
				$(is_default).addClass('active');
				// this is a last failsafe if none of the top menu items are active, the home page menu will be made active
				// create array 
				any_active = [];
				// check if any of the top menu items have the class 'active'
				$('#nav li.top').each(function() {
					// get true or false 
					yes_active = $(this).hasClass('active');
					// push the result each time into an array
					any_active.push(yes_active);
				})
				// sort the array alphabetically, thereby putting all of the false items first; any true items in array would go to the end
				any_active.sort();
				// pop out the last item of the array. if any of them were true, true would be last and would get popped out.
				active_check = any_active.pop().toString();
				// if nothing came back true (as in, none of the top menu items had a class of active
				if (active_check != 'true') {
					// just double check and remove the active class from any of the top menu items
					$('li#home_page').siblings('.top').removeClass('active').addClass('inactive');
					// and add the class to the home page menu item to make it active
					$('li#home_page').removeClass('inactive').addClass('active');
				}
			}
		}
	}
	jQuery('#nav ul li.top').each(function() {
		jQuery(this).hoverIntent(hoverIntentConfig);
	});
});/* 
 @minify true
 taken for minification from http://star-telegram.com/static/scripts/mi/polls/polls-20071128-AAY.js
This is an object oriented version of the poll javascript
This script does everything our ajax polls implementation needs, including:

1. showing appropriate html depending on if the person has voted or not
2. handle submission of the form
3. get results
etc
*/

/* object constructor */
function miPollAjax() {
    this.poll_id;
    this.story_id;
    this.section_id;
    this.stretched = false;
    this.vote_casted = false;

    // When you click to cast your vote this get's called
    this.submitPoll = function()
    {
        var poll_value = this.getPollValue();

        // Test if they chose a radio button to vote on
        if (poll_value != -1)
        {
            // vote_casted gets set in the beginning if they have already voted and set to true after voting.
            // That allows us to pop up an alert if they've already voted. 
            if ( this.vote_casted == true )
            {
                alert( "Limit 1 vote per user, you have already voted." );
            }
            else
            {
                // Build a url with the form data to send the iframe to to exec the perl script
                url = "/survey-bin/tabulate_poll.cgi?mi_pb_cache=1&expire_days=5&path=/&already_voted_error=You%20have%20already%20voted.%20Limit%201%20vote%20per%20user.&save=Cast%20Vote&value=Cast%20Vote";
                url = url + "&poll_id=" + this.poll_id;
                url = url + "&section_id=" + this.section_id;
                url = url + "&story_id=" + this.story_id;
                url = url + "&poll_response=" + poll_value;

		$("#poll_result").load(url); 
		this.hidePollForm();
            	this.fetchPollResults();
            	this.showPollResults();
                this.vote_casted = true;
            }
        }
        else
        {
            alert( "Please choose an option to vote for" )
        }
    }

    // This will retrieve poll results without casting a vote, by calling in the cgi results via jquery's 
    // AJAX support
    // Note: not passing "save" or "value" like the submitPoll function does prevents this call
    // from casing a vote. 
    this.fetchPollResults = function()
    {
        // Build a url with the form data to send the iframe to to exec the perl script
        url="/survey-bin/tabulate_poll.cgi?mi_pb_cache=1&expire_days=5&path=/&already_voted_error=You%20have%20already%20voted.%20Limit%201%20vote%20per%20user.";
        url = url + "&poll_id=" + this.poll_id;
        url = url + "&section_id=" + this.section_id;
        url = url + "&story_id=" + this.story_id;
	
	$("#poll_result").load(url); 
    }

    this.register_response = function( element )
    {
        this.tempElement = element;
        //this.handleResponse( 1, this.tempElement );
        this.stretch_graphs();
    }


    // This helper function looks at the list of poll responses and returns the index of the one selected
    this.getPollValue = function()
    {
        var radios = document.forms.poll_responses.poll_response;
        for ( var i=0; i < radios.length; i++ )
        {
            if ( radios[i].checked ) return ( radios[i].value );
        }
        return -1;
    }

    // Onload, hide either the poll form or the poll results based on the cookie
    this.visibilityCheck = function()
    {
        if ( this.alreadyVoted() )
        {
            //alert( "You have already voted." );
            this.hidePollForm();
            this.fetchPollResults();
            this.showPollResults();
            //this.showAlreadyVotedMessage();
            this.vote_casted = true;
        }
        else  // Otherwise show the form so they can vote
        {
            this.showPollForm();
        }
    }

    //checks to see if the user has voted already
    this.alreadyVoted = function()
    {
        // Get the cookie and parse it to see if this poll ID has been submitted before
        content = this.getPollCookie('mi_polls');
        //alert( "poll cookie => '" + this.getPollCookie('mi_polls') + "'" );
    
        // No cookie, do nothing
        if ( content == null )
        {
            return;
        }
    
        // Parse the cookie so we can see if they voted on this particular poll id
        sval = content.split ( ";" );
        num_cookies = sval.length;
        key = new Array();
        for ( x = 0; x < num_cookies / 2 + 1; x++ )
        {
            qval = sval[x].split("=");
            id = qval[0];
            poll_submitted = qval[1];
            key[id] = poll_submitted;
            //alert( "id => '" + id + "', value => '" + poll_submitted + "'" );
        }

        // If they already voted, hide the form, and show a message saying they already voted
        if ( key[this.poll_id] == 1 )
        {
            //alert( "You have already voted" );
            return true;
        }
        else
        {
            return false;
        }
    }

    // Grab the cookie so we can check if they've already submitted or not
    this.getPollCookie = function(cookie_name)
    {
        dc = document.cookie;
        cname = cookie_name + "=";
        clen = dc.length;
        cbegin = 0;
    
        while ( cbegin < clen )
        {
            vbegin = cbegin + cname.length;
    
            if ( dc.substring ( cbegin, vbegin ) == cname )
            {
                vend = dc.indexOf ( ";", vbegin );
                if ( vend == -1 ) vend = clen;
    
                return unescape ( dc.substring ( vbegin, vend ) );
            }
    
            cbegin = dc.indexOf ( " ", cbegin ) + 1;
    
            if ( cbegin == 0 ) break;
        }
        
        return null;
    }

    // The size of the box this stuff is going into can vary quite a bit so
    // This will scale up the size of those bars on the bar graph so they take up
    // More of the box.. If your graphs are running off the edge, bring .9 down to .8
    this.stretch_graphs = function()
    {
        this.stretched = true;
        var element_poll_result = document.getElementById("poll_result");
        var element_poll_form = document.getElementById("poll_form");
   
        // Detect how much room the box has that the results are going into 
        if ( element_poll_result.offsetWidth > 0 )
            div_width = element_poll_result.offsetWidth;
        else
            div_width = element_poll_form.offsetWidth;

        // Magical formula or deciding how much to increase the bar width    
        multiplier = (div_width * .9 - 20)/100;

        // Get each of those bars, and expand or shrink each one of them       
        var element_bar_result = document.getElementsByName("bar_result");

        for ( count = 0; count < element_bar_result.length; count++ )
        {
            pixels = element_bar_result[count].width;
            if ( pixels > 0 )
                element_bar_result[count].width = pixels * multiplier;
        }
    
    }

    // Hide/Show the poll form and poll results  
    this.hidePollForm = function()
    {
        //alert( "hide poll form" );
        var element = document.getElementById("poll_form");
        if (element) element.style.display= "none";
    }

    this.showPollForm = function()
    {
        var element = document.getElementById("poll_form");
        if (element) element.style.display= "block";
    }

    this.hidePollResult = function()
    {
        var element = document.getElementById("poll_result");
        if (element) element.style.display= "none";
    }

    this.hideAlreadyVotedMessage = function()
    {
        var element = document.getElementById("poll_already_voted");
        if (element) element.style.display="none";
    }

    this.showPollResults = function()
    {
        this.fetchPollResults();
        var element = document.getElementById("poll_result");
        if (element) element.style.display = "block";

        if (this.stretched == false)
        {
            this.stretch_graphs();
        }
    }

    this.showAlreadyVotedMessage = function()
    {
        element = document.getElementById("poll_already_voted");
        if (element) element.style.display = "block";
    }

} /* end object *//* @minify true */
/*
this script provides a way to test to see if a script has been loaded previously, and if so, does not load it again.
it checks for the object that will be created by a script, if the object exists, the script has been loaded.
*/

function miScriptScheduler() {

    this.scriptCheck = ""; /* value of function check (eg. window.jQuery)*/
    this.scriptPath = ""; /* file path to required script */
    //var cc = this; /*cache a copy of the object for use inside jquery methods*/

    /*
    method checks value of scriptCheck, if undefined a script node is created
    with the src attribute set to scriptPath. This node is then injected into the   DOM
    */
    
    this.scheduleScript = function ()
    {
        if(!this.scriptCheck)
        {
            /* script test function not found, load script with no waiting*/
                var tempElement = document.createElement("script");
                tempElement.src = this.scriptPath;
                var bases = document.getElementsByTagName('base');
                if(bases.length && bases[0].childNodes.length) {
                   bases[0].appendChild(tempElement);
                }
                else {
                  document.getElementsByTagName('head')[0].appendChild(tempElement);
                }
            
        }
        else {
            return(0);
        }
    } /*end scheduleScript method*/
} /* end constructor*/

/* photo_gallery.js
 * @author jcrane
 * @minify true
 */
function photoGallery(){
	var newHeight, slideHeight;
	var slideHeights = [];
	// determine tallest slide by looping through them and getting their height
	// also determine if photo is vertical (taller than it is wide) and if it is, add width: 400px to image style
	$('.gallery_slide').each(function(){
		slideHeight = $(this).height();
		slideHeights.push(slideHeight);
		slideWidth = $(this).width();
		if (slideHeight > slideWidth) {
			$(this).children('img').css('width','400px');
		}
	});
	// sort the heights in the array
	slideHeights = slideHeights.sort(sortNumber);
	// pop out the last (largest) height, and then give it to cycle below
	newHeight = slideHeights.pop();
	newHeight = newHeight + 20;
	$('#photo_gallery').cycle({
		fx: 'fade',
		speed: 'fast',
		timeout: 5000,
		pager: '#gallery_pager',
		next: '#gallery_next',
		prev: '#gallery_prev',
		height: newHeight
	});
	$('#photo_gallery').cycle('pause');
	$('#gallery_play').toggle(function(){
		$('#photo_gallery').cycle('resume', true);
		$(this).toggleClass('ui-icon-pause');
	}, function(){
		$('#photo_gallery').cycle('pause');
		$(this).toggleClass('ui-icon-pause');
	});
	$('#gallery_nav a, #gallery_nav .ui-icon').click(function(){
		injectAd();
	});
	// allow user to scroll through photos using left and right arrow keys
	function checkKey(e){
     switch (e.keyCode) {
        case 37:
          $('#gallery_prev').trigger('click');
            break;
        case 39:
           $('#gallery_next').trigger('click');
            break;
      }      
	}
	if ($.browser.mozilla) {
	    $(document).keypress (checkKey);
	} else {
	    $(document).keydown (checkKey);
	}
}/* @minify true */

// search **********************************************************************
//function searchFormSubmit(form) {
//      if (form.aff.value == 'archives' || form.aff[1].checked == true) {
//            window.location = "http://www.newslibrary.com/nlsearch.asp?search_mode=all&action=search&date_mode=year&year=last+180+days&sort=d%3Ah&nitems=10&region=st&dbquery=" + form.keywords.value;
//                return false;
//        } 
//	 else if (form.aff[2].checked == true || form.aff.value == 'web') {
//		window.location = "http://www.star-telegram.com/cgi-bin/mi/overture/overture.pl?Keywords=" + form.keywords.value;
//                return false;
//	}

//        return true;
//}
// end search ******************************************************************


// search **********************************************************************
function searchFormSubmit(form) {
        if (form.aff.value == 'archives' || form.aff[1].checked == true) {
                window.location = "http://www.newslibrary.com/nlsearch.asp?search_mode=all&action=search&date_mode=year&year=last+180+days&sort=d%3Ah&nitems=10&region=st&dbquery=" + form.keywords.value;
                return false;
        } 
	 else if (form.aff[2].checked == true || form.aff.value == 'web') {
		 var encoded_keywords = encodeURIComponent(form.keywords.value);
		 var section_num = '547';
		 var url_version = 'ysr';
		 var params = 'product=Yahoo%2COverture&' +
			      'collection=WEB&' +
			      'live_template=http%3A%2F%2Fwww.star-telegram.com%2F' + section_num + '%2Fv-' + url_version + '%2Findex.html&' + 
			      'preview_template=http%3A%2F%2Fpreview.star-telegram.com%2F' + section_num + '%2Fv-' + url_version + '%2Findex.html&' + 
			      'error_template=http%3A%2F%2Fwww.star-telegram.com%2F' + section_num + '%2Fv-err%2Findex.html&' +
			      'results_per_page=10&' +
			      'prop_related=1&prop_dym=1';
		 window.location = "http://search.star-telegram.com/search-bin/search.pl.cgi?sf_Keywords=" + encoded_keywords + '&' + params;

		 return false;
	}
        return true;
}
// end search ******************************************************************

// getParams *******************************************************************
function getParams(params) {
   var Params = new Object ();
   if ( ! params ) return Params; // return empty object
   var Pairs = params.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;

}
// end getParams *****************************************************************


function today_string() {
	// dependant on date functions defined in mi-utilities.js
	var today = new Date();
	return today.getDayString()+', '+today.getMonthString()+' '+today.getDate()+', '+today.getFullYear();
}

// text_digge_ variable configuration - set digger_is_off variable to 1 to turn off ***********

var digger_is_off;

// text_digger


/*global $ */
/* startelegram.functions_09.js
 * @minify true
 * @author jcranefwst
 */
// jQuery.noConflict();
// eventually want to make this object oriented, so...
var st = {};
// control opening, closing and which icons show when using service links at top of page
function removeCloseIcon() {
	$('.sub_service li').each(function() {
		$(this).click(function() {
			$(this).closest('.sub_service').slideUp('fast');
			$(this).siblings('.sub_service').slideToggle('fast');
			$(this).closest('.sub_service').siblings('.ui-icon').toggleClass('ui-icon-close');
			// return false;
		});
	});
}
function serviceLinks(){
	var isOpen;
	$('.service_link').each(function() {
			$(this).click(function(){
				var isOpen = $(this).parents('#service_links > ul > li').siblings().children('.sub_service');
				if (isOpen.is(':visible')) {
					$(this).parents('#service_links > ul > li').siblings().children('.sub_service').hide();
					$(this).siblings('.sub_service').slideToggle('fast').addClass('active');
					$(this).parents('#service_links > ul > li').siblings().children().siblings('.ui-icon').toggleClass('ui-icon-close');
					// testing icon behavior with/without next line
					$(this).siblings('.ui-icon').toggleClass('ui-icon-close');
					$('#header_wrap').addClass('z99');
				}
				else {
					$('#header_wrap').toggleClass('z99');
					$(this).siblings('.ui-icon').toggleClass('ui-icon-close');
					$(this).siblings('.sub_service').slideToggle('fast');
				}
			if ($(this).hasClass('feedback_link')) {
				// do nothing
				}	
			else { 
				return false;
			}
		});
	});
	
	$('#service_links .ui-icon').each(function() {
		hasCloseIcon = $(this).hasClass('ui-icon-close');
		$(this).click(function() {
			if ($(this).hasClass('ui-icon-close')) {
				$(this).toggleClass('ui-icon-close');
				$('#header_wrap').toggleClass('z99');
			}
		});
	});
	
	$('.sub_service li').each(function() {
		$(this).click(function() {
			$(this).closest('.sub_service').slideUp('fast');
			$(this).siblings('.sub_service').slideToggle('fast');
			$(this).closest('.sub_service').siblings('.ui-icon').toggleClass('ui-icon-close');
			$('#header_wrap').toggleClass('z99');
			// return false;
		});
	});
	
	// if one of the submenus is open and user clicks elswhere in document, close the submenu  
	
		// $('#header_wrap').click(function(){
			$('#pagebody').bind('click', function(){
				$('#service_links .sub_service:visible').hide();
				$('#service_links .sub_service').siblings('.ui-icon').removeClass('ui-icon-close');
				$('#header_wrap').removeClass('z99');
			});
		// click binding is causing cursor flicker issues in ie7, so this prevents 	
		/* $('#wrapper').click(function(e) {
  			e.stopPropagation();
		}); */
		// trying to add this functionality elswhere in this function so it works whenever dropdown is open
		/* $('#service_links').hover(function() {
			$('#header_wrap').addClass('z99');
			},
			function() {
				$('#header_wrap').removeClass('z99');
			}
		);	 */
		cornerPeel = $('#yahoo_1x1_ipatf, #yahoo_1x1_ipatf_1').find('script:eq(1)');
		text = cornerPeel.text();
		if (text) {
			if (text.indexOf('// no ads') == -1) {
				$('#service_links').css('padding-left', '120px');
			}
		}	
} // end function serviceLinks

// control font sizes of articles on story detail page
function fontSizeMultiplier(changeThis) {
	var fontSize = $(changeThis).css('font-size');
	fontSize = fontSize.replace('px','');
	fontSize = parseFloat(fontSize) * 1.2;
	fontSize += 'px';
	$(changeThis).css('font-size',fontSize);
}
function bigText(){
	$('.bigger_text').click(function(){
		fontSizeMultiplier('#story_body');
		$(this).addClass('active');
		$(this).siblings().removeClass('active');
	});	
}
function fontSizeSmaller(changeThis) {
	var fontSize = $(changeThis).css('font-size');
	fontSize = fontSize.replace('px','');
	fontSize = parseFloat(fontSize) / 1.2;
	fontSize += 'px';
	$(changeThis).css('font-size',fontSize);
}
function smallText(){
	$('.smaller_text').click(function(){
		fontSizeSmaller('#story_body');
		$(this).addClass('active');
		$(this).siblings().removeClass('active');
	});
}
function defaultText() {
	$('.default_text').click(function(){
		$('#story_body').css('font-size','1.1em');
		$(this).addClass('active');
		$(this).siblings().removeClass('active');
	});
}

// return default text back in an input text field if it is focused and then blurred
function inputFocusBlur() {	
	$('input.text').each(function() {
		var defaultValue = $(this).val();
		$(this).blur(function() {
			if (this.value === '') {
				this.value = defaultValue;
			}
		});
		$(this).focus(function() {
			// $(this).select();
			if (this.value == defaultValue) {
				this.value = '';
			}
		});
	});
}
// selects default text in a text field when it is clicked
function formTextSelect() {
	$('form .text').each(function() {
		$(this).focus(function() {
   			$(this).select();
		});
	});
}

// closes news alert when close icon is clicked
function closeBulletin() {
	$('#bulletin .ui-icon').click(function() {
		$('#bulletin').slideUp('fast');
		// $('#skyline').show();
	});
}

// creates tabs for article, photos and videos on story detail pages
function articleTabs() {
	var hasVideo, hasMap, hasComments, media_id, href, commentsPaging;
	var $story_content_tabs = $('#story_content_container').tabs();
	// toggles font size controls, so they're only shown when article tab is active
	var selected = $story_content_tabs.tabs('option', 'selected');
	$story_content_tabs.bind('tabsselect', function(event, ui) {
 		// if we're not selecting the first tab, which is the article tab, hide the text resize options
		if (ui.index !== 0) {
				$('.bigger_text, .smaller_text, .default_text').hide();
			}
		// or show them if we are selecting the article tab	
		else {
				$('.bigger_text, .smaller_text, .default_text').show();
			}	
	});
	// opens appropriate tab when photo or video link is clicked from story assets links
	$('#story_assets .photo_link, #photo_asset_thumb img').click(function() {
		$story_content_tabs.tabs('select','#article_photos');
		return false;
	});
	$('#story_assets .video_link, #story_assets #main_thumbnail').click(function() {
		$story_content_tabs.tabs('select','#article_videos');
		return false;
	});
	$('#story_assets .map_link, #map_asset_thumb img').click(function() {
		$story_content_tabs.tabs('select','#article_map');
		return false;
	});
	var video_url = document.location;
	video_url = video_url.toString();
	if (video_url.match('video')) {
	    $story_content_tabs.tabs('select','#article_videos');
		if (hasVideo == 'true') {
		// don't do anything b/c we already have our videoStack
		}
		else {
			media_id = $('#embedded_video').attr('name');
			getVmixVideoDetail(media_id);
			getVmixVideoDetailStack();
			hasVideo = 'true';
		}  
	}
	var graphics_url = document.location;
	graphics_url = graphics_url.toString();
	if (graphics_url.match('video')) {
	    $story_content_tabs.tabs('select','#article_graphics');
	}
	$('.link_to_video').click(function() {
		$('#story_content_container').tabs('select','#article_videos'); 
		window.scrollTo(0,300); 
		return false;
	})
	// this handles the events that happen when certain tabs are selected
	$story_content_tabs.bind('tabsselect', function(event, ui){
		href = new String(ui.tab.href);
		// if video tab selected
		if (href.match('article_videos')) {
			if (hasVideo == 'true') { 
				// don't do anything b/c we already have our videoStack
			}
			else {		
			// get the media id from the name attribute of the embedded_video div, which is set in the template
			media_id = $('#embedded_video').attr('name');
			// get the main video and the latest videos stack
			getVmixVideoDetail(media_id);
			getVmixVideoDetailStack();
			// variable to see if video already loaded, so we don't load each time the tab is selected
			hasVideo = 'true';
			}	
		}
		// if map tab is selected
		else if (href.match('article_map')) {
			if (hasMap == 'true') {
			// don't do anything b/c we already have our map
			}
			else {
				// get the api key from the name attribute of the map, which is set in the template
				api_key = $('#article_map .map').attr('name');
				// load the maps api, which will callback to the function to the load the maps
				initMapLoader(api_key);
				// variable to see if map is already loaded, so we don't load it each time the tab is selected
				hasMap = 'true';
			}
		}
		// change the comment pagination URLs to not take users to #Comments_Container div, which is added to URL through pluck javascript
		else if (href.match('article_comments')) {
			if (hasComments == 'true') {
			// don't do anything b/c we have already done this
			}
			else {
				// this variable is declared in MI_SiteLife.js, overriding to remove '#Comments_Container identifier from returned URL
				gSiteLife.mi.commenting = {
					submitReturnAddress: 'http://' + location.host + location.pathname + "?mi_pluck_action=comment_submitted&qwxq="+Math.floor(Math.random()*10000)+urlTS.getMilliseconds()
				};
				// need to do the same thing for the pagination links, but the #Comments_Container is inserted in a different way
				// that's a little tougher to get to, so we go about it this way
				// loop through the links inside the comment pagination div
				
				st.commentsPaging = function(){
					$('#nyxComments_pager span a').each(function(){
						// grab the href attribute
						paginationLink = $(this).attr('href');
						// cut it off at the hash
						paginationLink = paginationLink.substring(0, paginationLink.indexOf("#"));
						// give the new href back to the link
						$(this).attr('href', paginationLink);
					});
					hasComments == 'true';
				};
				st.commentsPaging();
			}
		}
	}); 
	$('#article_videos .cycle').cycle({
		speed: 'fast',
		timeout: 5000,
		pager: '#video_pager',
		next: '#video_next',
		prev: '#video_prev'
	});
	$('#article_videos .cycle').cycle('pause');
	$('#story_assets .map_link, #map_asset_thumb img').click(function() {
		$story_content_tabs.tabs('select','#article_map');
		return false;
	});	
	$('#story_assets .graphics_link, #graphic_asset_thumb img').click(function() {
		$story_content_tabs.tabs('select','#article_graphics');
		return false;
	});	
	$('#story_assets .chart_link').click(function() {
		$story_content_tabs.tabs('select','#article_chart');
		return false;
	});	
	// add class of last to remove bottom padding on last in list of links in story assets box
	$('#links_asset_thumb p:last').addClass('last');
	
	
	// TODO - fix in IE, this does not yet work in IE; problem is with commentsCount = $('#commentsCount').text(), line 311
	// grab the number of comments, and if there are comments, add number to comments tab
	// this needs to happen after thhe number is loaded in the 1st place by Pluck
	// this is not the best way to do this, keep working on figuring out how to grab that variable instead.
	/*
	// fisrt, set the interval of checking for the comments total to once a second
	commentCountInterval = setInterval('st.commentsCount()',1000);
	// only going to check ten times, once a second, so start at 1
	commentCountLimit = 1;
	st.commentsCount = function(){
		// grab the comments number from pluck comment count in story tools
		commentsCount = $('#commentsCount').text();		
		// if it's 0, it may not have been populated yet, so keep checking
		if (commentsCount == 0) {
			// make sure it hasn't been 10 times
			while (commentCountLimit < 10) {
				// run the interval timer
				commentCountInterval;
				// add this check to the count limit total
				commentCountLimit = commentCountLimit + 1;
			}
		}
		// or if the comment count is more than 0
		else {
			// wrap it in parentheses
			commentsTab = 'Comments (' + commentsCount + ')';
			// and add that number to the comments tab
			$('#comments_tab_test').children('a').text(commentsTab);
			// and clear the interval timer
			clearInterval(commentCountInterval);
		}
	}
	st.commentsCount(); */
	
	
	// check to see if a comment has just been submitted, and if it has, go the comments tab so the user can see their comment
	var comment_submitted, url, openCommentTab;
	url = document.location;
	url = url.toString();
	if(url.match(/comment_submitted/)) {
		openCommentTab = 'true';
		// st.commentsCount();
	}
	else if (url.match(/page_nav/)) {
		openCommentTab = 'true';
		// st.commentsCount();
	}
	else {
		comment_submitted = '';
	}
	if (openCommentTab) {
		$story_content_tabs.tabs('select', '#article_comments');
		// TODO: this is an attempt to run the commentsPaging function after a comment is submitted, so that those links are corrected.
		// this doesn't work, really i think it needs to run on document ready, or with a setTimeout maybe
		/* $story_content_tabs.tabs({ 
        	select: function(event, ui) { 
            	if($(ui.href) == "article_comments") { 
					st.commentsPaging();
				}
			}
		}); */
	}	
	$('#story_comments_count span.activity_text').bind('click',function() {
		$story_content_tabs.tabs('select','#article_comments');
		return false;
	});
	
	// get the comment count from first place it's displayed on page
	
	// commenting out injectAd function during troubleshooting of why tabs won't load
	// injectAd();
} // end articleTabs function
// sort numbers in an array
function sortNumber(a,b) {
	return a - b;
}
 function mycarousel_initCallback(carousel){
	jQuery('.jcarousel-control a').bind('click', function(){
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('id')));
		return false;
	});
	/* $('#skyline_options').hover( function() {
		$(this).toggleClass('ui-state-hover');
	},
	function() {
		$(this).toggleClass('ui-state-hover');
	}
	);
	$('#skyline_options').bind('click', function() {
		$('.jcarousel-control').slideToggle('fast');
		$(this).toggleClass('ui-icon-close');
	}); */
}
/*
* This is the callback function which receives notification
* when an item becomes the first one in the visible range.
*/
/* function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	if (idx == 1) {
		$('.jcarousel-control a#1').children('span').addClass('ui-icon-bullet');
		$('.jcarousel-control a#1').siblings().children('span').removeClass('ui-icon-bullet');
	}
	if (idx == 3) {
		$('.jcarousel-control a#3').children('span').toggleClass('ui-icon-bullet');
		$('.jcarousel-control a#3').siblings().children('span').removeClass('ui-icon-bullet');
	}
	if (idx == 5) {
		$('.jcarousel-control a#5').children('span').toggleClass('ui-icon-bullet');
		$('.jcarousel-control a#5').siblings().children('span').removeClass('ui-icon-bullet');
	}
	if (idx == 7) {
		$('.jcarousel-control a#7').children('span').toggleClass('ui-icon-bullet');
		$('.jcarousel-control a#7').siblings().children('span').removeClass('ui-icon-bullet');
	}
} */		
// runs functions when the DOM is ready
jQuery(document).ready(function() {
	// creates carousel for skyline
	jQuery('#skyline_items').jcarousel({
	scroll: 1,
	initCallback: mycarousel_initCallback
	// itemFirstInCallback: mycarousel_itemFirstInCallback
	});	
	// creates cycle for special features promos
	jQuery('#special_features_promos').cycle({
		fx: 'fade',
		timeout: 7000,
		speed: 300,
		pause: 1
	});
	
	// creates tabs on any div with class of tabs
	jQuery('.tabs').each(function() {
		$(this).tabs({ 
		    // collapsible:true,
			// event: 'mouseover',
			// creates accordion when applicable inside of those tabs 
			show: function(ui) { 
		        $('.accordion').accordion({ 
					icons: {
						'header': 'ui-icon-triangle-1-w',
						'headerSelected' : 'ui-icon-triangle-1-s'
						},
					// event: 'mouseover',
					// fillSpace: true
					autoHeight: false, 				
					change: function(event, ui) {
						// remove title of exposed accordions (open accordions)
						ui.newHeader.attr('title','');
						// change title of exposed accordions siblings (closed accordions)
						ui.newHeader.siblings('.header').attr('title','Click to show content');
					} 
				}); 
		    } 
		});
	}); 
	
	// give tab links mouseover functionality with a slight delay using hoverIntent plugin
	function tabHover() {
		$(this).trigger('click');
	}
	function tabOut(){ 
		// do nothing 
	}
	var tabConfig = {    
    	sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
    	interval: 40, // number = milliseconds for onMouseOver polling interval    
    	over: tabHover, // function = onMouseOver callback (REQUIRED)    
    	timeout: 300, // number = milliseconds delay before onMouseOut    
    	out: tabOut // function = onMouseOut callback (REQUIRED)    
	};
	// hoverIntent for tabs
	$('.tabs').each(function() {
		$(this).find('ul.tab_links li a').hoverIntent(tabConfig);
	});
	$('#story_content_container').find('ul.tab_links li a').hoverIntent(tabConfig);
	
	$('ul.tab_links').each(function() {
		$(this).children('li:first').addClass('first');
	});
	$('#share li a, .story_tool_option').each(function() {
		$(this).hover(
			function() {
				$(this).find('.ui-icon').addClass('ui-state-hover');
			},
			function() {
				$(this).find('.ui-icon').removeClass('ui-state-hover');
			}
		);
	});
		
	$('#story_tools #recommendation').click(function() {
		$(this).siblings('#recommendation_icon').addClass('ui-state-highlight');
	});
	
	$('.story.summary:last').addClass('last');
	
	// removed this for now, makes things pretty jumpy, need to revisit how to handle timestamps
	/* $('.story.summary').each(function() {
		$(this).hover(function() {
			$(this).children('.story_text').children('.story_header').children().children('.timestamp').show();
  		},
		function() {
			$(this).children('.story_text').children('.story_header').children().children('.timestamp').hide();
		});
	}); */
	// show and hide search bar options when clicking Show options text above search bar
	$('#search .search_options_toggle').click(function() {
		optionText = $(this).children('a').children('span');
		$(this).siblings('.search_options').slideToggle('fast');
		if (optionText.text().match('Show options')) {
			optionText.text('Hide options');
		}
		else if (optionText.text().match('Hide options')) {
			optionText.text('Show options');
		}
		return false;
	});
	$('#search_1100_label').click(function() {
		$('input#search_1100').attr('checked', 'checked');
		$(this).addClass('active_search');
		$(this).siblings('.radio_label').removeClass('active_search');
		return false;
	
	});
	$('#search_archives_label').click(function() {
		$('input#search_archives').attr('checked', 'checked');
		$(this).addClass('active_search');
		$(this).siblings('.radio_label').removeClass('active_search');
		return false;
		
	});
	$('#search_web_label').click(function() {
		$('input#search_web').attr('checked', 'checked');
		$(this).addClass('active_search');
		$(this).siblings('.radio_label').removeClass('active_search');
		return false;
	});
	
	
	// use hoverIntent on more menu option if it exists in main menu
	// moved config options below function definitions so they will be defined before referenced, 9-1-09
	
	function moreHover(){
		$(this).parents('li.more_nav_link').addClass('more_nav_link_active');
		$(this).siblings('.more_nav').addClass('more_nav_active').removeClass('more_nav_inactive');
	}
	function moreOutHover(){
		$(this).siblings('.more_nav').addClass('more_nav_inactive').removeClass('more_nav_active');
		$(this).parents('.more_nav_link').removeClass('more_nav_link_active');
	}
	var hoverIntentMoreConfig = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
	     interval: 10, // number = milliseconds for onMouseOver polling interval    
	     over: moreHover, // function = onMouseOver callback (REQUIRED)    
	     timeout: 350, // number = milliseconds delay before onMouseOut    
	     out: moreOutHover // function = onMouseOut callback (REQUIRED)    
	};
	$('#nav a.more_link').hoverIntent(hoverIntentMoreConfig);
	$('#nav a.more_link').click(function() { return false; });
	serviceLinks();
	closeBulletin();
	bigText();
	smallText();
	defaultText();
	formTextSelect();
	inputFocusBlur();
	/* $('#st_footer_bottom img').dblclick(function() {
		current_stripe = $('body').css('background-image');
		default_stripe = 'url(http://media.star-telegram.com/images/st_bg.png)';
		alterna_stripe = 'url(http://media.star-telegram.com/images/st_bg_2.png)';
		if (current_stripe == default_stripe) {
			$('body').css('background-image',alterna_stripe);
		}
		else if (current_stripe == alterna_stripe) {
			$('body').css('background-image',default_stripe);
		}	
	}) */
	$('#scores td.TSN5').closest('tr').addClass('odd');
	$('#scores td.TSN1').closest('tr').addClass('even');
	$('#scores tr.even + tr.odd, #scores tr.odd + tr.even').addClass('top_rule');
	$('#schedule tr:odd, #standings tr:odd, #leaders tr:odd').closest('tr').addClass('odd');
	
	// this is for the sports network widgets, to lazy load those javascript files	
	// LazyLoadTsnSchedule();	

	// this is to hide text digger tags. temporarily only displaying topics links until tags pages are generated
	$('#digger_topics p:eq(1)').hide();
	
	// this is to only display topics or tags if there are actually links, otherwise, hide the topics/tags label(s)
	// loop through each paragraph (topics are in one and tags in the other
	$('#digger_topics p').each(function() {
		// find the links if they exist
		hasLinks = $(this).find('a');
		// get number of links
		hasLinks = hasLinks.length;
		// if there aren't any links
		if (hasLinks < 1) {
			// hide the paragraph
   			$(this).addClass('hide');
		}
	});
}); // end main document ready function



function initMapLoader(apiKey) {
  var script = document.createElement("script");
  script.src = "http://www.google.com/jsapi?key=" + apiKey + "&callback=loadMaps";
  script.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(script);
}

// this is taken from current preredesign site, still will be used for templates using legacy highlights method	
function setLeftRightWidth() {
	if(window.leftRightWidth) {
		$("div.left_half").each(function(i){
			if(i < leftRightWidth.length){ // Check to see if a custom width has been defined for this DIV
				if(leftRightWidth[i][0]<=100) { // Only apply left width if it is less than or equal to 100
					$(this).width(leftRightWidth[i][0]+"%");
				}
			 }
		 }); 	
		$("div.right_half").each(function(i){
	 		if(i < leftRightWidth.length){ // Check to see if a custom width has been defined for this DIV
	 			if(leftRightWidth[i][0]<=100) { // Only apply right width if the left width is less than or equal to 100
	 				if(leftRightWidth[i][0]+leftRightWidth[i][1]>=100) { // If sum of the left and right widths is greater than 100 adjust right width
	 					leftRightWidth[i][1]=99-leftRightWidth[i][0]; //using 99 here to avoid problems with border widths
	 				}
	 				$(this).width(leftRightWidth[i][1]+"%");
	 			}
	 		}
	 	});
	 	// equalHeightLR();
	}
} 




/*
 * VALIDATION / OPINIONS MAILER FORM
 */

jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");

var $submission_type, $submission_email, submitOK;
// $submission_type = document.feedback.email_option.value;
/* function checkOptionValue() {

    if (document.feedback.email_option.value == "letter"){
          $submission_type="Letter to the Editor";
		  $submission_email="letters@star-telegram.com";
       }
	else if (document.feedback.email_option.value == "cheer"){
          $submission_type="Cheers and Jeers"; 
		  $submission_email="letters@star-telegram.com";
       } 
   else if (document.feedback.email_option.value == "test"){
          $submission_type="Test submission"; 
		  $submission_email="jasonljunk@star-telegram.com";
       }
   
} */

var http_request = false;
function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
                // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      http_request.onreadystatechange = alertContents; 
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
}

function alertContents() {
    if (http_request.readyState == 4) {
       if (http_request.status == 200) {
          // alert(http_request.responseText);
          result = http_request.responseText;
          $('#contentarea').html(result);  
document.getElementById('contentarea').innerHTML = result;
      } else {
          alert('Request status: ' + http_request.status + '. There was a problem with the request.');
      }
   }
}

function submitForm(){
	var $submission_type, $submission_email;
	$email_option = document.getElementById("email_option").value;
	$sender_name = document.getElementById("sender_name").value;
	$email_address = document.getElementById("email_address").value;
	$postal_address = document.getElementById("postal_address").value;
	$phone_number = document.getElementById("phone_number").value;
	$body_content = document.getElementById("body_content").value;
$submission_type = document.feedback.email_option.value;
	var poststr = 'submission_type=' + $submission_type + '&sender_name=' + $sender_name + '&phone_number=' + $phone_number + '&email_address=' + $email_address + '&postal_address=' + $postal_address + '&body_content=' + $body_content;
	makePOSTRequest('/cgi-bin/opinions_mailer.pl', poststr);
}
 
$(document).ready(function() {
	$("#opinions_mailer").validate({
		rules: {
			 sender_name: "required",
			 email_address: "required",
			 postal_address: "required",
 			 phone_number: {
				required: true,
				phoneUS: true
			}
		},
		messages: {
			 sender_name: "Enter your name",
			 email_address: "Please enter a valid email address",
			 postal_address: "Please enter your mailing address",
 			 phone_number: "Please enter your phone number"
		}, 
		submitHandler: function() {  
			submitForm();
			// form.submit();
		}
	});
})

function radarLoop() {
	url = '/static/accuweather/locradar_sixty_minute_loop.html';
	$('#weather_loop').load('/static/accuweather/locradar_sixty_minute_loop.html #pics', function(){
		$('#pics').cycle({
			fx: 'fade',
			speed: 10,
			timeout: 700
		});
	});
	$('#weather_loop').click(function() {
		window.open(url);
	});
}// **********************
// Name: st_google_map.js
// Function: This JavaScript file will render a Google Map on a Pubsys Story
// Author: Ara Yapejian
// Date: 1/29/08
// Modified by Jason Crane, 6-22-09, see note on mapInfoWindow, googlebar
/* @minify true */

// **********************

function miGoogleMap( myMapType, myMapControls, myMapZoom, mySetMarkerCenter, myMouseDrag) {
	// ***********
	// Here we are setting the default value for all passable arguments, these
	//   defaults will be used if no ( by 'no' we mean an empty string is passed)
	//   argument is passed during instantiation.
	// Arguments:
	//   mapType:           Should we show 'map', 'satellite', 'hybrid'
	//   mapControls:       Should we display 'zoom', 'type', 'none' or 'both'
	//   mapZoom:           What is the starting zoom level on map creation
	//   setMarkerCenter:   Should we place a Google Marker in the center of the map
	//   mapMouseDraggable: Enable or Disable mouse dragging 'true' or 'false'
		var mapType = 'map';
		var mapControls = 'both';	
		var mapZoom = 14;
		var setMarkerCenter = true;
		var mapMouseDraggable = true;
		if ( myMapType != 'null' ) 
			var mapType = myMapType;
		if ( myMapControls != 'null' )
			var mapControls = myMapControls;
		if ( myMapZoom != null )
			var mapZoom = myMapZoom;
		if ( (mySetMarkerCenter == true) || (mySetMarkerCenter == false)  )
			setMarkerCenter = mySetMarkerCenter;
		if ( (myMouseDrag == true) || (myMouseDrag == false) )
			mapMouseDraggable = myMouseDrag;
	// ***********

	// ***********
	// This is the function that actually does the displaying of the map
	// ***********
	this.initializeGoogleMap = function( location, divID ) {
		if ( GBrowserIsCompatible() ) {
			var geocoder = new GClientGeocoder();
			// added googleBar so users can search map now that it's much larger than before
			var opts = { resultList : G_GOOGLEBAR_RESULT_LIST_SUPPRESS, suppressInitialResultSelection : true, showOnLoad: true};
			var map = new GMap2(document.getElementById( divID ),{googleBarOptions: opts});
			map.enableGoogleBar();
			geocoder.getLatLng( location, function( point ) {
				if (!point) {
					// console.log("Address not Found!");
				} else {
					map.setCenter(point, mapZoom);
					// *******
					// Detect the map type user requested and set,
					//   default is G_NORMAL_MAP, so no need to detect.
					if ( mapType == 'satellite')
						map.setMapType(G_SATELLITE_MAP);
					if ( mapType == 'hybrid')
						map.setMapType(G_HYBRID_MAP);
					if ( mapType == 'map' )
						map.setMapType(G_NORMAL_MAP);
					// *******

					// *******
					// Detect what the user specified for map controls and set
					if ( mapControls != 'none') {
						if ( mapControls == 'zoom')
							map.addControl(new GSmallMapControl());
						if ( mapControls == 'type' )
			        			map.addControl(new GMapTypeControl());
						if ( mapControls == 'both' ) {
							map.addControl(new GSmallMapControl());
						        map.addControl(new GMapTypeControl()); }
					}
					// *******

					// *******
					// Enable / Disable mouse dragability of map
					if( mapMouseDraggable == true )
						map.enableDragging();
					if( mapMouseDraggable == false )
						map.disableDragging();
					// *******

					// *******
					// Detect if the user wants a marker on map center and display
					if ( setMarkerCenter == true )
						// original -- map.addOverlay( new GMarker(point) );
						var myHtml;
						function createMarker(point) {
						      var marker = new GMarker(point);
							   var myHtml = '<p><span class="bold">' + location + '</span><br /><a href="http://maps.google.com/maps?f=q&hl=en&geocode=&q=' + location + '&sspn=0.003603,0.006738&ie=UTF8&t=k&z=17&iwloc=addr&om=0&t=m">Get directions, search nearby, more</a></p>';
							 map.openInfoWindowHtml(point, myHtml);
							  GEvent.addListener(marker,"click", function() {						       
						        map.openInfoWindowHtml(point, myHtml);
						      });
						      return marker;
						  }
						map.addOverlay(createMarker(point));
				}
			});	
		}	
	}
}/*global $ */
/* vmix_stack.js
 * @author jcrane
 * @minify true
 */
var vmix_media_id, proxy, token, title, video_icon, video_link, link_close, last_modified, video_open, description, main_thumbnail, video, len, thumbnail, last_modified, video_link, video_link_close, thumbnail_open, each_open, title_open, title_close, description_open, description_close, close_div, video_content; 
function getVmixStack(tab_id, genre_ids) {
	proxy = "/cgi-bin/ajax/apiproxy_vmix.php?miaction=list&vmix=media.php?action=getMediaList&limit=3&author=Star-Telegram&genre_ids=" + genre_ids;
	$.getJSON(proxy, function(data){
		// TODO -->
		// started experimenting with doing this as a loop rather than each to improve performance
		// var l = data.media.length;
		// for (var i=0;i<l; i++) {
		$.each(data.media, function(i,video){
			token = video.token;
			title = video.title;
			description = video.description;
			len = 150;
			if (description.length > len) {
				/* Truncate the content of the description, then go back to the end of the previous word to ensure that we don't truncate in the middle of a word */
				description = description.substring(0, len);
				description = description.replace(/\w+$/, '');
				description += ' ...';
			}
			thumbnail = video.thumbnail[0].url;
			// console.log('thumbnail url is ' + thumbnail);
			last_modified = video.last_modified;
			vmix_media_id = video.id;
			link_close = '</a>';
			thumbnail_open = '<div class="thumbnail">';
			each_open = '<div class="media_stack">';	
			title_open = '<h4>';
			title_close = '</h4>';				
			video_open = '<div class="video" style="display:none">';
			description_open = '<p class="story_body">';
			description_close = '</p>';
			video_icon = '<div class="video_play_overlay hide"><img src="http://media.star-telegram.com/images/video_play_overlay.gif" width="25" /></div>';
			close_div = "</div>";
			// http://video.star-telegram.videos.vmixcore.com/vmix_hosted_apps/p/media?id=
			video_link = '<a href="http://www.star-telegram.com/videos#vmix_media_id=' + vmix_media_id + '">';
			thumbnail = '<img src="' + thumbnail + '" width="130"/>';
			// join an array rather than concatenate all those variables for faster performance
			video_content = each_open + video_icon + video_link + thumbnail + link_close + video_link + title_open + title + link_close + title_close + description_open + description + description_close + close_div;
			$(tab_id).append(video_content);
			$('.video_play_overlay').removeClass('hide');
		});
	});
}/*global $ */
/* vmix_video_detail.js
 * @author jcrane
* @minify true
*/
var vmix_media_id, error_message, detail_proxy, stack_proxy, token, title, description, main_thumbnail, video, len, thumbnail, last_modified, video_link, video_link_close, thumbnail_open, each_open, title_open, title_close, description_open, description_close, close_div, video_content;
function getVmixVideoThumb(vmix_media_id){
	detail_proxy = "/cgi-bin/ajax/apiproxy_vmix.php?miaction=single&vmix=media.php?action=getMedia&media_id=" + vmix_media_id;
	$.getJSON(detail_proxy, function(data){
		main_thumbnail = data.thumbnail[0].url;
		main_thumbnail = '<img src="' + main_thumbnail + '" width="148" />';
		$('#main_thumbnail').html(main_thumbnail);	
		$('#video_asset_thumb .video_play_overlay').removeClass('hide');
	});
}
function getVmixVideoDetail(vmix_media_id){
	error_message = "We\'re having some trouble finding that video at the moment. Sorry for the inconvenience";
	detail_proxy = "/cgi-bin/ajax/apiproxy_vmix.php?miaction=single&vmix=media.php?action=getMedia&media_id=" + vmix_media_id;
	$.getJSON(detail_proxy, function(data){
		// $.each(data.media, function(i,video){
		token = data.token;
		if (token == undefined) {
			$('#embedded_video').text(error_message);
		}
		else {
			// debug('token is ' + token);
			title = data.title;
			$('#video_title').append(title);
			description = data.description;
			$('#video_description').append(description);
			$('#video_asset_link').append(' | ' + title);
			video = '<embed id="player_swf" src="http:\/\/media.vmixcore.com\/core-flash\/UnifiedVideoPlayer\/UnifiedVideoPlayer.swf" quality="high" width="610" height="375" name="UnifiedVideoPlayer" align="middle" play="false" loop="false" quality="high" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" type="application\/x-shockwave-flash" flashvars="player_id=543fec5828893ebb9077596915defac8&auto_play=0&token=' + token + '" pluginspage="http:\/\/www.adobe.com\/go\/getflashplayer"><\/embed>';
			$('#embedded_video').html(video);
		} 
	});
}
function getVmixVideoDetailStack(){
	stack_proxy = "/cgi-bin/ajax/apiproxy_vmix.php?miaction=list&vmix=media.php?action=getMediaList&limit=4&author=Star-Telegram";
	$.getJSON(stack_proxy, function(data){
		$.each(data.media, function(i, video){
			token = video.token;
			title = video.title;
			description = video.description;
			len = 100;
			if (description.length > len) {
				/* Truncate the content of the description, then go back to the end of the previous word to ensure that we don't truncate in the middle of a word */
				description = description.substring(0, len);
				description = description.replace(/\w+$/, '');
				description += ' ...';
			}
			thumbnail = video.thumbnail[0].url;
			last_modified = video.last_modified;
			vmix_media_id = video.id;
			video_link = '<a href="http://www.star-telegram.com/videos#vmix_media_id=' + vmix_media_id + '">';
			video_link_close = '</a>';
			thumbnail_open = '<div class="thumbnail">';
			thumbnail = '<img src="' + thumbnail + '" width="130"/>';
			each_open = '<div class="media_stack">';
			title_open = '<h4>';
			title_close = '</h4>';
			description_open = '<p class="story_body">';
			description_close = '</p>';
			close_div = "</div>";
			video_content = each_open + thumbnail + video_link + title_open + title + video_link_close + title_close + description_open + description + description_close + close_div;
			$('#video_stacks').append(video_content);
			
		});
		$('#more_videos .media_stack:first').addClass('first');
			$('#more_videos .media_stack:last').addClass('last');
	});
}