var navBar_2007

//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

//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:00 AM'],//0
    ['2007/02/24','RMPA Contest','2_24_Sheridan.htm',1,"12:00 noon"],//1
    ['2007/03/03','RMPA Contest','3_3_Heritage.htm',1,"11:50 AM"],//2
    ['2007/03/10','RMPA Contest','3_10_Legacy.htm',1,"8:30 AM"],//2
    ['2007/03/17','WGI Regional','3_17_WGI.htm',1,""],	//4	
    ['2007/03/24','RMPA Contest','3_24_Northglenn.htm',1,"9:00 AM"],//5		
    ['2007/03/31','RMPA Contest','3_31_Longmont.htm',1,"1:00 PM"],//6			    
	['2007/04/07','RMPA Championship','4_7_Championship.htm',1,"8:30 AM"],//7									
	['2007/04/19','WGI World','4_21_WGI.htm',1,"4/21/2007"],//8					
	['2007/04/20','WGI World','4_21_WGI.htm',0,"4/21/2007"],//9						
	['2007/04/21','WGI World','4_21_WGI.htm',0,"4/21/2007"],//10						
	['2007/05/12','I & E','5_12_IE.htm',1,"2:00 PM"],//11		
	['2007/07/15','Membership Meeting','membershipMeeting.htm',1,"2:00 PM"],//12
	['2007/11/17','Day Of Percussion','DayOfPercussion.htm',1,"7:45 AM"]//13

  ];
  
today = new Array()
today = [
	[strToday,'today','today',0,""]			
	
  ];  
eventDates = today.concat(navBar_2007)
 
 
  //get the array in date order
  eventDates.sort()
  
  //default to empty
  nextEventDate=""
  nextEventTime=""
  nextEventDesc=""
  nextEventURL=""
  previousEventURL=""
  
  //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 == '2007/04/20' || strToday == '2007/04/21'){
  	previousIdx=7
  }
  if(strToday == '2007/04/19' || strToday == '2007/04/20' || strToday == '2007/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/19/2007' || nextEventDate == '4/20/2007' || nextEventDate == '4/21/2007'){
	  	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>')
	}
}


