function sprawdzFormularz()
{
	var tel = document.getElementById('fon').value;
	var emil = document.getElementById('emil').value;
	var desc = document.getElementById('desc').value;
	var miasto = document.getElementById('miasto').value;
	var imie = document.getElementById('imie').value;
	var wr2 = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;

	if (tel.length < 1)
	{
		alert("Proszę podać numer telefonu");
		return false;
	}

	if (miasto.length < 1)
	{
		alert("Proszę podać miasto");
		return false;
	}

	if (imie.length < 1)
	{
		alert("Proszę podać swoje imię");
		return false;
	}

	if (!emil.match(wr2) || emil.length < 2)
	{
		alert("Proszę podać prawidłowy adres e-mail");
		return false;
	}

	if (desc.length < 2)
	{
		alert("Proszę podać treść zapytania");
		return false;
	}
	return true;
}

function showDialog(elem)
{
   var url = elem.href;
   $('#ZORTBOX').dialog({ modal: true, width: 500, height: 520, close: function(event, ui) { startZortBox(); } });
   $('#ZORTBOX').load(url+"?ajax=true");
   return false;
}

function startZortBox()
{
   $('#ZORTBOX').remove();
   var ZortBox = document.createElement('div');
   ZortBox.id = "ZORTBOX";
   ZortBox.style.display = 'none';
   ZortBox.style.textAlign = 'center';
   var img = new Image;
   img.src = 'img/ajax-loader.gif';
   ZortBox.appendChild(img);
   document.body.appendChild(ZortBox);
}

var currentImage = 1;
function rotateImages()
{
   if (images)
   {
      var bckImage = currentImage;
      if (currentImage >= images.length)
         currentImage = 0;
      var im = document.getElementById('mainpageGalleryImage');
      if (im)
      {
         $(im).fadeOut(100, function() {
            im.src = images[currentImage].src;
            currentImage++;
            $(im).fadeIn(100);
            setTimeout('rotateImages()', 5000);
         });
         
      }
   }

}


function showDis(id, title)
{
   $('#dialog').remove();
   var dialog = document.createElement('div');
   dialog.id = 'dialog';
   dialog.title = title;
   dialog.innerHTML = $('#dis'+id).html();
   dialog.style.display = 'none';
   document.body.appendChild(dialog);
   $( "#dialog" ).dialog({
			modal: true,
         width: 300,
         height: 400
		});   
   return false;
}
