$(document).ready(function(){
	
	$('a[rel=lightbox]').lightbox();
	
	if($("#Mapa").attr("id")!=undefined) {
	   var script = document.createElement('script');
	   script.setAttribute('src', 'http://www.google.com/jsapi?key=ABQIAAAA1w92-qAT7vXp_oqRA9JXgRQzGrV2wEHkgUAqJ5TwaLzedJRU6xRSrM51sO1t13ry-ZRk8_TqoS-92g&callback=loadMaps');
	   script.setAttribute('type', 'text/javascript');
	   document.documentElement.firstChild.appendChild(script);
	}
	
	$(".klik").click(function(){
		$("#P"+$(this).attr("id")).animate({ height: 'toggle', opacity: 'toggle' }, "slow");
	});
	
	$("table.ExpandPlace").each(function(){ // 
		$(this).wrap('<div class="ExpandPlace" id="'+$(this).attr("id")+'" style="height:'+($(this).innerHeight()+10)+'px;"></div>');
		$(this).parent().html( '<div class="ExpandInside">'+$(this).find("td:eq(0)").html()+'<div class="Clear"></div></div>' );
	});
	
	$(".ExpandButton").click(function(){
		
		var id = $(this).attr("id");
		$(".ExpandPlace").each(function(){
			if($(this).attr('id')=="P"+id) {
				if($("#P"+id).css("display")=="none") {
					$("#P"+id).animate({ height: 'show', opacity: 'show' }, "slow", null, function(){
						$("#"+($(this).attr("id").substr(1))).addClass("sel");
					});
				}else $("#P"+id).animate({ height: 'hide', opacity: 'hide' }, "fast", null, function(){
						$("#"+($(this).attr("id").substr(1))).removeClass("sel");
					});
			}else $(this).animate({ height: 'hide', opacity: 'hide' }, "fast", null, function(){
						$("#"+($(this).attr("id").substr(1))).removeClass("sel");
					});
		});
	})
	
});
	
	function loadMaps() {
		google.load("maps", "2", {"callback" : mapsLoaded});
	}
	function mapsLoaded() {
		if (GBrowserIsCompatible()) {
			var xx = 52.253657;
			var yy = 20.991976;
		   var map = new GMap2(document.getElementById("Mapa"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
		   map.setCenter(new GLatLng(xx, yy), 14);
			map.addOverlay(new GMarker(new GLatLng(xx, yy)));
		}
	}

