//below are the meeting dates for the semester
//these dates must be in order!!!
var smstrStrg= "Spring 2005";
var yaerStrg = "2004-2005";
// Time of the meetings
var timeString= "18:00";
var officeremailaddress="basaofficers@lists.berkeley.edu";
var officersnailmail="University of California<br>400 Eshleman Hall #4500<br>Berkeley, CA 94720-4500";
var website = "http://basa.berkeley.edu";


//var mtgStrgs=new Array("September 12, 2003 " + timeString,"September  26, 2003 " + timeString,"October 10, 2003 " + timeString,"October 24, 2003 " + timeString,"November 7, 2003 " + timeString,"November 21, 2003 " + timeString,"December 5, 2003 "+ timeString);
var mtgStrgs=new Array("February 4, 2005 " + timeString,"February 18, 2005 " + timeString,"March  3, 2005 " + timeString,"March  18, 2005 " + timeString,"April 1, 2005 " + timeString,"April 29, 2005 "+ timeString);


// Possible possitions for officers
//var officialPositions = new Array('President','Vice President','Treasurer','Secretary','Publicity Chair','Publicity Chair');
//The name of the officers in respective order to Possible Positions array

//var officialOfficerNames  =new Array('Adaobi Mbanugo','Kene Ojukwu','Chinyere Mbagwu','Rahwa Gebretnsai','Anthony Muiru','Leslie Ezeh');

// Possible possitions for officers
var officialPositions = new Array('President','Vice President','Treasurer','Secretary','Publicity Chair','Publicity Chair', 'Commitee Coordinators');
//The name of the officers in respective order to Possible Positions array

//var officialOfficerNames  =new Array('Kene Ojukwu','Chinyere Mbagwu','Ogochukwu Okafor','Sire','Leslie Ezeh');
var officialOfficerNames  =new Array('Kenechukwu Ojukwu','Chinyere Mbagwu','Ogochukwu Okafor','Sire Sow','Audrey Echibe','Remi Ajiboye <br>  Anthony Muiru','Aba Yamouh <br>Ezechinyerem Uzosike');





//**********************Start Processing******************************
//*******************************************************************************************	
	
/// Prints the email address of the officers
function printEmail (){
//alert("hello")
//alert("<A href=\"mailto:" +officeremailaddress+"\">" +officeremailaddress + " </A>");
document.write("<A href=\"mailto:" +officeremailaddress+"\">" +officeremailaddress + " </A>");
}
function printPlainEmail(){
	document.write(officeremailaddress);
}
var dtarry= new Array(mtgStrgs.length);
//create dates for each meeting
for(i = 0; i < mtgStrgs.length; i++){
   var s=mtgStrgs[i];
   dtarry[i]=new Date(s);
   //alert(s)
   //alert(dtarry[i]);
}

//actual function that prints the date of the next meeting

 	//for pretty output
  	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  	var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	
	//prepare for nextMtgfxn
	var today = new Date();
	
//can inter a date and check if it is a past meeting

function nextMtgfxn() {
  
  var done=false;
  var cntr=0;
  var nextMtgDt=dtarry[0];
  dif=today - nextMtgDt;
//alert(dif);
//alert("today is " + today + "  next meeting is " + nextMtgDt);
  while(!done && (cntr < mtgStrgs.length)) {
     if(dif>=0) {
	   cntr++;
	   nextMtgDt=dtarry[cntr]
	   //alert("next meeting date is set to: " + nextMtgDt);
	   dif=today - nextMtgDt;
	  }
	  else {
	    nextMtgDt = dtarry[cntr];
	    done=true;
	  }
  }
  if(!done) {
     document.write("<br> There are no more meetings for the " + smstrStrg  + " semester")
  }
  else {	 
	 document.write("The next BASA meeting is on: ");
	 document.write("<FONT COLOR=\"red\">")
	 document.write(weekday[nextMtgDt.getDay()] + " ")
	 document.write(monthname[nextMtgDt.getMonth()] + " ")
	 document.write(nextMtgDt.getDate() + ", ")
	 document.write(nextMtgDt.getFullYear())
	 document.write("</FONT>")
   }
}

function isNextMeeting(testdate){
  
  var done=false;
  var cntr=0;
  var nextMtgDt=dtarry[0];
  dif=today - nextMtgDt;
//alert(dif);
//alert("today is " + today + "  next meeting is " + nextMtgDt);
  while(!done && (cntr < mtgStrgs.length)) {
     if(dif>=0) {
	   cntr++;
	   nextMtgDt=dtarry[cntr]
	   //alert("next meeting date is set to: " + nextMtgDt);
	   dif=today - nextMtgDt;
	  }
	  else {
	    nextMtgDt = dtarry[cntr];
	    done=true;
	  }
  }
  if(!done) {
    return false;
  }
  else {	
         //alert("nextmtgdt = " + nextMtgDt  + " testdate = " + testdate );
         if( (nextMtgDt-testdate) ==0){
		return true;
	}
	else {
		return false;
	}	
	}
}


//the next4 is for pictures.html
//All four variables below have to be updated to new set of pictures
//pictureLinkNum is for the location of the picture link so it can be updated dynamically
//starts from the left when making the links and displaying the pictures
var foldernames = new Array("pictures/mtg1_spg03/","pictures/talentshow02/","pictures/2001/");
var folderlnknames = new Array("1st Spring Meeting","Talent Show","2001 Pictures");
var foldersizes = new Array(44,80,41); //basically the last number displayed plus 1
var pictureLinkNum = 15;
	   
	   
       var findexmain=0;
       //variables for processing the pictures
       var which=0;
       var photos=new Array();
      //alert(foldernames[findex])
	   
       function setupCurrent(findex) {
		    findexmain=findex;
	  		var total=foldersizes[findex];
	  		var ftext=foldernames[findex]
			photos=new Array()

	  		for(i=0;i<total;i++) {
	       		if(i<10){
	      			photos[i] = ftext + "0" + i +".jpg";
	       		}
	      		else{
	     			photos[i] = ftext +i+ ".jpg";
       	      	}
	  		}
		}
		//picks which folder will be displayed by defolt from the foldernames array
        setupCurrent(0);
	//forward and backward functions
	 function backward(){
		if (which>0){
	  	  window.status=''
		  which--
		  document.images.photoslider.src=photos[which]
		  //alert(document.links);
		  document.links[pictureLinkNum].href = photos[which]
	    }
      }
	  function forward(){
		if (which<photos.length-1){
	      which++
	      document.images.photoslider.src=photos[which]
	      document.links[pictureLinkNum].href = photos[which]
		  //alert(document.links[14].href)
		  
		  //alert(document.links[9])
	    }
	    else{ 
	  	  window.status='End of gallery'
	    }
	  }
	  //alert(document.links[9].href)

//Prints out a table of meetings for the semester with the past meetings crossed out
function meetingTable() {
	 //this script creates the table of meeting dates
	 //and otputs that there are no more meetings for the specific semester
	 
	 
	 //Flag to see if there are any more meetings
	 var lastMtgFlag =(  (dtarry[ dtarry.length - 1 ] - today) > 0 ) ? false:true;
	 //if the last meeting has past then just print that there are no more meetings for this semester
	 // and that the new meeting dates will be posted soon
	 //alert(lastMtgFlag);
	 if(  lastMtgFlag) {
		var totStrg = '<center><FONT COLOR=\"red\" style="FONT-SIZE: 11pt">' 
		totStrg += 'There are no more meeting dates for the ' + smstrStrg + ' Semester. <br>'
		totStrg +='The new meeting dates will be posted as soon as possible' + '</FONT><br></center><br>'
	    document.write(totStrg)
	 }
	 else {
	 	//we can proceed with printing the table of meeting dates
	 	document.write('<DIV align=center><CENTER>')
		document.write('<TABLE border=0 borderColor=#111111 cellPadding=0 cellSpacing=0 id=AutoNumber2 style="BORDER-COLLAPSE: collapse" width="43%">')
		 
		  
	 	var twoElmntCntr = 0;

	 	for(i=0;i<dtarry.length;i++) {
      		var dy=dtarry[i].getDay();
			var mth=dtarry[i].getMonth();
			var datestring =  monthname[ mth ] + " "  + dtarry[i].getDate();
			//alert( weekday[ dy ] + " " + monthname[ mth ] + " "  + dtarry[i].getDate() + " , " + dtarry[i].getYear() + " " );
			//alert(datestring);
				 
			var beforeStrg = '<TD width="47%"><P align=center><FONT color=#0000cc style="FONT-SIZE: 12pt">'
			var strkBfrStrg   ='<strike>'
			var strkAftrStrg  = '</strike>'
			var afterStrg  = '</FONT></P></TD>'
			var strkFlag = false;
			var tmpDate=dtarry[i];
			var isNextMeetingDate=isNextMeeting(dtarry[i]);
			var colorString = (isNextMeetingDate) ? "color=\"red\"": 'color =#0000cc ';
			//alert( datestring + " " + isNextMeetingDate);
			//alert( datestring  + " is it a past meeting day ?  " + (tmpDate - today) )
			if( (tmpDate - today) < 0 ) {
		 		strkFlag = true;
			}
			//table formating conditions
			switch (twoElmntCntr)
			{
		 		case 0:
					beforeStrg = '<TD width="47%"><P align=center><FONT ' + colorString + ' style="FONT-SIZE: 12pt">'
					twoElmntCntr++;
					break;
				case 1:
					beforeStrg='<TD width="47%"><P align=center><FONT ' + colorString + ' style="FONT-SIZE: 12pt">'
					afterStrg ='</FONT></P></TD></TR>'
					twoElmntCntr--;
					break;
		 	}
					
		 	//start constructing the string	
		 	var tableEntry = beforeStrg;
		 	if (strkFlag) {
		 		tableEntry += strkBfrStrg;
				tableEntry += datestring;
				tableEntry += strkAftrStrg;
				tableEntry += afterStrg;
		 	}
		 	else {
				tableEntry += datestring;
				tableEntry += afterStrg;
			}
		 	//alert(tableEntry);
		 	document.write( tableEntry);
		 
	   	}
	   	document.write('</table></DIV>');
	}//closes the else case
	

}
	  
