window.addEvent('domready', function() {

	var replaceButton = new submitButtonReplacement('replacesubmit');
	
	$$('.spare-parts .post-small, .private-sales .post-small').each(function(el, index){
		el.getElement('.thumb-image').adopt(el.getElement('p').getElements('a')[0]);
		//el.getElement('.thumb-image').getElements('img').removeProperties('class');
	});
	
	if($('map_canvas')){
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map_canvas"));
			map.setCenter(new GLatLng(51.409684,-0.157865), 15);
			map.addControl(new GLargeMapControl());
			//map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.addOverlay(new GMarker(new GLatLng(51.409684,-0.157865)));
      }
	}

});

var submitButtonReplacement = new Class({
	initialize: function(classname){
		this.allButtons = $$('input.'+classname);
		this.replaceButtons();
	},
	replaceButtons :  function(){
		this.allButtons.each(function(input, index){
			input.setStyle('display', 'none');
			var theEm = new Element('em');
			var theAnchor = new Element('a', {
				'href': '#',
				'class': input.className,
				'html': input.value,
				'events': {
					'click': function(){
						input.click();
					}
				}
			});
			theEm.inject(theAnchor, 'top');
			theAnchor.inject(input, 'before');
		});
	}
});

function titleOver(e) {
	e.style.opacity = 0.5;
	e.style.filter = "alpha(opacity=50)";
}

function titleOut(e) {
	e.style.opacity = 1;
	e.style.filter = "alpha(opacity=100)";
}