function hide(){
//hide events that have finished or start in more than showmonths
months=document.getElementById('showmonths').value;
months=parseInt(months);
today=new Date();
cutoff=new Date();
cutoff.setMonth(today.getMonth()+months);//rolls over
today=ymd(today);
cutoff=ymd(cutoff);

i=1;
while (e=document.getElementById('event'+i)){
s=document.getElementById('start'+i).value;
f=document.getElementById('finish'+i).value;
//if(f<today) e.style.border='1px solid red';
//if(months && s>cutoff) e.style.border='1px solid blue';
if(f<today) e.style.display='none';
if(months && s>cutoff) e.style.display='none';
i++;
}
}

function ymd(dt){
//return yyyy-mm-dd
d=dt.getDate();
if (d<10) d='0'+d;
m=dt.getMonth()+1;
if (m<10) m='0'+m;
y=dt.getFullYear();
return y+'-'+m+'-'+d;
}

window.onload=hide;

