function init() {
	$('loader').style.display = 'none';
	$('contact').findFirstElement().activate();	
	$('submit').style.display = 'none';
	Event.observe('ajax-submit', 'click', ajaxform);
	new Validation('contact', {immediate:true});
	initialize();
	
}

function confirmation() {
	$('confirmation').style.display = 'block';
}

function loading() {
	$('loader').style.display = 'block';
	new PeriodicalExecuter(unloading, 1);
	new PeriodicalExecuter(confirmation, 1.2);	
}

function unloading() {
	$('loader').style.display = 'none';
}

function ajaxform() {
	var valid = new Validation('contact', {onsubmit:false});
	var result = valid.validate();
	if (result==true){
    	var pars = $('contact').serialize();
    	var url = 'mail.php';
		var requete = new Ajax.Request(url, {
			method: 'get',
			parameters: pars
		});
		loading();
		$('contact').style.display = 'none';
	}
	else {
		Effect.Shake('contact',{duration:0.5,distance:1});	
	}
	
}


function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(48.847582, 2.386597), 15);
        map.addControl(new GSmallMapControl());
		
		var point = new GLatLng(48.847582, 2.386597);
		map.addOverlay(new GMarker(point));
		map.openInfoWindowHtml(point,'<img src="assets/img/logo-small.gif" alt="Mediastroika" />')
      }
    }


	

Event.observe(document, 'dom:loaded', init);
