/*
  General functions
  made by Claudiu (claudiuj@gmail.com)
*/

/*
 TODO: here are 3 functions that make the same thing
 make a general function and replace the old versions
*/

function get_crt_date()
{
  var now = new Date();

  var month = now.getMonth();
  var day = now.getDate();
  var year = now.getYear();

  month = user_friendly_month(month);
  if (year < 2000)
    year = year + 1900;

  return " " + month + " " + day + ", " + year;
}


function get_diploma_date()
{
	var now = new Date();

  var month = now.getMonth();
  var day = now.getDate();
  var year = now.getYear();

  month = user_friendly_month(month);
  if (year < 2000)
    year = year + 1900;

  return " " + day + " " + month + " " + year;	
}

function user_friendly_month(month)
{
  if (month == '' || month < 0 || month > 11)
    return '';

  var month_label = new Object();

  month_label[0] = "Ianuarie";
  month_label[1] = "Februarie";
  month_label[2] = "Martie";
  month_label[3] = "Aprilie";
  month_label[4] = "Mai";
  month_label[5] = "Iunie";
  month_label[6] = "Iulie";
  month_label[7] = "August";
  month_label[8] = "Septembrie";
  month_label[9] = "Octombrie";
  month_label[10] = "Noiembrie";
  month_label[11] = "Decembrie";

  if (typeof(month_label[month]) == 'undefined')
    return '';

  return month_label[month];
}

	function MakeArray(n) {
		this.length = n
    return this
	}

function customDateString() {
		
		monthNames = new MakeArray(12)
		monthNames[1] = "Ianuarie"
		monthNames[2] = "Februarie"
		monthNames[3] = "Martie"
		monthNames[4] = "Aprilie"
		monthNames[5] = "Mai"
		monthNames[6] = "Iunie"
		monthNames[7] = "Iulie"
		monthNames[8] = "August"
		monthNames[9] = "Septembrie"
		monthNames[10] = "Octombrie"
		monthNames[11] = "Noiembrie"
		monthNames[12] = "Decembrie"
		
		dayNames = new MakeArray(7)
		dayNames[1] = "Duminica"
		dayNames[2] = "Luni"
		dayNames[3] = "Marti"
		dayNames[4] = "Miercuri"
		dayNames[5] = "Joi"
		dayNames[6] = "Vineri"
		dayNames[7] = "Sambata"
    
		currentDate = new Date()
    var theDay = dayNames[currentDate.getDay() + 1]
    var theMonth = monthNames[currentDate.getMonth() + 1]
    msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
    if (msie4) {
			var theYear = currentDate.getYear()
    }
    else {
    	var theYear = currentDate.getYear() +1900
    }
    return theDay + " " + currentDate.getDate() + " "  + theMonth + " " + theYear
	}
