(function($) {
$.fn.mapa = function(X,Y) {
    var zoom=14;
	var point = new GLatLng(X,Y);  
	var marker = new GMarker(point);

	if (GBrowserIsCompatible()) {
		var mapa = new GMap2(document.getElementById("MapaGoogle"));
		GEvent.addListener(marker, "click", function(){
			alert("Kąt Nieruchomości");
		});
		
		mapa.addControl(new GSmallZoomControl());
		mapa.setCenter(new GLatLng(X,Y), zoom);
		mapa.addOverlay(marker);
		}
	}
})(jQuery);

$(document).ready(function(){

/* SI */
//$.swapImage(".swapImage");
/* IFR */ 
$('.Galeria a').lightBox({fixedNavigation:true});
$('.lightbox').lightBox({fixedNavigation:true});
//if (GoogleMaps) $('#Mapa').mapa(50.0416988, 22.0027027);
/* EOR */
});

function chkThisForm(oBj) {
	var Error = false;
	var Komunikat = new Array();
	var Tekst = '';
 	if (!oBj.tytul.value.length>0) { Error = true; Komunikat[Komunikat.length] = 'Brak tytułu wiadomości';}
 	if (!oBj.imie_nazwisko.value.length>0) { Error = true; Komunikat[Komunikat.length] = 'Brak imienia i nazwiska';}
	if (!(isEmail(oBj.email.value) ||oBj.telefon.value.length>0 )) { Error = true; Komunikat[Komunikat.length] = 'Brak jednej z form kontaktu';}
 	if (!oBj.wiadomosc.value.length>0) { Error = true; Komunikat[Komunikat.length] = 'Brak wiadomości';}
	
	if (Error) {
		for (a = 0; a < Komunikat.length; a++) {
			Tekst += Komunikat[a] + "\n";
		}
		alert(Tekst);
		return false;
	}
	else {
	$('#Informacja').text('Trwa wysyłanie wiadomości...');
	$.get("/index.php?module=sendmessage&ajax=1", { 
		tytul: oBj.tytul.value, 
		imie_nazwisko: oBj.imie_nazwisko.value,
		email: oBj.email.value,
		telefon: oBj.telefon.value,
		wiadomosc: oBj.wiadomosc.value
		},
		function(data){
 		 	$('#Informacja').text(data);
			} );
	oBj.reset();
	return false;
	}
	
}
function sF(oBj) {
	if (oBj.value=='szukaj ofert...') oBj.value='';
	return false;
}
function isEmail(email) {
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 true;
}
function cA(bool,name) {
	oBj = document.SzukajForm;
	T = oBj.getElementsByTagName('input');
	for (a=0;a<T.length;a++) {
		if (T[a].name=='r[]' && name=='w1') bool?T[a].checked=true:T[a].checked=false;
		if (T[a].name=='or[]' && name=='w2') bool?T[a].checked=true:T[a].checked=false;
		if (T[a].name=='onr[]' && name=='w3') bool?T[a].checked=true:T[a].checked=false;
	}
	return false;
}