/*!
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008-2011 M. Alsup
 * Version: 1.3.1 (07-OCT-2011)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.3.2 or later
 */
;(function($) {

var ver = 'Lite-1.3';

$.fn.cycle = function(options) {
    return this.each(function() {
        options = options || {};
        
        if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
        this.cycleTimeout = 0;
        this.cyclePause = 0;
        
        var $cont = $(this);
        var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
        var els = $slides.get();
        if (els.length < 2) {
            window.console && console.log('terminating; too few slides: ' + els.length);
            return; // don't bother
        }

        // support metadata plugin (v1.0 and v2.0)
        var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
		var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
		if (meta)
			opts = $.extend(opts, meta);
            
        opts.before = opts.before ? [opts.before] : [];
        opts.after = opts.after ? [opts.after] : [];
        opts.after.unshift(function(){ opts.busy=0; });
            
        // allow shorthand overrides of width, height and timeout
        var cls = this.className;
        opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
        opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
        opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1]) || opts.timeout;

        if ($cont.css('position') == 'static') 
            $cont.css('position', 'relative');
        if (opts.width) 
            $cont.width(opts.width);
        if (opts.height && opts.height != 'auto') 
            $cont.height(opts.height);

        var first = 0;
        $slides.css({position: 'absolute', top:0, left:0}).each(function(i) { 
            $(this).css('z-index', els.length-i) 
        });
        
        $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
        if ($.browser.msie) els[first].style.removeAttribute('filter');

        if (opts.fit && opts.width) 
            $slides.width(opts.width);
        if (opts.fit && opts.height && opts.height != 'auto') 
            $slides.height(opts.height);
        if (opts.pause) 
            $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});

        var txFn = $.fn.cycle.transitions[opts.fx];
		txFn && txFn($cont, $slides, opts);
        
        $slides.each(function() {
            var $el = $(this);
            this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
            this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
        });

        if (opts.cssFirst)
            $($slides[first]).css(opts.cssFirst);

        if (opts.timeout) {
            // ensure that timeout and speed settings are sane
            if (opts.speed.constructor == String)
                opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
            if (!opts.sync)
                opts.speed = opts.speed / 2;
            while((opts.timeout - opts.speed) < 250)
                opts.timeout += opts.speed;
        }
        opts.speedIn = opts.speed;
        opts.speedOut = opts.speed;

 		opts.slideCount = els.length;
        opts.currSlide = first;
        opts.nextSlide = 1;

        // fire artificial events
        var e0 = $slides[first];
        if (opts.before.length)
            opts.before[0].apply(e0, [e0, e0, opts, true]);
        if (opts.after.length > 1)
            opts.after[1].apply(e0, [e0, e0, opts, true]);
        
        if (opts.click && !opts.next)
            opts.next = opts.click;
        if (opts.next)
            $(opts.next).bind('click', function(){return advance(els,opts,opts.rev?-1:1)});
        if (opts.prev)
            $(opts.prev).bind('click', function(){return advance(els,opts,opts.rev?1:-1)});

        if (opts.timeout)
            this.cycleTimeout = setTimeout(function() {
                go(els,opts,0,!opts.rev)
            }, opts.timeout + (opts.delay||0));
    });
};

function go(els, opts, manual, fwd) {
    if (opts.busy) return;
    var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
    if (p.cycleTimeout === 0 && !manual) 
        return;

    if (manual || !p.cyclePause) {
        if (opts.before.length)
            $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
        var after = function() {
            if ($.browser.msie)
                this.style.removeAttribute('filter');
            $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
            queueNext();
        };

        if (opts.nextSlide != opts.currSlide) {
            opts.busy = 1;
            $.fn.cycle.custom(curr, next, opts, after);
        }
        var roll = (opts.nextSlide + 1) == els.length;
        opts.nextSlide = roll ? 0 : opts.nextSlide+1;
        opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
    }
    
    function queueNext() {
        if (opts.timeout)
            p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev) }, opts.timeout);
    }
};

// advance slide forward or back
function advance(els, opts, val) {
    var p = els[0].parentNode, timeout = p.cycleTimeout;
    if (timeout) {
        clearTimeout(timeout);
        p.cycleTimeout = 0;
    }
    opts.nextSlide = opts.currSlide + val;
    if (opts.nextSlide < 0) {
        opts.nextSlide = els.length - 1;
    }
    else if (opts.nextSlide >= els.length) {
        opts.nextSlide = 0;
    }
    go(els, opts, 1, val>=0);
    return false;
};

$.fn.cycle.custom = function(curr, next, opts, cb) {
    var $l = $(curr), $n = $(next);
    $n.css(opts.cssBefore);
    var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb)};
    $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
        $l.css(opts.cssAfter);
        if (!opts.sync) fn();
    });
    if (opts.sync) fn();
};

$.fn.cycle.transitions = {
    fade: function($cont, $slides, opts) {
		$slides.not(':eq(0)').hide();
		opts.cssBefore = { opacity: 0, display: 'block' };
		opts.cssAfter  = { display: 'none' };
		opts.animOut = { opacity: 0 };
		opts.animIn = { opacity: 1 };
    },
    fadeout: function($cont, $slides, opts) {
		opts.before.push(function(curr,next,opts,fwd) {
			$(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
			$(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
		});
		$slides.not(':eq(0)').hide();
		opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
		opts.cssAfter  = { display: 'none', zIndex: 0 };
		opts.animOut = { opacity: 0 };
    }
};

$.fn.cycle.ver = function() { return ver; };

// @see: http://malsup.com/jquery/cycle/lite/
$.fn.cycle.defaults = {
	animIn:        {},
	animOut:       {},
	fx:           'fade',
    after:         null, 
    before:        null, 
	cssBefore:     {},
	cssAfter:      {},
    delay:         0,    
    fit:           0,    
    height:       'auto',
	metaAttr:     'cycle',
    next:          null, 
    pause:         0,    
    prev:          null, 
    speed:         1000, 
    slideExpr:     null,
    sync:          1,    
    timeout:       4000 
};

})(jQuery);
/*
 * 	 styleSelect - apply style to a select box
 *   (http://www.8stream.com/blog/entry/styleselect)
 *
 * 	 Copyright (c) 2010 Siim Sindonen, <siim@8stream.com>
 *   Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 * 
 *   Requires jQuery version: >= 1.3.2
 * 	 Version: 2.0.0 | 15.10.2010
 */

(function(a){function q(m,n){a("."+m).each(function(){var b=a(this).find(".styleSelect_item");a(this).find("span").each(function(){var k=a(this).attr("class");if(k=="passiveSelect"||k=="activeSelect")a(this).remove()});var i=a(this).find(".selected");a("<span></span>").text(i.text()).attr("id",i.parent().attr("id")).addClass("passiveSelect").appendTo(a(this));n===0&&a(this).css({width:b.width()})});a("."+m+" span").each(function(){if(a(this).attr("id")){a(this).removeClass();a(this).addClass("activeSelect")}})} a.fn.styleSelect=function(m){var n=1,b=a.extend({},a.fn.styleSelect.defaults,m);a("input,select,textarea,button").each(function(){var i=a(this);if(!i.attr("tabindex")){i.attr("tabindex",n);n++}});return this.each(function(){mainSelect=a(this);var i=mainSelect.attr("name"),k=i.replace(/\[.*\]/,""),l=mainSelect.attr("tabindex"),e="selectbox_"+k+(new Date).getTime();mainSelect.hide();k=a('<div tabindex="'+l+'"></div>').css({position:"relative","z-index":parseInt(1E3-l)}).addClass(b.styleClass).attr("id", e).insertBefore(mainSelect);a('<div class="styleSelect_item"></div>').appendTo(k).css({position:"absolute","z-index":""+parseInt(500-l)+"",top:b.optionsTop,left:b.optionsLeft}).hide();a('<div class="styleSelect_item_start"></div><div class="styleSelect_item_content"></div><div class="styleSelect_item_end">').appendTo(a("#"+e+" .styleSelect_item"));l=a("<ul></ul>").appendTo(a("#"+e+" .styleSelect_item_content"));var f="";mainSelect.find("option").each(function(){f+='<li id="'+a(this).val()+'"';if(a(this).attr("class"))f+= ' class="'+a(this).attr("class")+'" ';f+=">";f+='<span style="display: block;"';if(a(this).attr("selected"))f+=' class="selected" ';f+=">";f+=a(this).text();f+="</span>";f+="</li>"});l.append(f);q(b.styleClass,b.optionsWidth);a("#"+e).click(function(c){a(c.target).parents(".jspVerticalBar").attr("class")||a(this).find(".styleSelect_item").slideToggle(b.speed,function(){if(a(this).css("display")!="none"&&b.jScrollPane==1){a(this).find(".styleSelect_item_content").jScrollPane(b.jScrollPaneOptions); var d=a(".styleSelect_item_content").data("jsp"),g=a(".styleSelect_item_content").height(),h=a(".styleSelect_item_content .selected").position();if(h.top&&d!=null&&h.top>g)d.scrollTo(0,parseInt(h.top-g/2));else if(h.top&&h.top<g)d.scrollTo(0,parseInt(h.top-g));else d!=null&&d.scrollTo(0,0)}})});a("#"+e+" li").click(function(){o(a(this))});a("#"+e).keydown(function(c){var d=a(this).find(".selected").parent();if(b.jScrollPane==1)var g=a(".styleSelect_item_content").data("jsp"),h=a(".styleSelect_item_content").height(); if(c.keyCode==40||c.keyCode==39){var j=d.next();if(j.index()>0&&g!=null&&a("#"+e).find(".styleSelect_item").css("display")!="none"){var p=j.position();p.top!=null&&p.top>h&&g.scrollTo(0,parseInt(p.top))}o(j)}if(c.keyCode==37||c.keyCode==38){d=d.prev();j=d.index();if(g!=null&&b.jScrollPane==1&&a("#"+e).find(".styleSelect_item").css("display")!="none")if(j>0){j=d.position();j.top-h<h&&g.scrollTo(0,parseInt(j.top))}else g.scrollTo(0,0);o(d)}if(c.keyCode==13||c.keyCode==0||c.keyCode==32){a(this).find(".styleSelect_item").slideToggle(b.speed, function(){!a(c.target).find(".jspContainer").attr("class")&&b.jScrollPane==1&&a(this).find(".styleSelect_item_content").jScrollPane(b.jScrollPaneOptions)});return false}c.keyCode==9&&a(this).find(".styleSelect_item").hide(b.speed)});var o=function(c){c.siblings().find("span").removeClass("selected");c.find("span").addClass("selected");c=c.attr("id");var d=a('select[name="'+i+'"]');d.siblings().selected=false;d.find('option[value="'+c+'"]').attr("selected","selected");d.trigger(b.selectTrigger);q(b.styleClass, b.optionsWidth)};a("#"+e).click(function(c){c.stopPropagation()});a(document).click(function(){a("#"+e+" .styleSelect_item").hide()})})};a.fn.styleSelect.defaults={optionsTop:"26px",optionsLeft:"0px",optionsWidth:0,styleClass:"selectMenu",speed:0,selectTrigger:"change",jScrollPane:0,jScrollPaneOptions:""}})(jQuery);
