﻿Ext.namespace('Vt.Templates');

Vt.Templates.rlListModel =
'<tpl for="{0}">' +
'	{[xindex === 1 ? "<div class=\'vt-list-tipologia\'>{1}</div>" : ""]}' +
'	<hr style=\"color:lightgray\" />' +
'	{2}' +
'	<br  style="clear:both;" />' +
'</tpl>'
;

Vt.Templates.rlRistorante =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div id="item-{ID}" class="item-selector" ><a href="/Ristoranti/Details/{ID}">{Denominazione}</a></div>' +
'	<div class="">{[values.Indirizzo || ""]} - {[values.CAP || ""]}' +
'		{[values.Localita ? ", Loc. " + values.Localita: ""]}' +
'		{[values.Telefono ? ", Tel. " + values.Telefono: ""]}' +
'		{[values.Fax ? ", Tel. " + values.Fax: ""]}' +
'		{[values.IsConfirmed ? "" : "&nbsp;<img src=\'/Content/MapIcons/balls/red.png\' align=\'middle\'>"]}' +
'	</div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.rlBottega =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div id="item-{ID}" class="item-selector" ><a href="/Botteghe/Details/{ID}">{Denominazione}</a></div>' +
'	<div class="">{[values.Indirizzo || ""]} - {[values.CAP || ""]}' +
'		{[values.Localita ? ", Loc. " + values.Localita: ""]}' +
'		{[values.Telefono ? ", Tel. " + values.Telefono: ""]}' +
'		{[values.Fax ? ", Tel. " + values.Fax: ""]}' +
'	</div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.rlSagra =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div style="font-weight:bold;color: #950E28;" class="vt-date" >{[this.dateInterval(values)]}</div>' +
'	<div id="item-{ID}" class="vt-denominazione" ><a href="/Sagre/Details/{ID}">{Denominazione}</a></div>' +
'	<div class="vt-indirizzo">{[values.Indirizzo || ""]} - {[values.CAP || ""]}' +
'		{[values.Localita ? ", Loc. " + values.Localita: ""]}' +
'		{[values.Telefono ? ", Tel. " + values.Telefono: ""]}' +
'		{[values.Fax ? ", Tel. " + values.Fax: ""]}' +
'	</div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.rlManifestazione =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div style="font-weight:bold;color: #950E28;" class="item-selector" >{[this.dateInterval(values)]}</div>' +
'	<div id="item-{ID}" class="item-selector" ><a href="/Manifestazioni/Details/{ID}">{Denominazione}</a></div>' +
'	<div class="">{[values.Indirizzo || ""]} - {[values.CAP || ""]}' +
'		{[values.Localita ? ", Loc. " + values.Localita: ""]}' +
'		{[values.Telefono ? ", Tel. " + values.Telefono: ""]}' +
'		{[values.Fax ? ", Tel. " + values.Fax: ""]}' +
'	</div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.rlAmbulante =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div id="item-{ID}" class="item-selector" ><a href="/Ambulanti/Details/{ID}">{Denominazione}</a></div>' +
'	<div class="">{[values.Indirizzo || ""]} - {[values.CAP || ""]}' +
'		{[values.Localita ? ", Loc. " + values.Localita: ""]}' +
'		{[values.Telefono ? ", Tel. " + values.Telefono: ""]}' +
'		{[values.Fax ? ", Tel. " + values.Fax: ""]}' +
'	</div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.rlStorico =
'{[ values.Latitude !== 0 || values.Longitude !== 0 ? "<a href=\'#map-panel\' ><img src=\'/Content/Images/mappa_toscana30.jpg\' style=\'float:left;\' title=\'Lat: " + values.Latitude + " Long: " + values.Longitude + "\' /></a>" : ""]}' +
'<div style="float:left;margin-left: 1em;">' +
'	<div id="item-{ID}" class="item-selector" ><a href="/Storici/Details/{ID}">{Localita}</a></div>' +
'	<tpl if="this.exists(Email)">' +
'		<div><a href="mailto:{Email}">{Email}</a></div>' +
'	</tpl>' +
'	<tpl if="this.exists(Web)">' +
'		<div><a href="http://{Web}" target="_blank">{Web}</a></div>' +
'	</tpl>' +
'</div>';

Vt.Templates.ResultList = new Ext.XTemplate('<div class="vt-result-list">' +
'<tpl for=".">' +
'	<div class="vtt-restaurants-subtitle" style=""><img src="/Content/Images/Items/{ProvinciaID}.gif" alt=""><b>{Nome} e Provincia</b></div>' +
'	<tpl for="Comuni">' +
'		<div class="vt-list-comune">{Nome}</div>' +
String.format(Vt.Templates.rlListModel, 'Ristoranti', 'Ristoranti', Vt.Templates.rlRistorante) +
String.format(Vt.Templates.rlListModel, 'Botteghe', 'Botteghe', Vt.Templates.rlBottega) +
String.format(Vt.Templates.rlListModel, 'Sagre', 'Sagre e Fiere', Vt.Templates.rlSagra) +
String.format(Vt.Templates.rlListModel, 'Manifestazioni', 'Manifestazioni Fieristiche', Vt.Templates.rlManifestazione) +
String.format(Vt.Templates.rlListModel, 'Ambulanti', 'Mercati Ambulanti', Vt.Templates.rlAmbulante) +
String.format(Vt.Templates.rlListModel, 'Storici', 'Commercio Storico', Vt.Templates.rlStorico) +
'		<br />' +
'	</tpl>' +
'	<br />' +
'</tpl>' +
'</div>', {
	exists: function(o){
		return typeof o != 'undefined' && o != null && o != '';
	},
	dateInterval: function(values){
		if (values.StartDate.valueOf() === values.EndDate.valueOf()){
			return values.StartDate.format('d/m/Y');
		}
		else{
			return values.StartDate.format('d/m/Y') + '<span class="vt-date-end"> &gt; ' + values.EndDate.format('d/m/Y') + '</span>';
		}
	}
}
).compile();

