var lastImg = null;

function imgSwap(ev,imgName) {
if (imgName != 0) {
	lastImg = ev.src;
	ev.src = imgName;
	}	
	else
	{
	ev.src = lastImg;
	}
}
function checkFields(newForm) {
	if (newForm.title.value == '') {
		alert('Brak tytułu');
		return ;
	} else if (newForm.body.value == '') {
		alert('Brak treści');
		return ;
	}
	newForm.submit();
}


function fullsize(pI,title,desc) {
        if(document.all){picId = "/_uTils/site/gallery.html?" + pI + "&title=" + encodeURIComponent(escape(title)) + "&desc=" + encodeURIComponent(escape(desc));}
        else{picId = "/_uTils/site/gallery.html?" + pI + "&title=" + escape(title) + "&desc=" + escape(desc);}
//picId = encodeURI(picId);
        Win = window.open(picId,'DispalyWindow','width=300, height=300, resizable=yes, scrollbars=auto menubar=no, location=no');
        return;
}
function isN(v,f,n) {
	if(v.length>0)if((v!=~~v)||(v<=0)){alert('Wymagana jest liczba całkowita dodatnia.');o=eval('document.'+f+"."+n);o.value="";}
}
function openInNewWindow(href){
	return window.open(href, null, '');
}

var pM07,mybl2,db,nIE,IE;
var d = document;
nIE = (d.getElementById && (!d.all || window.opera));
IE = (d.getElementById && d.all && !window.opera);
v6 = (d.fireEvent && d.createComment);
      

function odGory(el) {
  var x = el.offsetTop;
  if (el.offsetParent != null)
    x += odGory(el.offsetParent);
  return x;
}

function myOffsetBottom(obj) {
  return obj.offsetTop+obj.offsetHeight;
}

function runPlywajaceMenu() {
  if (mybl2Height > pM07Height) {//menu niższe niż treść
    if (nIE) winY = window.pageYOffset;
    else if (IE) winY = db.scrollTop;
    if (winY < mybl2Top) winY = mybl2Top;
    else if (winY + pM07Height > mybl2Bottom) winY = mybl2Bottom - pM07Height;
    if (winY != lastY) {
      zGracja = modyfikator * (winY - lastY);
    } else zGracja = 0;
    if (zGracja > 0) zGracja = Math.ceil(zGracja);
    else zGracja = Math.floor(zGracja);
    if (zGracja != 0) {
      pM07.style.marginTop = parseInt(pM07.style.marginTop) + zGracja + 'px'; 
      lastY += zGracja;
    }
    setTimeout('runPlywajaceMenu()',1);
  }
}

function initPlywajaceMenu() {
  pM07 = d.getElementById('pM07');
  mybl2 = d.getElementById('mybl2');
  if (mybl2) {
    mybl2Top = odGory(mybl2);
    mybl2Bottom = myOffsetBottom(mybl2);
    mybl2Height = mybl2.offsetHeight;
    lastY = mybl2Top;
  }
  if (pM07) {
    db = (IE && v6) ? d.documentElement : d.body;
    if (IE && v6) modyfikator = .6;
    else modyfikator = .2;
    pM07Top = odGory(pM07);
    pM07Height = pM07.offsetHeight;
    pM07.style.marginTop = 0;
    runPlywajaceMenu();
  }
}
