// © airmedia.pl [UTF-8 file]
if(parent.frames.length!=0)parent.location.replace(location.href)
function $(i){return document.getElementById(i);}
function $$(i,t){return document.getElementById(i).getElementsByTagName(t);}
function addclass(el, na){el.className+=' '+na;}
function remclass(el, na){var re=new RegExp('( ?'+na+')','g'); el.className=el.className.replace(re,'');}
function isDefined(variable){return eval('(typeof('+variable+') != "undefined");');}

var misio = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5 && @_jscript_version <= 5.8)
misio=true;
@end @*/
var ms6 = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5 && @_jscript_version <= 5.6)
ms6=true;
@end @*/
var colop = 0;
var colin = 0;
var colsInt = null;

onload = function()
{
 for(var i=0; i<document.links.length; i++)
  if(document.links[i].rel == 'external') document.links[i].target = '_blank';
 colsInt = setInterval(layout_animate, 15); // animacja
 init_scroll(); // pasek miniatur
 ajax_nav(); // pasek nawigacji bez przeładowywania
 xchgm(); // antyspam
 image_info(); // obsługa informacji o fotce
 
if(document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages();
}

////////////////////////////////////////////////////////////////////////
var clickmessage="© AnnaPawleta.com";
function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}}}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}}}
function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}
////////////////////////////////////////////////////////////////////////

function layout_prepare()
{
 // links
 for(var i=0; i<document.links.length; i++)
  if(document.links[i].rel.length < 1) 
   document.links[i].onclick = function() { layout_out(this.href); return false; }

 // inner function
 function otCalc(el)
 {
  if(misio)
  {
   var iY = el.offsetTop;
   var par = el.offsetParent;
   while((par.offsetParent) && (par.offsetParent.tagName != "BODY"))
   {
    iY += par.offsetTop;
    par = par.offsetParent;
   }
   return iY;
  } else return el.offsetTop;
 }

 // variables
 colop = 0;
 colin = 0.03;

 // put content in the middle of clip
 var mh = $('left').clientHeight;
 if($('right').clientHeight > mh) mh = $('right').clientHeight;
 var cc = otCalc($('footer')) - otCalc($('left'));
 if(cc-mh > 1)
 {
  $('left').style.marginTop = Math.round((cc-mh) / 2)+'px';
  $('right').style.marginTop = Math.round((cc-mh) / 2)+'px';
 }
 return;
}

function layout_animate()
{
 colop += colin;
 if(colop > 1) colop = 1;
 colin += 0.01;
 if(colin > 0.1) colin = 0.1;
 if(misio)
 {
  $('left').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
  $('right').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
  if($('controls')) $('controls').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
 }
  else
 {
  $('left').style.opacity = colop;
  $('right').style.opacity = colop;
  if($('controls')) $('controls').style.opacity = colop;
 }
 if(colop == 1)
 {
  clearInterval(colsInt);
  colsInt = null;
 }
 return;
}

var mylink = null;
function layout_out(where)
{
 if(colsInt == null)
 {
  mylink = where;
  colop = 1;
  colin = 0.03;
  colsInt = setInterval(layout_animateout, 15);
 }
 return;
}

function layout_animateout()
{
 colop -= colin;
 if(colop < 0) colop = 0;
 colin += 0.01;
 if(colin > 0.1) colin = 0.1;
 if(misio)
 {
  $('left').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
  $('right').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
  if($('controls')) $('controls').style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity="+(colop*100)+")";
 }
  else
 {
  $('left').style.opacity = colop;
  $('right').style.opacity = colop;
  if($('controls')) $('controls').style.opacity = colop;
 }
 if(colop == 0)
 {
  clearInterval(colsInt);
  colsInt = null;
  document.location.href = mylink;
 }
 return;
}

var emailReplaceArray = [['O','@'],[',','.']];
function xchgm()
{
 var replTab = emailReplaceArray;
 for (var i = 0; i < replTab.length; i++) {
      var s = escape(replTab[i][0].replace(/\s/g, ''));
      replTab[i][0] = s.replace(/%u/g, '\\u').replace(/%/g, '\\x');
    }
    var getEmail = function(s) {
      s = s.replace(/\s/g, '');
      for (var i = 0; i < replTab.length; i++) {
        s = s.replace(new RegExp(replTab[i][0], 'g'), replTab[i][1]);
      }
      return s;
    };
    var as = document.getElementsByTagName('a');
    var html = document.getElementsByTagName('html')[0];
    var text = html.textContent != undefined ? 'textContent' : 'innerText';
    for (var i = 0; i < as.length; i++) {
      if (! as[i].className.match(/(^|\s)eaddr($|\s)/)) continue;
      var email = getEmail(as[i][text]);
      as[i].setAttribute('href', 'mailto:' + email);
	  as[i][text] = email;
    }
 emailReplaceArray = undefined;
 if($('lew')) $('lew').value = 21;
}

function sprawdz()
{
 var ret = true;
 if($('imie').value.length < 3) { ret=false; alert('Podaj imię i nazwisko (ew. firmę)'); }
 if(ret && $('tresc').value.length < 3) { ret=false; alert('Wiadomość powinna zawierać treść.'); }
 if(ret && $('miasto').value.length < 3) { ret=false; alert('Wpisz miejscowość.'); }
 return ret;
}

function ajax_nav()
{
 var nlist = $$('right','ul');
 for(var i=0; i<nlist.length; i++)
  if(nlist[i].className=='nav')
  {
   var lnks = nlist[i].getElementsByTagName('a');
   for(var j=0; j<lnks.length; j++)
   {
	lnks[j].onclick=function() {
     var ajax = new sack();
	 // loading
	 var bg = document.createElement('div');
	 bg.setAttribute('id', 'loader');
	 with(bg.style) {
	  position='absolute';
	  top='0';
	  left='0';
	  width='100%';
	  height=$('right').offsetHeight+'px';
	  backgroundImage='url(img/axbg.gif)';
	  textAlign='center';
	 }
	 var im = document.createElement('img');
	 im.setAttribute('src', 'img/loader.gif');
	 im.setAttribute('alt', 'Wczytuję ...');
	 with(im.style) {
	  border='0';
	  width='32px';
	  height='32px';
	  marginTop=Math.round($('right').offsetHeight/2)+'px';
	 }
	 bg.appendChild(im);
	 $('right').appendChild(bg);
	 // run ajax
	 with(ajax)
	 {
      setVar('href', this.href);
      requestFile = 'ax_navig.php';
      method = 'post';
      element = 'right';
      onError = function() { alert('Błąd: brak komunikacji z serwerem!'); }
	  onCompletion = function() { ajax_nav(); recalc_IE(); }
      runAJAX();
	 }
     return!1;
	}
   }
  }
}

function recalc_IE()
{
 if(!misio) return false;
 var t = $('fotos').getElementsByTagName('li');
 if(t.length < 1) return false;
 var iY = t[0].offsetTop;
 var par = t[0].offsetParent;
 while((par.offsetParent) && (par.offsetParent.tagName != "BODY"))
 {
  iY += par.offsetTop;
  par = par.offsetParent;
 }
 var w = 0;
 for(var i=0; i<t.length; i++)
 {
  var sp = t[i].getElementsByTagName('span')[0];
  if(w == 0)
  {
   sp.style.visibility = 'hidden';
   sp.style.display = 'block';
   w = sp.offsetHeight;
   sp.style.display = '';
   sp.style.visibility = '';
  }
  sp.style.top = (iY-w)+'px';
 }
 return true;
}

var scrlpos = 0;
var scrnpos = 0;
var scrint = null;
var skrok = 3;
var isov1 = 0;
var isov2 = 0;
var ovint = null;
var xx = 0;
var mw = 0;

function init_scroll()
{
 if($('controls'))
 {
  var uel = $('fotos');

  // popraw widok podglądu
  var t = uel.getElementsByTagName('li');
  if(misio)
  {
   $('controls').style.position='static';
   var iY = t[0].offsetTop;
   par = t[0].offsetParent;
   while((par.offsetParent) && (par.offsetParent.tagName != "BODY"))
   {
    iY += par.offsetTop;
    par = par.offsetParent;
   }
  }
  var s = 0;
  var w = 0;
  for(var i=0; i<t.length; i++)
  {
   var sp = t[i].getElementsByTagName('span')[0];
   if(s == 0 || w == 0)
   {
	sp.style.visibility = 'hidden';
	sp.style.display = 'block';
    s = sp.offsetWidth;
    w = sp.offsetHeight;
	sp.style.display = '';
	sp.style.visibility = '';
   }
   sp.style.top = '-'+w+'px';
   sp.style.right = 'auto';
   sp.style.bottom = 'auto';
   sp.style.left = (Math.round(t[i].offsetWidth / 2) + t[i].offsetLeft - Math.round(s / 2))+'px';
   if(misio) sp.style.top = (iY-w)+'px';
   var ael = t[i].getElementsByTagName('a')[0];
   t[i].onmouseover = function()
                      {
					   this.getElementsByTagName('span')[0].style.marginLeft = ((-$('fotos').scrollLeft) + $('bleft').offsetWidth  )+'px';
					   addclass(this, 'hov');
					  }
   ael.onfocus = function()
                 {
				  this.getElementsByTagName('span')[0].style.marginLeft = ((-$('fotos').scrollLeft) + $('bleft').offsetWidth  )+'px';
				  addclass(this.parentNode, 'hov');
                 }
   t[i].onmouseout = function() { remclass(this, 'hov'); }
   ael.onblur = function() { remclass(this.parentNode, 'hov'); }
   ael.onclick = function() { pokafotke(this.getAttribute('rel')); return!1; }
  }

  // zrób scrolla
  mw = uel.scrollWidth;
  var ow =  uel.offsetWidth;
  var t = uel.getElementsByTagName('li');
  if(t.length < 1) return false;
  uel.style.display = 'none';

  var btn1 = document.createElement("a");
  btn1.className = 'bttn';
  btn1.setAttribute('id', 'bleft');
  btn1.style.paddingRight = '5px';
  btn1.onclick = function() { return!1; }
  var tx = document.createTextNode('« poprzednie');
  btn1.appendChild(tx);
  var btn2 = document.createElement("a");
  btn2.className = 'bttn';
  btn2.setAttribute('id', 'bright');
  btn2.style.paddingLeft = '5px';
  btn2.onclick = function() { return!1; }
  tx = document.createTextNode('następne »');
  btn2.appendChild(tx);
  var cn = uel.parentNode;
  cn.insertBefore(btn2, uel.nextSibling);
  cn.insertBefore(btn1, uel);

  uel.style.width = (ow-(btn1.offsetWidth + btn2.offsetWidth))+'px';
  uel.style.display = '';
  uel.scrollLeft = scrlpos = 0;
  disableBtn(btn1);
  if(t.length < 15) disableBtn(btn2);
  mw -= uel.clientWidth; // (btn1.offsetWidth + btn2.offsetWidth)

  btn1.onmouseover = function x1() { isov1 = 1; }
  btn2.onmouseover = function x2() { isov2 = 1; }
  btn1.onmouseout = function x3() { isov1 = 0; skrok = 3; }
  btn2.onmouseout = function x4() { isov2 = 0; skrok = 3; }
  if(ovint == null) ovint = setInterval(doOvctrl, 10);

 }
}

function enableBtn(b)
{
 remclass(b, 'dis');
}

function disableBtn(b)
{
 addclass(b, 'dis');
}

function doOvctrl()
{
 if(isov1 == 1 && scrint==null && scrlpos > 0 && ovint!=null)
 {
  clearInterval(ovint);
  ovint = null;
  scrlpos -= 60;
  if(scrlpos < 0) scrlpos = 0;
  scrint = setInterval(doScroll, 30);
 }
 else
 if(isov2 == 1 && scrint==null && scrlpos < mw && ovint!=null)
 {
  clearInterval(ovint);
  ovint = null;
  scrlpos += 60;
  if(scrlpos > mw) scrlpos = mw;
  scrint = setInterval(doScroll, 30);
 }
}

function doScroll()
{
 xx++;
 if(xx > 4) { xx=0; skrok++; }
 if(skrok > 15) skrok = 15;
 if(scrnpos > scrlpos)
 {
  scrnpos -= skrok;
  if(scrnpos < scrlpos) scrnpos = scrlpos;
  $('fotos').scrollLeft = scrnpos;
 }
 if(scrnpos < scrlpos)
 {
  scrnpos += skrok;
  if(scrnpos > scrlpos) scrnpos = scrlpos;
  $('fotos').scrollLeft = scrnpos;
 }
 if(scrnpos == scrlpos && scrint != null)
 {
  clearInterval(scrint);
  scrint = null;
  if($('fotos').scrollLeft == 0) disableBtn($('bleft')); else enableBtn($('bleft'));
  if(scrnpos >= mw) disableBtn($('bright')); else if(mw > $('fotos').offsetWidth) enableBtn($('bright'));
  if(ovint == null) ovint = setInterval(doOvctrl, 10);
 }
}

var iiH = 0;
var iSt = 8;
var Hmax = 42;
var Hint = null;

function image_info()
{
 iiH = 0;
 iSt = 8;
 Hint = null;
 if($('icont'))
 {
  $('icont').style.width = $('fotka').offsetWidth+'px';
  if(!ms6)
   $('icont').style.left = $('fotka').offsetLeft+'px';
    else $('icont').style.bottom = '14px';
  document.body.onmouseover=hideInfo;
  var eall = $('info').getElementsByTagName('*');
  for(var i=0; i<eall.length; i++) eall[i].onmouseover=function(e) { e=e||event; e.cancelBubble=true; showInfo(); return!1; }
 }
 return;
}

function incH()
{
 if($('icont'))
 {
  if(iiH < Hmax)
  {
   iSt -= iSt/10;
   if(iSt < 2) iSt = 2;
   iiH += iSt;
   if(iiH > Hmax) iiH = Hmax;
   if(iiH < 0) iiH = 0;
   $('icont').style.height = Math.round(iiH)+'px';
  }
   else
  {
   iiH = Hmax;
   $('icont').style.height = Math.round(iiH)+'px';
   clearInterval(Hint);
   Hint = null;
  }
 } else return false;
 return true;
}

function decH()
{
 if($('icont'))
 {
  if(iiH > 0)
  {
   iSt += iSt/10;
   if(iSt > 8) iSt = 8;
   iiH -= iSt;
   if(iiH > Hmax) iiH = Hmax;
   if(iiH < 0) iiH = 0;
   $('icont').style.height = Math.round(iiH)+'px';
  }
   else
  {
   iiH = 0;
   $('icont').style.height = Math.round(iiH)+'px';
   clearInterval(Hint);
   Hint = null;
  }
 } else return false;
 return true;
}

function showInfo()
{
 if($('icont') && (iiH < Hmax))
 {
  if(Hint != null)
  {
   clearInterval(Hint);
   Hint = null;
  }
  Hint = setInterval(incH, 30);
 }
 return;
}

function hideInfo()
{
 if($('icont') && (iiH > 0))
 {
  if(Hint != null)
  {
   clearInterval(Hint);
   Hint = null;
  }
  Hint = setInterval(decH, 30);
 }
 return;
}

function pokafotke(n)
{
 document.location.hash = n;
 var ajax = new sack();
 with(ajax)
 {
  setVar("foto", n);
  requestFile = 'ax_foto.php';
  method = 'post';
  element = 'left';
  onError = function() { alert('Błąd: brak komunikacji z serwerem!'); }
  onCompletion = function() { $('loader').style.display = ''; recalc_IE(); image_info(); }
 }
 $('fotka').onload = function() { this.onload = null; }
 if(Hint != null)
 {
  clearInterval(Hint);
  Hint = null;
 }
 $('left').onmouseout=null;
 $('loader').style.display = 'block';
 $('icont').style.height = Hmax+'px';
 ajax.runAJAX();
}

var minis = false;

function pokaMiniatury(g)
{
 if(!minis)
 {
  var ft = $('info').getElementsByTagName('*');
  for(var i=0; i<ft.length; i++) ft[i].style.visibility = 'hidden';
  $('fotos').style.display = 'none';
  $('bleft').style.display = 'none';
  $('bright').style.display = 'none';
  var nwin = document.createElement('div');
  nwin.setAttribute('id', 'nwin');
  nwin.style.height = $('info').offsetHeight+'px';
  nwin.style.overflow = 'visible';
  if(ms6)
  {
   nwin.style.background = 'navy';
  }
  $('info').insertBefore(nwin, $('fotka'));
  var li = document.createElement('img');
  li.setAttribute('src', 'img/loader.gif');
  li.style.display = 'block';
  li.style.marginTop = (Math.round($('info').offsetHeight / 2)-16)+'px';
  li.style.marginLeft = 'auto';
  li.style.marginRight = 'auto';
  nwin.appendChild(li);
  var ajax = new sack();
  with(ajax)
  {
   setVar("galeria", g);
   requestFile = 'ax_allm.php';
   method = 'post';
   element = 'nwin';
   onError = function() { alert('Błąd: brak komunikacji z serwerem!'); }
   onCompletion = function() { 
      var x = $('nwin').offsetHeight; // for stupid IE
      nwin.style.height = 'auto';
      $('left').style.height = $('nwin').offsetHeight+'px';
	  if(!isDefined('mld'))
	  {
	   var sc = document.createElement('script');
	   sc.type = 'text/javascript';
       sc.src = 'mlbox_inc.js';
	   document.getElementsByTagName('head')[0].appendChild(sc);
	  } else initml();
     }
  }
  ajax.runAJAX();
  minis = true;
 }
 return!1;
}

function pokaPasek()
{
 if(minis)
 {
  var nwin = $('nwin');
  $('info').removeChild(nwin);
  $('left').style.height = '';
  var ft = $('info').getElementsByTagName('*');
  for(var i=0; i<ft.length; i++) ft[i].style.visibility = '';
  $('fotos').style.display = '';
  $('bleft').style.display = '';
  $('bright').style.display = '';
  minis = false;
 }
 return!1;
}

function xwin(page, x, y)
{
 var sx = screen.availWidth;
 var sy = screen.availHeight;
 var px = (sx/2)-(x/2);
 var py = (sy/2)-(y/2);
 var nwi = window.open(page,'xwin','dependent=yes,toolbar=no,top='+py+',left='+px+',width='+x+',height='+y+',resizable=no,scrollbars=no,status=no');
 nwi.focus();
 return;
}