if(document.getElementById('calendar-container')) {
	Calendar.setup({
	    cont          : "calendar-container",
	    weekNumbers   : true,
	    selection     : Calendar.dateToInt(new Date()),
	    showTime      : 12
	});
}

var map = null;
var point = null;

if(document.getElementById("map_canvas")) {
	map = new GMap2(document.getElementById("map_canvas"));
	point = new GLatLng(54.680867, 25.363959);
	map.setCenter(point, 15);
	map.setUIToDefault();
	map.addOverlay(new GMarker(point));
	document.body.onunload = GUnload;
}

function findPathInPrint() {
	address = window.opener.document.getElementById('street').value + ',' + window.opener.document.getElementById('city').value;
	geocoder = new GClientGeocoder();
    geocoder.getLocations(address, overlayDirections);
}

function findPath() {
	if(document.getElementById('street').value == "" || document.getElementById('city').value == "") {
		alert("Įveskite bent vieną laukus");
	}
	address = document.getElementById('street').value + ',' + document.getElementById('city').value;
    geocoder = new GClientGeocoder();
    geocoder.getLocations(address, overlayDirections);
}

function overlayDirections(response) {
	place = response.Placemark[0];	
    fromAddress = place.Point.coordinates[1] + ',' + place.Point.coordinates[0];
    gdir = new GDirections(map, document.getElementById("directions"));
    toAddress = 54.680867 + ',' + 25.363959;
    gdir.load("from: " + fromAddress + " to: " + toAddress, {preserveViewport:false,travelMode:G_TRAVEL_MODE_DRIVING});  
    map.setCenter(point, 12);
}
