$(document).ready(function(){
	$('#logosy').flash({
		src: 'assets/flash/logosy.swf',
		width: 980,
		height: 58,
		wmode: 'transparent'
	});
	
	$('#slider').nivoSlider();
	
	$('#slider').corner("bl 20px");
	$('#footer').corner("top 20px");
	
	$('#topMenu').flash({
		src: 'assets/templates/stemar/menu.swf',
		width: 378,
		height: 288,
		flashvars: {menuXML:'menu.html'},
		wmode: 'transparent',
		scale: 'noscale',
		align: 'top'
	});
	
	/*google maps*/
	var map;
	var arrMarkers = [];
	var arrInfoWindows = [];
	
	function mapInit(){
		var centerCoord = new google.maps.LatLng(52.43144643764319, 16.81878089904785);
		var mapOptions = {
			zoom: 15,
			center: centerCoord,
			mapTypeId: google.maps.MapTypeId.TERRAIN
		};
		map = new google.maps.Map(document.getElementById("map"), mapOptions);
		
		$.getJSON("assets/js/map.json", {}, function(data){
			$.each(data.places, function(i, item){
				$("#markers").append('<div class="newsShortDiv"><a href="kontakt.html#" onclick="return false" rel="' + i + '"><h3 style="color: #000000;">' + item.title + '</h3><p>' + item.description + '</p></a></div>');
				var marker = new google.maps.Marker({
					position: new google.maps.LatLng(item.lat, item.lng),
					map: map,
					title: item.title
				});
				arrMarkers[i] = marker;
				var infowindow = new google.maps.InfoWindow({
					content: "<h3>"+ item.title +"</h3><p>"+ item.adres +"</p>"
				});
				arrInfoWindows[i] = infowindow;
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.open(map, marker);
				});
			});
		});
	}
	$(function(){
		// initialize map (create markers, infowindows and list)
		mapInit();
		
		// "live" bind click event
		$("#markers a").live("click", function(){
			var i = $(this).attr("rel");
			// this next line closes all open infowindows before opening the selected one
			//for(x=0; x < arrInfoWindows.length; x++){ arrInfoWindows[x].close(); }
			arrInfoWindows[i].open(map, arrMarkers[i]);
		});
	});
	
	/* googlemaps end*/
});

//Cufon.set('textShadow', '2px 2px 0 #6f0e0f');
Cufon('h1,h2,h3,h4');
