   function Validovat(theForm)
   {
       var email = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$");
       if (document.getElementById('email').value=="" || !email.test(document.getElementById('email').value))
       {
         alert("Zadejte, prosím, svůj email.");
         document.getElementById('email').focus();
         return false;
       }

       if ((document.getElementById('phone').value=="")||(document.getElementById('phone').value.length < 9))
       {
         alert("Zadejte, prosím, svůj telefon.");
         document.getElementById('phone').focus();
         return false;
       }

     return true;
   }

var Page = function() {
	this.mapScale = 15;
	this.googleDisabled = false;
}

Page.prototype.showAddress = function(address) {
	if(this.googleDisabled) {
		return true;
	}
	if(!address) {
		//var address = $('#contactAddress').val();
		var address = $('#contactStreet').val() + ' ' + $('#contactCity').val() + ' ' + $('#contactPsc').val();
		if(!address || address.length < 5) {
			//alert('Neuvedena adresa');
			return false;
		}
	}
	if(!this.map) {
		this.geocoder = new google.maps.Geocoder();
		$('#contactMap').css('display', 'block');
	    var myOptions = {
	      zoom: this.mapScale,
	      disableDefaultUI: true,
	      navigationControl:true,
	      navigationControlOptions: {
	    	    style: google.maps.NavigationControlStyle.ZOOM_PAN
    	  },
	      mapTypeId: google.maps.MapTypeId.ROADMAP
	    };
	    this.map = new google.maps.Map(document.getElementById('contactMap'), myOptions);
	}
	this.geocoder.geocode({"address": address}, function(results, status) {
		//alert(this.geocoder);
		if (status == google.maps.GeocoderStatus.OK) {
            Page.map.setCenter(results[0].geometry.location);
            if(!Page.marker) {
	            Page.marker = new google.maps.Marker({
	                map: Page.map,
	                position: results[0].geometry.location,
	                draggable: true
	            });
	            google.maps.event.addListener(Page.marker, 'drag', Page.saveCoords);
            } else {
            	Page.marker.setPosition(results[0].geometry.location);
            }
            Page.saveCoords();
          } else {
            alert("Geocode was not successful for the following reason: " + status);
          }
	});

}

Page.prototype.saveCoords = function() {
	var point = Page.marker.getPosition();
	document.getElementById('contactMapX').value = point.lng()-0;
	document.getElementById('contactMapY').value = point.lat()-0;
	document.getElementById('contactMapGPS').value = (new String(point.lat()).substr(0,6)) + ' ' + (new String(point.lng()).substr(0,6));
	//document.getElementById('contactMapGPS').innerHTML = (new String(point.lat()).substr(0,6).replace('.', '°')+'′'+'N') + ' ' + (new String(point.lng()).substr(0,6).replace('.', '°')+'′'+'E');
}

Page = new Page();
