var is = new BrowserCheck();
var x_tresc;
var y_tresc;
var x_base;
var y_base;
var spejs;

oknowysk=null;

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

function show(id) {
	if (is.ns) document.layers[id].visibility = "show"
	else if (is.ie) document.all[id].style.visibility = "visible"
}

function hide(id) {
	if (is.ns) document.layers[id].visibility = "hide"
	else if (is.ie) document.all[id].style.visibility = "hidden"
}

function findWH() {
	winFW = (!is.ie) ? window.Width : document.body.width;
	winFH = (!is.ie) ? window.Height : document.body.height;
	winW = (!is.ie) ? window.innerWidth : document.body.offsetWidth-20;
	winH = (!is.ie) ? window.innerHeight : document.body.offsetHeight-4;
	x_base = (!is.ie) ? Math.round((winW - 752) / 2) - 8 : Math.round((winW - 752) / 2);
	y_base = (!is.ie) ? Math.round((winH * 0.78) - 339) - 13 : Math.round((winH * 0.78) - 339);
	x_base = (x_base < 0) ? 0 : x_base;
	y_base = (y_base < 0) ? 0 : y_base;
	x_tresc = x_base + 283;
	y_tresc = y_base + 23;
	spejs = y_base * 0.7;
}

function makeLiquid() {
	if ((is.ns && (winW!=window.innerWidth || winH!=window.innerHeight)) || is.ie)
	history.go(0)
}

function css(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") return '<STYLE TYPE="text/css">\n'
	else if (id=="END") return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (document.layers)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	str = css('START')+str+css('END')
	document.write(str)
	if (showAlert) alert(str)
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function init() {
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function showPic(id, w, h, podpis) {
	trescOkna = "<html><head><title>MAGIT :: kioski multimedialne ::</title><link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\"></head><body bgcolor=\"#ffa70a\" topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 marginheight=0 marginwidth=0><img src=\"" + id + "\" width=\"" + w + "\" height=\"" + h + "\" alt=\"" + podpis + "\" border=\"0\"><p class=\"podpis\">&nbsp;" + podpis + "</p></body></html>";
//	trescOkna = "<html><body bottommargin=0 leftmargin=0 marginheight=0 marginwidth=0 rightmargin=0><img src=\"referencje/' +id + '.gif\" width=\"424\" height=\"600\" alt=\"\" border=\"0\"></body></html>";
	//okno = "okno" + w + h;
	if (oknowysk!=null)
	{
		oknowysk.close();
		oknowysk=null;
	}
	oknowysk=window.open("about:blank", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,width=" + w + ",height=" + h + ",top=0,left=0");
	oknowysk.document.write(trescOkna);
	//eval(okno + ".focus()");
	//alert(okno)
}

function showFoto(id) {
  okno = "okno" + Math.round(Math.random()*1000);
	window.open(id, okno, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,channelmode=no,width=600,height=500,top=50,left=100');
}
