window.addEvent('domready', function() {
	
	var hoverItems = new Array();
	
	hoverItems.combine($$('.tags li'));
	hoverItems.combine($$('.loc li'));
	hoverItems.push($('logo').getElement('h1'));
	hoverItems.combine($$('.entry .left h3.year'));
	hoverItems.combine($$('.entry h1.link'));
	if($('entries'))
	{
		hoverItems.combine($('entries').getElements('h1'));
	}
	
	hoverItems.each(function(item){
		
		item.addEvent('mouseenter', function(){
			if(!this.hasClass('hover'))
			{
				this.addClass('hover');
			}
		});
		item.addEvent('mouseleave', function(){
			if(this.hasClass('hover'))
			{
				this.removeClass('hover');
			}
		});
		
	});
	
	if($('submitcomment'))
	{
		var submitDiv = $('submitcomment');
		formHTML = '';
		formHTML+= '			<form id="submitcommentForm" action="/comment_submit.php" method="post">\n';
		formHTML+= '				<input name="comment_post" value="'+window.location+'" type="hidden"/>\n';
		formHTML+= '				<b>name</b><br/>\n';
		formHTML+= '				<input class="text" name="comment_user" type="text"><br/>\n';
		formHTML+= '				<b>comment (no html please)</b><br/>\n';
		formHTML+= '				<textarea class="text" name="comment_comment"></textarea><br/>\n';
		formHTML+= '				<input value="leave comment" type="submit"/><br/>\n';
		formHTML+= '			</form>\n';
		submitDiv.set('html', formHTML);
	}
	
	$$('.loc').each(function(item, index){
		item.addEvent('mouseenter', function(){
			if(!$('map_canvas'))
			{
				temp = new Element('div', {
					'id':'map_canvas',
					'styles':{
						'background':'white',
						'border':'4px solid #ccc',
						'position':'absolute',
						'width':'492px',
						'height':'292px',
						'top':'0px',
						'left':'0px',
						'opacity':'0',
						'z-index':'10000'
					}
				});
				document.body.appendChild(temp);
			}
			my_canvas = $('map_canvas');
			var fx = new Fx.Morph(my_canvas, {duration:500, wait:true});
			var map = new GMap2(my_canvas);
			myLat = item.getAttribute('lat');
			myLong = item.getAttribute('lng');
			myZoom = item.getAttribute('zoom');
			myZoom = myZoom.toInt();
			if(myZoom == 0)
			{
				myZoom = 7;
			}
			
			map.setCenter(new GLatLng(myLat.toFloat(), myLong.toFloat()), myZoom);
			var point = new GLatLng(myLat.toFloat(), myLong.toFloat());
			map.addOverlay(new GMarker(point));
			
			my_canvas.style['left'] = (item.getLeft()+item.getSize().x+30)+'px';
			my_canvas.style['top'] = (item.getTop())+'px';
			
			fx.start({
				'opacity':'1'
			});
		});
		item.addEvent('mouseleave', function(){
			if($('map_canvas'))
			{
				var fx = new Fx.Morph($('map_canvas'), {duration:500, wait:true});
				fx.start({
					'opacity':'0'
				});
			}
		});
	});
	
});