jQuery(document).ready(function(){
	
	$(".submenu li a").click(function(e){
		if($(this).next().length > 0) {
			e.preventDefault();
			var clicked = $(this);
			
			$(".submenu li ul").each(function() {
				if(clicked != $(this)) {
					$(this).slideUp("fast");
				}
			});
			
			if($(this).next().css("display") == "none") {
				$(this).next().slideDown("fast");
			}
			else {
				$(this).next().slideUp("fast");
			}
			
			return false;
		}
	});
	
	if($('#oferta_slideshow').length) {
		$('#oferta_slideshow').cycle();
	}
	
	if($('#slideshow_maly').length) {
		$('#slideshow_maly').cycle();
	}	
	
	if($("#map").length) {
		load();
	}
	
	if($(".oferta_galeria a").length) {
		$(".oferta_galeria a").fancybox({
			"titlePosition":"over",
			"cyclic":true
		});
	}
	
	if($("a[rel=fancy]").length) {
		$("a[rel=fancy]").fancybox({
			"titlePosition":"over",
			"cyclic":true
		});
	}
		
});



function load() {
	//stworzenie obiektu koorydnat
	var center = new GLatLng(52.279,16.861411);
	var mark = new GLatLng(52.274057,16.861411);
	//ustawienie markera w miejscu wycentorwania mapy
	var marker = new GMarker(mark, {draggable: false});
	
	if (GBrowserIsCompatible()) {
		//map to id div gdzie ma sie pojawic mapa
		var map = new GMap2(document.getElementById("map"));    
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.enableDoubleClickZoom();
	
	
		// ustaw mape w pkt center z zoomem 14	
		map.setCenter(center, 14);
		map.addOverlay(marker);
		marker.openInfoWindowHtml("<table><tr><td style=\"padding-right: 20px;\"><img src=\"/assets/images/logo_dymek.jpg\" alt=\"logo\" /></td><td><p class=\"gmap_adres\"><b>Videoradar Sp. z o.o.</b><br/>ul. Brzozowa 10<br/>62-040 Puszczykowo</p></td></tr></table>");	
	}				   
}
