#' this fills y with 0 for x that are not in the range of dates
#' (thanks to Duncan Murdoch for the suggestion)
#' 
#' @param x dates
#' @param y numbers
#' @param start start date in the extended date vector
#' @param end end date in the extended date vector
#' @param by see ?seq.Date
panel.loess.fill <- function(x, y, by = "day", start = min(x), end = max(x), ...){
    xx <- seq.Date( start, end, by= by )
    yy <- numeric( length(xx) )
    not.zero <- xx %in% x
    if( any( not.zero ) ) yy[ not.zero ] <- y
    loess.out <- loess( as.numeric(yy) ~ as.numeric(xx) )
    panel.lines( xx, predict( loess.out), ... )
}

#' this draws a vertical line for each year between start and end
#'
#' @param start first year
#' @param end end last year
#' @param col passed to panel.abline
#' @param lwd passed to panel.abline
#' @param ... further parameters for panel.abline
panel.yearlines <- function( 
    start = 1998, end = 2010, 
    lwd = 0.5, col = "gray", ... ){
    
    firstday <- function( year ){
        as.Date( sprintf( "%d-01-01", year ) )
    }
    years <- firstday( seq.int( start, end ) )
    panel.abline( v = years, col = col, lwd = lwd, ... )
}