var ns4=(document.layers)?true:false;
var ie4=(document.all)?true:false;
var DOM=(document.getElementById)?true:false;
var ie5=(DOM && document.all);
var ns6=(DOM && !document.all);

var zaladowana=false;
var swapping=(ns4||ie4||DOM);
var obrazki=new Array;

function random(limit){
 today = new Date();
 num = today.getTime();
 num = Math.round(Math.abs(Math.sin (num)*1000000)) % limit;
 return num;
}

function frm_num(nr,ile){
 pom=''+nr
 while(pom.length<ile){pom='0'+pom}
 return pom
}

function preload(nazwa,nazwa_pliku,w,h){
 if(nazwa_pliku==null)
  nazwa_pliku=nazwa;
 for(i=0;i<2;i++){
  if((!w==null)&&(!h==null))
   obrazki[''+nazwa+'_'+i]=new Image(w,h)
  else
   obrazki[''+nazwa+'_'+i]=new Image;
  obrazki[''+nazwa+'_'+i].src='gfx/'+nazwa_pliku+'_'+i+'.gif';
 }
}

if(swapping){
}

function obiekt(nazwa,id){
 if(DOM)
  return document.getElementById(nazwa)
 else
 if(ns4)
  if(id!=null)
   return document.layers[id].document[nazwa]
  else
   return document[nazwa]
 else
 if(ie4)
  return document.all[nazwa]
 else
  return null;
}

function warstwa(id){
 if(DOM)
  return obiekt(id).style
 else
 if(ie4)
  return document.all[id].style
 else
  return document.layers[id]
}

function getx(id){
 var w=warstwa(id);
 if(DOM)
  return w.offsetLeft
 else
 if(ns4)
  return parseInt(w.pageX)
 else
  return parseInt(w.left);
}

function gety(id){
 var w=warstwa(id)
 if(DOM)
  return w.offsetTop
 else
 if(ns4)
  return parseInt(w.pageY)
 else
  return parseInt(w.top);
}

function lmove(id,x,y){
 var w=warstwa(id)
 if(ns4){
  w.pageX=parseInt(x)
  w.pageY=parseInt(y)
 }
 else{
  w.left=parseInt(x)
  w.top=parseInt(y)
 }
}

function lvis(id,stan){
 var w=warstwa(id)
 if(DOM){
  if(stan)
   w.visibility='visible'
  else
   w.visibility='hidden'
 }else
 if(ns4){
  if(stan)
   w.visibility='show'
  else
   w.visibility='hide'
 }else
 if(ie4){
  if(stan)
   w.visibility='visible'
  else
   w.visibility='hidden'
 }
}

function swap_image(nazwa,nowy,id){
 obraz=obiekt(nazwa,id);
 if(swapping&&zaladowana)
  if((typeof(obraz)=='object')&&(typeof(nowy)=='object'))
   if(nowy.complete)
    obraz.src=nowy.src
}

function switch_img_old(nazwa,stan,nr){
 if(nr==null)nr='';
 if(stan)
  swap_image('im_'+nazwa+nr,obrazki[nazwa+'_1'])
 else
  swap_image('im_'+nazwa+nr,obrazki[nazwa+'_0']);
}

function switch_img(obraz,nazwa,stan){
 if(zaladowana){
  if(stan)
   obraz.src=obrazki[nazwa+'_1'].src;
  else
   obraz.src=obrazki[nazwa+'_0'].src;
 }
}

function image_on(obraz){
 if(obraz.style)
  obraz.style.borderColor="#FF0000";
}

function image_out(obraz){
 if(obraz.style)
  obraz.style.borderColor="#000000";
}

function set_bg(nazwa,kolor){
 obk=obiekt(nazwa);
 if(obk)
  if(obk.style)
   obk.style.backgroundColor=kolor;
}

function BlurLinks(){
	if(document.getElementById){
		lnks=document.getElementsByTagName('a');
		for(i=0;i<lnks.length;i++){
			lnks[i].onfocus=new Function("if(this.blur)this.blur()");
		}
	}
}


function obsluga_pol(){
 inp=document.getElementsByTagName('input');
 for(i=0;i<inp.length;i++){
  if(inp[i].className=='pole'){
   inp[i].onfocus=new Function("if(this.style)with(this.style){borderColor='#707ea7';backgroundColor='#FFFFFF';color='#000000';borderWidth='2px';}");
   inp[i].onblur=new Function("if(this.style)with(this.style){borderColor='#666666';backgroundColor='#FFFFFF';color='#444444';borderWidth='1px';}");
  }
 }
 inp=document.getElementsByTagName('textarea');
 for(i=0;i<inp.length;i++){
  if(inp[i].className=='pole'){
   inp[i].onfocus=new Function("if(this.style)with(this.style){borderColor='#707ea7';backgroundColor='#FFFFFF';color='#000000';borderWidth='2px';}");
   inp[i].onblur=new Function("if(this.style)with(this.style){borderColor='#666666';backgroundColor='#FFFFFF';color='#444444';borderWidth='1px';}");
  }
 }
}

function obsluga_img(){
 inp=document.getElementsByTagName('img');
 for(i=0;i<inp.length;i++){
  if((inp[i].className=='link')||(inp[i].className=='link2')){
   inp[i].onmouseover=new Function("if(this.style)with(this.style){borderColor='#000000';}");
   inp[i].onmouseout=new Function("if(this.style)with(this.style){borderColor='#707ea7';}");
  }
 }
}

function obsluga_list(){
 inp=document.getElementsByTagName('tr');
 for(i=0;i<inp.length;i++){
  if(inp[i].className=='linia1'){
   inp[i].onmouseover=new Function("if(this.style)with(this.style){backgroundColor='#FFE5E5';}");
   inp[i].onmouseout=new Function("if(this.style)with(this.style){backgroundColor='#FFFFFF';}");
  }else
  if(inp[i].className=='linia2'){
   inp[i].onmouseover=new Function("if(this.style)with(this.style){backgroundColor='#FFE5E5';}");
   inp[i].onmouseout=new Function("if(this.style)with(this.style){backgroundColor='#F5F5F5';}");
  }
 }
}

function pass_forgot(){
 if(document.forms["logowanie"]){
  if(!(document.forms["logowanie"].elements["id"].value>'')){
   alert("Najpierw podaj identyfikator...");
   document.forms["logowanie"].elements["id"].focus();
   return false;
  }else{
   document.forms["logowanie"].elements["forgot"].value="1";
   document.forms["logowanie"].submit();
   return false;
  }
 }else
  return false;
}

function set_login(){
 if(document.forms["logowanie"])
  document.forms["logowanie"].elements["id"].focus();
}

function init(){
 zaladowana=true;
// BlurLinks();
 obsluga_pol();
 obsluga_img();
// obsluga_list();
 set_login();
}

 