$(document).ready(function() {
	$('.lighboxlink').lightBox();
	if ($('#mapka_flash').length > 0)
		swfobject.embedSWF("/content/swf/mapa_650x600.swf", "mapka_flash", "650", "600", "9.0.0","expressInstall.swf");
	
	if ($('#flash_glowna').length > 0)
		swfobject.embedSWF("/content/swf/banner_960x345.swf", "flash_glowna", "960", "345", "9.0.0","expressInstall.swf");
	
	if ($('#mala_mapka_flash').length > 0)
		swfobject.embedSWF("/content/swf/mapa_450x420.swf", "mala_mapka_flash", "420", "420", "9.0.0","expressInstall.swf");
	
	if ($('#zaprojektuj_okna').length > 0)
		swfobject.embedSWF("/content/swf/preloader.swf", "zaprojektuj_okna", "936", "575", "9.0.0","expressInstall.swf");
	
	$('#m_zaprojektuj_okna').click(function() {
		openWizualizator();
	});
	
	if ($('#mapka_kontakt').length > 0) {
		var geocoder = new google.maps.Geocoder();
		var address = 'Lublin, Łęczyńska 1';
		var address2 = 'Garbów';
		var center = 'Jastków';
		
		var myOptions = {
			zoom: 11,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			disableDefaultUI: true,
			zoomControl: true,
			zoomControlOptions: {
				style: google.maps.ZoomControlStyle.LARGE
			}
		};
		var map = new google.maps.Map(document.getElementById("mapka_kontakt"), myOptions);
		
		geocoder.geocode({
			'address': center
		}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
			}
		});
		
		geocoder.geocode({
			'address': address
		}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				var marker = new google.maps.Marker({
					map: map,
					position: results[0].geometry.location
				});
			}
		});
		
		geocoder.geocode({
			'address': address2
		}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				var marker = new google.maps.Marker({
					map: map,
					position: results[0].geometry.location
				});
			}
		});
	}
});

function isEmail(email) {
	email = email.replace(/[ ]/g,'');
	var regEmail = /^([a-zA-Z0-9._-]{1,})@([a-zA-Z0-9._-]{1,})\.([a-zA-Z]{2,4})$/;
	if (!regEmail.test(email)) return false;
	else return email;
}
	
function getWojewodztwo(param) {
	$.ajax({
		url: 'index.php?module=kontakt&akcja=wojewodztwo&row='+param+'&ajax=1',
		type: 'post',
		success: function(response) {
			$('#sklepy').empty();
			$('#sklepy').append(response);
		}
	});
}

function openWizualizator() {
	var myWindow = window.open(
		'/index.php?module=zaprojektuj-okna&ajax=1', 
		'myWindow', 
		'width=950,height=590'
	);
}
