/**
 * @author BitArtis.pl
 */
$(document).ready(function() {
   $.swapImage(".swapImage");
   $('table.clean').show();
   $('table.clean img').click(function() {
   	chkForm();
	});
});

function chkForm() {
	$('p#Kod').html('Trwa sprawdzanie...');
	$.ajax({
		type: "POST",
  		url: "index.php?ajax=1&module=ajaxrequest",
		data:{email:$('table.clean input[@name="email"]')[0].value},
		success: function(html){
			if (html=="ERROR #0") $('p#Kod').html('<strong>Wystąpił błąd!</strong><br />Podany adres email jest niepoprawny.');
    		else if (html=="ERROR #1") $('p#Kod').html('<strong>Uwaga!</strong><br />Podany adres email znajduje się już w naszej bazie.');
			else if (html=='OK') $('p#Kod').html('<strong>Dziękujemy!</strong><br />podany adres email został zarejestrowany.');
			else return false;
  			},
		error: function() {
			$('p#Kod').html('Przepraszamy wystąpił błąd. Poadny adres nie został dodany. Proszę spróbować później.');
			}
		})
	return false;
}


function sendMail()
	{
	if (document.contactForm.email.value == '')
	{
		window.alert('Prosze podac adres e-mail');
		return;
	}
    if (document.contactForm.email.value.length < 4) 
	{
		window.alert('Prosze podac poprawny adres e-mail');
		return;
	}
	if (document.contactForm.email.value != '')
	{
		if (document.contactForm.email.value.indexOf('@') < 0)
		{
            window.alert('Prosze podac poprawny adres e-mail');
			return;
		}
	}
	if (confirm('Czy na pewno chcesz otrzymywac Newslatter?'))
       document.contactForm.submit();
	}
	
	
function sendMail_konsultacje()
	{
	if (document.contactForm.mail_content.value == '')
	{
		window.alert('Tresc wiadomosci nie moze byc pusta.');
		return;
	}
    if ( (document.contactForm.email.value.length < 4) && (document.contactForm.phone.value < 3) )
	{
		window.alert('Prosze podac adres e-mail lub telefon kontaktowy.');
		return;
	}
	if (document.contactForm.email.value != '')
	{
		if (document.contactForm.email.value.indexOf('@') < 0)
		{
            window.alert('E-mail jest nieprawidlowy.');
			return;
		}
	}
	if (confirm('Czy na pewno chcesz wyslac zapytanie?'))
       document.contactForm.submit();
	}	
	
function sendMail_kontakt()
	{
	if (document.contactForm.phone.value.length < 6) 
	{
		window.alert('Prosze podac telefon kontaktowy.');
		return;
	}	
	if (document.contactForm.nazwa.value.length < 3) 
	{
		window.alert('Prosze podac imie.');
		return;
	}	
	if (document.contactForm.nazwa2.value.length < 3) 
	{
		window.alert('Prosze podac nazwisko.');
		return;
	}	
	if (confirm('Czy na pewno chcesz wyslac formularz?'))
       document.contactForm.submit();
	}
	
	


function load() { 
if (GBrowserIsCompatible()) { 
         var map = new GMap2(document.getElementById("map")); 
         map.addControl(new GSmallMapControl()); 
         map.setCenter(new GLatLng(52.24317445282235, 21.016416549682617), 15); 
         var info='<div style="background-color: #fff; width: 300px; font-size: 11px; FONT-FAMILY: Verdana, Tahoma, Arial, Sans-Serif; color:#000; text-align:center"><B>Mie&#347;cimy si&#281; w budynku hotelu Bristol.</B><hr>Wej&#347;cie od ulicy Karowej - id&#261;c ul. Karow&#261; od Krakowskiego Przedmie&#347;cia, drugie du&#380;e wej&#347;cie po lewej stronie <hr></div>'; 
         var point = new GLatLng(52.242175894402926, 21.015944480895996); 
         var marker = new GMarker(point); 
         GEvent.addListener(marker, "click", function() { 
          marker.openInfoWindowHtml(info); 
         }); 
         map.addOverlay(marker); 
         marker.openInfoWindowHtml(info); 

} 
} 


	
