var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;
var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;
var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;

var gx={switchers:{}};var g;(g=function(o)
{
	if(o.$e==undefined)o.$e='';
	if(typeof((h={
		init:function(){},
		_init:function()
		{
			g.onload=(typeof(t=window.onload)=='function')?t:function(){};
			window.onload=function(){g.onload();g({$:'init'})};
		},
		_cd:function(id)
		{
			o=document.createElement('div');
			o.id=id;
			return o;
		},
		_gc:function(s)
		{
			var arr=new Array()
			var els=(s.i==undefined?document:g(s.i)).getElementsByTagName("*");
			for(var i=0;i<els.length;i++ )if(g({$:'_hc',$e:{c:els[i].className,s:s.cn}}))arr.push(els[i]);
			return arr;
		},
		_hc:function(v)
		{
			var exp=new RegExp("^(.* )?"+v.s+"( .*)?$", "g");
			return exp.test(v.c)
		},
		_switcher:function(v)
		{
			//r='';
			ps=g({$:'_gc',$e:{cn:'page',i:v.id}});
			navi=g(document.createElement('DIV')).css({height:25,p2osition:'relative',t2op:15});
			navi.className='snav';
			ih='<table class="snavi" id="tl-'+v.id+'" cellspacing=0><tr>';
			timer=g({$:'_gc',$e:{cn:'timer',i:v.id}});
			gx.switchers[v.id]={actual:1,items:{},timer:Math.max(((timer[0]!=undefined)?((isNaN(tmp=timer[0].innerHTML)?0:tmp)*1000):5000),1000)};
			eli=0;
			for(el in ps)if(gpsel=(g(ps[el])))
			{

				tmp=gpsel.getElementsByTagName('h6');
				tdc='active';
				if(g({$:'_hc',$e:{c:ps[el].className,s:'page_dn'}}))
				{
					ps[el].css({visibility:'hidden',position:'absolute'});
					tdc='inactive';
				}
				eli++;
				ih+='<td onclick="g({$:\'_switch\',$e:{id:\''+ps[el].id+'\',sn:\''+v.id+'\',ct:'+eli+'}})" id="bt-'+ps[el].id+'" class="'+tdc+'"><a href="javascript://'+tmp[0].innerHTML+'">'+tmp[0].innerHTML+'</a><br><b></b></td>';
				gx.switchers[v.id].items[eli]=ps[el].id;
			}
			gx.switchers[v.id].count=eli;
			ih+='</tr></table>';
			navi.innerHTML=ih;
			g(v.id).appendChild(navi);
			sum=0;
			for(el in ps)if(gpsel=(g(ps[el])))
			{
				tmp=g('bt-'+ps[el].id).getElementsByTagName('a');
				sum+=wd=tmp[0].offsetWidth+19;
				g('bt-'+ps[el].id).css({width:wd});
			}
			g('tl-'+v.id).css({marginLeft:Math.floor((228-sum)/2)-2})
			g({$:'_switchLoop',$e:{id:v.id}})
		},
		_switchLoop:function(v)
		{
			if((tmp=gx.switchers[v.id].actual+1)>gx.switchers[v.id].count)tmp=1;
			gx.switchers[v.id].timeout=setTimeout("g({$:'_switch',$e:{id:'"+gx.switchers[v.id].items[tmp]+"',sn:'"+v.id+"',ct:"+tmp+"}})",gx.switchers[v.id].timer);
		},
		_switch:function(v)
		{
			a=v.id
			gx.switchers[v.sn].actual=v.ct;
			clearTimeout(gx.switchers[v.sn].timeout);
			g({$:'_switchLoop',$e:{id:v.sn}})
			do{v=g(v.id).parentNode}
			while(!(g({$:'_hc',$e:{c:g(v.id).className,s:'switcher'}})));
			ps=g({$:'_gc',$e:{cn:'page',i:v.id}});
			for(el in ps)if(gpsel=(g(ps[el])))
			{
				if(gpsel.id==a)
				{
					gpsel.style.position='static';
					gpsel.style.visibility='visible';
					g('bt-'+gpsel.id).className='active';
				}
				else
				{
					gpsel.style.position='absolute';
					gpsel.style.visibility='hidden';
					g('bt-'+gpsel.id).className='inactive';
				}
			}
		}
	})[o.$])=='function')return h[o.$](o.$e);
	else {
		o=(typeof(o)=='object'?o:document.getElementById(o));
		if((o)&&(!o.vget))
			for(e in f={
			vget:{init:true,opacity:1,lastHeight:0,version:0.1},
			vset:function(v)
			{
				for(e in v)this.vget[e]=v[e];
				return this;
			},
			hide:function()
			{
				return this.vset({display:(t=this.style.display)=='none'?this.vget.display:t}).css({display:'none',opacity:0});
			},
			show:function()
			{
				return this.css({display:((u=this.style.display)=='none'?(t=this.vget.display)==undefined?'':t:u)});
			},
			fadein:function(r)
			{
				if(r==undefined)
				{
					this.show();
					clearTimeout(this.vget.fadetimeout);
				}
				op=Math.min(this.style.opacity*1+0.05,1);
				if(op<1)this.vset({fadetimeout:setTimeout("g('"+this.id+"').fadein(1)",15)});
				this.css({opacity:op});
				return this;
			},
			fadeout:function(r)
			{
				if(r==undefined)clearTimeout(this.vget.fadetimeout);
				op=Math.max(this.style.opacity*1-0.15,0);
				if(op>0)this.vset({fadetimeout:setTimeout("g('"+this.id+"').fadeout(1)",15)});
				if(op==0)this.hide();
				this.css({opacity:op});
				return this;
			},
			css:function(s)
			{
				for(e in s)
				{
					if(e=='opacity')
					{
						this.vset({opacity:s[e]});
						this.style.opacity=s[e];
						this.style.filter='alpha(opacity='+Math.round(s[e]*100)+')';
					}
					else this.style[e]=s[e];
				}
				return this;
			}
		}){o[e]=f[e];};
	}
	if((o)&&(!o.id))o.id='ID-'+Math.random(1000);
	return o?o:false;
})({$:'_init'});

function iDump(v) {
	var t='';
	for(e in v) {
		x=v[e]
		if (typeof(x)=='function')
			{}//t+=e+'=[function]; ';
		else if (typeof(x)=='object')
			t+=e+"=[object];\n";
		else if (typeof(x)=='string')
			t+=e+"="+x+";\n";
		else
			t+=e+'='+x+";\n";
	}
	alert(t);
}

if(document.getElementsByTagName){
	var elems=document.getElementsByTagName('base');
	if (elems.length) {
		document.base=elems[0].href;
	}
}

function iLeft(text,separator) {
  var p=text.indexOf(separator);
  if (p>=0)
  	return(text.substr(0,p));
  else
  	return(text);
}

function iRight(text,separator) {
  var p=text.indexOf(separator);
  if (p>=0)
  	return(text.substr(p+separator.length));
  else
  	return('');
}

function iLeftBack(text,separator) {
  var p=text.lastIndexOf(separator);
  if (p>=0)
  	return(text.substr(0,p));
  else
  	return('');
}

function iRightBack(text,separator) {
  var p=text.lastIndexOf(separator);
  if (p>=0)
  	return(text.substr(p+separator.length));
  else
  	return(text);
}

function iPosition(obj){
	var curleft=curtop=0;
	if(obj.offsetParent)
	while(1)
	{
		curtop+=obj.offsetTop;
		if(obj.className!='eikcuf')curleft += obj.offsetLeft;
		if(!obj.offsetParent)break;
		obj=obj.offsetParent;
	}
	else if(obj.y)
	{
		curtop += obj.y;
		curleft += obj2.x;
	}
	return({X:curleft,Y:curtop});
}
function iFlashHtml(src,width,height,id,bgcolor,flashvars) {
	/*var vars=[];
	for(e in flashvars) {
		vars.push(e+'='+iFlashEscape(flashvars[e]));
	}
	vars=vars.join('&');*/

	var html='';
	if (id) {
		html+='<SCRIPT LANGUAGE=VBScript\> \n';
		html+='on error resume next \n';
		html+='Sub '+id+'_FSCommand(ByVal command, ByVal args)\n';
		html+='  call '+id+'_DoFSCommand(command, args)\n';
		html+='end sub\n';
		html+='</SCRIPT\> \n';
	}
	html+='<object type="application/x-shockwave-flash"';
	html+='   width="'+width+'px"';
	html+='   height="'+height+'px"';
	if (id) {
		html+='   id="'+id+'"';
		html+='   name="'+id+'"';
	}
	html+='   data="'+src+'">';
	html+='<param name=movie value="'+src+'">';
	html+='<param name=flashvars value="'+flashvars+'">';
	html+='<param name=quality value=high>';
	html+='<param name=menu value=false>';
	if (bgcolor=='transparent')
		html+='<param name=wmode value=transparent>';
	else if (bgcolor)
		html+='<param name=bgcolor value='+bgcolor+'>';
	html+='</object>';
	//alert(html);
	return(html);
}

function iFlashGenerate(src,width,height,id,bgcolor,flashvars,install) {
	var html='';
	if ((!install)||(iFlashVersion()>=6)) {
		html+=iFlashHtml(src,width,height,id,bgcolor,flashvars);
	} else if (install) {
		html+='<p>Do prawidłowego działania serwisu wymagany jest plugin Macromedia Flash 6 lub nowszy.</p><p>';
		html+=iFlashHtml('layout/flash.swf',70,70,'href=index.php');
		html+='</p><p>Nie widzisz animacji? Zainstaluj plugin:</p><p>';
		html+='<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target=_blank><img src="layout/flash.gif" width=75 height=75></a>';
		html+='</p>';
	}
	document.write(html);
}

function iFlashVersion() {
	var i,v=0;
	if (navigator.plugins.length) {
		var p=navigator.plugins;
		if ((p)&&(p.length>0)&&(p['Shockwave Flash']))	{
			var w=p['Shockwave Flash'].description.split(' ');
				for(i=0;i<w.length;i++) {
					var j=parseInt(w[i]);
					if (!isNaN(j))
						v=Math.max(v,j);
				}
		}
		return(v);
  	} else {
		for(v=10;v>0;v--) {
			var x=null;
			try {
				x=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+v);
			} catch(e) {}
			if (x) return(v);
		}
		return(0);
	}
}

function iBannerGenerate(banners)
{
	var r=Math.floor(Math.random()*banners.length);
	banner_width=iLeft(banners[r]['banner_size'],'x');
	banner_height=iRight(banners[r]['banner_size'],'x');
	if(iRightBack(banners[r]['banner_source'],'.')=='swf') {
		iFlashGenerate(banners[r]['banner_source'],banner_width,banner_height,false,'transparent','click='+escape(banners[r]['banner_target'])+'&clicktag='+escape(banners[r]['banner_target'])+'&gdaclick='+escape(banners[r]['banner_target'])+'&banner_language='+banners[r]['banner_language']+'&home='+banners[r]['banner_home']+'&new_window='+banners[r]['banner_newwindow'],false);
	} else {
		var t='';
		if (banners[r]['banner_target']){
			if (banners[r]['banner_newwindow']=='1')
				t+='<a href="'+banners[r]['banner_target']+'" target="_blank">';
			else
				t+='<a href="'+banners[r]['banner_target']+'">';
		}
		t+='<img src="'+banners[r]['banner_source']+'" alt="" style="width:'+banner_width+'px;height:'+banner_height+'px;">';
		if (banners[r]['banner_target'])
			t+='</a>';
		document.write(t);
	}
}

function iBannerGenerateMore(banners,count)
{
	var i=1;
	while(banners.length>0)
	{
		document.write('<td'+((i==count)||(banners.length==1)?' class="last"':'')+'>');
		var j=Math.floor(Math.random()*banners.length);
		iBannerGenerate(banners.splice(j,1));
		document.write('<\/td>');
		if(++i>count){break}
	}
}
