$(document).ready(function(){
	if ($('#mapa').length>0) {
		initialize();
	}
	
	
	$('.lighboxlink').lightBox();
	
    $('#newsletter_wypisz').click(function(){
        var email = $('#newsletter_email').val();
        if (email == '') {
            $('#newsletter>div').remove();
            $('#newsletter').prepend('<div>Nie podano adresu e-mail.</div>');
        }
        else {
            $('input[name="wypisz"]').val(1);
            $('#newsletter_form').submit();
        }
    });
});

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 initialize() {

		var latlng = new google.maps.LatLng(50.040852,22.005594);
		var myOptions = {
			zoom: 15,
			center: latlng,
			mapTypeControl: true,
		    mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
		    zoomControl: true,
		    zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL }, 
		    mapTypeId: google.maps.MapTypeId.ROADMAP };
		var map = new google.maps.Map(document.getElementById("mapa"), myOptions);
		var marker = new google.maps.Marker({ position: latlng, title:"Poland, Rzeszów, Piłsudskiego 32" });
		marker.setMap(map);
}
