document.addEvent('domready',function(){
	if($('photos')){
		$$('p#imagepicker a.imagetrigger').each(function(a){
			a.addEvent('click',function(e){
				e = new Event(e).stop();
				$('imagepicked').setProperty('src',a.getProperty('href'));
			});
		});
	}
	if($('details_select')){
		$$('.house_detail').each(function(detail){
			if(detail.getProperty('id') !== 'details_'+$('details_select').getProperty('value')){
				detail.setStyle('display','none');
			}
			/*else{
				$('contact-button').setProperty('href',$('contact-button').getProperty('href') + '&subhouse=' + $('details_select').getProperty('value'));
			}*/
		});
		$('details_select').addEvent('change',function(){
			$$('.house_detail').each(function(detail){
				if(detail.getProperty('id') !== 'details_'+this.getProperty('value')){
					detail.setStyle('display','none');
				}
				else{
					detail.setStyle('display','block');
				}
			}.bind(this));
		});
	}
	if($$('.go-back')){
		$$('.go-back').each(function(goback){
			goback.addEvent('click',function(e){
				new Event(e).stop();
				window.history.back();
			});
		});
	}
	if($$('a.call-to-action')){
		$$('a.call-to-action').each(function(cta){
			cta.addEvent('click', function(e){
				new Event(e).stop();
				window.open('/fr/avis.php', 'avis', 'width=800;height=400;left=20;top=20');
			});			
		});
	}
});
