
function Zaladuj(str, dvid) {
    //alert(str);
    //alert(dvid);
    new Ajax.Request(str, {
        onSuccess: function (transport) {
            $(dvid).innerHTML = transport.responseText;
        }
    });

    //alert('koniec');
}


function PokazPopup() {
    if (readCookie("dvpopup_<%# BanerPopUpID %>")!="<%# BanerPopUpID %>") {

    var tempstr = window.location.href;
    //alert(tempstr.length);
    //if (tempstr.indexOf("nmieszkaniowe") > 0) {
    if (tempstr.length < 24 || tempstr.indexOf("nmieszkaniowe") > 0) {
        if ($('dvPopUp').innerHTML != "") {
            $('dvPopUp').setStyle({ 'left': (getViewPortSizeX() - $('dvPopUp').getWidth()) / 2 + 'px' });
            $('dvPopUp').setStyle({ 'top': (getViewPortSizeY() - $('dvPopUp').getHeight()) / 2 + 'px' });
            $('dvPopUp').show();

            createCookie("dvpopup_<%# BanerPopUpID %>","<%# BanerPopUpID %>",1);
        }
        }
    }
}

function ZamknijPopup() {
    $('dvPopUp').hide();
}

function hideTab(tabId) {
    if (document.getElementById(tabId)) {
        document.getElementById(tabId).style.display = "none";
    }
}
function hideTabs() {
    hideTab('grpSprzedaz');
    hideTab('grpKupno');
    hideTab('grpNajem');
    hideTab('grpWynajem');
    hideTab('grpDevelop');
    hideTab('grpKomercyjne');
}
function showTab(tabId) {
    hideTabs();
    //if (tabId != null) {
        document.getElementById(tabId).style.display = "block";
        //alert(tabId);
        if (tabId == 'ctl00_cntAktualnosci_grpSprzedaz') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "block";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "none";
            

            document.getElementById('sprz').className = "grPierwszaObramowanieZmien";
            document.getElementById('kupn').className = "grPierwszaObramowanie";
            document.getElementById('naje').className = "grPierwszaObramowanie";
            document.getElementById('wynajem').className = "grPierwszaObramowanie";
            document.getElementById('deve').className = "grPierwszaObramowanie";
            document.getElementById('kome').className = "grPierwszaObramowanie";
        } else if (tabId == 'ctl00_cntAktualnosci_grpKupno') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "block";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "none";

            document.getElementById('sprz').className = "grPierwszaObramowanie";
            document.getElementById('kupn').className = "grPierwszaObramowanieZmien";
            document.getElementById('naje').className = "grPierwszaObramowanie";
            document.getElementById('wynajem').className = "grPierwszaObramowanie";
            document.getElementById('deve').className = "grPierwszaObramowanie";
            document.getElementById('kome').className = "grPierwszaObramowanie";
        } else if (tabId == 'ctl00_cntAktualnosci_grpNajem') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "block";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "none";

            document.getElementById('sprz').className = "grPierwszaObramowanie";
            document.getElementById('kupn').className = "grPierwszaObramowanie";
            document.getElementById('naje').className = "grPierwszaObramowanieZmien";
            document.getElementById('wynajem').className = "grPierwszaObramowanie";
            document.getElementById('deve').className = "grPierwszaObramowanie";
            document.getElementById('kome').className = "grPierwszaObramowanie";
        } else if (tabId == 'ctl00_cntAktualnosci_grpWynajem') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "block";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "none";

            document.getElementById('sprz').className = "grPierwszaObramowanie";
            document.getElementById('kupn').className = "grPierwszaObramowanie";
            document.getElementById('naje').className = "grPierwszaObramowanie";
            document.getElementById('wynajem').className = "grPierwszaObramowanieZmien";
            document.getElementById('deve').className = "grPierwszaObramowanie";
            document.getElementById('kome').className = "grPierwszaObramowanie";
        } else if (tabId == 'ctl00_cntAktualnosci_grpDevelop') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "block";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "none";

            document.getElementById('sprz').className = "grPierwszaObramowanie";
            document.getElementById('kupn').className = "grPierwszaObramowanie";
            document.getElementById('naje').className = "grPierwszaObramowanie";
            document.getElementById('wynajem').className = "grPierwszaObramowanie";
            document.getElementById('deve').className = "grPierwszaObramowanieZmien";
            document.getElementById('kome').className = "grPierwszaObramowanie";
        } else if (tabId == 'ctl00_cntAktualnosci_grpKomercyjne') {
            document.getElementById('ctl00_cntAktualnosci_grpSprzedaz').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKupno').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpNajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpWynajem').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpDevelop').style.display = "none";
            document.getElementById('ctl00_cntAktualnosci_grpKomercyjne').style.display = "block";

            document.getElementById('sprz').className = "grPierwszaObramowanie";
            document.getElementById('kupn').className = "grPierwszaObramowanie";
            document.getElementById('naje').className = "grPierwszaObramowanie";
            document.getElementById('wynajem').className = "grPierwszaObramowanie";
            document.getElementById('deve').className = "grPierwszaObramowanie";
            document.getElementById('kome').className = "grPierwszaObramowanieZmien";
        } else {
            document.getElementById('sprz').className = "grPierwszaObramowanieZmien";
        }
    //}
}

function OpenMap(u,i){
	var de=window.open(u+"mapa.aspx?id="+i,"","width=800,height=600")
}
function Show(u,i){
	var de=window.open(u+"regulamin.aspx?id="+i,"","width=800,height=600")
}
function ShowPrint(url){
	var w=window.open(url,"","width=700,scrollbars=yes,resizable=yes,menubar=yes ");
}
function Pokaz(o){
	var x=document.getElementById(o);
	if (x.style.display!="block"){x.style.display="block"} else {x.style.display="none"};
}
function ShowNotatnikPrint(){
	var w=window.open("wydruk_notatnik.aspx","","width=700,scrollbars=yes,resizable=yes,menubar=yes ");
}



// oferta.js //



var scroll=0;
var scrollValue = 0;
var scrollrodzaj=1;


if (document.getElementById("galeria") == null) {
    var gal=document.getElementById("galeria1");
    }
else {
    var gal=document.getElementById("galeria");
}



function scrolldown(i){
	scroll=1;
	scrollrodzaj=i;	
}
function scrollout(){
	scroll=0;	
}
function startscroll(){
	//gal=document.getElementById("galeria");
	if (document.getElementById("galeria") == null) {
        var gal=document.getElementById("galeria1");
        }
    else {
        var gal=document.getElementById("galeria");
    }
	var dcx=window.setInterval("step()",50); 
	
	scrollValue = 0;
}
function step(){
	if (scroll==1){
	    //gal=document.getElementById("galeria");
	    if (document.getElementById("galeria") == null) {
            var gal=document.getElementById("galeria1");
            }
        else {
            var gal=document.getElementById("galeria");
        }
	    
	    scrollValue += scrollrodzaj;
	    
	    if (scrollValue < 0) scrollValue = 0;
	    gal.style.marginLeft = -scrollValue*20 + "px"	 
	}
}




function zmien(nazwaObrazka,naJakiSrc, naJakiHref, naJakiTitle) 
{
    //alert(naJakiSrc);
    //alert(naJakiHref);
    if (document.images)
     {
        window.document.images[nazwaObrazka].src=naJakiSrc;
     }             
  try
  {
    window.document.getElementById("OfertaPokaz").setAttribute('href', naJakiHref);
    window.document.getElementById("OfertaPokaz").setAttribute('title', naJakiTitle);  
  }
  catch(e){
    alert(e);      
  }
}
function zmien2(nazwaObrazka,naJakiSrc, naJakiHref, naJakiTitle) 
{
    //alert(naJakiSrc);
    //alert(naJakiHref);
    if (document.images)
     {
        window.document.images[nazwaObrazka].src=naJakiSrc;
     }             
  try
  {
    window.document.getElementById("OfertaPokaz2").setAttribute('href', naJakiHref);
    window.document.getElementById("OfertaPokaz2").setAttribute('title', naJakiTitle);  
  }
  catch(e){
    alert(e);      
  }
}


function myWyslij(url)
{
    //alert(url);
    var i = ""; 
    $$('.listaWyslij').each(function(e) {
            if (e.checked == true) {
                i += e.value + ","
            }
        });   
        
    var c = document.getElementById("ctl00_cntMain_txtWybraneOferty").value;

    if (c == "wyslij") {    
        window.open(url+"/powOferty.aspx?id="+i,"","width=500,height=300")
    } else if (c == "zapytaj") {
        window.open(url+"/zapOferty.aspx?id="+i,"","width=500,height=300")
    };
    //return true;
}


function DodajDoNotatnika(Id, msg) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(","+Id+",") == -1) c += Id+",";
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);
    
    if (msg != "") alert(msg);
}

function UsunZNotatnika(Id, msg, reload) {
    var c = readCookie("notatnik");
    
    if (c === null) c = "";
    
    if (c.indexOf(Id+",") > -1) {
        c = c.replace(Id+",", "");
    }
    
    eraseCookie("notatnik");
    
    createCookie("notatnik", c, 31);

    if (msg != "") alert(msg);
    
    if (reload) {
        document.location.reload(false);
    }
}


var ilosc = "";              
if ($('ctl00_cntMain_ilZdjec') != null) { ilosc = $('ctl00_cntMain_ilZdjec').value; }

var iter = ilosc-1;
var r = ilosc-1;


function Morpheus(r) {

    if (r == 0) {
        new Effect.Morph('baner' + (ilosc-1), {
            style: 'opacity:1'
        });

        setTimeout(function () {
            for (var i = 0; i < ilosc; i++) {
                $('baner' + i).setStyle({ opacity: 1 });
            }
        }, 3000);

        r = ilosc-1;
        iter = ilosc-1;
        slide();
    }
    else {

        new Effect.Morph('baner' + r, {
            style: 'opacity:0'
        });
        iter -= 1;

        slide();
    }
};


function slide() {
    if ($$('.dvBannerGal')[0] != null) { 
        setTimeout('Morpheus(' + iter + ')', 3000);
    } 
}

//function slideshow() {
//    if ($$('.dvBannerGal')[0] != null) {
//        Morpheus(iter);
//    }
//}





function Powiadom(id) {
    var w = window;
    var d = document;
    var c = d.getElementsByTagName((d.compatMode && d.compatMode == 'CSS1Compat') ? 'HTML' : 'BODY')[0];
    var ww = w.innerWidth ? w.innerWidth + w.pageXOffset : c.clientWidth + c.scrollLeft;

    //var elementOffsetTop = $('OfertaLista' + id).cumulativeOffset()['top'];
    var elementOffsetTop = $$('body')[0].cumulativeScrollOffset()['top'];
    //$('body').getHeight() + 'px';
    //alert(elementOffsetTop1);

    var top = elementOffsetTop + 200 + 'px';
    var left = ww / 2 - 1370 / 2 + 'px';

    var newdv = new Element('div', { id: 'dvPowiadomZnajomego' });
    $('wrapper').insert({ before: newdv });
    //({ top: link })

    if (d.body && typeof d.body.clientWidth != 'undefined') {
        var winHeight = d.body.clientHeight
    }
    //alert(winHeight);
    $('dvPowiadomZnajomego').setStyle({ 'height': '1852px' });

    $('dvZnajomy').setStyle({ 'display': 'block' });
    $('dvZnajomy').morph('opacity: 1; height: 272px; left: ' + left + '; top: ' + top + ';');

}

function ClosePowiadom(msg) {
    $('dvPowiadomZnajomego').remove();
    if ($('ctl00_cntOutterWrapper_txtPowNazwisko')) {
        var pn = $('ctl00_cntOutterWrapper_txtPowNazwisko');
        var pe = $('ctl00_cntOutterWrapper_txtPowEmail');

        pn.setStyle({ 'border': '1px solid #333' });
        pe.setStyle({ 'border': '1px solid #333' });

        pn.value = '';
        pe.value = '';

        $('dvZnajomy').setStyle({ 'opacity': '0', 'height': '1px', 'left': '0px', 'top': '0px' });
    }

    if (msg != '0') {
        alert(msg);
    }
}
function HidePowiadom() {
    $('dvPowiadomZnajomego').remove();
    $('dvZnajomy').morph('opacity: 0; height: 1px; left: 0px;');
}
