//List all event dates in this array in order
var datearr = new Array('2-21-2012','3-6-2012','3-14-2012','3-20-2012','4-3-2012','4-17-2012','5-1-2012','5-15-2012','6-5-2012','6-19-2012','7-10-2012','7-24-2012','8-7-2012','8-21-2012','9-4-2012','9-18-2012','10-9-2012','10-23-2012','11-6-2012','12-4-2012','12-18-2012');

//Expired date eval function
function autoExpire(expdatestr,displaytype) {

// Set seminar name, time and link variables
var seminarname = "<h3><a href=http://www.floridahospitallapband.com/weight-loss-surgery-seminars-ormond-beach.html>LAP-BAND&reg; Info Session</a></h3>";
var seminartime = " 6:00 pm"; //Leave extra space in front of time for formatting reasons
var seminarlink = "<a href=http://www.floridahospitallapband.com/weight-loss-surgery-seminars-ormond-beach.html>More...</a></p>";

	 //Weekday Array 
	var weekday=new Array(7);
	weekday[0]="Sunday";
	weekday[1]="Monday";
	weekday[2]="Tuesday";
	weekday[3]="Wednesday";
	weekday[4]="Thursday";
	weekday[5]="Friday";
	weekday[6]="Saturday"; 

	//Month Array
	var month=new Array(12);
	month[0]="January";
	month[1]="February";
	month[2]="March";
	month[3]="April";
	month[4]="May";
	month[5]="June";
	month[6]="July";
	month[7]="August";
	month[8]="September";
	month[9]="October";
	month[10]="November";
	month[11]="December";

	//Split passed in expdatestr date variable from function
	var mySplitResult = expdatestr.split("-");
	var expireMonth =  mySplitResult[0];   // Month you want your content to stop displaying. Two digits.
	var expireDay =  mySplitResult[1];     // Day you want your content to stop displaying. Two digits.
	var expireYear =  mySplitResult[2];  // Year you want your content to stop displaying. Four digits.
  
	//Set date for analyisis in Javascript
	var d = new Date();
	d.setDate(expireDay);
	d.setMonth(expireMonth-1);
	d.setFullYear(expireYear);

	//Compile human-readable date
	var dayname = weekday[d.getUTCDay()];
	var monthname = month[d.getUTCMonth()];
	var datename = dayname + ", " + monthname + " " + expireDay  + ", " + expireYear;

  //Puts expire year, month, and day together.
  var expireDate = expireYear + expireMonth + expireDay;  // puts EXPIRE year, month, and day together.

  var nowDate = new Date();
  var day = nowDate.getUTCDate();
  var month = nowDate.getUTCMonth();
  var correctedMonth = month + 1;  //month - JavaScript starts at "0" for January, so we add "1"

  if (correctedMonth < 10) {  // if less than "10", put a "0" in front of the number.
    correctedMonth = "0" + correctedMonth;
  }
   
  if (day < 10) {  // if less than "10", put a "0" in front of the number.
    day = "0" + day;
  }

  var year = nowDate.getYear();  //Get the year. Firefox and Netscape might use century bit, and two-digit year.
  if (year < 1900) {
    year = year + 1900;  //This is to make sure Netscape AND FireFox doesn't show the year as "107" for "2007."
  }

  var GMTdate = year + "" + correctedMonth + "" + day;  //corrected month GMT date.
 
//Compare dates and write outpuit test for display types 
if ((GMTdate <= expireDate) && (displaytype == "bulletlist")){
	document.write('<li>' + datename + '</li>');
  }
  else if ((GMTdate <= expireDate) && (displaytype == "blocklist")){
	  var blockoutput = seminarname + '<p>' + datename + seminartime + '<br>' + seminarlink;
	  return blockoutput;
  }
  else if ((GMTdate <= expireDate) && (displaytype == "monthlist")){
	return monthname;
  }
  else
  {
  return "expired";
  }
  
}

var unique = function(origArr) {  
    var newArr = [],  
        origLen = origArr.length,  
        found,  
        x, y;  
  
    for ( x = 0; x < origLen; x++ ) {  
        found = undefined;  
        for ( y = 0; y < newArr.length; y++ ) {  
            if ( origArr[x] === newArr[y] ) {  
              found = true;  
              break;  
            }  
        }  
        if ( !found) newArr.push( origArr[x] );  
    }  
   return newArr;  
};
