/* 	Funzione di conversione della data. Value = 0 significa formato Inglese, 1 formato Italiano. 
	date deve essere nel formato mm-gg-aaaa, mm/gg/aaaa oppure nel formato restituito dalla funzione
	Date(). */

function fDate(date, value) {
	var thisday= new Date(date)
	var iday = thisday.getDate()
	var  imonth=(thisday.getMonth()) +1
	var iyear=thisday.getYear()
	if (iday < 10) {iday = "0" + iday}	
	if (value==1)
	{
		if (imonth==1){imonth = "Gennaio"};if (imonth==2){imonth = "Febbraio"};if (imonth==3){imonth = "Marzo"}
		if (imonth==4){imonth = "Aprile"};if (imonth==5){imonth = "Maggio"};if (imonth==6){imonth = "Giugno"}
		if (imonth==7){imonth = "Luglio"};if (imonth==8){imonth = "Agosto"};if (imonth==9){imonth = "Settembre"}
		if (imonth==10){imonth = "Ottobre"};if (imonth==11){imonth = "Novembre"};if (imonth==12){imonth = "Dicembre"}
	}
	else
	{
		if (imonth==1){imonth = "January"};if (imonth==2){imonth = "February"};if (imonth==3){imonth = "March"}
		if (imonth==4){imonth = "April"};if (imonth==5){imonth = "May"};if (imonth==6){imonth = "June"}
		if (imonth==7){imonth = "July"};if (imonth==8){imonth = "August"};if (imonth==9){imonth = "September"}
		if (imonth==10){imonth = "October"};if (imonth==11){imonth = "November"};if (imonth==12){imonth = "December"}
	}
//	-----------------------------------------------------------------------
//		AGGIUNTA DEL SUFFISSO PER IL FORMATO INGLESE
		sSuff="<sup>th</sup>"
		if (iday == 01 || iday == 21 || iday == 31)
		{sSuff="<sup>st</sup>"}
		if (iday == 02 || iday == 22)
		{sSuff="<sup>nd</sup>"}
		if (iday == 03 || iday == 23)
		{sSuff="<sup>rd</sup>"}
//	-----------------------------------------------------------------------
	if (value == 0)
		{var result = (iday + sSuff + " " + imonth + " " + iyear)}
	else
		{var result = (iday + " " + imonth + " " + iyear)}
	return result
}

/* Funzione che ritorna il numero di giorni all'interno del mese */
function fGetDays(imonth,iyear){
	imonth = imonth - 1
	var data = new Date(iyear,imonth,01,00,00,00,00)
	var i
	for(i=1;i<=32;i++){
		data = new Date(iyear,imonth,i,00,00,00,00)
		if (data.getMonth() != imonth){
			var i=i-1
			return i
		}
	}
}