/**
 *
 */
 	function Worldmap ( mapId, contactsId )
	{
		var self = this;
	
		/**
		 *
		 */
		 	this.__construct = function ( mapId, contactsId )
			{
				self.map		= document.getElementById ( mapId );
				self.contacts	= document.getElementById ( contactsId );
				
				if ( self.map )			self.parseMap ( );
				if ( self.contacts )	self.hideContacts ( );
			}
			
		/**
		 *
		 */
		 	this.parseMap = function ( )
			{
				var areas = self.map.getElementsByTagName ( 'area' );
				for ( var i in areas )
				{
					if ( areas[ i ].href )
					{
						if ( ! areas[ i ].href.match ( /o=(\d+)/ ) ) continue;
						
						areas[ i ].href = '#contacts';
						areas[ i ].oId = RegExp.$1;
						
						var country = translate ( areas[ i ].alt, language );
						
						areas[ i ].alt = country;
						areas[ i ].title = country;
						
						addEvent ( areas[ i ], 'click', self.activateContact );
					}
				}
			}
			
		/**
		 *
		 */
		 	this.hideContacts = function ( )
			{
				var contacts = self.contacts.getElementsByTagName ( 'div' );
				for ( var i in contacts )
				{
					if ( contacts[ i ].id && contacts[ i ].id.match ( /c(\d+)/ ) )
					{
						contacts[ i ].style.display = 'none';
					}
				}
				
				self.contacts.style.display = 'block';
			}
			
		/**
		 *
		 */	
		 	this.activateContact = function ( )
			{
				self.hideContacts ( );
				
				var contact = document.getElementById ( 'c' + this.oId );
				if ( contact )
				{
					contact.style.display = 'block';
				}
			}
		 
		/**
		 *
		 */
			addEvent ( window, 'load', function ( ) { self.__construct ( mapId, contactsId ) } );
	}

/**
 *
 */
	var worldmap = new Worldmap ( 'worldmap', 'contacts' );