//set the default venue to show
var activeElement = 'img-village0-active-div';

	window.addEvent('domready', function()
	{
		//define the scroll variable
		var scroll = new Fx.Scroll('map-content-container', {
			wait: false,
			duration: 1,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});
		
		/*activate default venue stuff*/
		$(activeElement).removeClass('hide');
		activelink = activeElement.split("-");
		activelink = 'link-'+activelink[1];
		$(activelink).addClass('active');
				
		//event listener and function 
		$('map').getElements('div').addEvent('mouseenter', function(e)
		{
			e = new Event(e).stop();
			imageMapRollover(this.id);
			
		});
		
		$('map-widget-container').getElements('li').addEvent('mouseenter', function(e)
		{
			
			e = new Event(e).stop();
			mapLinkHover(this.id);
			
		});
		
		/*FUNCTIONS*/
		function mapLinkHover(id)
		{
			currentItem = (id).split('-');
			currentItem = currentItem[1];
			
			oldItem = (activeElement).split('-');
			oldItem = oldItem[1];
			
			/*remove old active link*/
			activeLink = 'link-'+oldItem;
			$(activeLink).removeClass('active');
			
			$(id).addClass('active'); //add new active link
			
			$(activeElement).addClass('hide'); //hide active image
			
			currentImage = 'img-'+currentItem+'-active-div';
			$(currentImage).removeClass('hide');
			
			activeElement = currentImage;

			scroll.toElement(currentItem); //scroll the content panel
			
			//change "more information" link
			hiddenLink = $(id).getElement('a').href;
			$('more-info').href = hiddenLink;
		}
		
		function imageMapRollover(id)
		{	
			currentImage = id;
			temp = id.split('-');
			activeImage = temp[0]+'-'+temp[1]+'-active-'+temp[2];
			
			currentItem = (id).split('-');
			currentItem = currentItem[1];
			
			if(currentImage.match("-active") == null)
			{
				//to help it not through "is undefined" errors when you hammer it
				if(typeof(activeImage) == "undefined")
				{
					activeImage = activeElement;
				}
				
				/*change images over*/
				$(activeImage).removeClass('hide');
				$(activeElement).addClass('hide');
				activelink = activeElement.split("-");
				activelink = 'link-'+activelink[1];
				$(activelink).removeClass('active');
				
				activeElement = activeImage; //set new active image
				
				//find the new active link
				activelink = activeElement.split("-");
				activelink = 'link-'+activelink[1];
				
				//make it active
				$(activelink).addClass('active');

				scroll.toElement(currentItem); //scroll the content panel
				
				//change "more information" link
				hiddenLink = $(id).getElement('a').href;
				$('more-info').href = hiddenLink;
			
			}
		}
		
		
		
		
		
		

	});
