/**
 * NON-JQUERY
 * 
 */
 
 
/** Add-this bookmark button customisations*/ 
var addthis_config = {
    services_exclude: 'facebook, myspace, print, favorites, friendster'
}

 
/**
 * JQUERY :: Document ready
 * 
 */
$(function() {
    	$("a.pdf-download-link").wrapInner("<span></span>");

    if(jQuery().colorbox){
        $("a[rel='lightbox']").colorbox();
        $("a[rel='mapbox']").colorbox({
            width:"80%", 
            height:"80%", 
            iframe:true
        });
        $("a[class='gmaplink']").colorbox({
            width:"80%", 
            height:"80%", 
            iframe:true
        });
    }
	
    $(".stripe tr:even").addClass("alt");
	
	var IE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false;
if(IE6) {
	} else {
	$("#lab2011").removeClass("hidden");
}

	
    $("#headerinner input[name='q']").searchText({
        searchValue: 'Search CSR'
    });
	
    $('#headerinner input.support').searchText({
        searchValue: 'Search CSR Support'
    });

    $(".sidebartooltip a[title]").tooltip({
        opacity: 0.9, 
        offset: [60,0], 
        effect: 'slide', 
        tip: '#tooltip'
    });
	
	 $(".platformtooltip area[title]").tooltip({
        opacity: 0.9, 
        offset: [90,0], 
        effect: 'slide', 
        tip: '#tooltip'
    });
	
	
    $('#main-home-left').innerfade({ animationtype: 'fade', speed: 750, timeout: 8500, type: 'sequence', containerheight: '185px' }); 
	setTimeout(function() { 
	$('#main-home-right').innerfade({ animationtype: 'fade', speed: 750, timeout: 8500, type: 'sequence', containerheight: '185px' }); 
	}, 4000);

    
	
	
	if(jQuery().tabs){
        $("ul#tabnav").tabs("div#homebannerinner > img", { 
            /* tabs configuration goes here */ 
            rotate: true
        }).slideshow({
            autoplay: true,
            interval: '7000'
        });
    }
	
    $('.listhide span').toggle(expand_group, collapse_group);
	
    $('a.link-external').click(function(){
        var selection = confirm('CSR are not responsible for the content of external resources.\n\nAre you sure you wish to leave csr.com?');
        if(selection == true){
            return true;
        }else{
            return false;
        }
    });

/* $("a[href^='http:']:not([href*='csr.freshleafmedia.co.uk'][target='_blank'])").live('click', function(){
        $(this).attr('target','_blank');
    });*/

	
//$("ul.newstabs").tabs("div.newscontent > div");
});

// ------------------------------------------------------------------------

/**
 * Expand Group
 *
 * Un-hides class .hidden
 *
 */
function expand_group(){
    $('.hidden').fadeIn('fast');
    return false;
}
// ------------------------------------------------------------------------

/**
 * Collapse Group
 *
 * re-hides class .hidden
 *
 */
function collapse_group(){
		
    $('.hidden').fadeOut('fast');
    return false;
}
// ------------------------------------------------------------------------




/**
 * Search field default text plugin
 * 
 */
(function($) {

    $.fn.searchText = function(options) {

        var defaults = {
            searchValue : 'Search'
        };

        return this.each(function() {

            var opts = $.extend(defaults, options), $searchField = $(this);

            $searchField.val(opts.searchValue);

            $searchField.click(function() {
                if ($searchField.val() == opts.searchValue) {
                    $searchField.val('');
                }
            });

            $searchField.blur(function() {
                if ($searchField.val() == '') {
                    $searchField.val(opts.searchValue);
                }
            });


        });
    };

})(jQuery);
// ------------------------------------------------------------------------

/**
 * Suckerfish Hover for IE reverse compatibility
 * 
 */
sfHover = function() {
    var sfEls = document.getElementById("navinner").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
// ------------------------------------------------------------------------



/**
 * tools.tooltip 1.1.3 - Tooltips done right.
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tooltip.html
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : November 2008
 * Date: ${date}
 * Revision: ${revision} 
 */
(function($) { 

    var instances = [];
	
    // static constructs
    $.tools = $.tools || {};
	
    $.tools.tooltip = {
        version: '1.1.3',
		
        conf: { 
			
            // default effect variables
            effect: 'toggle',			
            fadeOutSpeed: "fast",
            tip: null,
			
            predelay: 0,
            delay: 30,
            opacity: 1,			
            lazy: undefined,
			
            // 'top', 'bottom', 'right', 'left', 'center'
            position: ['top', 'center'], 
            offset: [0, 0],			
            cancelDefault: true,
            relative: false,
            oneInstance: true,
			
			
            // type to event mapping 
            events: {
                def: 			"mouseover,mouseout",
                input: 		"focus,blur",
                widget:		"focus mouseover,blur mouseout",
                tooltip:		"mouseover,mouseout"
            },			
			
            api: false
        },
		
        addEffect: function(name, loadFn, hideFn) {
            effects[name] = [loadFn, hideFn];	
        } 
    };
	
	
    var effects = { 
        toggle: [ 
        function(done) { 
            var conf = this.getConf(), tip = this.getTip(), o = conf.opacity;
            if (o < 1) {
                tip.css({
                    opacity: o
                });
            }
            tip.show();
            done.call();
        },
			
        function(done) { 
            this.getTip().hide();
            done.call();
        } 
        ],
		
        fade: [
        function(done) {
            this.getTip().fadeIn(this.getConf().fadeInSpeed, done);
        },  
        function(done) {
            this.getTip().fadeOut(this.getConf().fadeOutSpeed, done);
        } 
        ]		
    };   

    function Tooltip(trigger, conf) {

        var self = this, $self = $(this);
		
        trigger.data("tooltip", self);
		
        // find the tip
        var tip = trigger.next();
		
        if (conf.tip) {
			
            tip = $(conf.tip);
			
            // multiple tip elements
            if (tip.length > 1) {
				
                // find sibling
                tip = trigger.nextAll(conf.tip).eq(0);	
				
                // find sibling from the parent element
                if (!tip.length) {
                    tip = trigger.parent().nextAll(conf.tip).eq(0);
                }
            } 
        } 				
		
        /* calculate tip position relative to the trigger */  	
        function getPosition(e) {	
			
            // get origin top/left position 
            var top = conf.relative ? trigger.position().top : trigger.offset().top, 
            left = conf.relative ? trigger.position().left : trigger.offset().left,
            pos = conf.position[0];

            top  -= tip.outerHeight() - conf.offset[0];
            left += trigger.outerWidth() + conf.offset[1];
			
            // adjust Y		
            var height = tip.outerHeight() + trigger.outerHeight();
            if (pos == 'center') 	{
                top += height / 2;
            }
            if (pos == 'bottom') 	{
                top += height;
            }
			
            // adjust X
            pos = conf.position[1]; 	
            var width = tip.outerWidth() + trigger.outerWidth();
            if (pos == 'center') 	{
                left -= width / 2;
            }
            if (pos == 'left')   	{
                left -= width;
            }	 
			
            return {
                top: top, 
                left: left
            };
        }		

		
        // event management
        var isInput = trigger.is(":input"), 
        isWidget = isInput && trigger.is(":checkbox, :radio, select, :button"),			
        type = trigger.attr("type"),
        evt = conf.events[type] || conf.events[isInput ? (isWidget ? 'widget' : 'input') : 'def']; 
		
        evt = evt.split(/,\s*/); 
        if (evt.length != 2) {
            throw "Tooltip: bad events configuration for " + type;
        }
				
        trigger.bind(evt[0], function(e) {
			
            // close all instances
            if (conf.oneInstance) {
                $.each(instances, function()  {
                    this.hide();		
                });
            }
				
            // see if the tip was launched by this trigger
            var t = tip.data("trigger");			
            if (t && t[0] != this) {
                tip.hide().stop(true, true);
            }			
			
            e.target = this;
            self.show(e); 
			
            // tooltip close events
            evt = conf.events.tooltip.split(/,\s*/);
            tip.bind(evt[0], function() {
                self.show(e);
            });
            if (evt[1]) {
                tip.bind(evt[1], function() {
                    self.hide(e);
                });
            }
			
        });
		
        trigger.bind(evt[1], function(e) {
            self.hide(e); 
        });
		
        // ensure that the tip really shows up. IE cannot catch up with this.
        if (!$.browser.msie && !isInput && !conf.predelay) {
            trigger.mousemove(function()  {					
                if (!self.isShown()) {
                    trigger.triggerHandler("mouseover");	
                }
            });
        }

        // avoid "black box" bug in IE with PNG background images
        if (conf.opacity < 1) {
            tip.css("opacity", conf.opacity);		
        }
		
        var pretimer = 0, title = trigger.attr("title");
		
        if (title && conf.cancelDefault) { 
            trigger.removeAttr("title");
            trigger.data("title", title);			
        }						
		
        $.extend(self, {
				
            show: function(e) {
				
                if (e) {
                    trigger = $(e.target);
                }				

                clearTimeout(tip.data("timer"));					

                if (tip.is(":animated") || tip.is(":visible")) {
                    return self;
                }
				
                function show() {
					
                    // remember the trigger element for this tip
                    tip.data("trigger", trigger);
					
                    // get position
                    var pos = getPosition(e);					
					
                    // title attribute					
                    if (conf.tip && title) {
                        tip.html(trigger.data("title"));
                    } 				
					
                    // onBeforeShow
                    e = e || $.Event();
                    e.type = "onBeforeShow";
                    $self.trigger(e, [pos]);				
                    if (e.isDefaultPrevented()) {
                        return self;
                    }
			
					
                    // onBeforeShow may have altered the configuration
                    pos = getPosition(e);
					
                    // set position
                    tip.css({
                        position:'absolute', 
                        top: pos.top, 
                        left: pos.left
                        });					
					
                    // invoke effect
                    var eff = effects[conf.effect];
                    if (!eff) {
                        throw "Nonexistent effect \"" + conf.effect + "\"";
                    }
					
                    eff[0].call(self, function() {
                        e.type = "onShow";
                        $self.trigger(e);			
                    });					
					
                }
				
                if (conf.predelay) {
                    clearTimeout(pretimer);
                    pretimer = setTimeout(show, conf.predelay);	
					
                } else {
                    show();	
                }
				
                return self;
            },
			
            hide: function(e) {

                clearTimeout(tip.data("timer"));
                clearTimeout(pretimer);
				
                if (!tip.is(":visible")) {
                    return;
                }
				
                function hide() {
					
                    // onBeforeHide
                    e = e || $.Event();
                    e.type = "onBeforeHide";
                    $self.trigger(e);				
                    if (e.isDefaultPrevented()) {
                        return;
                    }
					
                    effects[conf.effect][1].call(self, function() {
                        e.type = "onHide";
                        $self.trigger(e);		
                    });
                }
				 
                if (conf.delay && e) {
                    tip.data("timer", setTimeout(hide, conf.delay));
					
                } else {
                    hide();	
                }			
				
                return self;
            },
			
            isShown: function() {
                return tip.is(":visible, :animated");	
            },
				
            getConf: function() {
                return conf;	
            },
				
            getTip: function() {
                return tip;	
            },
			
            getTrigger: function() {
                return trigger;	
            },
			
            // callback functions			
            bind: function(name, fn) {
                $self.bind(name, fn);
                return self;	
            },
			
            onHide: function(fn) {
                return this.bind("onHide", fn);
            },

            onBeforeShow: function(fn) {
                return this.bind("onBeforeShow", fn);
            },
			
            onShow: function(fn) {
                return this.bind("onShow", fn);
            },
			
            onBeforeHide: function(fn) {
                return this.bind("onBeforeHide", fn);
            },

            unbind: function(name) {
                $self.unbind(name);
                return self;	
            }			

        });		

        // bind all callbacks from configuration
        $.each(conf, function(name, fn) {
            if ($.isFunction(fn)) {
                self.bind(name, fn);
            }
        }); 		
		
    }
		
	
    // jQuery plugin implementation
    $.prototype.tooltip = function(conf) {
		
        // return existing instance
        var api = this.eq(typeof conf == 'number' ? conf : 0).data("tooltip");
        if (api) {
            return api;
        }
		
        // setup options
        var globals = $.extend(true, {}, $.tools.tooltip.conf);		
		
        if ($.isFunction(conf)) {
            conf = {
                onBeforeShow: conf
            };
			
        } else if (typeof conf == 'string') {
            conf = {
                tip: conf
            };	
        }

        conf = $.extend(true, globals, conf);
		
        // can also be given as string
        if (typeof conf.position == 'string') {
            conf.position = conf.position.split(/,?\s/);	
        }
		
        // assign tip's only when apiement is being mouseovered		
        if (conf.lazy !== false && (conf.lazy === true || this.length > 20)) {	
				
            this.one("mouseover", function(e) {	
                api = new Tooltip($(this), conf);
                api.show(e);
                instances.push(api);
            }); 
			
        } else {
			
            // install tooltip for each entry in jQuery object
            this.each(function() {
                api = new Tooltip($(this), conf); 
                instances.push(api);
            });
        } 

        return conf.api ? api: this;		
		
    };
		
}) (jQuery);

		

/**
 * tools.tooltip "Slide Effect" 1.0.0
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tooltip.html#slide
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Since  : September 2009
 * Date: ${date}
 * Revision: ${revision} 
 */
(function($) { 

    // version number
    var t = $.tools.tooltip;
    t.effects = t.effects || {};
    t.effects.slide = {
        version: '1.0.0'
    }; 
		
    // extend global configuragion with effect specific defaults
    $.extend(t.conf, { 
        direction: 'up', // down, left, right 
        bounce: false,
        slideOffset: 10,
        slideInSpeed: 200,
        slideOutSpeed: 200, 
        slideFade: !$.browser.msie
    });			
	
    // directions for slide effect
    var dirs = {
        up: ['-', 'top'],
        down: ['+', 'top'],
        left: ['-', 'left'],
        right: ['+', 'left']
    };
	
    /* default effect: "slide"  */
    $.tools.tooltip.addEffect("slide", 
		
        // show effect
        function(done) { 

            // variables
            var conf = this.getConf(), 
            tip = this.getTip(),
            params = conf.slideFade ? {
                opacity: conf.opacity
                } : {}, 
            dir = dirs[conf.direction] || dirs.up;

            // direction			
            params[dir[1]] = dir[0] +'='+ conf.slideOffset;
			
            // perform animation
            if (conf.slideFade) {
                tip.css({
                    opacity:0
                });
            }
            tip.show().animate(params, conf.slideInSpeed, done); 
        }, 
		
        // hide effect
        function(done) {
			
            // variables
            var conf = this.getConf(), 
            offset = conf.slideOffset,
            params = conf.slideFade ? {
                opacity: 0
            } : {}, 
            dir = dirs[conf.direction] || dirs.up;
			
            // direction
            var sign = "" + dir[0];
            if (conf.bounce) {
                sign = sign == '+' ? '-' : '+';
            }			
            params[dir[1]] = sign +'='+ offset;			
			
            // perform animation
            this.getTip().animate(params, conf.slideOutSpeed, function()  {
                $(this).hide();
                done.call();		
            });
        }
        );  
	
})(jQuery);	


/**
 * tools.tabs 1.0.4 - Tabs done right.
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tabs.html
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : November 2008
 * Date: ${date}
 * Revision: ${revision} 
 */  
(function($) {
		
    // static constructs
    $.tools = $.tools || {};
	
    $.tools.tabs = {
        version: '1.0.4',
		
        conf: {
            tabs: 'a',
            current: 'current',
            onBeforeClick: null,
            onClick: null, 
            effect: 'default',
            initialIndex: 0,			
            event: 'click',
            api:false,
            rotate: false
        },
		
        addEffect: function(name, fn) {
            effects[name] = fn;
        }
    };		
	
	
    var effects = {
		
        // simple "toggle" effect
        'default': function(i, done) { 
            this.getPanes().hide().eq(i).show();
            done.call();
        }, 
		
        /*
			configuration:
				- fadeOutSpeed (positive value does "crossfading")
				- fadeInSpeed
		*/
        fade: function(i, done) {
            var conf = this.getConf(), 
            speed = conf.fadeOutSpeed,
            panes = this.getPanes();
			
            if (speed) {
                panes.fadeOut(speed);	
            } else {
                panes.hide();	
            }

            panes.eq(i).fadeIn(conf.fadeInSpeed, done);	
        },
		
        // for basic accordions
        slide: function(i, done) {			
            this.getPanes().slideUp(200);
            this.getPanes().eq(i).slideDown(400, done);			 
        }, 

        // simple AJAX effect
        ajax: function(i, done)  {			
            this.getPanes().eq(0).load(this.getTabs().eq(i).attr("href"), done);	
        }
		
    };   	
	
    var w;
	
    // this is how you add effects
    $.tools.tabs.addEffect("horizontal", function(i, done) {
	
        // store original width of a pane into memory
        if (!w) {
            w = this.getPanes().eq(0).width();
        }
		
        // set current pane's width to zero
        this.getCurrentPane().animate({
            width: 0
        }, function() {
            $(this).hide();
        });
		
        // grow opened pane to it's original width
        this.getPanes().eq(i).animate({
            width: w
        }, function() { 
            $(this).show();
            done.call();
        });
		
    });	
	 

    function Tabs(tabs, panes, conf) { 
		
        var self = this, $self = $(this), current;

        // bind all callbacks from configuration
        $.each(conf, function(name, fn) {
            if ($.isFunction(fn)) {
                $self.bind(name, fn);
            }
        });
		
		
        // public methods
        $.extend(this, {				
            click: function(i, e) {
				
                var pane = self.getCurrentPane();				
                var tab = tabs.eq(i);												 
				
                if (typeof i == 'string' && i.replace("#", "")) {
                    tab = tabs.filter("[href*=" + i.replace("#", "") + "]");
                    i = Math.max(tabs.index(tab), 0);
                }
								
                if (conf.rotate) {
                    var last = tabs.length -1; 
                    if (i < 0) {
                        return self.click(last, e);
                    }
                    if (i > last) {
                        return self.click(0, e);
                    }						
                }
				
                if (!tab.length) { 
                    if (current >= 0) {
                        return self;
                    }
                    i = conf.initialIndex;
                    tab = tabs.eq(i);
                }				
				
                // current tab is being clicked
                if (i === current) {
                    return self;
                }
				
                // possibility to cancel click action				
                e = e || $.Event();
                e.type = "onBeforeClick";
                $self.trigger(e, [i]);				
                if (e.isDefaultPrevented()) {
                    return;
                }
				
                // call the effect
                effects[conf.effect].call(self, i, function() {

                    // onClick callback
                    e.type = "onClick";
                    $self.trigger(e, [i]);					
                });			
				
                // onStart
                e.type = "onStart";
                $self.trigger(e, [i]);				
                if (e.isDefaultPrevented()) {
                    return;
                } 
				
                // default behaviour
                current = i;
                tabs.removeClass(conf.current);	
                tab.addClass(conf.current);				
				
                return self;
            },
			
            getConf: function() {
                return conf;	
            },

            getTabs: function() {
                return tabs;	
            },
			
            getPanes: function() {
                return panes;	
            },
			
            getCurrentPane: function() {
                return panes.eq(current);	
            },
			
            getCurrentTab: function() {
                return tabs.eq(current);	
            },
			
            getIndex: function() {
                return current;	
            }, 
			
            next: function() {
                return self.click(current + 1);
            },
			
            prev: function() {
                return self.click(current - 1);	
            }, 
			
            bind: function(name, fn) {
                $self.bind(name, fn);
                return self;	
            },	
			
            onBeforeClick: function(fn) {
                return this.bind("onBeforeClick", fn);
            },
			
            onClick: function(fn) {
                return this.bind("onClick", fn);
            },
			
            unbind: function(name) {
                $self.unbind(name);
                return self;	
            }			
		
        });
		
		
        // setup click actions for each tab
        tabs.each(function(i) { 
            $(this).bind(conf.event, function(e) {
                self.click(i, e);
                return false;
            });			
        });

        // if no pane is visible --> click on the first tab
        if (location.hash) {
            self.click(location.hash);
        } else {
            if (conf.initialIndex === 0 || conf.initialIndex > 0) {
                self.click(conf.initialIndex);
            }
        }		
		
        // cross tab anchor link
        panes.find("a[href^=#]").click(function(e) {
            self.click($(this).attr("href"), e);		
        }); 
    }
	
	
    // jQuery plugin implementation
    $.fn.tabs = function(query, conf) {
		
        // return existing instance
        var el = this.eq(typeof conf == 'number' ? conf : 0).data("tabs");
        if (el) {
            return el;
        }

        if ($.isFunction(conf)) {
            conf = {
                onBeforeClick: conf
            };
        }
		
        // setup options
        var globals = $.extend({}, $.tools.tabs.conf), len = this.length;
        conf = $.extend(globals, conf);		

		
        // install tabs for each items in jQuery		
        this.each(function(i) {				
            var root = $(this); 
			
            // find tabs
            var els = root.find(conf.tabs);
			
            if (!els.length) {
                els = root.children();	
            }
			
            // find panes
            var panes = query.jquery ? query : root.children(query);
			
            if (!panes.length) {
                panes = len == 1 ? $(query) : root.parent().find(query);
            }			
			
            el = new Tabs(els, panes, conf);
            root.data("tabs", el);
			
        });		
		
        return conf.api ? el: this;		
    };		
		
}) (jQuery); 


/**
 * jQuery TOOLS plugin :: tabs.slideshow 1.0.2
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/tabs.html#slideshow
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * Launch  : September 2009
 * Date: ${date}
 * Revision: ${revision} 
 */
(function($) {
	
    var t = $.tools.tabs; 
    t.plugins = t.plugins || {}; 
    t.plugins.slideshow = { 
        version: '1.0.2',
		
        // CALLBACKS: onBeforePlay, onPlay, onBeforePause, onPause,  
        conf: {
            next: '.forward',
            prev: '.backward',
            disabledClass: 'disabled',
            autoplay: false,
            autopause: true,
            interval: 3000, 
            clickable: true,
            api: false
        }
    };


    // jQuery plugin implementation
    $.prototype.slideshow = function(conf) {
	
        var globals = $.extend({}, t.plugins.slideshow.conf),
        len = this.length, 
        ret;
			 
        conf = $.extend(globals, conf);	 
		
        this.each(function() {
			
            var tabs = $(this), api = tabs.tabs(), $api = $(api), ret = api; 
			
            // bind all callbacks from configuration
            $.each(conf, function(name, fn) {
                if ($.isFunction(fn)) {
                    api.bind(name, fn);
                }
            });
		
			
            function find(query) {
                return len == 1 ? $(query) : tabs.parent().find(query);	
            }	
			
            var nextButton = find(conf.next).click(function() {
                api.next();		
            });
			
            var prevButton = find(conf.prev).click(function() {
                api.prev();		
            });
			
            // interval stuff
            var timer, hoverTimer, startTimer, stopped = false;
	

            // extend the Tabs API with slideshow methods			
            $.extend(api, {
					
                play: function() {
		
                    // do not start additional timer if already exists
                    if (timer) {
                        return;
                    }
					
                    // onBeforePlay
                    var e = $.Event("onBeforePlay");
                    $api.trigger(e);
					
                    if (e.isDefaultPrevented()) {
                        return api;
                    }				
					
                    stopped = false;
					
                    // construct new timer
                    timer = setInterval(api.next, conf.interval);
	
                    // onPlay
                    $api.trigger("onPlay");				
					
                    api.next();
                },
			
                pause: function() {
					
                    if (!timer) {
                        return api;
                    }
					
                    // onBeforePause
                    var e = $.Event("onBeforePause");
                    $api.trigger(e);					
                    if (e.isDefaultPrevented()) {
                        return api;
                    }		
					
                    timer = clearInterval(timer);
                    startTimer = clearInterval(startTimer);
					
                    // onPause
                    $api.trigger("onPause");		
                },
				
                // when stopped - mouseover won't restart 
                stop: function() {					
                    api.pause();
                    stopped = true;	
                },
				
                onBeforePlay: function(fn) {
                    return api.bind("onBeforePlay", fn);
                },
				
                onPlay: function(fn) {
                    return api.bind("onPlay", fn);
                },

                onBeforePause: function(fn) {
                    return api.bind("onBeforePause", fn);
                },
				
                onPause: function(fn) {
                    return api.bind("onPause", fn);
                }
				
            });
	
			
		
            /* when mouse enters, slideshow stops */
            if (conf.autopause) {
                var els = api.getTabs().add(nextButton).add(prevButton).add(api.getPanes());
				
                els.hover(function() {					
                    api.pause();					
                    hoverTimer = clearInterval(hoverTimer);
					
                }, function() {
                    if (!stopped) {						
                        hoverTimer = setTimeout(api.play, conf.interval);						
                    }
                });
            } 
			
            if (conf.autoplay) {
                startTimer = setTimeout(api.play, conf.interval);				
            } else {
                api.stop();	
            }
			
            if (conf.clickable) {
                api.getPanes().click(function()  {
                    api.next();
                });
            } 
			
            // manage disabling of next/prev buttons
            if (!api.getConf().rotate) {
				
                var cls = conf.disabledClass;
				
                if (!api.getIndex()) {
                    prevButton.addClass(cls);
                }
                api.onBeforeClick(function(e, i)  {
                    if (!i) {
                        prevButton.addClass(cls);
                    } else {
                        prevButton.removeClass(cls);	
					
                        if (i == api.getTabs().length -1) {
                            nextButton.addClass(cls);
                        } else {
                            nextButton.removeClass(cls);	
                        }
                    }
                });
            }
			
        });
		
        return conf.api ? ret : this;
    };
	
})(jQuery); 





/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news"> 
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *  
 *  $('#news').innerfade({ 
 *	  animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 
 *	  speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 
 *	  timeout: Time between the fades in milliseconds (Default: '2000'), 
 *	  type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 
 * 		containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *	  runningclass: CSS-Class which the container get’s applied (Default: 'innerfade'),
 *	  children: optional children selector (Default: null)
 *  }); 
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
            'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
                var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
                        current = Math.floor ( Math.random ( ) * ( elements.length ) );
                    } while (last == current );             
                    $.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
            } else if ( settings.type == 'random_start' ) {
                settings.type = 'sequence';
                var current = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function(){
                    $.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
                }, settings.timeout);
                $(elements[current]).show();
            }	else {
                alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
            }
        }
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                removeFilter($(this)[0]);
            });
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if(element.style.removeAttribute){
        element.style.removeAttribute('filter');
    }
}




