if(parent.frames.length!=0)parent.location.replace(location.href)
function $(i){return document.getElementById(i);}
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 cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
window.onload = function()
{
 setActiveStyleSheet(title);
 xchgm();
 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 = '122';
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function sprawdz()
{
 var ret = true;
 if($('imie').value.length < 3) { ret=false; alert('Proszę podać Imię i nazwisko lub nazwę firmy.'); }
 if(ret && $('tresc').value.length < 3) { ret=false; alert('Wiadomość powinna zawierać treść.'); }
 return ret;
}

function nwin(page, x, y, scr)
{
 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,'mwin','dependent=yes,toolbar=no,top='+py+',left='+px+',width='+x+',height='+y+',resizable=no,scrollbars='+scr+',status=yes', true);
 nwi.focus();
 return;
}

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 setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function switchStyles()
{
 var a = getActiveStyleSheet();
 if(a == 'default') setActiveStyleSheet('highcontrast');
  else setActiveStyleSheet('default');
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

var vs = null;
var vw = null;
var ct = null;
var scrollInt = null;
var offset = 0;
var maxof = 0;
var accel = 1;
var la,ra;
function initScroll()
{
 vw = $('view');
 vs = $('vslider');
 vw.className = 'js';

 la=document.createElement('a');
 la.className='leftArrow';
 la.href='#';
 la.onclick=function() { return false; }
 la.onmouseover=function() { moveScroll(0); }
 la.onmouseout=function() { stopScroll(); }
 vw.appendChild(la);

 ra=document.createElement('a');
 ra.className='rightArrow';
 ra.href='#';
 ra.onclick=function() { return false; }
 ra.onmouseover=function() { moveScroll(1) }
 ra.onmouseout=function() { stopScroll(); }
 vw.appendChild(ra);

 ct=$('vslider').getElementsByTagName('div')[0];
 offset=ct.offsetLeft;
 maxof=(ct.offsetWidth-vs.offsetWidth-14)*-1;
 if(maxof >= 0)
 {
  la.onmouseover=null;
  la.style.cursor='default';
  la.style.backgroundPosition='-30px 0';
  ra.onmouseover=null;
  ra.style.cursor='default';
  ra.style.backgroundPosition='-30px 0';
 }
  else
 {
  if(offset==0)
  {
   la.style.cursor='default';
   la.style.backgroundPosition='-30px 0';
  }
  if(offset==maxof)
  {
   ra.style.cursor='default';
   ra.style.backgroundPosition='-30px 0';
  }
 }
 return true;
}

function moveScroll(d)
{
 if(scrollInt!=null) return false;
 if(d!=1) d=0;
 accel=0.5;
 scrollInt = setInterval(doScroll, 20, d);
}

function stopScroll()
{
 if(scrollInt!=null)
 {
  clearInterval(scrollInt);
  scrollInt=null;
 }
}

function doScroll(d)
{
 accel+=(accel/10);
 if(accel>7) accel=7;
 if(d==0) offset+=Math.round(accel);
  else  offset-=Math.round(accel);
 if(offset>0) offset=0;
 if(offset<maxof) offset=maxof;
 ct.style.left=offset+'px';
 if(offset==0)
 {
  la.style.cursor='default';
  la.style.backgroundPosition='-30px 0';
 }
  else
   if(la.style.cursor=='default')
   {
	la.style.cursor='';
	la.style.backgroundPosition='';
   }
 if(offset==maxof)
 {
  ra.style.cursor='default';
  ra.style.backgroundPosition='-30px 0';
 }
  else
   if(ra.style.cursor=='default')
   {
	ra.style.cursor='';
	ra.style.backgroundPosition='';
   }
 return true;
}

var ajxobj=false;
function loadps(id)
{
 if(ajxobj==false)
 {
  $('psite').innerHTML = '&nbsp;';
  $('psite').style.backgroundImage='url(img/ml_load.gif)';
  try {
	ajxobj = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e1) {
   try {
	ajxobj = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e2) {
      ajxobj=false;
     }
   }
  if(!ajxobj) {
	if(typeof XMLHttpRequest != "undefined") {
		ajxobj = new XMLHttpRequest();
	} else {
		return false;
	}
  }
  ajxobj.open("GET", 'getsite.php?id='+encodeURIComponent(id)+'&rndv='+new Date().getTime());
  ajxobj.onreadystatechange = function() {
	  if(ajxobj.readyState==4)
	  {
		if(ajxobj.status=='200') $('psite').innerHTML=ajxobj.responseText;
		$('psite').style.backgroundImage='none';
		ajxobj=false;
		for(var i=0;i<mld.links.length;i++) if(mld.links[i].rel && mld.links[i].rel.match(/(^|\s)mlbox($|\[|\s)/) && mld.links[i].onclick==null) mld.links[i].onclick=mlbox;
	  }
  }
  ajxobj.send(null);
 }
 return false;
}
