Date.prototype.getDiff = function(date, interval){
  if (typeof date == "string"){
     date = new Date(date);
  }
  if (isNaN(date) || !(date instanceof Date)){
     return NaN; //invalid date passed
  }
  if (typeof interval == "undefined") interval = "ms"; //msec (default)
  var diff = this - date; //alert(this+' - '+date+" = "+diff)//diff in msec
  switch(interval.toLowerCase()){
    case "s": //sec
      diff = diff/1000; break;
    case "n": //min
      diff = diff/(1000*60); break;
    case "h": //hr
      diff = diff/(1000*60*60); break;
    case "d": //day
      diff = diff/(1000*60*60*24); break;
    case "m": //month
      diff = diff/(1000*60*60*24*30); break;
    case "y": //year
      diff = diff/(1000*60*60*24*365); break;
    default:
      ; //msec
  }
  return Math.floor(diff);
}


function getBdayList(numDays){
  var bday,temp,idx,diff;
  var today = new Date();
  var bdayList = new Array();  
  for (var i=0;i<arrBday.length;i++){
    bday = new Date(arrBday[i][1]);
    if (isNaN(bday)) continue;
    temp = new Date(today.getFullYear(), bday.getMonth(), bday.getDate(), 23, 59, 59, 999);
    diff = temp.getDiff(today, "d");
    if (diff >= 0 && diff <= numDays){
       idx = bdayList.length;
       bdayList[idx] = new Object();
       bdayList[idx].name = arrBday[i][0];
       bdayList[idx].bday = arrBday[i][1];
       bdayList[idx].age = today.getDiff(bday, "y");       
       if (diff > 0) bdayList[idx].age = bdayList[idx].age + 1;
       bdayList[idx].today = (diff == 0) ? true : false;
       bdayList[idx].site = arrBday[i][2];
	          bdayList[idx].end = arrBday[i][3];
			  bdayList[idx].an = arrBday[i][4];	          
			  bdayList[idx].text = arrBday[i][5];
			  bdayList[idx].data= arrBday[i][6];
    }
  }
  return bdayList;    
}

function displayBdayList(){
  var bdayList = getBdayList(0);
  var len = bdayList.length;
  var s1 = ""; //today's bday list
  var s2 = ""; //next  day
  if (len>0){
    for (var i=0; i<len; i++){
       if (bdayList[i].today){
          if (s1 != ""){
             s1 += ' ' + bdayList[i].an + ' <a href="' + bdayList[i].site + '"target="_blank">' + bdayList[i].name + '</a> ' + bdayList[i].text + ' ' + bdayList[i].age + ' ' + bdayList[i].end + ' <br>';
          }
          else{
             s1 = '<span class="cherry_11_bold">Calendar ' + bdayList[i].data + ' <br></span>' + bdayList[i].an + ' <a href="' + bdayList[i].site + ' "target="_blank">' + bdayList[i].name + '</a> ' + bdayList[i].text + ' ' + bdayList[i].age + ' ' + bdayList[i].end + ' <br>';
 }  
       }
       else{
          if (s2 != ""){
             s2 += ' ' + bdayList[i].an + ' <a href="' + bdayList[i].site + ' "target="_blank">' + bdayList[i].name + '</a> ' + bdayList[i].text + ' ' + bdayList[i].age + ' ' + bdayList[i].end + ' <br>';
          }
          else{
             s2 = '<span class="cherry_11_bold">Calendar ' + bdayList[i].data + ' <br></span>' + bdayList[i].an + ' <a href="' + bdayList[i].site + ' "target="_blank">' + bdayList[i].name + '</a> ' + bdayList[i].text + ' ' + bdayList[i].age + ' ' + bdayList[i].end + ' <br>';
 }  
       }
     }
  }
  else{
    s1 = '  Nici un eveniment important nu a avut loc astazi ' ;
  }
  
  
  document.write('<span class="cherry_11">' + s1 + '</span><span class="cherry_11">' + s2 + '</span>');
}