[jQuery] setTimeout in jquery function

[jQuery] setTimeout in jquery function


I am (attempting) to convert a standard javascript function to a jquery
function. It targets an image within a given div and changes it height and
width. Here is the old function, where z is the image. img_act_height,
max_width etc are global variables:
function zoom_in() {
    if(z.width==0){
        z.border=0;
    }
    if(z.width!=0){
        if(z.width<max_width) {
            z.width+=step;
            z.height=Math.round(z.width*((img_act_height)/(img_act_width)));
        setTimeout("zoom_in()",time_length);
        } else {
            window.alert('Maximum Width exceeded\n© Qiksearch zoOom.');
        }
    }
}
Here is my attempt:
$.fn.zoom_in = function() {
    w = $("img",this).attr("width");
    if(w==0){
        z.border=0;
    }
    if(w!=0){
        if(w<max_width) {
            newWidth=w+step;
            $("img",this).attr("width", newWidth);
            newHeight=Math.round(newWidth*image_scale);
            $("img",this).attr("height", newHeight);
        setTimeout("zoom_in()",time_length);
        } else {
            window.alert('Maximum Width exceeded');
        }
    }
}
I'm not sure how to change the line:
setTimeout("zoom_in()",time_length)
to that the function can call itself. Help appreciated.
--
View this message in context: http://www.nabble.com/setTimeout-in-jquery-function-tf2830530.html#a7902446
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/