/******************/
/* Menu functions */
/******************/
window.Menu = {
    delay        : 800,
    timer        : null,
    menuitem    : null,
    animationOpen: 400,
    animationClose: 300,

    /**
     * apply
     * @param    string    selector
     */
    apply: function(selector)
    {
        $(selector).hover(Menu.open, Menu.setTimer);
        $(document).click(Menu.close);
    },

    /**
     * cancelTimer
     */
    cancelTimer: function()
    {
        if (Menu.timer)
        {
            clearTimeout(Menu.timer);
            Menu.timer = null;
        }
    },

    /**
     * setTimer
     */
    setTimer: function()
    {
        Menu.timer = window.setTimeout(Menu.close, Menu.delay);
    },

    /**
     * close
     * @param    string    current_menu_id
     */
    close: function(current_menu_id)
    {
        if (Menu.menuitem)
        {
            if (Menu.menuitem.data("menuID") != current_menu_id)
            {
                // als er nog een submenu open is, dan meteen verdwijnen
                // anders uitfaden
                if ($(".open", $(Menu.menuitem).parent()).length > 0)
                {
                    $(".submenu", Menu.menuitem).css({ height: 'auto', zIndex: "" }).hide();
                }
                else
                {
                    $(".submenu", Menu.menuitem).css({ height: 'auto', zIndex: "" }).fadeOut(Menu.animationClose);
                }

                $(Menu.menuitem).removeClass("open");
            }
        }

         // ook submenu's sluiten waarvan de parent misschien niet .open heeft
        $(".submenu:visible").each( function()
        {
           if ( !$(this).parent('li').hasClass('open') )
           {
               $(this).hide();
           }
        });
    },

    /**
     * open
     */
    open: function()
    {
        current_menu = $(this);

        var al_submenu_open = ( $(".open", $(Menu.menuitem).parent()).length > 0 );

        // alle overige submenu's sluiten
        if ( al_submenu_open == true )
        {
            $(".open", $(Menu.menuitem).parent()).each( function() {
                Menu.close( $(this).data("menuID") );
            });
        }

        current_menu.addClass("open");

        // uniek menu id per submenu, dit om bij het sluiten te checken of niet de actieve wordt gesloten
        if (!current_menu.data("menuID"))
        {
            current_menu.data("menuID", (Math.random() + '' + Math.random()).replace(/\./g, ""))
        }

        Menu.cancelTimer();
        Menu.close(current_menu.data("menuID"));
        Menu.menuitem = current_menu;

        // als er al een submenu open is, niet nogmaals animeren.
        if (al_submenu_open == true)
        {
            $(".submenu", Menu.menuitem).css({ height: 'auto', zIndex: 100 }).show();
        }
        else
        {
            $(".submenu", Menu.menuitem).css({ height: 'auto', zIndex: 100 }).slideDown(Menu.animationOpen);
        }
    }

};

/**
 * maak hele blokken klikbaar
 *
 * @param    bool    trigger_click        trigger het click event ipv de url.    default is false
 * @return    jQuery
 */
$.fn.hoverClick = function(trigger_click)
{
    return this.live("mouseover mouseout", function(event)
    {
        if (event.type == 'mouseover')
        {
            if ($("a", this).length)
            {
                $(this).addClass("hover").css("cursor", "pointer");
                $(this).attr("title", $("a:first", this).attr("title"));

                $(this).one("click", function()
                {
                    if (trigger_click)
                    {
                        $("a:first", this).trigger("click");
                    }
                    else
                    {
                        window.location = $("a:first", this).attr("href");
                    }

                    return false;
                });
            }
        }
        else
        {
            $(this).removeClass("hover");
        }
    });
};

/**
 * bij hover een className toevoegen/eraf halen
 *
 * @param    string    className        default is 'hover'
 * @return    jQuery
 */
$.fn.hoverClass = function(className)
{
    if (!className)
    {
        className = 'hover';
    }

    return this.live('mouseover mouseout', function(event)
    {
        if (event.type == 'mouseover')
        {
            $(this).addClass(className);
        }
        else
        {
            $(this).removeClass(className);
        }
    });
};

/**
 * jquery.defaultvalue
 * @param    string    defaultvalue
 * @return    jQuery
 */
$.fn.defaultvalue = function(defVal)
{
    return this.each(function()
    {
        var $input = $(this);
        if ($input.val() == "" || $input.val() == defVal)
        {
            $input.addClass("defaultvalue").val(defVal);
        }

        $input
                .focus(function()
        {
            if ($input.val() == defVal)
            {
                $input.val("").removeClass("defaultvalue");
            }
        })
                .blur(function()
        {
            if ($input.val() == "")
            {
                $input.addClass("defaultvalue").val(defVal);
            }
        });
    });
};

/**
 * Maakt van een UL een horizontale scroller
 *
 * @param   jQuery object
 * @return  void
 */
$.fn.horizontalScrollable = function()
{
    //Get our elements for faster access and set overlay width
    var div = this;
    var ul = $('ul', this);

    // unordered list's left margin
    var ulPadding = 15;

    //Get menu width
    var divWidth = div.width();

    //Find last image container
    var lastLi = ul.find('li:last-child');

    //When user move mouse over menu
    div.mousemove(function(e)
    {

        //As images are loaded ul width increases,
        //so we recalculate it each time
        var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

        var left = (e.pageX - div.offset().left) * (ulWidth - divWidth) / divWidth;
        div.scrollLeft(left);
    });
};

/**
 * .corner werkt niet op een border. alleen op een achtergrond.
 * deze functie truukt om er voor te zorgen dat het toch op een border werkt.
 *
 * @author         DS
 * @copyright     a&m impact 2010
 * @requires     jquery.corner
 * @param         jQuery object, object settings [border_radius, border_width, border_color, background_color]
 * @return         jQuery
 */
$.fn.roundedBorder = function(settings)
{
    this.css({ border: 'none' }).children().wrapAll('<div class="roundedBorder"></div>');

    // padding kopieren minus de gewenste border
    var paddings = ['padding-top', 'padding-left', 'padding-right', 'padding-bottom'];
	for(var i=0; i<4; i++)
	{
		var padding = parseInt(this.css(paddings[i]).replace('px'));
   		$(".roundedBorder", this).css(paddings[i], padding - settings.border_width);
	}

    // border-width als padding op hoofd element zetten
    $(".roundedBorder", this)
		.css({ 'backgroundColor': settings.background_color })
		.corner(settings.border_width + "px")
		.corner(settings.border_radius + "px keep");
		
    this.css({	'padding': settings.border_width, 
				'backgroundColor': settings.border_color })
		.corner(settings.border_radius + "px keep");

    return this;
};

/**
 * imageCorner geeft een afbeelding ronde hoeken met behulp van 4 afbeeldingen.
 * jquery.corner kan dat niet
 *
 * @author        DS
 * @copyright     a&m impact 2010
 * @param        jQuery object
 * @return        jQuery
 */
$.fn.imageCorner = function()
{
    return this
		.css({ position: "relative" })
		.append("<span class='corner_topleft'></span><span class='corner_topright'></span><span class='corner_btmleft'></span><span class='corner_btmright'></span>");
};

/**
 * Dusseldorp Gallery
 *
 * @author DS
 */
var dusseldorp_gallery = {

    /**
     * Initialize Dusseldorp Gallery
     */
    init: function(selector_thumbs, selector_nav_prev, selector_nav_next, start_image)
    {
	    dusseldorp_gallery.selector_thumbs = selector_thumbs;
        dusseldorp_gallery.current_image = start_image;
        dusseldorp_gallery.selector_nav_prev = selector_nav_prev;
        dusseldorp_gallery.selector_nav_next = selector_nav_next;

        // thumb activeren
        dusseldorp_gallery.showImage(dusseldorp_gallery.current_image);

        $(document).keyup(function(event)
        {
            switch (event.keyCode)
            {
                case 37:
                    dusseldorp_gallery.prevImage();
                    break;

                case 39:
                    dusseldorp_gallery.nextImage();
                    break;
            }
        });

        $(selector_thumbs).click(function()
        {
            var index = $(this).parent().index();

            if ($.browser.msie)
            {
                index = index - 1;
            }

            dusseldorp_gallery.showImage(index);
            dusseldorp_gallery.handleNavigationVisibility();
        });

        $(selector_nav_prev).click(function()
        {
            if (!$(this).is(":visible"))
            {
                return false;
            }

            dusseldorp_gallery.prevImage();
        });

        $(selector_nav_next).click(function()
        {
            if (!$(this).is(":visible"))
            {
                return false;
            }

            dusseldorp_gallery.nextImage();
        });

        // eenmalig weergave van navigatie bepalen
        dusseldorp_gallery.handleNavigationVisibility();
    },

    /**
     * prevImage shows previous image, if available
     */
    prevImage: function()
    {
        if (dusseldorp_gallery.current_image < 1)
        {
            return false;
        }

        dusseldorp_gallery.showImage(dusseldorp_gallery.current_image - 1);

        // weergave van navigatie bepalen
        dusseldorp_gallery.handleNavigationVisibility();
    },

    nextImage: function()
    {
        if (dusseldorp_gallery.current_image >= ( $(dusseldorp_gallery.selector_thumbs).length - 1 ))
        {
            return false;
        }

        dusseldorp_gallery.showImage(dusseldorp_gallery.current_image + 1);

        // weergave van navigatie bepalen
        dusseldorp_gallery.handleNavigationVisibility();
    },

    /**
     * Show/hide next/previous navigation buttons
     */
    handleNavigationVisibility: function()
    {
        // weergave van vorige bepalen
        if (dusseldorp_gallery.current_image == 0)
        {
            $(dusseldorp_gallery.selector_nav_prev).fadeOut(200);
        }

        else
        {
            $(dusseldorp_gallery.selector_nav_prev).fadeIn(200);
        }

        // weergave van volgende bepalen
        if (dusseldorp_gallery.current_image >= ( $(".gallery ul li").length - 1 ))
        {
            $(dusseldorp_gallery.selector_nav_next).fadeOut(200);
        }

        else
        {
            $(dusseldorp_gallery.selector_nav_next).fadeIn(200);
        }
    },

    /**
     * Show image number 'index'
     *
     * @param index
     */
    showImage: function(index)
    {
        var $li = $(".gallery ul li:eq(" + index + ")");

        // huidige vergroting prepareren
        var $source = $(".gallery .vergroting img");
        $source.attr({ id: "source" }).css({ zIndex: 10 });

        if (player != null)
        {
            try
            {
                player.sendEvent('STOP');
            }
            catch(ex)
            {
            }
        }

        if ($('img', $li).hasClass('video'))
        {
            // delete source image, create mediaspace element
            $("<div id='videocontainer'></div>").hide().css({zIndex: 20, position:'relative'}).insertAfter($source).fadeIn(500, function()
            {
                $source.hide();
            });

            var so = new SWFObject(config.submap + '/fla/player-licensed.swf', 'mpl', '580', '410', '9');
            so.addParam('allowfullscreen', 'true');
            so.addParam('allowscriptaccess', 'always');
            so.addParam('wmode', 'opaque');
            so.addParam('menu', 'false');
            so.addVariable('file', $('img', $li).attr('rel'));
            so.addVariable('autostart','true');
            so.write('videocontainer');
        }
        else
        {
            // huidige vergroting kopieren
            var $clone = $(".gallery .vergroting img#source:eq(0)").clone();
            $clone.attr({ id: "clone", src: $('img', $li).attr('rel') }).css({zIndex: 20});

            if ($("#videocontainer").length)
            {
                $clone.css({ zIndex: $("#videocontainer").css('zIndex') + 1 });
                $("#videocontainer").fadeOut(500);

                $clone.hide().insertAfter($source).fadeIn(500, function()
                {
                    // als er een videoplayer in staat, die altijd weggooien
                    if ($("#videocontainer").length)
                    {
                        $("#videocontainer").remove();
                    }

                    $clone.css({ zIndex:20 });

                    $source.remove();
                });
            }
            else
            {

                $clone.hide().appendTo($source.parent()).fadeIn(500, function()
                {
                    // als er een videoplayer in staat, die altijd weggooien
                    if ($("#videocontainer").length)
                    {
                        $("#videocontainer").remove();
                    }

                    $source.remove();
                });

            }
        }

        // thumb activeren
        dusseldorp_gallery.activateThumb(index);

        dusseldorp_gallery.current_image = index;
    },

    /**
     * Thumbnail activator
     *
     * @param index
     */
    activateThumb: function(index)
    {
        $(".gallery ul li").removeClass('actief');

        var $li = $(".gallery ul li:eq(" + index + ")");
        $li.addClass('actief');
    }

};

/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.09 (11-MAR-2010)
 * Requires jQuery v1.3.2 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Authors: Dave Methvin and Mike Alsup
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round).
 *  corners: one or more of: top, bottom, tr, tl, br, or bl.  (default is all corners)
 *  width:   width of the effect; in the case of rounded corners this is the radius.
 *           specify this value using the px suffix such as 10px (yes, it must be pixels).
 */
;
(function($)
{

    var style = document.createElement('div').style;
    var moz = style['MozBorderRadius'] !== undefined;
    var webkit = style['WebkitBorderRadius'] !== undefined;
    var radius = style['borderRadius'] !== undefined || style['BorderRadius'] !== undefined;
    var mode = document.documentMode || 0;
    var noBottomFold = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);

    var expr = $.browser.msie && (function()
    {
        var div = document.createElement('div');
        try
        {
            div.style.setExpression('width', '0+0');
            div.style.removeExpression('width');
        }
        catch(e)
        {
            return false;
        }
        return true;
    })();

    function sz(el, p)
    {
        return parseInt($.css(el, p)) || 0;
    }

    ;
    function hex2(s)
    {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0' + s : s;
    }

    ;
    function gpc(node)
    {
        while (node)
        {
            var v = $.css(node, 'backgroundColor');
            if (v && v != 'transparent' && v != 'rgba(0, 0, 0, 0)')
            {
                if (v.indexOf('rgb') >= 0)
                {
                    var rgb = v.match(/\d+/g);
                    return '#' + hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
                }
                return v;
            }
            node = node.parentNode; // keep walking if transparent
        }
        return '#ffffff';
    }

    ;

    function getWidth(fx, i, width)
    {
        switch (fx)
        {
            case 'round':  return Math.round(width * (1 - Math.cos(Math.asin(i / width))));
            case 'cool':   return Math.round(width * (1 + Math.cos(Math.asin(i / width))));
            case 'sharp':  return Math.round(width * (1 - Math.cos(Math.acos(i / width))));
            case 'bite':   return Math.round(width * (Math.cos(Math.asin((width - i - 1) / width))));
            case 'slide':  return Math.round(width * (Math.atan2(i, width / i)));
            case 'jut':    return Math.round(width * (Math.atan2(width, (width - i - 1))));
            case 'curl':   return Math.round(width * (Math.atan(i)));
            case 'tear':   return Math.round(width * (Math.cos(i)));
            case 'wicked': return Math.round(width * (Math.tan(i)));
            case 'long':   return Math.round(width * (Math.sqrt(i)));
            case 'sculpt': return Math.round(width * (Math.log((width - i - 1), width)));
            case 'dogfold':
            case 'dog':    return (i & 1) ? (i + 1) : width;
            case 'dog2':   return (i & 2) ? (i + 1) : width;
            case 'dog3':   return (i & 3) ? (i + 1) : width;
            case 'fray':   return (i % 2) * width;
            case 'notch':  return width;
            case 'bevelfold':
            case 'bevel':  return i + 1;
        }
    }

    ;

    $.fn.corner = function(options)
    {
        // in 1.3+ we can fix mistakes with the ready state
        if (this.length == 0)
        {
            if (!$.isReady && this.selector)
            {
                var s = this.selector, c = this.context;
                $(function()
                {
                    $(s, c).corner(options);
                });
            }
            return this;
        }

        return this.each(function(index)
        {
            var $this = $(this);
            // meta values override options
            var o = [$this.attr($.fn.corner.defaults.metaAttr) || '', options || ''].join(' ').toLowerCase();
            var keep = /keep/.test(o);                       // keep borders?
            var cc = ((o.match(/cc:(#[0-9a-f]+)/) || [])[1]);  // corner color
            var sc = ((o.match(/sc:(#[0-9a-f]+)/) || [])[1]);  // strip color
            var width = parseInt((o.match(/(\d+)px/) || [])[1]) || 10; // corner width
            var re = /round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;
            var fx = ((o.match(re) || ['round'])[0]);
            var fold = /dogfold|bevelfold/.test(o);
            var edges = { T:0, B:1 };
            var opts = {
                TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o),
                BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o)
            };
            if (!opts.TL && !opts.TR && !opts.BL && !opts.BR)
            {
                opts = { TL:1, TR:1, BL:1, BR:1 };
            }

            // support native rounding
            if ($.fn.corner.defaults.useNative && fx == 'round' && (radius || moz || webkit) && !cc && !sc)
            {
                if (opts.TL)
                {
                    $this.css(radius ? 'border-top-left-radius' : moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
                }
                if (opts.TR)
                {
                    $this.css(radius ? 'border-top-right-radius' : moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
                }
                if (opts.BL)
                {
                    $this.css(radius ? 'border-bottom-left-radius' : moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
                }
                if (opts.BR)
                {
                    $this.css(radius ? 'border-bottom-right-radius' : moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
                }
                return;
            }

            var strip = document.createElement('div');
            $(strip).css({
                overflow: 'hidden',
                height: '1px',
                minHeight: '1px',
                fontSize: '1px',
                backgroundColor: sc || 'transparent',
                borderStyle: 'solid'
            });

            var pad = {
                T: parseInt($.css(this, 'paddingTop')) || 0,     R: parseInt($.css(this, 'paddingRight')) || 0,
                B: parseInt($.css(this, 'paddingBottom')) || 0,  L: parseInt($.css(this, 'paddingLeft')) || 0
            };

            if (typeof this.style.zoom != undefined)
            {
                this.style.zoom = 1;
            } // force 'hasLayout' in IE
            if (!keep)
            {
                this.style.border = 'none';
            }
            strip.style.borderColor = cc || gpc(this.parentNode);
            var cssHeight = $(this).outerHeight();

            for (var j in edges)
            {
                var bot = edges[j];
                // only add stips if needed
                if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR)))
                {
                    strip.style.borderStyle = 'none ' + (opts[j + 'R'] ? 'solid' : 'none') + ' none ' + (opts[j + 'L'] ? 'solid' : 'none');
                    var d = document.createElement('div');
                    $(d).addClass('jquery-corner');
                    var ds = d.style;

                    bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                    if (bot && cssHeight != 'auto')
                    {
                        if ($.css(this, 'position') == 'static')
                        {
                            this.style.position = 'relative';
                        }
                        ds.position = 'absolute';
                        ds.bottom = ds.left = ds.padding = ds.margin = '0';
                        if (expr)
                        {
                            ds.setExpression('width', 'this.parentNode.offsetWidth');
                        }
                        else
                        {
                            ds.width = '100%';
                        }
                    }
                    else
                    {
                        if (!bot && $.browser.msie)
                        {
                            if ($.css(this, 'position') == 'static')
                            {
                                this.style.position = 'relative';
                            }
                            ds.position = 'absolute';
                            ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';

                            // fix ie6 problem when blocked element has a border width
                            if (expr)
                            {
                                var bw = sz(this, 'borderLeftWidth') + sz(this, 'borderRightWidth');
                                ds.setExpression('width', 'this.parentNode.offsetWidth - ' + bw + '+ "px"');
                            }
                            else
                            {
                                ds.width = '100%';
                            }
                        }
                        else
                        {
                            ds.position = 'relative';
                            ds.margin = !bot ? '-' + pad.T + 'px -' + pad.R + 'px ' + (pad.T - width) + 'px -' + pad.L + 'px' :
                                    (pad.B - width) + 'px -' + pad.R + 'px -' + pad.B + 'px -' + pad.L + 'px';
                        }
                    }

                    for (var i = 0; i < width; i++)
                    {
                        var w = Math.max(0, getWidth(fx, i, width));
                        var e = strip.cloneNode(false);
                        e.style.borderWidth = '0 ' + (opts[j + 'R'] ? w : 0) + 'px 0 ' + (opts[j + 'L'] ? w : 0) + 'px';
                        bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                    }

                    if (fold && $.support.boxModel)
                    {
                        if (bot && noBottomFold)
                        {
                            continue;
                        }
                        for (var c in opts)
                        {
                            if (!opts[c])
                            {
                                continue;
                            }
                            if (bot && (c == 'TL' || c == 'TR'))
                            {
                                continue;
                            }
                            if (!bot && (c == 'BL' || c == 'BR'))
                            {
                                continue;
                            }

                            var common = { position: 'absolute', border: 'none', margin: 0, padding: 0, overflow: 'hidden', backgroundColor: strip.style.borderColor };
                            var $horz = $('<div/>').css(common).css({ width: width + 'px', height: '1px' });
                            switch (c)
                            {
                                case 'TL': $horz.css({ bottom: 0, left: 0 }); break;
                                case 'TR': $horz.css({ bottom: 0, right: 0 }); break;
                                case 'BL': $horz.css({ top: 0, left: 0 }); break;
                                case 'BR': $horz.css({ top: 0, right: 0 }); break;
                            }
                            d.appendChild($horz[0]);

                            var $vert = $('<div/>').css(common).css({ top: 0, bottom: 0, width: '1px', height: width + 'px' });
                            switch (c)
                            {
                                case 'TL': $vert.css({ left: width }); break;
                                case 'TR': $vert.css({ right: width }); break;
                                case 'BL': $vert.css({ left: width }); break;
                                case 'BR': $vert.css({ right: width }); break;
                            }
                            d.appendChild($vert[0]);
                        }
                    }
                }
            }
        });
    };

    $.fn.uncorner = function()
    {
        if (radius || moz || webkit)
        {
            this.css(radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
        }
        $('div.jquery-corner', this).remove();
        return this;
    };

    // expose options
    $.fn.corner.defaults = {
        useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
        metaAttr:  'data-corner' // name of meta attribute to use for options
    };

})(jQuery);

/**
 * jquery.cycle.lite.1.0.min.js
 */
(function(D)
{
    var A = "Lite-1.0";
    D.fn.cycle = function(E)
    {
        return this.each(function()
        {
            E = E || {};
            if (this.cycleTimeout)
            {
                clearTimeout(this.cycleTimeout)
            }
            this.cycleTimeout = 0;
            this.cyclePause = 0;
            var I = D(this);
            var J = E.slideExpr ? D(E.slideExpr, this) : I.children();
            var G = J.get();
            if (G.length < 2)
            {
                if (window.console && window.console.log)
                {
                    window.console.log("terminating; too few slides: " + G.length)
                }
                return
            }
            var H = D.extend({}, D.fn.cycle.defaults, E || {}, D.metadata ? I.metadata() : D.meta ? I.data() : {});
            H.before = H.before ? [H.before] : [];
            H.after = H.after ? [H.after] : [];
            H.after.unshift(function()
            {
                H.busy = 0
            });
            var F = this.className;
            H.width = parseInt((F.match(/w:(\d+)/) || [])[1]) || H.width;
            H.height = parseInt((F.match(/h:(\d+)/) || [])[1]) || H.height;
            H.timeout = parseInt((F.match(/t:(\d+)/) || [])[1]) || H.timeout;
            if (I.css("position") == "static")
            {
                I.css("position", "relative")
            }
            if (H.width)
            {
                I.width(H.width)
            }
            if (H.height && H.height != "auto")
            {
                I.height(H.height)
            }
            var K = 0;
            J.css({position:"absolute",top:0,left:0}).hide().each(function(M)
            {
                D(this).css("z-index", G.length - M)
            });
            D(G[K]).css("opacity", 1).show();
            if (D.browser.msie)
            {
                G[K].style.removeAttribute("filter")
            }
            if (H.fit && H.width)
            {
                J.width(H.width)
            }
            if (H.fit && H.height && H.height != "auto")
            {
                J.height(H.height)
            }
            if (H.pause)
            {
                I.hover(function()
                {
                    this.cyclePause = 1
                }, function()
                {
                    this.cyclePause = 0
                })
            }
            D.fn.cycle.transitions.fade(I, J, H);
            J.each(function()
            {
                var M = D(this);
                this.cycleH = (H.fit && H.height) ? H.height : M.height();
                this.cycleW = (H.fit && H.width) ? H.width : M.width()
            });
            J.not(":eq(" + K + ")").css({opacity:0});
            if (H.cssFirst)
            {
                D(J[K]).css(H.cssFirst)
            }
            if (H.timeout)
            {
                if (H.speed.constructor == String)
                {
                    H.speed = {slow:600,fast:200}[H.speed] || 400
                }
                if (!H.sync)
                {
                    H.speed = H.speed / 2
                }
                while ((H.timeout - H.speed) < 250)
                {
                    H.timeout += H.speed
                }
            }
            H.speedIn = H.speed;
            H.speedOut = H.speed;
            H.slideCount = G.length;
            H.currSlide = K;
            H.nextSlide = 1;
            var L = J[K];
            if (H.before.length)
            {
                H.before[0].apply(L, [L,L,H,true])
            }
            if (H.after.length > 1)
            {
                H.after[1].apply(L, [L,L,H,true])
            }
            if (H.click && !H.next)
            {
                H.next = H.click
            }
            if (H.next)
            {
                D(H.next).bind("click", function()
                {
                    return C(G, H, H.rev ? -1 : 1)
                })
            }
            if (H.prev)
            {
                D(H.prev).bind("click", function()
                {
                    return C(G, H, H.rev ? 1 : -1)
                })
            }
            if (H.timeout)
            {
                this.cycleTimeout = setTimeout(function()
                {
                    B(G, H, 0, !H.rev)
                }, H.timeout + (H.delay || 0))
            }
        })
    };
    function B(J, E, I, K)
    {
        if (E.busy)
        {
            return
        }
        var H = J[0].parentNode,M = J[E.currSlide],L = J[E.nextSlide];
        if (H.cycleTimeout === 0 && !I)
        {
            return
        }
        if (I || !H.cyclePause)
        {
            if (E.before.length)
            {
                D.each(E.before, function(N, O)
                {
                    O.apply(L, [M,L,E,K])
                })
            }
            var F = function()
            {
                if (D.browser.msie)
                {
                    this.style.removeAttribute("filter")
                }
                D.each(E.after, function(N, O)
                {
                    O.apply(L, [M,L,E,K])
                })
            };
            if (E.nextSlide != E.currSlide)
            {
                E.busy = 1;
                D.fn.cycle.custom(M, L, E, F)
            }
            var G = (E.nextSlide + 1) == J.length;
            E.nextSlide = G ? 0 : E.nextSlide + 1;
            E.currSlide = G ? J.length - 1 : E.nextSlide - 1
        }
        if (E.timeout)
        {
            H.cycleTimeout = setTimeout(function()
            {
                B(J, E, 0, !E.rev)
            }, E.timeout)
        }
    }

    function C(E, F, I)
    {
        var H = E[0].parentNode,G = H.cycleTimeout;
        if (G)
        {
            clearTimeout(G);
            H.cycleTimeout = 0
        }
        F.nextSlide = F.currSlide + I;
        if (F.nextSlide < 0)
        {
            F.nextSlide = E.length - 1
        }
        else
        {
            if (F.nextSlide >= E.length)
            {
                F.nextSlide = 0
            }
        }
        B(E, F, 1, I >= 0);
        return false
    }

    D.fn.cycle.custom = function(K, H, I, E)
    {
        var J = D(K),G = D(H);
        G.css({opacity:0});
        var F = function()
        {
            G.animate({opacity:1}, I.speedIn, I.easeIn, E)
        };
        J.animate({opacity:0}, I.speedOut, I.easeOut, function()
        {
            J.css({display:"none"});
            if (!I.sync)
            {
                F()
            }
        });
        if (I.sync)
        {
            F()
        }
    };
    D.fn.cycle.transitions = {fade:function(F, G, E)
    {
        G.not(":eq(0)").css("opacity", 0);
        E.before.push(function()
        {
            D(this).show()
        })
    }};
    D.fn.cycle.ver = function()
    {
        return A
    };
    D.fn.cycle.defaults = {timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}
})(jQuery)
