// Constants Declaration
// Global Now() function
function Now() {return new Date();}

// Global Constants
var JANUARY   = 0;
var FEBRUARY  = 1;
var MARCH     = 2;
var APRIL     = 3;
var MAY       = 4;
var JUNE      = 5;
var JULY      = 6;
var AUGUST    = 7;
var SEPTEMBER = 8;
var OCTOBER   = 9;
var NOVEMBER  = 10;
var DECEMBER  = 11;

var SUNDAY    = 0;
var MONDAY    = 1;
var TUESDAY   = 2;
var WEDNESDAY = 3;
var THURSDAY  = 4;
var FRIDAY    = 5;
var SATURDAY  = 6;

// Conversion factors as varants to eliminate all the multiplication
var SECONDS_CF     = 1000;
var MINUTES_CF     = 60000;          // 60 * 1000
var HOURS_CF       = 3600000;        // 60 * 60 * 1000
var DAYS_CF        = 86400000;       // 24 * 60 * 60 * 1000
var WEEKS_CF       = 604800000;      // 7 * 24 * 60 * 60 * 1000
var FORTNIGHTS_CF  = 1209600000;     // 14 * 24 * 60 * 60 * 1000
var MONTHS_CF      = 2592000000;     // 30 * 24 * 60 * 60 * 1000  (approx = 1 month)
var QUARTERS_CF    = 7776000000;     // 90 * 24 * 60 * 60 * 1000  (approx = 3 months)
var YEARS_CF       = 31557600000;    // 365 * 24 * 60 * 60 * 1000 (approx = 1 year)
var DECADES_CF     = 315576000000;   // 10 * 365 * 24 * 60 * 60 * 1000 (approx = 1 decade)
var CENTURIES_CF   = 3155760000000;  // 100 * 365 * 24 * 60 * 60 * 1000 (approx = 1 century)

// DateTime Extensions
Date.prototype.getMonthName = function() {

	var blnCustomResourceDefined = false;
	var MyResourceManager;
	
	if(arguments[1]){ 
		blnCustomResourceDefined = true;
		MyResourceManager = arguments[1];
	}
		
	var index = (0 == arguments.length) ? this.getMonth() : arguments[0];
	
	switch(index)
	{
		case JANUARY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("January")  :  "January";
	    case FEBRUARY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("February")  :  "February";
	    case MARCH:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("March") : "March";
	    case APRIL:  
	    	return blnCustomResourceDefined ? MyResourceManager.GetString("April") : "April";
	    case MAY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("May") : "May";	    
	    case JUNE:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("June") : "June";	    
	    case JULY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("July") : "July";	    
	    case AUGUST:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("August") : "August";	    
		case SEPTEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("September") : "September";		
		case OCTOBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("October") : "October";		
		case NOVEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("November") : "November";		
		case DECEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("December") : "December";		
		default:
			throw "Invalid month index: " + index.toString();
  }
}
Date.prototype.getMonthAbbreviation = function() {

	var blnCustomResourceDefined = false;
	var MyResourceManager;

	if(arguments[1]){ 
		blnCustomResourceDefined = true;
		MyResourceManager = arguments[1];
	}

	var index = (0 == arguments.length) ? this.getMonth() : arguments[0];
	switch(index)
	{
    case JANUARY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("January").substring(0,3) : "Jan";
	    case FEBRUARY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("February").substring(0,3) : "Feb";
	    case MARCH:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("March").substring(0,3) : "Mar";
	    case APRIL:  
	    	return blnCustomResourceDefined ? MyResourceManager.GetString("April").substring(0,3) : "Apr";
	    case MAY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("May").substring(0,3) : "May";	    
	    case JUNE:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("June").substring(0,3) : "Jun";	    
	    case JULY:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("July").substring(0,3) : "Jul";	    
	    case AUGUST:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("August").substring(0,3) : "Aug";	    
		case SEPTEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("September").substring(0,3) : "Sep";		
		case OCTOBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("October").substring(0,3) : "Oct";		
		case NOVEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("November").substring(0,3) : "Nov";		
		case DECEMBER:  
			return blnCustomResourceDefined ? MyResourceManager.GetString("December").substring(0,3) : "Dec";
    default:
      throw "Invalid month index: " + index.toString();
  }
}
Date.prototype.getDayName = function() {

	var blnCustomResourceDefined = false;
	var MyResourceManager;

	if(arguments[1]){ 
		blnCustomResourceDefined = true;
		MyResourceManager = arguments[1];
	}

	  var index = (0 == arguments.length) ? this.getDay() : arguments[0];
	switch(index)
	{
	case SUNDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Sunday") : "Sunday";
    case MONDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Monday") : "Monday";    
    case TUESDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Tuesday") : "Tuesday";    
    case WEDNESDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Wednesday") : "Wednesday";    
    case THURSDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Thursday") : "Thursday";    
    case FRIDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Friday") : "Friday";    
    case SATURDAY: 
		return blnCustomResourceDefined ? MyResourceManager.GetString("Saturday") : "Saturday";    
    default:
      throw "Invalid day index: " + index.toString();
  }
}
Date.prototype.getDayAbbreviation = function() {

	var blnCustomResourceDefined = false;
	var MyResourceManager;

	if(arguments[1]){ 
		blnCustomResourceDefined = true;
		MyResourceManager = arguments[1];
	}

	var index = (0 == arguments.length) ? this.getDay() : arguments[0];
	switch(index)
	{
    case SUNDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Sunday").substring(0,3) : "Sun";
    case MONDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Monday").substring(0,3) : "Mon";
    case TUESDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Tuesday").substring(0,3) : "Tue";
    case WEDNESDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Wednesday").substring(0,3) : "Wed";
    case THURSDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Thursday").substring(0,3) : "Thu";
    case FRIDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Friday").substring(0,3) : "Fri";
    case SATURDAY: 
      return blnCustomResourceDefined ? MyResourceManager.GetString("Saturday").substring(0,3) : "Sat";
    default:
      throw "Invalid day index: " + index.toString();
  }
}

Date.prototype.getCivilianHours = function() {
  return (this.getHours() < 12) ? this.getHours() : this.getHours() - 12;
}
Date.prototype.getMeridiem = function() {
  return (this.getHours() < 12) ? "AM" : "PM";
}
Date.prototype.to_s = Date.prototype.toString;

/* 
    Ultra-flexible date formatting

    %YYYY = 4 digit year         (2005)
    %YY   = 2 digit year         (05)
    %MMMM = Month name           (March)
    %MMM  = Month abbreviation   (March becomes Mar)
    %MM   = 2 digit month number (March becomes 03)
    %M    = 1 or 2 digit month   (March becomes 3)
    %DDDD = Day name             (Thursday)
    %DDD  = Day abbreviation     (Thu)
    %DD   = 2 digit day          (09) 
    %D    = 1 or 2 digit day     (9)
    %HH   = 2 digit 24 hour      (13)
    %H    = 1 or 2 digit 24 hour (9)
    %hh   = 2 digit 12 Hour      (01)
    %h    = 1 or 2 digit 12 Hour (01)
    %mm   = 2 digit minute       (02)
    %m    = 1 or 2 digit minute  (2)
    %ss   = 2 digit second       (59)
    %s    = 1 or 2 digit second  (1)
    %nnn  = milliseconds
    %p    = AM/PM indicator
*/
Date.prototype.format = function(fs, MyResourceManager) {

   fs = fs.replace(/%YYYY/, this.getFullYear().toString());
   fs = fs.replace(/%YY/, this.getFullYear().toString().substr(2,2));
   
   fs = fs.replace(/%MMMM/, this.getMonthName(this.getMonth(),MyResourceManager).toString());
   fs = fs.replace(/%MMM/,this.getMonthAbbreviation(this.getMonth(),MyResourceManager).toString());
   fs = fs.replace(/%MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : "0" + (this.getMonth() + 1).toString());
   fs = fs.replace(/%M/, (this.getMonth() + 1).toString());
   
   fs = fs.replace(/%DDDD/, this.getDayName(this.getDay(), MyResourceManager).toString());
   fs = fs.replace(/%DDD/, this.getDayAbbreviation(this.getDay(),MyResourceManager).toString());
   fs = fs.replace(/%DD/, this.getDate() > 9 ? this.getDate().toString() : "0" + this.getDate().toString());
   fs = fs.replace(/%D/, this.getDate().toString());
   
   fs = fs.replace(/%HH/, this.getHours() > 9 ? this.getHours().toString() : "0" + this.getHours().toString());
   fs = fs.replace(/%H/, this.getHours().toString());
   fs = fs.replace(/%hh/, this.getCivilianHours() > 9 ? this.getCivilianHours().toString() : "0" + this.getCivilianHours().toString());
   fs = fs.replace(/%h/, this.getCivilianHours());

   fs = fs.replace(/%mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : "0" + this.getMinutes().toString());
   fs = fs.replace(/%m/, this.getMinutes().toString());

   fs = fs.replace(/%ss/, this.getSeconds() > 9 ? this.getSeconds().toString() : "0" + this.getSeconds().toString());
   fs = fs.replace(/%s/, this.getSeconds().toString());

   fs = fs.replace(/%nnn/, this.getMilliseconds().toString());
   fs = fs.replace(/%p/, this.getMeridiem());
   return fs;
}

// Timezone Management

var objForNormalizeDate; // conterrā le informazioni per normalizzare la data dell'evento
var objForPlayingDate; // conterrā le informazioni della data in cui si disputa l'evento
var objForClient; // conterrā le informazioni per la data del client di visualizzazione
//
// oggetti di tipo TInfoData che conterranno informazioni sulle date:
var normalizedData; // conterrā le info sulla data normalizzata
var myDataDisputa; // conterrā la data calcolata secondo il paese in cui si disputa l'evento
var myDataClient; // conterrā la data calcolata secondo il paese in cui si visualizza l'informazione
//
//
// oggetto che conterrā le informazioni da utilizzare per i calcoli sulle date:
function TInfoTimezone(data, biasHost, biasPlay, isDaylight, biasDaylight, strGMTInfo) {
    this.data = data;
    this.biasHost = biasHost;
    this.biasForPlay = biasPlay;
    this.isDaylight = isDaylight;
    this.biasDaylight = biasDaylight;
    this.retGMTString = strGMTInfo;
}
//
// oggetto che contiene le informazioni sulla data:
function TInfoData(data, GMT) {
    this.data = data;
    this.stringGMT = GMT;
}
//
// restituisce la data dell'evento in cui si disputa lo stesso; quindi con GMT applicato
function getGMTCalculatedDate(infoOnTimezone) {
    var biasDiff = 0, isDiffNegative = 0, UTC_elapsed = 0;                
    var dataEventoElapsed = new Number(infoOnTimezone.data); // rappresentazione numerica della data
    var ore = 0, min = 0, retGMT = new String(" (GMT");
    var tmpGMTString;
        
    if (infoOnTimezone.isDaylight == 1)
        infoOnTimezone.biasHost += infoOnTimezone.biasDaylight;
    biasDiff = infoOnTimezone.biasForPlay - infoOnTimezone.biasHost;
    isDiffNegative = String(biasDiff).indexOf("-");
    UTC_elapsed = Math.abs(biasDiff) * 60 * 1000; // trasforma in millisecondi
    //
    // aggiunta o sottrazione dei millesecondi in base al formato UTC:
    if (isDiffNegative == 0) // si tratta di negativo
        dataEventoElapsed += UTC_elapsed;
    else
        dataEventoElapsed -= UTC_elapsed;                
    //
    // crea stringa per la visualizzazione del GMT:
    tmpGMTString = new String(infoOnTimezone.retGMTString);
    if (tmpGMTString.length > 0) 
        retGMT = infoOnTimezone.retGMTString;
    else {
        ore = Math.floor(Math.abs(biasDiff) / 60);
        min = Math.floor(Math.abs(biasDiff) % 60);
        if (ore <= 9) ore = "0" + ore;
        if (min <= 9) min = "0" + min;                                
        var tmp = new String(new Date(infoOnTimezone.data).getTimezoneOffset());        
        if (ore != 0 || min != 0) {
            retGMT += (tmp.indexOf("-") == 0) ? " +" : " -";             
            retGMT += ore;
            if (Number(min) != 0)
				retGMT += ":" + min;
        }
        retGMT += ")";
    }                                
    return (new TInfoData(new Date(dataEventoElapsed), retGMT)); // crea la nuova data
}

// prende una data e restituisce una stringa che rappresenta la stessa informazione eliminando quelle del giorno corrente.
// es: se le date hanno lo stesso giorno,mese ed anno, verrā visualizzata solo l'ora, minuti e secondi.
function getRelativeDate(dataEvento, dataUtente) {
    var tmpDate = new Date(dataEvento);
    var today = new Date(dataUtente);
    var retString = new String("");                
    var eventTime = (tmpDate.getHours() < 10 ? "0" + tmpDate.getHours() : tmpDate.getHours()) + ":" + 
					(tmpDate.getMinutes() < 10 ? "0" + tmpDate.getMinutes() : tmpDate.getMinutes());// + ":" + 
					//(tmpDate.getSeconds() < 10 ? "0" + tmpDate.getSeconds() : tmpDate.getSeconds());
    //
    // aggiunge l'anno:
    if (tmpDate.getFullYear() == today.getFullYear() && tmpDate.getMonth() == today.getMonth() && tmpDate.getDate() == today.getDate())
        retString = eventTime;
    else if (tmpDate.getFullYear() == today.getFullYear()) 
		retString = (tmpDate.getDate() < 10 ? "0" + tmpDate.getDate() : tmpDate.getDate()) + "/" + ((tmpDate.getMonth() + 1 < 10) ? "0" + (tmpDate.getMonth() + 1) : (tmpDate.getMonth() + 1)) + " " + eventTime;	
	else 
		retString = (tmpDate.getDate() < 10 ? "0" + tmpDate.getDate() : tmpDate.getDate()) + "/" + ((tmpDate.getMonth() + 1 < 10) ? "0" + (tmpDate.getMonth() + 1) : (tmpDate.getMonth() + 1)) + "/" + tmpDate.getFullYear() + " " + eventTime;
    return (retString);
}

//
// si occupa di visualizzare la data sul client giā in GMT
//
// MODIFICATO GIANNI
// Data: 25/03/08
// valore: new Date(dateToPlaying).getTimezoneOffset()
//vecchio: new Date().getTimezoneOffset()
function getClientGMTDate(dateToPlaying) {
	var objForClient = new TInfoTimezone(normalizedData.data, 0, new Date(dateToPlaying).getTimezoneOffset(), 0, 0, ""); // oggetto da utilizzare per il calcolo della data sul client
	
	myDataClient = getGMTCalculatedDate(objForClient);	// calcola la data
	window.document.write(getRelativeDate(myDataClient.data, new Date()));
}

//
// funzione da richiamare come primaria perchč esegue tutte le inizializzazioni:
function initAndDisplayInfo(clientIdToolTip, dateToNormalize, biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize,
							dateToPlaying, biasHostToPlaying, biasPlayToPlaying, isDayligthToPlaying, biasDaylightToPlaying, descToPlaying) {
	//
	// inizializza gli oggetti:
	objForNormalizeDate = new TInfoTimezone(new Date(dateToNormalize), biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize);
	objForPlayingDate = new TInfoTimezone(new Date(dateToPlaying), biasHostToPlaying, biasPlayToPlaying, isDayligthToPlaying, biasDaylightToPlaying, descToPlaying);
	normalizedData = getGMTCalculatedDate(objForNormalizeDate); 
	objForPlayingDate.data = normalizedData.data; 
	myDataDisputa = getGMTCalculatedDate(objForPlayingDate);
	if (Number(objForNormalizeDate.data) != Number(myDataDisputa.data) && (clientIdToolTip != "undefined" || clientIdToolTip != ""))
	   window.document.getElementById(clientIdToolTip).title =  getRelativeDate(myDataDisputa.data, new Date()) + '' + myDataDisputa.stringGMT; 
	   //myDataDisputa.data.toLocaleString() + myDataDisputa.stringGMT;	
	getClientGMTDate(dateToNormalize);	
}

//
// funzione da richiamare come primaria perchč esegue tutte le inizializzazioni:
function initAndDisplayInfoClient(clientIdToolTip, dateToNormalize, biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize, infoDisplay)
{
	//
	// inizializza gli oggetti:
	objForNormalizeDate = new TInfoTimezone(new Date(dateToNormalize), biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize);
	normalizedData = getGMTCalculatedDate(objForNormalizeDate); 
// MODIFICATO GIANNI
// Data: 25/03/08
// valore: new Date(dateToNormalize).getTimezoneOffset()
//vecchio: new Date().getTimezoneOffset()	
	var objForClient = new TInfoTimezone(normalizedData.data, 0, new Date(dateToNormalize).getTimezoneOffset(), 0, 0, ""); // oggetto da utilizzare per il calcolo della data sul client	
	
	myDataClient = getGMTCalculatedDate(objForClient);	// calcola la data	
		
	//window.document.write(getShortDateTime(new Date(myDataClient.data))); // + " " + myDataClient.stringGMT);
	window.document.write(getFilledShortDate(new Date(myDataClient.data), false, false));
	/* 
	if (typeof infoDisplay == "undefined") {
		if (Number(objForNormalizeDate.data) != Number(myDataClient.data) && (typeof clientIdToolTip != "undefined" || clientIdToolTip != ""))
			window.document.getElementById(clientIdToolTip).title = getRelativeDate(dateToNormalize, new Date()) + normalizedData.stringGMT;
		window.document.write(getShortDateTime(new Date(myDataClient.data))); // + " " + myDataClient.stringGMT);
	}	
	 else {
		if (Number(objForNormalizeDate.data) != Number(myDataClient.data))
			window.document.write(" <u>" + getRelativeDate(myDataClient.data, new Date()) + "</u>&nbsp;" + getShortDateTime(new Date(dateToNormalize)) + " " + normalizedData.stringGMT);
		else
			window.document.write(getShortDateTime(new Date(dateToNormalize)) + "&nbsp;" + normalizedData.stringGMT);
	}
	*/
}

/*
  Same as initAndDisplayInfoClient with the exception of the last parameter: 
  formatType	->	0 - dateandtime | 1 - only date in numeric format (eg. 13/05/07)	| 2	-	only date in compact description (eg. 13 MAG 07) | 3 - only hour 
*/
function initAndDisplayInfoClientExtended(dateToNormalize, biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize, formatType)
{
	//
	// inizializza gli oggetti:
	objForNormalizeDate = new TInfoTimezone(new Date(dateToNormalize), biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize);
	normalizedData = getGMTCalculatedDate(objForNormalizeDate); 
// MODIFICATO GIANNI
// Data: 25/03/08
// valore: new Date(dateToNormalize).getTimezoneOffset()
//vecchio: new Date().getTimezoneOffset()	
	var objForClient = new TInfoTimezone(normalizedData.data, 0, new Date(dateToNormalize).getTimezoneOffset(), 0, 0, ""); // oggetto da utilizzare per il calcolo della data sul client	
	
	myDataClient = getGMTCalculatedDate(objForClient);	// calcola la data	
	window.document.write(myDataClient.data.format(formatType));
	
	return;
}

function initAndDisplayInfoClientSearch(clientIdToolTip, dateToNormalize, biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize, infoDisplay)
{
	//
	// inizializza gli oggetti:
	objForNormalizeDate = new TInfoTimezone(new Date(dateToNormalize), biasHostToNormalize, biasPlayToNormalize, isDayligthToNormalize, biasDaylightToNormalize, descToNormalize);
	normalizedData = getGMTCalculatedDate(objForNormalizeDate); 
	var objForClient = new TInfoTimezone(normalizedData.data, 0, new Date(dateToNormalize).getTimezoneOffset(), 0, 0, ""); // oggetto da utilizzare per il calcolo della data sul client	
	myDataClient = getGMTCalculatedDate(objForClient);	// calcola la data	
	
	//window.document.write(getShortDateTime(new Date(myDataClient.data))); // + " " + myDataClient.stringGMT);
	window.document.write(getFilledShortDate(new Date(myDataClient.data), false, false));
	/*
	if (typeof infoDisplay == "undefined") {
		if (Number(objForNormalizeDate.data) != Number(myDataClient.data) && (typeof clientIdToolTip != "undefined" || clientIdToolTip != ""))
			window.document.getElementById(clientIdToolTip).title = getRelativeDate(dateToNormalize, new Date()) + normalizedData.stringGMT;
		window.document.write(getShortDateTime(new Date(myDataClient.data))); // + " " + myDataClient.stringGMT);
	} 	
	else {
		if (Number(objForNormalizeDate.data) != Number(myDataClient.data))
			window.document.write("<u>" + getRelativeDate(myDataClient.data, new Date()) + "</u>&nbsp;" + getShortDateTime(new Date(dateToNormalize)) + " " + normalizedData.stringGMT);
		else
			window.document.write(getShortDateTime(new Date(dateToNormalize)) + " " + normalizedData.stringGMT);
	}
	*/
}



//
// prende un parametro di tipo dd/mm/yyyy hh:mm:ss e restituisce mm/dd/yyyy hh:mm:ss
function getInvertedDate(data) {	
	var stringFormat = new String();
	var retDateString = new String();
	var firstSeparator;
	var lastSeparator;
	var timeSeparator;
	var tmpValore;
	
	stringFormat = data;
	firstSeparator = stringFormat.indexOf("/");
	lastSeparator = stringFormat.lastIndexOf("/");
	timeSeparator = stringFormat.indexOf(" ");
	tmpValore = parseInt(stringFormat.substring(0, firstSeparator), 10);
	retDateString = parseInt(stringFormat.substring(firstSeparator + 1, lastSeparator), 10) + '/' + tmpValore + '/';
	if (timeSeparator == -1) // non č presente il time
		retDateString += parseInt(stringFormat.substring(lastSeparator + 1), 10);
	else
		retDateString += parseInt(stringFormat.substring(lastSeparator + 1, timeSeparator), 10) + stringFormat.substring(timeSeparator);
	return (retDateString);
}

//
// prende una data e la restituisce come stringa in formato dd/mm/yyyy hh:mm:ss
function getShortDateTime(inputDate) {
	var data = new Date(inputDate);
	
	return (data.getDate() + '/' + (data.getMonth() + 1) + '/' + data.getFullYear() + ' ' + data.getHours() + ':' + data.getMinutes() + ':' + data.getSeconds());
}


//
// prende una data UTC e la restituisce come stringa in formato dd/mm/yyyy hh:mm:ss UTC
function getShortUTCDateTime(inputDate) {
	var data = new Date(inputDate);
	
	return (data.getUTCDate() + '/' + (data.getUTCMonth() + 1) + '/' + data.getUTCFullYear() + ' ' + data.getUTCHours() + ':' + data.getUTCMinutes() + ':' + data.getUTCSeconds());
}

// Converte la data in un formato che visualizza opzionalmente i minuti e/o i secondi
function getFilledShortDate(data, noTime, noSecond) {
	var tmpDate = new Date(data);
	var tmp;
	
	tmp = (tmpDate.getDate() < 10 ? "0" + tmpDate.getDate() : tmpDate.getDate()) + '/' +
			(tmpDate.getMonth() < 9 ? "0" + (tmpDate.getMonth() + 1) : (tmpDate.getMonth() + 1)) + '/' + tmpDate.getFullYear();	
	if (tmpDate.getHours() == 0 && tmpDate.getMinutes() == 0 && tmpDate.getSeconds() == 0)
	   return (tmp);
	if (noTime == false) {
		tmp += ' ' + (tmpDate.getHours() < 10 ? "0" + tmpDate.getHours() : tmpDate.getHours()) + ":" + 
					(tmpDate.getMinutes() < 10 ? "0" + tmpDate.getMinutes() : tmpDate.getMinutes());
		if (noSecond == false)		
			if (tmpDate.getSeconds() != 0)
				tmp += ':' + (tmpDate.getSeconds() < 10 ? "0" + tmpDate.getSeconds() : tmpDate.getSeconds());
	}
	return (tmp);
}

// Converte la data in un formato compatto senza l'indicazione dell'ora/minuti/secondi
function getShortTime(data) {

	var tmpDate = new Date(data);
	var tmp;
	
	if (tmpDate.getHours() != 0){
		
		tmp += ' ' + (tmpDate.getHours() < 10 ? "0" + tmpDate.getHours() : tmpDate.getHours()) + ":" + (tmpDate.getMinutes() < 10 ? "0" + tmpDate.getMinutes() : tmpDate.getMinutes());
		
		if (tmpDate.getSeconds() != 0)
			tmp += ':' + (tmpDate.getSeconds() < 10 ? "0" + tmpDate.getSeconds() : tmpDate.getSeconds());
	
	}else{
		tmp	='0:00';
	}
		
	return (tmp);
}

//
// effettua il calcolo del GMT sull'ora del browser passata come parametro:
function getClientGMTInfo(data) {
	var localDate = new Date(data);
	var localOffset = localDate.getTimezoneOffset();
	var ore, min, tmp;
	var retGMT = new String("(GMT ");
	
    ore = Math.floor(Math.abs(localOffset) / 60);
    min = Math.floor(Math.abs(localOffset) % 60);
	//if (ore <= 9) ore = "0" + ore;
	if (min <= 9) min = "0" + min;                                            
    tmp = new String(localOffset);        
    if (ore != 0 || min != 0) {
        retGMT += (tmp.indexOf("-") == 0) ? " +" : " -"; 
        retGMT += ore;
        if (Number(min) != 0)			
			retGMT += ":" + min;
    }
    retGMT += ")";			
    return (retGMT);
}
