// 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'],
//feb
['February Half-Term Camp: Monday 15th / Friday 19th February 2010','Results of Winter Tournament','Put the AGM in your diary: March 3rd at 7:30PM'],
//mar
['New!! &nbsp;Monthly Tuesday Night Mix-In Curry starts on March 2nd at 8:30pm','Please come to the AGM: March 3rd at 7:30PM'],
//apr
['Junior Easter Tournaments - Tues 6th / Wed 7th April 6th. Book your place now!','Junior Easter Camp - Monday 12th to Friday 16th April.  Book your place now!','Tuesday 13th Night Mix-In TakeAway at 8:30pm','New Dome Down Date:<br/>Thursday April 15th','Reminder! Yearly Club Fees due May 1st'],
//may
['Ask at Mix-In about the Monthly Tuesday Night Mix-In TakeAway at 8:30pm','Summer Season begins - Check the Website mid-April for playing details','Mix-In moves back to Sunday afternoon with a new format<br/><a href="pdfs_docs/Sunday_2010_ All-in-mix-in.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>','Monday 3rd May Bank Holiday<br/>Singles Round-Robin Competition<br/>8:30-11:30 inc. breakfast<br/><a href="pdfs_docs/bankholsingles.pdf" title="Be patient - opens a pdf file" target="_blank">Click here for details</a>','American Tournament &amp; BBQ<br/>May 15th at 2pm. <a href="pdfs_docs/Am_Tourn_May10.pdf" title="Be patient - opens a pdf file" target="_blank">Click here for details</a>', 'Wimbledon Ticket Draw at Club, 7.30pm on Wednesday 19th May. Bring your LTA Membership Number'],
//jun
['1st of Month Tuesday Night Mix-In TakeAway at 8:30pm.<br/><a href="pdfs_docs/Tuesday Night Mix.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
['10th July: Club Finals Day and BBQ<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>','13th July Tuesday Night Mix-In TakeAway at 8:30pm.<br/><a href="pdfs_docs/Tuesday Night Mix.pdf" target="_blank" title="Be patient - opens a pdf file">Click here for details</a>','Summer Camps:<br/>Monday July 26th - Friday July 30th<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>'],
//aug
['We hope you have a great summer holiday!!','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: Dome/Indoor Club Fees renewal due Oct 1st. &nbsp;Penalty for late payment.','NEW Dome erected between 21st-24th. Play available from Oct 3rd (est)'],
//oct
['Winter schedules begin.<a href="membership.html">See Playing times here<a/>','Remember to enter the Dome Championships. Entries due by 24th'],
//nov
['November 21st 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>', 'Reminder: Check the Christmas Holiday openings', 'Winter Tournament Players get your matches underway now' ]

]

showDays=300 // number of days to automatically show updates when page loads, 0 = never
showMonths=2 // 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

