[jQuery] New slideshow plugin, though its buggy.

[jQuery] New slideshow plugin, though its buggy.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Hi guys
I've created a slide-show plug-in (below). However, I've noted that it
can be buggy. Sometimes it takes absolutely _ages_ to "kick-in",
leaving the use with no image for upwards of 10 seconds.
Anybody think they can improve on this code? ;)
--------------------------------------------------------
</font></font><font size="-1"><font face="Helvetica, Arial, sans-serif">/**
 * Quick and easy slideshow plugin
 *
 * @param int d delay in ms
 * @param string s speed of method (slow|normal|fast)
 * @param string m method (fade|slide)
 * @param string e alternative element to use
 */
$.fn.slideShow = function(d, e, m, s)
{
    var d = d || 1000;
    var s = s || 'slow';
    var m = m || 'fade';
    var e = e || 'img';
    return this.each(function(){
        var x = new $.doSlideShow(this, d, e, m, s);
    });
};
/**
 * Quick and easy slideshow plugin
 *
 * @param array c container element
 * @param array e elements to display in slideshow
 * @param int d delay in ms
 * @param string s speed of method (slow|normal|fast)
 * @param string m method (fade|slide)
 */
$.doSlideShow = function(c, d, e, m, s)
{
    var c = c || null;
    var e = e || [];
    var d = d || 1000;
    var s = s || 'slow';
    var m = m || 'fade';
    var i = -1;
    var o = this;
    var timer = null;
    this.previous = function()
    {
        var t = $(e, c).size() -1;
        return i; //( i-1 < 0 ) ? t : i-1 ;
    }
    this.advance = function()
    {
        i++;
        if( i > ($(e, c).size()-1) ) { i = 0; }
        return i;
    }
    this.hideElements = function()
    {
        if($(e, c).size() > 1)
        // If there's only 1 element,
        // we don't do the slideshow.
        {
            switch(m)
            {
                case 'fade':
                    $(e, c).fadeOut(0);
                case 'slide':
                    $(e, c).slideUp(0);
            }
            timeout = setTimeout( function(){ o.switchElement(); } , 0
);
        }
    }
    this.switchElement = function()
    {
        try
        {
            var p = this.previous();
            var n = this.advance();
            $(e+':nth-child(' + n + ')', c).css('z-index', 100001);
            $(e+':nth-child(' + p + ')', c).css('z-index', 100000);
            switch(m)
            {
                case 'fade':
                    $(e+':nth-child(' + n + ')', c).fadeIn(s);
                    $(e+':nth-child(' + p + ')', c).fadeOut(s);
                case 'slide':
                    $(e+':nth-child(' + n + ')', c).slideDown(s);
                    $(e+':nth-child(' + p + ')', c).slideUp(s);
            }
            timeout = setTimeout( function(){ o.switchElement(); } , d
);
        }
        catch(ex)
        {
            alert(ex);
        }
    }
    timer = this.hideElements();
};
--------------------------------------------------------
</font></font><font size="-1"><font face="Helvetica, Arial, sans-serif"><div
id="imagecontainer">
    <div><img src="img1.gif" /></div>
   ...
</div>
--------------------------------------------------------
$('#imagecontainer').slideShow(7500, 'div', 'fade', 'slow');
</font></font><font size="-1"><font face="Helvetica, Arial, sans-serif">--------------------------------------------------------
</font></font>
<div class="moz-signature">-----
<font color="#333333"><font size="-1"><font
face="Helvetica, Arial, sans-serif"><u><b>Phillip
B Oldham </b></u>
<small>
<b>kilo75 ltd</b>
a: Round Foundry Media Centre, Foundry St, Leeds, LS11 5QP
t: +44 (0) 870 420 2410
e: <a href="mailto:phillip.oldham@kilo75.com">phillip.oldham@kilo75.com</a>
w: <a href="http://kilo75.com/">//kilo75.com/</a>
</small></font></font>
<hr align="left" noshade="noshade" size="1" width="350"><font
color="#333333" face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>Policies</b>
</font>

<font color="#333333" face="Verdana, Arial, Helvetica, sans-serif"
size="1">This e-mail and its attachments are intended for the above
named
recipient(s) only and may be confidential. If they have come to you
in error, please reply to this e-mail and highlight the error. No action
should be taken regarding content, nor must you copy or show them
to anyone.</font>






<font color="#333333" face="Verdana, Arial, Helvetica, sans-serif"
size="1">This e-mail has been created in the knowledge that Internet
e-mail
is not a 100% secure communications medium, and we have taken
steps to ensure that this e-mail and attachments are free from any
virus. We must advise that in keeping with good computing practice
the recipient should ensure they are completely virus free, and that
you understand and observe the lack of security when e-mailing us.
</font>








</font>
<hr align="left" noshade="noshade" size="1" width="350"></div>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/