// JavaScript Document

//Sound//

function EvalSound(soundobj) {
  var thissound=document.getElementById(soundobj);
  thissound.Play();
}


updates=[
//jan
['We hope you had a wonderful Christmas Break', 'Happy New Year!','Remember to get your Winter Tournament matches played','Singles box league running. Sign up & shed those Xmas pounds!'],
//feb
[/*'Half-Term Morning Camp:<br/> Monday 21st/Friday 25th. <a href="pdfs_docs/holidaycourses/feb_halfterm_2011.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for form to print</a>'*/'Put the AGM in your diary: March 6th at 7:30PM','Singles box league running. Sign up & shed those Xmas pounds!'],
//mar
['Please come to the AGM:<br/>Tuesday March 6th at 7:30PM','Dome Finals Day – Saturday 24th March','Junior Membership Subs due on April 1st'],
//apr
['Junior Membership Subs due on the 1st','Junior Easter Tournaments - dates to follow',/*'Junior Easter Camp - April 11th to April 15th',*/'Dome Down Date: Late April - Helpers wanted!','Reminder!<br/>Adult Yearly Club Fees due May 1st<br/>&pound;30 penalty if paid after May 15th.'],
//may
['Adult Yearly Club Fees due on the 1st',/*'Monday 2nd Bank Holiday - Singles Round-Robin tournament &nbsp;<a href="pdfs_docs/Round_Robin_May 2011.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>','Wimbledon Ticket Draw at Club, 7.30pm on Wednesday 18th May. Bring your LTA Membership Number. &nbsp;Plus EGM','Saturday 21st - American Tournament<br/>2pm start plus BBQ&nbsp; <a href="pdfs_docs/Am_Tourn_May_11.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>'*/],
//jun
['Enjoy the Summer Weather!?', 'American Tournament Sat 25th at 2pm<br/>Seniors and Intermets welcome<br/>Tea, Cakes and Pimms - <a href="pdfs_docs/Am_Tourn_250611.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>' /*'Half-Term Camp: June 1st - June 4th<br/><a href="pdfs_docs/holidaycourses/may_halfterm_2010.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>','June 19th - MidSummer Beach Party!!<br/><a href="pdfs_docs/beach_2010.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>','Summer Tournament - Singles and Doubles'*/],
//jul
['9th July: Club Finals Day and Tea'/* <br/><a href="pdfs_docs/Club_championships_2010.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for Match details</a>&nbsp;&nbsp;<a href="pdfs_docs/Club_championships_2010_BBQ.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for BBQ details</a>'*/,'Summer Camps:<br/>Monday July 25th - Friday July 29th<br/>Monday August 1st - Friday August 5th<br/><a href="pdfs_docs/holidaycourses/summer_camp_2011.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>'],
//aug
['We hope you have a great summer holiday!!'/*'Tuesday 9th:<br/>All the Astroturf Courts closed until 6pm for moss treatment'*/,'Tuesday 30th:<br/>Acrylic Courts 3/4/5 closed for 2 weeks for resurfacing<br/><a href="pdfs_docs/Court_resurface_Aug2011.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>' /*,'Summer Camp:<br/>Monday August 2nd - Friday August 6th<br/><a href="pdfs_docs/holidaycourses/2010_summer_camp.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>','Tuesday Aug 10th - Moss Treatment on Synthetic Courts.&nbsp; Evening play only.'*/],
//sept
[/*'Sunday 12th September Junior Finals Day',*/ 'Reminder:<br/>Dome/Indoor Club Fees renewal due Oct 1st.<br/>Penalty for late payment!'],
//oct
['Winter schedules begin'/*<a href="membership.html">See Playing times here<a/>'*/,'Dome play planned to be available from 2nd Week of Oct','Remember to enter the Dome Championships','October Half Term Course:<br/>Monday October 24th - Friday October 28th<br/><a href="pdfs_docs/holidaycourses/oct_halfterm_2011.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>'],
//nov
['Remember to get your Dome Championship games underway'/*'Saturday 19th is Quiz Night!! <br/> World Famous!! Starts at 7:30pm '/*<br/> £10 per person includes supper <br> 10 teams of 6 (maximum) <br/> First come first served so get your team name to Steve Nicholls early<br/> Each team gets a free bottle of wine <br/> <a href="quiz.html">Click here for Poster</a>','Reminder: Check the booking system for Winter Tournament'*/],
//dec
[/*'Holiday Courses on Dec 21st &amp; 22nd.<br/> <a href="holiday.html">See details here</a>',*/'Come to our Christmas Party!<br/>Saturday 10th at 19:30 <br/><a href="pdfs_docs/tennis_xmas_party.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>','Reminder:<br/>Check the Christmas Holiday openings:<br/><a href="pdfs_docs/CHRISTMAS_AIRDOME_2011.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>','There are special DOME Offers over Christmas and New Year:<br/><a href="pdfs_docs/XMAS_BOOKINGS_OFFER.pdf" title="Please be patient - opens a PDF file" target="_blank">Click here for details</a>','Winter Tournament Players get your matches underway now' ]

]

showDays=300 // number of days to automatically show updates when page loads, 0 = never
showMonths=3 // how many previous months updates to show

months=new Array("January","February","March","April","May","June","July","August","September","October","November","December") 
showing=0

function initWhatsNew(){
updateList=document.getElementById("update_list")
// populate whats new screen with updates covering last 6 months
now=new Date() // todays date
mth=now.getMonth() // current month
mthStart=mth+1;  //show month after next
year=now.getFullYear() // current year

isUpdates=0
updateList.innerHTML=""

for(var i=0;i<showMonths;i++){
if(mthStart>11)
	{
	mthStart=mthStart-12;
	year++
	}
if(mthStart<0)
	{
mthStart=11
year--
	}

if(updates[mthStart][0]!=''){
updateList.innerHTML+='<b>'+months[mthStart]+' '+year+'</b><br/>'

for(var j=0;j<updates[mthStart].length;j++){
updateList.innerHTML+='<li>'+updates[mthStart][j]+'<br/>'
}

isUpdates=1
}
mthStart--
}

if(isUpdates==0){ // if no updates
document.getElementById("show_new").style.visibility="hidden"
return
}

today=new Date().getTime()
lastMod=new Date(document.lastModified).getTime()
validPeriod = lastMod + (1000 * 60 * 60 * 24 * showDays)

updateDiv=document.getElementById("w_n_update")

wWidth=document.body.clientWidth
wHeight=document.body.clientHeight

sWidth=updateDiv.offsetWidth
sHeight=updateDiv.offsetHeight

updateDiv.style.left=(wWidth-sWidth)/2+"px"
updateDiv.style.top=updateDiv.offsetTop-sHeight+"px"

defPos=parseInt(updateDiv.style.top)
topPos=defPos
stopPos=200 // top position layer scrolls down to in relation to page top (zero)

if(showDays!=0&&today<validPeriod)
{
showWhatsNew()
//hideWhatsNew()
}

}
showMe=""
hideMe=""

function showWhatsNew()
{
document.getElementById("w_n_update").style.visibility="visible"
if (topPos<stopPos){
topPos+=30
updateDiv.style.top=topPos+"px"
showMe=setTimeout("showWhatsNew()",50)
}
else{
clearTimeout(showMe)
}
showing=1
document.getElementById("show_new").innerHTML="Hide Club Activity Calendar"
document.getElementById("show_new").onclick=function(){
hideWhatsNew()
}
}



function hideWhatsNew(){
if(showing==0){return}
clearTimeout(showMe)
if (topPos>defPos) {
topPos-=50
updateDiv.style.top=topPos+"px"
hideMe=setTimeout("hideWhatsNew()",50)
}
else{
clearTimeout(hideMe)
}

document.getElementById("show_new").innerHTML="Show Club Activity Calendar"
document.getElementById("show_new").onclick=function(){
showWhatsNew()
}
}

// add onload="initWhatsNew()" to the opening BODY tag


