// ----- iBrowser

var iBrowser={Family:false};
if (typeof(window.opera)!='undefined') iBrowser.Family='opera';
else if (navigator.plugins.length>0) iBrowser.Family='mozilla';
else if (navigator.appName=='Microsoft Internet Explorer') iBrowser.Family='msie';

if(document.getElementsByTagName){
	var elems=document.getElementsByTagName('base');
	if (elems.length)	document.base=elems[0].href;
}

function iFormReload(form) {
	var step=form[(document.iDocumentPrefix?document.iDocumentPrefix:'')+'Step'];
	if (step)
		step.value='Update';
	form.submit();
}

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 iDump(v) {
	var t='';
	for(e in v) {
		x=v[e]
		if (typeof(x)=='function'){}
		else if (typeof(x)=='object') t+=e+"=[object];\n";
		else if (typeof(x)=='string') e+"="+x+";\n";//t+='';//
		else t+=e+'='+x+";\n";
	}
	alert(t);
}

function iPosition(obj) {
	var curleft=curtop=0;
	if(obj.offsetParent)
	{
		curleft=obj.offsetLeft;
		curtop=obj.offsetTop;
		while(obj=obj.offsetParent)
		{
			curleft+=obj.offsetLeft;
			curtop+=obj.offsetTop;
		}
	}
	return({X:curleft,Y:curtop});
}

function iCookieSet(name1,value1,expire1){
	document.cookie=name1+"="+escape(value1)+(!expire1?"":("; expires="+expire1.toGMTString()))+"; path=/";
}

function iCookieGet(name1){
	var k1,j1,text1=name1+"=";
	if(document.cookie.length>0){
		j1=document.cookie.indexOf(text1);
		if(j1!=-1){
			j1+=text1.length;
			k1=document.cookie.indexOf(";", j1);
			if(k1==-1) k1 = document.cookie.length;
			return unescape(document.cookie.substring(j1, k1))
		}
	}
}

// --- iFlash ---

function iFlashHtml(src,width,height,id,bgcolor,flashvars) {

	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>';
	return(html);
}

function iFlashGenerate(src,width,height,id,bgcolor,flashvars,install) {
	var html='';
	if ((!install)||(iFlashVersion()>=8)) {
		html+=iFlashHtml(src,width,height,id,bgcolor,flashvars);
	} else if (install) {
		html+='<p>Do prawidłowego działania serwisu wymagany jest plugin Macromedia Flash 8 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 iWindowOpen(url,width,height) {
	var x=Math.round((window.screen.width-width)/2);
	var y=Math.round((window.screen.height-height)/2);
	if ((url.substr(0,4)!='http')&&(document.base))
		url=document.base+url;
	window.open(url,'','left='+x+',top='+y+',width='+width+',height='+height+',resizable,scrollbars,status,menu');
}

function iDec2Hex(Dec)
{
	var hexChars = "0123456789ABCDEF";
	Dec=Math.round(Dec);
	var a=Dec%16;
	var b=(Dec-a)/16;
	hex=""+hexChars.charAt(b)+hexChars.charAt(a);
	return hex;
}

function iPageOnLoad() {

}

function iMediaPlayerGenerate(filename)
{
	html='<object id="MediaPlayer1" width="516" height="390" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,0902" standby="Loading Microsoft(r) Windows Media(tm) Player components..." type="application/x-oleobject">';
	html+='<param name="AutoStart" value="True">';
	html+='<param name="PlayCount" value="999">';
	html+='<param name="DisplaySize" value="4">';
	html+='<param name="ShowControls" value="True">';
	html+='<param name="ShowStatusBar" value="False">';
	html+='<param name="ShowDisplay" value="False">';
	html+='<param name="FileName" value="'+filena2me+'">';
	html+='<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+filename+'" name="MediaPlayer1" width="516" height="390" autostart=1 playCount=999 DisplaySize=4 ShowControls=1 volume=0>';
	html+='</embed></object>';
	document.getElementById("movie").innerHTML=html;
}

//function iPicturesListGenerate(p1,p2,p3,p4) 
function iPicturesListGenerate(p)
{
	if(p[0]){
		var ret = '';
		var i = 0;
		//for(var i = 0; i < p[0].length;){
		while(p[0].length>0){
			i = Math.floor(Math.random()*p[0].length);
			ret += '<picture url="'+p[0][i].url+'" name="'+p[0][i]['pname']+'" title="'+p[0][i]['ptitle']+'"></picture>';
			p[0].splice(i,1);
		}
		return ret;
	}else{
		var ret = '';
		for(var i = 1; i < p.length; i++){
			if(p[i].length>0){
				p[i]=p[i][Math.floor(Math.random()*(p[i].length))];
				ret += '<picture url="'+p[i]['url']+'" name="'+p[i]['pname']+'" title="'+p[i]['ptitle']+'"></picture>';
			}
		}
		return ret;
	}
}
var IE = document.all?true:false

function gid(o){return document.getElementById(o);}
var lbq,lba,lbc,lbh,lbu,lbt,lbx,lb1,lb2,lb3,lbi,lbi1,lbi2,lbi3,lbpre,lbadd;
function lb_init(tits,idi,tech,url1,url2,url3)
{
	lbi1=url1;lbi2=url2;lbi3=url3;
	tech=unescape(tech);
	if(tits.substr(0,1)=='@'){lbpre='lb2';lbadd=200;}else{lbpre='lb';lbadd=0}
	gid(lbpre+'_p').src='layout/0.gif';
	gid('lb_bg').style.display='block';
	gid('lb_bg').style.height=(document.body.scrollTop+document.body.clientHeight)+'px';
	lbq=3;if(url3==''){lbq=2;}if(url2==''){lbq=1;}
	lbt=300+document.body.scrollTop;lba=1;
	lbs=408;lbd=29;
	lbc=gid(lbpre+'_c');lbh=gid(lbpre+'_h');if(lbpre=='lb'){lbu=gid(lbpre+'_u');}
	if(lbpre=='lb'){
		gid(lbpre+'_img1').src=url1;gid(lbpre+'_img2').src=url2;gid(lbpre+'_img3').src=url3;
		gid(lbpre+'_title').innerHTML=tits;gid(lbpre+'_id').innerHTML=idi;gid(lbpre+'_tech').innerHTML=tech;
		lbu.style.opacity=0;
		if(lbq==3){gid(lbpre+'_first').style.visibility='visible';gid(lbpre+'_second').style.visibility='visible';gid(lbpre+'_last').style.visibility='visible';}
		if(lbq==2){gid(lbpre+'_first').style.visibility='visible';gid(lbpre+'_second').style.visibility='visible';gid(lbpre+'_last').style.visibility='hidden';}
		if(lbq==1){gid(lbpre+'_first').style.visibility='hidden';gid(lbpre+'_second').style.visibility='hidden';gid(lbpre+'_last').style.visibility='hidden';}
	}
	else
	{
		gid(lbpre+'_title').innerHTML=tits.substr(1,tits.length);
		gid(lbpre+'_tech').innerHTML=tech;
	}
	lbc.style.left=document.body.clientWidth/2-(lbpre=='lb'?230:371)+'px';
	lbc.style.top=lbt+'px';lbc.style.display='block';
	gid(lbpre+'_p').src=url1;
	lb_imgUpdate();
	lb_open();
}

function lb_imgUpdate()
{
	gid(lbpre+'_p').src=gid(lbpre+'_p').src;
	lbi=setTimeout("lb_imgUpdate()",1000);
}

function lb_close()
{
	gid(lbpre+'_c').style.display='none';
	gid('lb_bg').style.display='none';
	clearTimeout(lb1);clearTimeout(lb2);clearTimeout(lb3);
	gid(lbpre+'_p').src='layout/0.gif';
}

function lb_update()
{
	lbc.style.left=document.body.clientWidth/2-(lbpre=='lb'?230:371)+'px';
	gid('lb_bg').style.height=(document.body.scrollTop+document.body.clientHeight)+'px';
	lb3=setTimeout("lb_update()",30);
}

function lb_open()
{
  lb_update()
	if(lba<=lbs)
	{
		lbx=lba/lbs;
		lbc.style.top=(lbt-Math.round(lbx*(lbpre=='lb'?210:250)))+'px';
		tmpo1=Math.round(lbx*100)/25-1;
		tmpo2=Math.round(lbx*100)/50-1;
		tmpo1=(tmpo1>1?1:(tmpo1<0?0:tmpo1));tmpo2=(tmpo2>1?1:(tmpo2<0?0:tmpo2));
		lbc.style.opacity=tmpo1;
		lbh.style.opacity=tmpo2;
		lbh.style.height=(Math.round(lbx*(lbpre=='lb'?420:645)))+'px';//420:570
		if(lbd>1)lbd--;
		lba+=lbd;
		lb1=setTimeout("lb_open()",10);
	}
	else if(lbq>1&&lbpre=='lb')
	{
		lba=1;lbd=29;
		lb2=setTimeout("lb_show()",500);
	}
}

function lb_show()
{
	if(lba<=lbs)
	{
	  lbx=lba/lbs;
		lbh.style.height=(Math.round(lbx*105))+420+'px';
		lbu.style.opacity=Math.round(lbx*100)/50-1;
		lba+=lbd;
		if(lbd>1)lbd--;
		lb2=setTimeout("lb_show()",10)
	}
}

function lb_loadImage(objSrc)
{
	clearTimeout(lbi);
	document.getElementById('lb_p').src=objSrc;
}
