// thanks for hao@hiphopart.pl

Verbose="";

isNS = (navigator.appName == "Netscape");
isV=navigator.appVersion.substring(0,1);
  if (!isNS) {
   isIEv=navigator.appVersion.match(/MSIE ([0-9,\.]+)(\;|\))/);
   if (isIEv!=null) {isV=Number(isIEv[1]);
	} 
  }

if (((isNS)&&(isV>=4))||((!isNS)&&(isV>=4))) {isUS=0} else {isUS=1}

isIE = (!isNS && isV>=5);
isMoz = (isNS && isV>=5);
isNN=(isNS && isV<5);
isOpac=isIE||isMoz;

doc=document;
oIE=doc.all;
oMoz=doc.getElementById?doc.getElementsByTagName('div'):0;
oNS=doc.layers;
loaded=0;

var isSpeed=0;

divs=[];
cdh=new cdhobj();

function cdhobj() {
this.nDiv=oNS?fnDiv4:oIE?fnDiv:fnDivM;
}


function cdhInit(chkspd) {
findD(oIE?oIE.tags('div'):oMoz?oMoz:oNS)
if (chkspd) checkSpeed()
loaded=1;
cdhUpd();
}

function findD(o) {
for (var i=0;i<o.length;i++) {with (o[i]) {getD(o[i],id); if (oNS)findD(document.layers)} }
}

function getD(o,id) {
divs[id]=o;
if (oNS) {o.style=o;o.id=o.name;if (o.ide) o.id=o.ide; else o.ide=o.id;}
o.tX=0;o.tY=0;o.tW=0;o.tH=0;
o.sPos=fsPos;
o.sClip=oNS?fsClip4:fsClip;
o.sAlpha=oNS?fUns:oIE?fsAlpha:fsAlphaM;
o.sInner=oNS?fsInner4:fsInner;
o.sVisible=fsVisible;
o.sDim=oNS?fsDim4:fsDim;
o.aFilter=isIE?faFilter:fUns;
o.gDim=oNS?fgDim4:fgDim;
o.inner=o.inner?o.inner:'';
}



function cdhUpd() {
  cdh.width=isNS?window.innerWidth-20:document.body.clientWidth;
  cdh.height=isNS?window.innerHeight-20:document.body.clientHeight;
}

function fnDiv4(n,w,s,p) {
//if (!loaded) {fnDivT(n,w,s,p);return}
p=p?p:window;
s=!s?'show':'hide';
o=new Layer(w,p);
o.name=n;o.ide=n;

o.visibility=s;
getD(o,n);
}

function obj(){
}

function fnDivT(n,w,s,p) {
s=!s?'visible':'hidden';
o=new obj();
o.document=doc;
o.name=n;o.id=n;o.ide=n;
o.sInner=fsInner4;
//o.inner="<style>#"+n+"{position:absolute;width:"+w+";visibility:"+s+"}</style><div id='"+n+"'>"; 
o.inner="<style>#"+n+"{position:absolute;width:"+w+";visibility:"+s+"}</style><div id='"+n+"'>"; 
o.nazwa=n;
divs[n]=o;
//getD(o,n);
//alert(o.inner)
}

function fnDiv(n,w,s,p) {
p=p?p:doc.body;
s=!s?'visible':'hidden';
p.insertAdjacentHTML('BeforeEnd',"<div id='"+n+"' style='position:absolute;width:"+w+";visibility:"+s+" '></div>"); 
getD(doc.all[n],n);
}


function fnDivM(n,w,s,p) {
p=p?p:doc.body;
s=!s?'visible':'hidden';
var o=document.createElement('div');
o.style.position='absolute';
o.style.width=w;
o.style.visibility=s;
o.id=n;
p.appendChild(o);
getD(o,n);
}


function fUns() {
  return;
}

function fsPos(x,y) {this.style.left=x;this.style.top=y;}

function fsClip(x,y,w,h) {this.style.clip="rect("+y+"px "+(x+w)+"px "+(y+h)+"px "+x+"px)"}
function fsClip4(x,y,w,h) {this.clip.left=x;this.clip.top=y;this.clip.width=w;this.clip.height=h;}

function fsAlpha(o) {
//window.status='Alpha: '+o;
this.style.filter="alpha(opacity="+Math.round(o)+")";

//if (!this.filters || !this.filters.item) {return}
//var ob=this.filters.item("DXImageTransform.Microsoft.Alpha");
//  if (ob != 'undefined') {ob.Opacity=o}
}
function fsAlphaM(o) {this.style.MozOpacity=Math.round(o)+'%'}

function fsInner(h,c) {this.innerHTML=(c?'<span class='+c+'>':'')+h+(c?'<span>':'');}
function fsInner4(h,c) {
this.document.writeln((this.inner?this.inner:'')+(c?'<span class='+c+'>':'')+h+(c?'<span>':'')+(this.inner?'</div>':''));
//if (c) this.document.write('<span class='+c+'>');this.document.write(h);if (c) this.document.write('</span>');
if (this.inner!='') {this.inner='';alert(this.nazwa+' - '+document.menu0K);getD(doc.layers[this.nazwa],this.nazwa);}
else this.document.close()
}

function fsVisible(v) {this.style.visibility=v==1?'visible':v==0?'hidden':v;}

function fsDim(w,h) {this.style.width=w;this.style.height=h;}
function fsDim4(w,h) {}

function faFilter(a) {
if (a && this.style.filter.search(/Alpha/)<0) {this.style.filter+=" progid:DXImageTransform.Microsoft.Alpha(opacity=100)"}
}


function fgDim() {
with (this){tX=Number(style.left.match(/[\-\d]+/));tY=Number(style.top.match(/[\-\d]+/));tW=offsetWidth;tH=offsetHeight;}
}

function fgDim4() {
with (this) {tX=left;tY=top;tW=clip.right;tH=clip.bottom;}
}


function setHeight(nazwa,h) {
if (isNS && isV<5) {
                } else {
	el=(isNS)?document.getElementById(nazwa):document.all[nazwa+'img'];
	el.height=h;
	}
}

function showVerbose() {
if (!divs['LVerbose'])cdh.nDiv('LVerbose',200,0);
divs['LVerbose'].sInner("<font>V - "+Verbose.replace(/\n/g,'<br>')+"</font>",'foncisz');
divs['LVerbose'].sPos(200,10);
divs['LVerbose'].style.backgroundColor='#ffffff';
divs['LVerbose'].style.zIndex=200;
setTimeout("showVerbose()",500);
}

function checkSpeed() {
Verbose+='\nChkSpd';
if (top.isSpeed) {isSpeed=top.isSpeed;return}
Verbose+='\nstart';
cdh.nDiv('chkSpd',20,0);
divs['chkSpd'].sInner("<img src=img/spacer.gif width=10 height=10>",'');
divs['chkSpd'].sPos(10,10);

ms=Number(new Date());

for (i=0;i<50;i++) {
divs['chkSpd'].sPos(i/10,i/10);
}
window.status="ok";

ms=Number(new Date())-ms+1;
 
top.isCheck=ms;
isCheck=ms;
Verbose+= "\n\n Speed "+ms;
ms=Math.round(ms/10);

if (ms==0) {ms=1;}
top.isSpeed=ms;
isSpeed=ms;

}

