var wsk_numer_inwestycji = 0;
var blokadaPrzewijaniaPrawa = 0;
var blokadaPrzewijaniaLewa = 0;
var blockScroll = 0;
//var widokRozmiar = 2;

function moveToPreviousAfter() {
    blockScroll = 0;
}
function moveToPrevious() {
    if (blockScroll == 1) {
        return false;
    }
    blockScroll = 1;
    tmp = document.createElement('li');
    tmp.innerHTML = $('lista').lastChild.innerHTML;
    $('lista').insertBefore(tmp, $('lista').firstChild);
    $('imageBoxInside').style.left = -104;
    $('lista').removeChild($('lista').lastChild);
    new Effect.Move('imageBoxInside', { x: 104, y: 0, transition: Effect.Transitions.sinoidal, 'afterFinish':moveToPreviousAfter });
}

function moveToNextAfter() {
    blockScroll = 0;
    tmp = document.createElement('li');
    tmp.innerHTML = $('lista').firstChild.innerHTML;
    $('lista').appendChild(tmp);
    $('lista').removeChild($('lista').firstChild);
    $('imageBoxInside').style.left = 0;
}

function moveToNext() {
    if (blockScroll == 1) {
        return false;
    }
    blockScroll = 1;
    new Effect.Move('imageBoxInside', { x: -104, y: 0, transition: Effect.Transitions.sinoidal, 'afterFinish':moveToNextAfter});
}



function moveToNextAfterTime() {
	setInterval("moveToNext()",8000);
}

function initMultiWyszLok() {
    if (document.getElementById('imageBoxInside')) {
        setInterval("moveToNext()",8000);
    }

    document.getElementById("lok").onfocus = function() {
       if (this.value == this.getAttribute("valuedefault") || this.value == '') {
          this.value ='';
          if (document.getElementById('lista_dzialow_v').value == '14') {
              tmptyp = 0;
          } else if (document.getElementById('lista_dzialow_v').value == '30') {
              tmptyp = 1;
          } else if (document.getElementById('sprzedaz_v').value == '-1') {
              tmptyp = 1;
          } else {
              tmptyp = 0;
          }
          document.getElementById('sug_cont').innerHTML = '<div id="sug_cont2">'+liczba_ofert[document.getElementById("lista_dzialow_v").value + tmptyp]+'</div>';
          this.className = this.className.replace(' sug_dtext', '');
          createList(this.getAttribute('sug_nr'));
       }
    }

    document.getElementById("lok").onblur = function() {
       if (this.value == '') {
          this.value = this.getAttribute('valuedefault');
          this.className = this.className.replace(' sug_dtext', '');
       }
       tmpnr = this.getAttribute('sug_nr');
       clearList(tmpnr);
       sug_selected_index[tmpnr] = -1;
    }

    document.getElementById("lista_dzialow_v").update = function() {
        if (this.value == "31") {
            document.location.href='/oferty-zagraniczne/';
        }
    }
}

function sprawdzWyszukiwarkaGlowna() {
    if (document.getElementById('lok').value == '' 
        || (document.getElementById('lok').value == document.getElementById('lok').getAttribute('valuedefault')
            && document.getElementById('lok').getAttribute('valuedefault_check'))
        ) {
        alert('Proszę wpisać fragment lokalizacji (przynajmniej 3 litery).'); 
        return false;
    } else {
        return true;
    }
}
