 var clientPC = navigator.userAgent.toLowerCase();
 var clientVer = parseInt(navigator.appVersion);
 
 var ie = (document.all) ? true : false;   

 var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
 var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                 && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                 && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
 var is_moz = 0;

 var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
 var is_mac = (clientPC.indexOf("mac")!=-1);
 
 if (!ie) {
  document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = mousePos;
  var pozX, pozY;
 }
 
 function GetX(obj) {
  var curleft = 0;
  obj = o(obj);
  
   if (obj.offsetParent) {
    while (obj.offsetParent) {
     curleft += obj.offsetLeft
     obj = obj.offsetParent;
    }
   }
   else if (obj.x)
    curleft += obj.x;
    
  return curleft;
 }

 function GetY(obj) {
  var curtop = 0;
  obj = o(obj);
  
   if (obj.offsetParent) {
    while (obj.offsetParent) {
     curtop += obj.offsetTop
     obj = obj.offsetParent;
    }
   }
   else if (obj.y)
    curtop += obj.y;
    
  return curtop;
 } 

 function mousePos(e) {
  pozX = e.pageX;
  pozY = e.pageY;
 }  

 function o (id) {
  if (document.getElementById) {
    obj=document.getElementById(id);
  } else if (document.layers) {
    obj=document.layers[id];
  } else if (document.all) {
    obj=document.all[id];
  } else {
    obj=false;
  }

  return obj;
 }
 
 function o_style (name) {
  if (document.getElementById) {
   obj=document.getElementById(name).style;
  } else if (document.layers) {
   obj=document.layers[name];
  } else if (document.all) {
   obj=document.all[name].style;
  } else {
   obj=false;
  }

  return obj;
 }   
     
 function o_hide (name) {
  if (document.getElementById) {
   obj = document.getElementById(name).style.visibility = "hidden";
  } else if (document.layers) {
   obj = document.layers[name].visibility = "hide";
  } else if (document.all) {
   obj = document.all[name].style.visibility = "hidden";
  } else {
   obj=false;
  }
 }

 function o_show (name) {
  if (document.getElementById) {
   obj = document.getElementById(name).style.visibility = "visible";
  } else if (document.layers) {
   obj = document.layers[name].visibility = "show";
  } else if (document.all) {
   obj = document.all[name].style.visibility = "visible";
  } else {
   obj=false;
  }
 }
      
 function NapiszNewsa () {
  var mydiv = o('napisznewsa');
  mydiv.style.display = (mydiv.style.display == 'block') ? 'none' : 'block';
  if (o('formMail')) {
   if (o('formMail').value == '') o('formMail').focus();
   else o('formTitle').focus();
  } else {
   if (o('formAuthor')) o('formTitle').focus();
  }
 }

 function PV () {
  return confirm('Czy chcesz oddać głos na wybraną opcję?');
 }

 function PH (optid,im) {
  var img = o(optid);

  img.src = 'http://img.magicsport.pl/sonda/'+im+'.gif';
 }

 function Edytuj () {
  o('edytuj').className = (o('edytuj').className == 'edytuj') ? 'edytuj_a' : 'edytuj';
  o_style('edytuj_opcje').display = (o_style('edytuj_opcje').display == 'none') ? 'block' : 'none';
  setCookie('edytuj_status',o_style('edytuj_opcje').display,'','/','.magicsport.pl');
 }

 function setCookie (cookieName, cookieValue, expires, path, domain, secure) {
  document.cookie = escape(cookieName) + '=' + escape(cookieValue)
                    + (expires ? '; expires=' + expires.toGMTString() : '')
                    + (path ? '; path=' + path : '')
                    + (domain ? '; domain=' + domain : '')
                    + (secure ? '; secure' : '');
 }

 function getCookie (cookieName) {
  var cookieValue = '';
  var posName = document.cookie.indexOf(escape(cookieName) + '=');
  if (posName != -1) {
   var posValue = posName + (escape(cookieName) + '=').length;
   var endPos = document.cookie.indexOf(';', posValue);
   if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
   else cookieValue = unescape(document.cookie.substring(posValue));
  }
  return (cookieValue);
 }
 
 var lastScreen = 0;
 
 function showScreen (id,url,w,h) {
  if (lastScreen > 0 && lastScreen == id) {
   hideScreen();
   return;
  }
  
  x = GetX('showScreen'+id);
  y = GetY('showScreen'+id); 
  
  y -= h/2;
  
  if (y < 200) y = 200; 
  
  if (w < 400) {
   x -= w+25;
  } else {
   x -= w/2;
   x -= 230;
  }
  
  o('myScreen').src = 'http://img.magicsport.pl/kategorie/0.gif';
  o_style('dlScreen').top = y+'px';
  o_style('dlScreen').left = x+'px';
  o('myScreen').src = url+"?x="+id;
  o_show('dlScreen');
  
  lastScreen = id;
 }
 
 function hideScreen () {
  o('myScreen').src = 'http://img.magicsport.pl/kategorie/0.gif';
  o_hide('dlScreen');             
  lastScreen = 0;
 }
 
 function hitCount (id) {
  var tmpcnt = o('hitCount'+id).innerHTML;
  tmpcnt = parseInt(tmpcnt);
  tmpcnt++;
  if (tmpcnt == 1) tmpcnt = tmpcnt+' raz';
  else tmpcnt = tmpcnt+' razy';
  
  o('hitCount'+id).innerHTML = tmpcnt;
 }
 
 function catImg (id,im) {
  if (im == '') im = '0.gif';
  o('catImg'+id).src = 'http://img.magicsport.pl/dl/kategorie/'+im;
 }
 
 function setSort (key) {
  setCookie('sortKey',key);
 }
 
 function setOrd (key) {
  setCookie('sortOrd',key);
 } 
 
 function setCount (cnt) {
  setCookie('sortCount',cnt);
 }   
 
 var bars = new Array;
 
 function resizeBar (id,maxw) {
  var x = o_style('bar'+id).width;
  x = parseInt(x);
  
  if (x < 50) x += 3;
  if (x > 50) x += 5;
  if (x > 100) x += 10;
  if (x > 200) x += 20;
  if (x > 300) x += 30;
  
  if (x <= maxw) o_style('bar'+id).width = x+'px';
  else clearInterval(bars[id]);
 }
 
 function progressBar (id,maxw) {
  bars[id] = setInterval('resizeBar('+id+','+maxw+')',5);  
 }