if(parent.frames.length!=0)parent.location.replace(location.href)

function $(i){return document.getElementById(i);}

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 ax_p = null;
var currfoto = false;
var intsl = false;
var sek = 0;
var maxsek = 9;
var pausesl = false;
var fcnt = 0;
var intsc = false;
var scrpos = 0;
var scrstartpos = 0;
var scrspeed = 0;
var scrmax = 0;
var fdv = 1;
var fdd = 0;
var fdi = false;
var ax_w = null;

function odlicz()
{
 if(sek < 1 || pausesl) return!1;
 sek--;
 if(sek==0)
 {
  sek = maxsek;
  pausesl = true;
  var pt=$('slider').getElementsByTagName('img');
  pt[fcnt].style.borderColor = '';
  fcnt++;
  if(fcnt >= pt.length) fcnt = 0;
  photo(pt[fcnt].getAttribute('alt'), false);
 }
 $('odl').innerHTML = sek;
}

function fade()
{
 fdv+=fdd;
 if(fdd < 0 && fdv < 0.6)
 {
  fdv = 0.6;
  clearInterval(fdi);
  fdi = false;
 }
 if(fdd > 0 && fdv > 1)
 {
  fdv = 1;
  clearInterval(fdi);
  fdi = false;
 }
 $('content').style.opacity = fdv;
 if(misio) $('content').style.filter = 'Alpha(Opacity='+fdv*100+')';
 return true;
}

function fadeIn()
{
 fdd = -0.05;
 if(fdi) clearInterval(fdi);
 fdi = setInterval(fade, 30);
 return true;
}

function fadeOut()
{
 fdd = 0.05;
 if(fdi) clearInterval(fdi);
 fdi = setInterval(fade, 30);
 return true;
}

function startslide()
{
 if(intsl) return!1;
 sek = maxsek;
 fcnt = 0;
 intsl = setInterval(odlicz, 1000);
 $('odl').innerHTML = sek;
}

function stopslide()
{
 if(!intsl) return!1;
 clearInterval(intsl);
 instsl = false;
 $('slider').getElementsByTagName('img')[fcnt].style.borderColor = '';
 $('odl').innerHTML = '';
 return true;
}

function photo(pf, startsl)
{
 if(ax_p == null)
 {
  ax_p = new sack();
  ax_p.requestFile = 'getphoto';
  ax_p.method = 'POST';
  ax_p.element = 'ximg';
  ax_p.setVar('h', $('content').offsetHeight);
  ax_p.setVar('w', $('content').offsetWidth);
  ax_p.setVar('f', pf);
  ax_p.onCompletion = function() { ax_p = null; }
  ax_p.onError = function() { alert('Wystąpił błąd podczas komunikacji z serwerem!'); ax_p = null; $('ldr').style.display = ''; }
  $('ldr').style.display = 'block';
  fadeIn();
  currfoto=pf;
  ax_p.runAJAX();
  if(startsl) { pausesl = true; startslide(); }
  return true;
 }
 return false;
}

function detectScroll()
{
 sw = $('slider').offsetWidth;
 iw = $('innslide').offsetWidth;
 if(iw < sw)
 {
  $('innslide').style.width='100%';
  $('lewo').style.display='none';
  $('prawo').style.display='none';
 }
  else
 {
  scrpos = scrstartpos = $('innslide').offsetLeft - 16;
  scrmax = Math.abs($('innslide').offsetWidth - $('slider').offsetWidth + 32)*-1;
  $('lewo').onmouseout=function() { stopScroll(); }
  $('prawo').onmouseout=function() { stopScroll(); }
  $('lewo').onmouseover=function() { startScroll(3); }
  $('prawo').onmouseover=function() { startScroll(-3); }
 }
 return true;
}

function stopScroll()
{
 if(!intsc) return!1;
 clearInterval(intsc);
 intsc = false;
 return true;
}

function startScroll(v)
{
 if(intsc) return!1;
 scrspeed = v;
 intsc = setInterval(doScroll, 25);
 return true;
}

function doScroll()
{
 stp = false;
 if(scrpos > scrstartpos) { scrpos=scrstartpos; $('innslide').style.marginLeft=scrpos+'px'; stp=true; stopScroll(); }
 if(scrpos < scrmax) { scrpos=scrmax; $('innslide').style.marginLeft=scrpos+'px'; stp=true; stopScroll(); }
 if(!stp)
 {
  if(Math.abs(scrspeed) < 15) scrspeed*=1.02;
  scrpos+=parseInt(scrspeed);
  if(scrpos > scrstartpos) { scrpos=scrstartpos; }
  if(scrpos < scrmax) { scrpos=scrmax; }
  $('innslide').style.marginLeft=scrpos+'px';
 }
 return true;
}

window.onload=function(){
	for(var i=0;i<document.links.length;i++){
		if(document.links[i].rel && document.links[i].rel == 'external'){
			document.links[i].target='_blank';
		}
	}
	if($('nopole')) $('nopole').value = '61';
	if(ms6)
	{
		alert('Ta strona nie działa z przeglądarką Internet Explorer 6!\nZmień swoją przegladarkę na nowszą niż 11 letnia...');
	}
	 xchgm()
}

window.onresize=function(){
	if(currfoto) photo(currfoto, false);
}

function xchgm(){
var emailReplaceArray = [['0','@'],[',','.']];
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;}

function showWindow(idname)
{
 var els=document.getElementsByTagName('div');
 for(var x=0;x<els.length;x++)
  if(els[x].className=='window')
  {
   if(els[x].getAttribute('id')!=idname) els[x].style.display='';
  }
 $(idname).style.display='block';
}

function closeWindow(el)
{
 el.parentNode.parentNode.style.display='';
}

function wyslij()
{
 var ret = true;
 if($('imie').value.length < 3) { ret=false; alert('Podaj imię i nazwisko (ew. firmę)'); }
 if(ret && $('miasto').value.length < 3) { ret=false; alert('Wpisz miejscowość.'); }
 if(ret && $('tresc').value.length < 3) { ret=false; alert('Wiadomość powinna zawierać treść.'); }
 if(ret)
 {
  if(ax_w == null)
  {
   ax_w = new sack();
   ax_w.requestFile = 'sendform';
   ax_w.method = 'POST';
   ax_w.element = 'sndret';
   ax_w.setVar('imie', $('imie').value);
   ax_w.setVar('tresc', $('tresc').value);
   ax_w.setVar('miasto', $('miasto').value);
   ax_w.setVar('lew', $('nopole').value);
   ax_w.setVar('email', $('email').value);
   ax_w.setVar('skad', $('trafil').value);
   ax_w.setVar('telefon', $('telefon').value);
   ax_w.onCompletion = function() {
	    var rv = $('sndret').innerHTML;
		ax_w = null;
		if(rv == 'send_ok')
		{
		 alert('Twoja wiadomość została wysłana.');
		 $('subbtn').childNodes[0].nodeValue='Wyślij ponownie';
		}
		 else
		{
		 if(rv == 'err_send') alert('Nie udało się wysłać formularza.\nSpróbuj ponownie za chwilę.');
		 if(rv == 'err_no_param') alert('Nie uzupełniono wymaganych pól.');
		 $('subbtn').childNodes[0].nodeValue='Wyślij formularz';
		}
		$('subbtn').disabled=false;
	}
   ax_w.onError = function() {
		alert('Wystąpił błąd podczas komunikacji z serwerem!');
		ax_w = null;
		$('subbtn').disabled=false;
		$('subbtn').childNodes[0].nodeValue='Wyślij formularz';
	}
   $('subbtn').disabled=true;
   $('subbtn').childNodes[0].nodeValue='Wysyłam ....';
   ax_w.runAJAX();
   return!1;
  }
  return!1;
 }
 return!1;
}


/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* 2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
		return null;
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}
				
							if (self.responseStatus[0] == "200") {
								this.elementObj = document.getElementById(self.element);
								if(this.elementObj.nodeName.toLowerCase() != 'img') this.elementObj.innerHTML = self.response;
								 else
								 {
								  this.elementObj.onload=function()
								  {
									  $('ldr').style.display = '';
									  $('ximg').onload = null;
									  $('content').style.backgroundImage='url('+$('ximg').src+')';
									  fadeOut();
									  if(intsl) $('slider').getElementsByTagName('img')[fcnt].style.borderColor = 'white';
									  pausesl = false;
								  }
								  this.elementObj.src=self.response;
								 }
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}
