var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;



function showEvent(n){
if(n==1) document.getElementById('eventInfo').innerHTML ="Two Horns and Strings<br />11am Peppermint Bay<br />6pm Nant Distillery";
if(n==2) document.getElementById('eventInfo').innerHTML ="Two Horns and Strings<br />1pm Devonport Art Gallery<br /> 5pm UTAS Inveresk";
if(n==3) document.getElementById('eventInfo').innerHTML ="Trout Quintet<br />11am Meadowbank Estate <br />5pm The Priory, Bothwell";
if(n==4) document.getElementById('eventInfo').innerHTML ="Trout Quintet<br />1pm Spreyton<br />5pm Fitzpatrick Inn";
if(n==5) document.getElementById('eventInfo').innerHTML ="Program TBA<br />11am Meadowbank Estate<br />7pm Home Hill Winery";
if(n==6) document.getElementById('eventInfo').innerHTML ="Program TBA<br />7pm St Helens<br /> Tidal Waters Resort";

if(n==7) document.getElementById('eventInfo').innerHTML ="Program TAB <br />11am Swansea<br />Clarendon, Evandale";
if (n==8) document.getElementById('eventInfo').innerHTML ="Virtuosi Tasmania<br />Committee Meeting<br />at the Martins 8am";

	
	
	
	
	
	}
function deleteEvent(n){
if(n==1 || n==2 || n==3 || n==4 || n==5 ||n==6 || n==7|| n==8) document.getElementById('eventInfo').innerHTML ="<br /><br /><br />"; 

}


// function becomes a method for each month object
function getFirstDay(theYear, theMonth){
    var firstDate = new Date(theYear,theMonth,1);
    return firstDate.getDay() + 1;
}
// number of days in the month
function getMonthLen(theYear, theMonth) {
    var oneDay = 1000 * 60 * 60 * 24;
    var thisMonth = new Date(theYear, theMonth, 1);
    var nextMonth = new Date(theYear, theMonth + 1, 1);
    var len = Math.ceil((nextMonth.getTime() - 
        thisMonth.getTime())/oneDay);
    return len;
}

// create basic array
theMonths = new MakeArray(12);
// load array with English month names
function MakeArray(n) {
    this[0] = "January"
    this[1] = "February"
    this[2] = "March"
    this[3] = "April"
    this[4] = "May"
    this[5] = "June"
    this[6] = "July"
    this[7] = "August"
    this[8] = "September"
    this[9] = "October"
    this[10] = "November"
    this[11] = "December"
    this.length = n;
    return this;
}
function virtuosi(){
// initialize some variables for later
var today = new Date();
var theDate=today.getDate();
var theYear = today.getFullYear();
var theMonth = today.getMonth(); // for index into our array

// which is the first day of this month?
var firstDay = getFirstDay(theYear, theMonth);
// total number of <td>...</td> tags needed in for loop below
var howMany = getMonthLen(theYear, theMonth) + firstDay;

// start assembling HTML for table
var content = "<table id='calender'>";
// month and year display at top of calendar
content += "<tr style='text-align:center;color:#F00'><td colspan='7'>" + theMonths[theMonth] + " " + theYear + "</td></tr>";
// days of the week at head of each column
content += "<tr style='text-align:center'><td>Su</td><td>M</td><td>Tu</td><td>W</td>";
content += "<td>Th</td><td>F</td><td>Sa</td></tr>";
content += "<tr>";

// populate calendar
for (var i = 1; i < howMany; i++) {
    if (i < firstDay) {
        // 'empty' boxes prior to first day
        content += "<td></td>";
    } else {
        // enter date number
		if((theMonth==6) && (i-firstDay +1 == 3)) {content += "<td id='dateEvent' onmouseover='showEvent(1)'onmouseout='deleteEvent(1)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==6) && (i-firstDay +1 == 4)) {content += "<td id='dateEvent' onmouseover='showEvent(2)'onmouseout='deleteEvent(2)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==7) && (i-firstDay +1 == 7)) {content += "<td id='dateEvent' onmouseover='showEvent(3)'onmouseout='deleteEvent(3)'>" + (i - firstDay + 1) + "</td>"}  
		else if((theMonth==7) && (i-firstDay +1 == 8)) {content += "<td id='dateEvent' onmouseover='showEvent(4)'onmouseout='deleteEvent(4)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==9) && (i-firstDay +1 == 21)) {content += "<td id='dateEvent' onmouseover='showEvent(5)'onmouseout='deleteEvent(5)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==9) && (i-firstDay +1 == 22)) {content += "<td id='dateEvent' onmouseover='showEvent(6)'onmouseout='deleteEvent(6)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==9) && (i-firstDay +1 == 23)) {content += "<td id='dateEvent' onmouseover='showEvent(7)'onmouseout='deleteEvent(7)'>" + (i - firstDay + 1) + "</td>"} 
		else if((theMonth==1) && (i-firstDay +1 == theDate)) {content += "<td id='coloredDateToday'>" + (i - firstDay + 1) + "</td>"}
		else if ((theMonth==6) && (i-firstDay +1 == 29)){content += "<td id='specialDateEvent' onmouseover='showEvent(8)'onmouseout='deleteEvent(8)'>" + (i - firstDay + 1) + "</td>"}  
		else {content += "<td align='center'>" + (i - firstDay + 1) + "</td>"}
    }
    // start new row after each week
    if (i % 7 == 0 &&  i  != howMany) {
        content += "</tr><tr>"
    }
}

content += "</table>"

return content;
}

function stayTunedChecker(){
var emailAddress = document.getElementById('email').value;
	if(emailAddress!==""){
	re=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		if(re.test(emailAddress)){return true}
	window.alert(emailAddress + " does not look like an email address to me.\nPlease try again?");
	document.getElementById('email').focus();
	document.getElementById('email').select();
	return false;
	}
}



var pictureOne = new Image();
var pictureTwo = new Image();
var pictureThree = new Image();
var pictureFour = new Image();
var pictureFive = new Image();
var pictureSix = new Image();
var pictureSeven = new Image();
var pictureEight = new Image();
var pictureNine = new Image();

pictureOne.src = "/images/imageOne.jpg";
pictureTwo.src = "/images/imageTwo.jpg";
pictureThree.src = "/images/imageThree.jpg";
pictureFour.src = "/images/imageFour.jpg";
pictureFive.src = "/images/imageFive.jpg";
pictureSix.src = "/images/imageSix.jpg";
pictureSeven.src = "/images/imageSeven.jpg";
pictureEight.src = "/images/imageEight.jpg";
pictureNine.src = "/images/imageNine.jpg";

VTplayers = new Array (pictureOne.src, pictureTwo.src, pictureThree.src, pictureFour.src, pictureFive.src, pictureSix.src, pictureSeven.src, pictureEight.src, pictureNine.src);
thisImage = 0;
imageCount = VTplayers.length;

function rotate(){
 
 thisImage++;
  if(thisImage == imageCount){
  thisImage = 0}
document.getElementById('VTmusicians').src = VTplayers[thisImage];
window.setTimeout("rotate()", 4 *1000);
}

