var UNKN_BROWSER_MSG='Váš prohlížeč nebyl\nrozpoznán skriptem';

var browser=new initBrowser();
var resolution=new initResolution("");

function initResolution(dir){
	this.cnt=0;
	this.availW=new Array();
	this.availH=new Array();
	this.w=screen.width;
	this.h=screen.height;
	this.baseDir=dir;
	this.finalW=0;
	this.finalH=0;
	this.finalRes='NA';
	this.winW=0;
	this.winH=0;
	this.scrollH=0;
	this.scrollW=0;

	if(this.baseDir!='' && this.baseDir.charAt(this.baseDir.length-1)!='/')this.baseDir+='/';

	if(browser.id=='NN'){
		this.winW=window.innerWidth;
		this.winH=window.innerHeight;
		/*pro this.scrollW & this.scrollH volat this.rescan()*/
	}else if(browser.id=='IE'){
		/*az po nacteni body zavolat this.rescan()*/
	}else alert('initResolution: '+UNKN_BROWSER_MSG);

	this.reg=function(w, h){//registruje rozliseni | !nejdriv! registruj, pak pouzivej | registruj od nejnizsiho
		var i;

		this.availW[this.cnt]=w;
		this.availH[this.cnt]=h;
		this.cnt++;

		for(i=0;i<this.cnt;i++)
			if(this.availW[i]<=this.w && this.availH[i]<=this.h){
				this.finalW=this.availW[i];
				this.finalH=this.availH[i];
				this.finalRes=this.finalW+'x'+this.finalH;
			}
		if(this.finalRes=='NA'){//pokud neni rozliseni k dispozici pouzije se nejmensi mozne
			alert('Pro tuto stránku, bohužel,\nnení k dispozici\ntak malé rozlišení:(\nPoužije se nejmenší možné');
			this.finalW=w;
			this.finalH=h;
			this.finalRes=w+'x'+h;
		}
	}
	this.img=function(obj, fn){//do <img> jako onload
		var oldFn;

		oldFn=obj.src;
		fn=this.baseDir+'img/'+this.finalRes+'/'+fn;
		oldFn=oldFn.substr(oldFn.indexOf('/')+1);
		if(oldFn.substr(oldFn.length-fn.length)!=fn)obj.src=fn;
	}
	this.style=function(name){//do <head>
		document.write('<link rel="stylesheet" type="text/css" href="'+this.baseDir+'css/'+this.finalRes+'/'+name+'.css" />\n');
	}
	this.script=function(name){//do <head>
		document.write('<scr'+'ipt type="text/javascript" src="'+this.baseDir+'js/'+this.finalRes+'/'+name+'.js"></scr'+'ipt>\n');
	}
	this.rescan=function(){//IE vrati velikost okna az PO parsovani <body>, FF+IE scroll
		this.scrollH=document.body.scrollHeight;
		this.scrollW=document.body.scrollWidth;

		if(browser.id=='NN'){
			this.winW=window.innerWidth;
			this.winH=window.innerHeight;
		}else if(browser.id=='IE'){
			this.winW=document.body.offsetWidth;
			this.winH=document.body.offsetHeight;
		}else alert('initResolution: '+UNKN_BROWSER_MSG);
	}
}
function initBrowser(){
	this.name=navigator.appName;
	if(this.name.indexOf("Microsoft")!=-1)
		this.id='IE';
	else
		this.id='NN';
}
