function resizeLayout()
{
  $("#o-middle").css("float", "left");
  var w;
  var middle = $("#o-middle").width();
  if(middle == $(window).width() && $(window).width() > 990)
  {
    middle = 990;
    $("#o-middle").css("width", "990px");
  }
  w = ($(window).width()-middle)/2;
  if(w > 0)
  {
    $("#o-left").css("width", w+"px");
    $("#o-right").css("width", w+"px");
  }
  else
  {
    $("#o-left").css("width", "0");
    $("#o-right").css("width", "0");
  }
}

function close_intro()
{
  $("#intro-div").remove();
  $("#map-div").show();
}

function hideDIV(item) 
{	
document.getElementById(item).style.display='none';		
}
function showDIV(item)
{	
document.getElementById(item).style.display='block';					      
}
//## form search
function xquery()
{
	if(document.search.query.value == 'szukaj...')
		document.search.query.value = '';		
}
function xqueryb()
{
	if(document.search.query.value == '')
		document.search.query.value = 'szukaj...';		
}

function xclickblur(name, value)
{  
  $("input[name="+name+"]").blur(function(){
    if($(this).val() == '')
      $(this).attr("value", value);
  });
  
  $("input[name="+name+"]").click(function(){
    if($(this).val() == value)
      $(this).attr("value", '');
  });
}

function dialogText(html)
{
    $(html).dialog("destroy");
    $(html).dialog({
      show: 'blind',
      hide: 'blind',
      modal: true,
      draggable: false,
      resizable: false,
      buttons: {
                Zamknij: function(){
                  $(this).dialog('close');
                }
      }
    });
}

function helpButt()
{
  $(".help").hover(function(){
    $(this).append("<div id='helpslot'><a>Otwórz dział pomocy</a></div>");
    $("#helpslot a").click(function(){
      $(".close").attr("class", "close2");
      $("#newslot").attr("id", "hide-newslot").hide();
      $(".zakladka[idZak=1]").trigger('click');
      $(".close2").attr("class", "close");
    });
  }, function(){
    $("#helpslot").remove();
  }); 
}

function adClose(ad_class)
{
  if(ad_class)
  {
    $("."+ad_class).live("click", function(){
      $(this).parent("div").remove();
      return false;
    });
  }
}

function nwsform() {
    $('#submitnewsletter').show();
    $('#nwsform').show();
}

function closenws() {
    $('#submitnewsletter').hide();
    $('#nwsform').hide();
}

function submitnws() {
	if (document.getElementById('zgoda1').checked==true && document.getElementById('zgoda2').checked==true && document.getElementById('emailnewsletter').value.length>0) {
            $.ajax({
                type: 'POST',
                url: "newsletter.php?savenws=1",
                data: $("#nwsitems").serialize(),
                success: function(data) {
                    var newData = $.parseJSON(data);
                    if (newData.success > 0) {
                        alert("Zapisany do newslettera");
                        $('#submitnewsletter').hide();
                        $('#nwsform').hide();
                        $("#emailnewsletter").setValue("");
                    } else {
                        alert("Wystąpił błąd, spróbuj jeszcze raz");
                    }
                }
            });  
	} else {
		alert('Proszę zaznaczyć wszystkie pola');
	}  
}

