/**
 * Create the marker to enable user-defined style and behaviour.
 */
function template_annuaire_createMarker(constructor, row, coords, baseurl, elus)
{
	var typeid = row.typeuid;
	if (elus == "elus"){
		var image = baseurl + 'fileadmin/templates/images/picto/icon_elus_petit.png';
		var icon = new google.maps.Icon(null, image);
		icon.iconSize = new google.maps.Size(36, 31);
		icon.iconAnchor = new google.maps.Point(14, 30);
		icon.infoWindowAnchor = new google.maps.Point(23, 5);
	}else{
		if(elus == "militant"){
			var image = baseurl + 'fileadmin/templates/images/picto/picto41.png';

			var icon = new google.maps.Icon(null, image);
			icon.iconSize = new google.maps.Size(37, 44);
			icon.shadowSize = new google.maps.Size(50, 44);
			icon.iconAnchor = new google.maps.Point(12, 40);
			icon.infoWindowAnchor = new google.maps.Point(29, 4);
			icon.maxHeight = 10;
		}else{
			if(typeid == ""){
				var image = baseurl + 'fileadmin/templates/images/picto/picto.png';
				
				var icon = new google.maps.Icon(null, image);
				icon.iconSize = new google.maps.Size(36, 28);
				icon.shadowSize = new google.maps.Size(36, 44);
				icon.iconAnchor = new google.maps.Point(12, 40);
				icon.infoWindowAnchor = new google.maps.Point(29, 4);
				icon.maxHeight = 10;
			}else{
				var image = baseurl + 'fileadmin/templates/images/picto/picto'+typeid+'.png';

				var icon = new google.maps.Icon(null, image);
				icon.iconSize = new google.maps.Size(37, 44);
				icon.shadowSize = new google.maps.Size(50, 44);
				icon.iconAnchor = new google.maps.Point(12, 40);
				icon.infoWindowAnchor = new google.maps.Point(29, 4);
				icon.maxHeight = 10;
			}
		}
	}
	var options = {};
	options.icon = icon;
	return new constructor(coords, options);
}
/**
 * Returns the description of the info window for the specified row.
 * See EXT:basecontact/res/js/bcCreateElement.js:basecontact_createElements for the
 * syntax of the object to return.
 */
function template_annuaire_getInfoWindowDescription(row, elus)
{
	/*
	 * Access to fields and available fields.
	 * - row.uid: The uid of the sheet.
	 * - row.name: The name of the sheet.
	 * - row.category: The category of the sheet.
	 * - row.type: The type of the sheet.
	 * - row.detailsUrl: The URL for details page.
	 * - row.catuid: The uid of the category.
	 * - row.typeuid: The uid of the type.
	 * - row.c.fieldname: Access to the value of the field fieldname from category.
	 * - row.t.fieldname: Access to the value of the field fieldname from type.
	 * - row.f.fieldname: Access to the value of the field fieldname which is a predefined field.
	 * - row.a.name: Access to the custom value named name.
	 */
	
	if(elus == "elus"){
		var description = [
			{
				'tag':'p',
				'properties': {
					'className': 'canton'
				},
				'children': [
					{
						'tag': '',
						'value': 'Canton : '
					},
					{
						'tag': '',
						'value': row.c.canton
					}
				]
			},
			{
				'tag': 'p',
				'properties': {
					'className': 'elu'
				},
				'children': [
					{
						'tag': '',
						'value': 'Elu : '
					},
					{
						'tag': '',
						'value': row.name
					}
				]
			},
			{
				'tag': 'p',
				'properties': {
					'className': 'politique'
				},
				'children': [
					{
						'tag': '',
						'value': 'Groupe politique : '
					},
					{
						'tag': '',
						'value': row.c.groupepolitique
					}
				]
			}
		];
		
		if (row.a.details_link != ''){
			description[1].children[1] = {
				'tag': 'a',
				'properties': {
					'href': row.a.details_link
				},
				'children': [
					description[1].children[1]
				]
			};
		}
	}else{
		if(elus == "militant"){
			var description = [
				{
					'tag': 'p',
					'properties': {
						'className': 'titre'
					},
					'children': [
						{
							'tag': '',
							'value': row.name
						}
					]
				},
				{
					'tag': 'p',
					'properties': {
						'className': 'adresse'
					},
					'children': [
						{
							'tag': '',
							'value':  row.f.adresse
						}
					]
				},
				{
					'tag': 'p',
					'properties': {
						'className': 'adresse'
					},
					'children': [
						{
							'tag': '',
							'value': row.f.codepostal
						},
						{
							'tag': '',
							'value': ' '
						},
						{
							'tag': '',
							'value':  row.f.ville
						}
					]
				}
			];
			if (row.a.details_link != ''){
				description[0].children[0] = {
					'tag': 'a',
					'properties': {
						'href': row.a.details_link
					},
					'children': [
						description[0].children[0]
					]
				};
			}
		}else{
			if(elus == "cartes"){
				var description = [
					{
						'tag': 'p',
						'properties': {
							'className': 'titre'
						},
						'children': [
							{
								'tag': '',
								'value': row.name
							}
						]
					},
					{
						'tag': 'p',
						'properties': {
							'className': 'adresse'
						},
						'children': [
							{
								'tag': '',
								'value':  row.f.adresse
							}
						]
					},
					{
						'tag': 'p',
						'properties': {
							'className': 'adresse'
						},
						'children': [
							{
								'tag': '',
								'value': row.f.codepostal
							},
							{
								'tag': '',
								'value': ' '
							},
							{
								'tag': '',
								'value':  row.f.ville
							}
						]
					},
					{
						'tag': 'p',
						'properties': {
							'className': 'tel'
						},
						'children': [
							{
								'tag': '',
								'value': 'Téléphone: '
							},
							{
								'tag': '',
								'value': row.f.tel
							}
						]
					}
				];
			}else{
				var description = [
					{
						'tag': 'p',
						'properties': {
							'className': 'titre'
						},
						'children': [
							{
								'tag': '',
								'value': row.name
							}
						]
					}
				];
				if (row.a.details_link != ''){
					description[0].children[0] = {
						'tag': 'a',
						'properties': {
							'href': row.a.details_link
						},
						'children': [
							description[0].children[0]
						]
					};
				}
			}
		}
	}
	
	return description;
}


/*template_annuaire_details_proximite_init_events(prefix, map)
{
}*/
