//the bday array data can be generated from server-side
var arrBday = [
['sbcjr', '10/5'],
['Wes_Guynn', '12/21'],
['bArkLEY', '9/23'],
['Elisabeth', '3/21'],
['missfiddlestix92', '7/27'],
['Fruitiply', '4/28'],
['cds12', '8/13'],
['sbcsr', '5/1'],
['apollocreed1285', '12/6'],
['Bekah', '1/16'],
['Mrs_Corbett', '1/18'],
['Tim', '2/7'],
['nighthawk', '12/17'],
['MikeyMo', '4/1'],
['BenH', '5/11'],
['Rach', '11/9'],
['Hannah', '9/26'],
['austin31194', '3/11'],
['doob', '7/17'],
['CoachEdge', '10/12'],
['junior', '10/2'],
['Balla', '3/3'],
['djc', '4/9'],
['Kurt', '8/9'],
['its_ruth_fo', '4/26'],
['Gretsher', '11/12'],
['MMOLord', '4/20'],
['poop', '4/3'],
['CR9', '11/10'],
['Judy', '10/13'],
['Katie', '4/15'],
['Pkblonde', '1/14'],
['Delilah', '6/15'],
['Geralyn', '6/6'],
['Fang', '12/3'],
['chad', '12/20'],
['Talon', '2/23'],
['Jazz', '4/5'],
['Daniel', '9/22'],
['Statzman', '6/1'],
['Tania', '10/7'],
['Emy', '12/20'],
['Mel', '11/20'],
['MarknMary', '9/29'],
['MarknMary', '11/10'],
['kerwood', '6/12'],
['Beka', '4/2'],
['Ruthie', '11/30'],
['Lee', '2/13'],
['sandeecb', '9/3'],
['scbarton95', '3/22'],
['PastorCorbett', '5/1'],
['Tylerfallstick', '4/8'],
['B-Chick', '3/3'],
['BullDawg', '2/4'],
['yaitsthatgirl-35', '6/8'],
['megan', '7/24'],
['Wenda', '10/1'],
['Jushna', '8/8'],
['tootsie', '10/18'],
['cc529', '5/29'],
['Xythos', '11/25'],
['Ron', '2/3'],
['Kimmie', '9/11'],
['JDS', '7/29'],
['David', '4/25'],
['Abbie', '7/29'],
['LuvLadyVolz', '12/11'],
['Renee', '7/17'],
['vato17', '3/26'],
['Jan', '8/6'],
['zachary11', '9/1'],
['katie123', '9/2'],
['Amy', '12/9'],
['Taylor', '4/2'],
['joe', '2/18'],
['Waylon', '3/7'],
['Jess', '6/29'],
['RAE', '4/3'],
['Sweety09', '3/26'],
['captin', '6/30'],
['MaryAtJesusFeet', '8/16'],
['SarahJoy', '7/7'],
['Vlobos', '10/2'],
['KaleeBri408', '4/1'],
['Mike_n_Sarah', '3/16'],
['Brittany', '11/23'],
['Sam', '7/23'],
['apollosgirl', '3/15'],
['Brannon_and_Em', '3/13'],
['hanszell', '3/14'],
['Brannon_and_Em', '6/5'],
['DanielGardner', '12/9'],
['baybayrican', '10/28'],
['Jake', '6/20'],
['Trey', '11/20'],
['Mike', '1/1'],
['chris', '2/1'],
['courtney', '2/21'],
['Linda', '5/12'],
['Kate', '11/5'],
['Kayla', '5/11'],
['tripleb', '11/13'],
['nate', '9/14'],
['Scott', '7/9'],
['Jill', '7/12'],
['MissyBennett', '9/22'],
['Becci', '12/14'],
['Becci', '10/8'],
['Amykens', '9/9'],
['Celia', '6/30'],
['Carly', '5/11'],
['Danny', '1/26'],
['arth247', '10/1'],
['Dawgfan', '2/3'],
['Josh', '7/8'],
['Kerri', '4/2'],
['Korn', '3/12'],
['JenDonatella', '8/6'],
['Emily', '10/1'],
['Antepenultimate1', '12/27'],
['Trucker', '6/8'],
['Grandpa', '9/17'],
['Grandpa', '5/31'],
['1000', '4/18'],
['Anna', '8/16'],
['mmerich', '3/20'],
['ARStricklen', '5/19'],
['beebop', '12/8'],
['Jonathan', '3/16'],
['InChristAlone', '6/8'],
['EmilyS', '6/14'],
['mayjo', '10/25'],
['Bobbalina', '6/11'],
['Luke', '9/24'],
['AnnaBanana', '6/13'],
['brettnheather', '1/18'],
['brettnheather', '3/31'],
['Mandy', '6/6'],
['Panda', '11/24'],
['Roughrider', '6/28'],
['dawniedoowop', '8/29'],
['Rebecca', '12/13'],
['NaiNai', '3/18'],
['Lia', '6/5'],
['Lchristie0826', '8/26'],
['lizardking21', '10/13'],
['Jefa', '12/25'],
['Melissa', '8/4'],
['greycool', '5/24'],
['ruth_ann', '2/21'],
['sydney', '6/10'],
['susan', '7/23'],
['PopyJoe', '6/30'],
['carolyn', '4/18'],
['Gordon', '8/29'],
['Juahng', '5/31'],
['-Brunette-', '8/21'],
['bookworm', '3/23'],
['emma', '11/4'],
['txter', '11/11'],
['chadwick', '6/19'],
['Jerry', '8/2'],
['Jerry', '4/30'],
['HannahGirl', '11/3'],
['Gracie', '3/17'],
['miriam', '3/13'],
['ramsey', '10/3'],
['DJS', '5/24'],
['Abel', '7/24'],
['cindyloowhoo', '4/22'],
['Worsten', '6/12'],
['Alisa', '5/20'],
['ilovebacon55', '2/22'],
['etan', '9/21'],
['Robin', '8/7'],
['Mrs_Smith', '8/19'],
['blaster01', '10/12'],
['AmyJB', '5/24'],
['sarah', '7/16'],
['Alberto', '2/28'],
['Ben', '3/20'],
['Tiff', '6/4'],
['bagldorch', '4/8'],
['Kyndrapoo', '4/12'],
['Atrain', '1/18'],
['HazMAT', '11/30'],
['Philip', '12/7'],
['roseofsharon', '6/18'],
['JP14', '6/12'],
['Ray', '7/11'],
['Nathan', '12/10'],
['Essi', '3/18'],
['Isaac', '5/2'],
['cat', '3/26'],
['Tori', '12/17'],
['Yessi', '8/20'],
['Ohara', '1/19'],
['join', '1/8'],
['colton', '3/23'],
['Sierra', '9/11'],
['Joanna', '1/26'],
['tryston', '9/4'],
['chenee', '6/16'],
['Lisa', '8/14'],
['Tony', '2/14'],
['3982662', '10/8'],
['lleng', '4/27'],
['Mimi', '8/10'],
['LINA', '8/18'],
['Val', '3/18'],
['Jay', '1/5'],
['Est', '3/8'],
['mylovelyself', '5/11'],
['Red', '2/4'],
['nuttyone', '9/21'],
['Syd', '5/29'],
['Tilley', '10/16'],
['Tilley', '3/6'],
['Bulldog', '12/10'],
['Andrew2011', '4/29'],
['Pam', '12/5'],
['Jane', '6/11'],
['Jane', '7/8'],
['Gladys', '10/17'],
['Spurds', '5/23'],
['tosha', '8/3'],
['Kristin', '9/18'],
['Kris', '9/18'],
['Bri-Fri121', '2/13'],
['MrsM', '12/23'],
['glaucoromulo', '7/2'],
['sanglin', '1/19'],
['Ashleigh', '12/19'],
['Ashleigh', '3/29'],
['Niole', '7/16'],
['Crystalliie', '5/24'],
['MarBear', '12/21'],
['shayrach', '2/16'],
['jcjamman', '2/8'],
['jcjamman', '3/19'],
['Shell', '3/5'],
['Carebear', '8/12'],
['andrew96', '2/9'],
['Judy-K', '11/13'],
['ENH', '3/11'],
['armymomtwoboys', '11/17'],
['Zach', '1/12'],
['smee', '3/16'],
['Red', '12/17'],
['zackharyburgess99', '5/31'],
['Melanie', '9/26'],
['court', '2/26'],
['Traci', '12/11'],
['Zhawbaker', '10/14'],
['tweety', '11/16'],
['sabriabeck', '1/12'],
['Rebekah', '4/2'],
['pastortalbert', '11/22'],
['redigerstephanie', '9/7'],
['atkinson', '2/11'],
['atkinson', '4/20'],
['timskys', '2/23'],
['dcgaugler2905', '12/30'],
['shrimp', '8/2'],
['Sandee', '12/31'],
['Alyssa', '2/26'],
['Alyssa123', '2/3'],
['alyssa789', '2/10'],
['nicole', '7/16'],
['nicole', '1/21'],
['rafita', '12/26'],
['momof7', '7/21'],
['momof7', '7/15'],
['AllenP', '9/22'],
['Rachel', '4/3'],
['LauraW', '2/25'],
['Michele', '2/28'],
['Michael', '8/6'],
['JSG', '9/10'],
['harvest', '5/7'],
['Dennis', '1/5'],
['Wes', '6/10'],
['Fernando', '11/19'],
['iluvJesus', '12/1'],
['Malorious', '3/5'],
['wes_lucas', '6/10'],
['bethers1998', '1/19'],
['Gallagators', '1/19'],
['ibcdeaf10', '5/12'],
['Kaitlin', '11/5'],
['Theophilus', '8/9'],
['mmerich', '8/17'],
['navyfamily2005', '6/9'],
['navyfamily2005', '10/29'],
['air258', '4/22'],
['sir-emeth', '5/30'],
['FrankCastle', '3/4'],
['gemma46', '10/14'],
['Glen', '9/16'],
['kaix0519', '5/3'],
['campluver321', '2/26'],
['Thelifeofjesus', '12/25'],
['Bubba', '2/29'],
['amiecj', '4/15'],
['antonuccigirl', '3/26'],
['Garrett', '4/18'],
['ashleighg', '12/9'],
['ashleighg', '3/29'],
['Mario_Dayza', '7/24'],
['Mario_Dayza', '4/21'],
['Michelle', '9/9'],
['Jody', '3/21'],
['jennychi0212', '2/12'],
['Baceballfan360', '6/19'],
['Pepe', '7/29'],
['cherylhoward', '4/18'],
['cherylhoward', '7/26'],
['sun159159', '7/1'],
['iluvJesus', '2/14'],
['camplover16', '2/26'],
['applezzy', '7/15'],
['JennyLF', '2/14'],
['Jody', '2/14'],
['Shanda', '1/10'],
['Janell', '12/21'],
['Tiffany', '7/27'],
['study', '7/13'],
['godfather', '8/8'],
['Tarelle', '10/25'],
['Drama', '5/11'],
['mrsberry', '3/22'],
['Fred', '9/21'],
['samantha', '10/20'],
['kaity', '5/11'],
['christianvolume', '12/16'],
['ymlangston', '6/16'],
['ymlangston', '6/13'],
['vanessa', '9/29'],
['vanessa', '2/10'],
['emrose15', '8/13'],
['Dar', '7/3'],
['hollywolly19', '1/19'],
['JamesAmy04', '9/16'],
['JamesAmy04', '11/3'],
['jecksonandrade', '12/18'],
['Filmgirl', '2/28'],
['teriscott1', '1/13'],
['teriscott1', '4/17'],
['jedidiahbeeman', '4/2'],
['jedidiahbeeman', '4/20'],
['Bennettfamily', '9/19'],
['Debra', '6/18'],
['Debra', '6/9'],
['Corrie10', '2/20'],
['kenenell', '8/7'],
['kenenell', '6/11'],
['Lillie', '12/18'],
['babs', '6/6'],
['babs', '7/27'],
['amberm2010', '10/11'],
['Kendra', '5/30'],
['slip', '7/30'],
['DGHNMH22', '8/21'],
['1963', '5/24'],
['robemny', '10/28'],
['jgranville', '3/20'],
['proudmom', '10/21'],
['beenedudette', '11/27'],
['daughterofsarah', '6/1'],
['Sinner2Saint', '7/23'],
['kaitlyn', '5/11'],
['calligraaf', '10/22'],
['calligraaf', '1/21'],
['skyklone21', '4/24'],
['EstherRose93', '3/8'],
['Kala', '6/20'],
['JoeyandKaren', '2/18'],
['JoeyandKaren', '7/27'],
['', '/'],
];

function getBdaysThisWeek(){
var arrMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var bday, idx;
var bdayList = new Array();
var today = new Date();

for (var i=0;i<arrBday.length;i++){
var bday = new Date(arrBday[i][1] + '/' + today.getFullYear());
if (isNaN(bday)) continue;

if ( isBdayInRange(bday, 7) ){
idx = bdayList.length;
bdayList[idx] = new Object();
bdayList[idx].name = arrBday[i][0];
bdayList[idx].bday = bday;
bdayList[idx].month = arrMonth[bday.getMonth()]; 
}
}
if (bdayList.length > 0){ //sort asc by birthdate
bdayList.sort(
function(a, b){
if (a.bday < b.bday) return -1
if (a.bday > b.bday) return 1;
return 0;
}
);
}
return bdayList;
}

function isBdayInRange(bday, interval){

var today = new Date(); 
//have to override time so entire day will be valid
today.setHours(0,0,0,0);
//if the birthday has already occurred in the year, increment to the next year
if (bday < today)
bday.setFullYear(bday.getFullYear() + 1);

// get ms between dates (UTC) and make into "difference" date
var iDiffMS = bday.valueOf() - today.valueOf();
//divide iDiffMS by 1000, Seconds, Minutes, Hours
nDays = parseInt(iDiffMS / 1000 / 60 / 60 / 24);

if(parseInt(nDays) <= parseInt(interval))
return true;
else
return false;
}

function displayBdayList(){
var date = new Date().getDate();	
var bdayList = getBdaysThisWeek();
var len = bdayList.length;
var s = "";
if (len>0){
s += '<ul>';
	for (var i=0; i<len; i++){
//be mindful of the string-line continuation character (\) at the end of the first line
s += '<li style="list-style-type: none;"' + ((date == bdayList[i].bday.getDate())?' class="bdayToday"':'')+ '>\
<a href="http://fruitiply.com/' + bdayList[i].name + '"><strong>' + bdayList[i].name + '</strong></a> - ' 
+ bdayList[i].month + ' ' + bdayList[i].bday.getDate() + '</li>'; 
}
s += '</ul>';
}
else{
s += "No birthdays this week.";
}
document.write(s);
}

