/**
 * Javascript for TYPO3 extension "chm_library" for the sidebar map
 * 
 * @author Chris Müller <chm@gmx.li> 
 * @version $Id$
 * @package tx_chmimagegallery
 */ 

/*jslint
	bitwise: true,
	browser: true,
	eqeqeq: true,
	immed: true,
	newcap: true,
	nomen: true,
	onevar: true,
	plusplus: true,
	regexp: true,
	undef: true
*/
/*global

*/


/***** Processing *************************************************************/

function ChmLibrarySidebarMap() {
	/***** Object variables ***************************************************/

	/**
	 * Map object
	 * @type GMap2
	 * @private
	 */
	var map = null;



	/***** Initializing *******************************************************/

	/**
	 * Initializing
	 * This function will be called, when the html page is loaded
	 * @public
	 */	
	this.init = function () {
		// Neue Karte innerhalb des HTML-Containers erstellen
		map = new GMap2($(ChmLibrarySidebarMapConfig.map.id), {mapTypes: ChmLibrarySidebarMapConfig.map.types});
		map.disableDragging();

		// Set coordinates and zoom level
		coordinates = new GLatLng(ChmLibrarySidebarMapConfig.map.lat, ChmLibrarySidebarMapConfig.map.lng);
		map.setCenter(coordinates, ChmLibrarySidebarMapConfig.map.zoomlevel);

		// set icon
		icon = new GIcon(G_DEFAULT_ICON);
		icon.image = ChmLibrarySidebarMapConfig.img.standard;
		icon.mozPrintImage = ChmLibrarySidebarMapConfig.img.standardPrintMoz;
		icon.printImage = ChmLibrarySidebarMapConfig.img.standardPrint;

		if (map.isLoaded()) {
			var marker = new GMarker(coordinates, {icon: icon, clickable: false});
			map.addOverlay(marker);
		}
	}
}



/***** Start *****************************************************************/

document.observe('dom:loaded', function() {
	if (ChmLibrarySidebarMapConfig) {
		var chmLibrarySidebarMap = new ChmLibrarySidebarMap();
		chmLibrarySidebarMap.init();
	}
});


