if screen size

if screen size

I have the following code:

$('ul.nav li ul').hide();
        $('ul.nav > li').hover(function () {
        if ($(this).find('ul').length > 0) {
            $(this).find('ul').stop().slideDown('fast');
        }
        },function () {
            if ($(this).find('ul').length > 0) {
                $(this).find('ul').stop().slideUp('fast');
            }
        });

But i dont want it to execute if my screen size is below 560px, is there a way I can do this? I tried wrapping
      if ($(window).width() > 560) {

}

around it but it doesn't make a different, not sure if it's because I've got an if within an if..

Can anyone help??

Kelly