//create a string for today's date
var today = new Date()
var strMonth = today.getMonth() + 1
strMonth = strMonth.toString()
if(strMonth.length < 2) { strMonth = "0" + strMonth }
var strYear = today.getYear()
if(strYear < 2000) { strYear = strYear + 1900}
var strDay = today.getDate().toString()
if(strDay.length < 2) { strDay = "0" + strDay }
var strToday = strYear + "/" + strMonth + "/" + strDay

/*****************************2010 Events*****************************************/  
var navBar_2010
//create an array of the dates for each event and the associated label and url
navBar_2010 = new Array()
navBar_2010 = [
//today gets inserted somewhere so index numbers don't stay the same!!
    ['2010/02/13','Evaluation Clinic','2_13_EvalShow.htm',1,'Northglenn HS'],
    ['2010/02/27','RMPA Contest','2_27_Loveland.htm',1,"Loveland HS"],
    ['2010/03/06','RMPA Contest','3_6_Legacy.htm',1,"Legacy HS"],
    ['2010/03/13','RMPA Contest','3_13_MountainRange.htm',1,"Mountain Range HS"],
    ['2010/03/20','WGI Regional','3_20_WGI.htm',1,"Northglenn HS"],	
    ['2010/03/27','RMPA Contest','3_27_Longmont.htm',1,"Longmont HS"],	
	['2010/04/03','RMPA Championship','4_3_Championship.htm',1,"Budweiser Event Center"],
	['2010/04/15','WGI World','4_15_WGI.htm',1,"Dayton OH"],				
	['2010/04/16','WGI World','4_15_WGI.htm',0,"4/15/2010"],
	['2010/04/17','WGI World','4_15_WGI.htm',0,"4/15/2010"],	
	['2010/05/15','I & E','5_15_IE.htm',1,"Mountain Range HS"],
	['2010/06/20','Membership Meeting','6_20_Meeting.htm',1,"Bear Creek HS"]	
  ];
//WARNING!!  Don't forget to set change this code eventDates = today.concat(navBar_2010); apx line 111.

/*****************************2009 Events*****************************************/  
var navBar_2009
//create an array of the dates for each event and the associated label and url
navBar_2009 = new Array()
navBar_2009 = [
//today gets inserted somewhere so index numbers don't stay the same!!
    ['2009/02/14','Evaluation Clinic','2_14_EvalShow.htm',1,'TBD'],
    ['2009/02/28','RMPA Contest','2_28_MountainRange.htm',1,"TBD"],
    ['2009/03/07','RMPA Contest','3_7_Pomona.htm',1,"Mountain Range HS"],
    ['2009/03/14','RMPA Contest','3_14_Legacy.htm',1,"TBD"],
    ['2009/03/21','WGI Regional','3_21_WGI.htm',1,"TBD"],	
    ['2009/03/28','RMPA Contest','3_28_Longmont.htm',1,"Northglenn HS"],	
	['2009/04/04','RMPA Championship','4_4_Northglenn.htm',1,"Budweiser Events Center"],
	['2008/04/16','WGI World','4_16_WGI.htm',1,"Dayton OH"],				
	//['2008/04/17','WGI World','4_16_WGI.htm',0,"4/16/2008"],
	//['2008/04/18','WGI World','4_16_WGI.htm',0,"4/16/2008"],	
	['2009/05/16','I & E','4_4_Northglenn.htm',1,"Mountain Range HS"]
  ];

/*****************************2008 Events*****************************************/  
var navBar_2008
//create an array of the dates for each event and the associated label and url
navBar_2008 = new Array()
navBar_2008 = [
//today gets inserted somewhere so index numbers don't stay the same!!
    ['2008/02/16','Evaluation Clinic','2_16_EvalShow.htm',1,'9:40 AM'],
    ['2008/03/01','RMPA Contest','3_1_MountainRange.htm',1,"9:51 AM"],
    ['2008/03/08','RMPA Contest','3_8_Pomona.htm',1,"9:45 AM"],
    ['2008/03/15','RMPA Contest','3_15_Legacy.htm',1,"8:30 AM"],
    ['2008/03/22','WGI Regional','3_22_WGI.htm',1,"11:00 AM"],	
    ['2008/03/29','RMPA Contest','3_29_Longmont.htm',1,"10:45 AM"],	
	['2008/04/05','RMPA Contest','4_5_Northglenn.htm',1,"9:30 AM"],								
	['2008/04/12','RMPA Championship','4_12_Championship.htm',1,"9:00 AM"],								
	['2008/04/17','WGI World','4_17_WGI.htm',1,"4/19/2008"],				
	//['2008/04/18','WGI World','4_17_WGI.htm',0,"4/17/2008"],
	//['2008/04/19','WGI World','4_17_WGI.htm',0,"4/17/2008"],					
	['2008/05/10','I & E','5_10_IE.htm',1,"9:34 AM"],
	['2008/11/22','Day of Percussion','DayOfPercussion.htm',1,"7:45 AM"]			
  ];

/*****************************2007 Events*****************************************/
var navBar_2007
//create an array of the dates for each event and the associated label and url
navBar_2007 = new Array()
navBar_2007 = [
//today gets inserted somewhere so index numbers don't stay the same!!
    ['2007/02/10','Evaluation Clinic','2_10_EvalShow.htm',1,'9:40 AM'],
    ['2007/02/24','RMPA Contest','2_24_Sheridan.htm',1,"12:00 noon"],
    ['2007/03/03','RMPA Contest','3_3_Heritage.htm',1,"11:50 AM"],
    ['2007/03/10','RMPA Contest','3_10_Legacy.htm',1,"8:30 AM"],
    ['2007/03/17','WGI Regional','3_17_WGI.htm',1,""],	
    ['2007/03/24','RMPA Contest','3_24_Northglenn.htm',1,"9:00 AM"],	
    ['2007/03/31','RMPA Contest','3_31_Longmont.htm',1,"1:00 PM"],		    
	['2007/04/07','RMPA Championship','4_7_Championship.htm',1,"8:30 AM"],								
	['2007/04/19','WGI World','4_21_WGI.htm',1,"4/21/2007"],				
	//['2007/04/20','WGI World','4_21_WGI.htm',0,"4/21/2007"],					
	//['2007/04/21','WGI World','4_21_WGI.htm',0,"4/21/2007"],
	['2007/05/12','I & E','5_12_IE.htm',1,"2:00 PM"],	
	['2007/07/15','Membership Meeting','membershipMeeting.htm',1,"2:00 PM"],
	['2007/11/17','Day Of Percussion','DayOfPercussion.htm',1,"7:45 AM"]

  ];
  
 
today = new Array()
today = [
	[strToday,'today','today',0,""]			
	
  ];  

//set the event dates to the latest navigation bar
eventDates = today.concat(navBar_2010)
 
 
  //get the array in date order
  eventDates.sort()
  
  //default to empty
  nextEventDate=""
  nextEventTime=""
  nextEventDesc=""
  nextEventURL="events.htm#nextEvent"
  previousEventURL="events.htm"
  
  //set the previous and next event indexes
  for (i=0;i < eventDates.length;i++){
  	//alert(eventDates[i][0] + ' ' + eventDates[i][1])
	//What if today is same as an event date - seems to work okay, show date comes before today in the sort order
  	if(strToday == eventDates[i][0]){
		todayIdx = i
		previousIdx = i-1
		if(previousIdx < 1){
		  //What if there are new events before today
		  //what if the event is a "no show in nav"?		  
		  previousIdx = 0
		}
		nextIdx = i+1
		//is the next day the same as today?  if so then this is the day of the event.  make the nextEvent today's event and previous is -2		
		if(nextIdx <= eventDates.length-1){//valid array
			if(eventDates[nextIdx][0] == strToday){
				nextIdx=i
				previousIdx=i-1
				//alert(nextIdx)		
			}
		}			
	    //today is the last date in the array and we want the event before that		
		if(nextIdx > eventDates.length-1){
		  //what if the event is a "no show in nav"?			
		  //nextIdx = eventDates.length-2
		  //changed mind - don't show next event if we're out of events
		  nextIdx=-1
		}
		break;		
	}
  }

  /*Wgi has multiple dates, keep it as the next event until the 22nd
  if(strToday == '2008/04/20' || strToday == '2008/04/21'){
  	previousIdx=7
  }
  if(strToday == '2008/04/19' || strToday == '2008/04/20' || strToday == '2008/04/21'){
	  nextIdx=8
  } */ 

  
  if(previousIdx > -1 && previousIdx < eventDates.length){//have a valid index
	  previousEventURL=eventDates[previousIdx][2]
  }
  
  if(nextIdx > -1 && nextIdx < eventDates.length){//have a valid index
  	  fullDate = eventDates[nextIdx][0].split('/')
	  curMonth = fullDate[1]
	  if(curMonth.substring(0,1) == 0){curMonth = curMonth.substring(1,2)}
	  curYear = fullDate[0]
	  //curYear = curYear.substring(2,4)
	  nextEventDate=curMonth+"/"+fullDate[2]+"/"+curYear
	  if(nextEventDate == '4/15/2010' || nextEventDate == '4/16/2010' || nextEventDate == '4/17/2010'){
	  	//nextEventDate = nextEventDate + "-"
	  }
	  nextEventTime=eventDates[nextIdx][4]
	  nextEventDesc=eventDates[nextIdx][1]
	  nextEventURL=eventDates[nextIdx][2]
  }
 
  
  //alert("today" + todayIdx)
  //alert("previous" + previousIdx)  
  //alert("next" + nextIdx)

function amINextEvent(myDate){
 if(myDate == nextEventDate){
 	return true;
 }
 return false;
}

function writeNextStar(myDate){
	if(amINextEvent(myDate)){
		document.write('<a name="nextEvent"><img src="../../images/starTransparent.gif" width="12" height="12" border="0"></a>')
	}
}

