// detekce klienta ***

var BWSver=navigator.appVersion.toLowerCase();
var BWSagt=navigator.userAgent.toLowerCase();
var BWSos=navigator.platform.toLowerCase();

/* kompatibilita */
var BWSdom=document.getElementById?1:0; // W3C DOM
var BWSopera=(BWSdom && window.opera)?1:0; // verze 5.0 a vyssi
var BWSie=(document.all && document.all.item && !BWSopera)?1:0; // verze 4.0 a vyssi
var BWSns6=(BWSdom && !BWSie && !BWSopera && BWSagt.indexOf("gecko"))?1:0; // verze 6.0 a vyssi
var BWSns4=(document.layers && !BWSdom)?1:0; // verze 4.xx
	
/* verze */
var BWSie4=(BWSie && !BWSdom && !BWSopera)?1:0;
var BWSie50=(BWSie && BWSver.indexOf("msie 5.0")!=-1 && BWSdom)?1:0;
var BWSie55=(BWSie && BWSver.indexOf("msie 5.5")!=-1 && !BWSie50 && BWSdom)?1:0;
var BWSie6=(BWSie && BWSver.indexOf("msie 6")!=-1 && BWSdom)?1:0;
var BWSie7=(BWSie && BWSver.indexOf("msie 7")!=-1 && BWSdom)?1:0;

/* operační systém */
var OSwin32=((BWSagt.indexOf("win32")!=-1) || (BWSagt.indexOf("32bit")) || (BWSos == "win32"))?1:0;
var OSmac=(BWSagt.indexOf("mac")!=-1)?1:0;
var OSlinux=(BWSagt.indexOf("linux")!=-1)?1:0;


var BWSok=(BWSdom || BWSie || BWSopera || BWSns4)?1:0;
var BWSsbcfg=(BWSie && !BWSie4 && !BWSie50)?1:0;


// reload pro korekci zobrazen vrstev při změně velikosti okna v NS4	***

function nsResizeFix(init) {
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.pgW=innerWidth; document.pgH=innerHeight; onresize=nsResizeFix; }}
	else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}


// výběr stylů ***

function chooseCSS(level) {
	var cdupstr=level;
	var CSSpath="classes/";
	
	switch(cdupstr) {
		case 0: var cdupstr=""; break;
		case 1: var cdupstr="../"; break;
		case 2: var cdupstr="../../"; break;
		case 3: var cdupstr="../../../"; break;
		case 4: var cdupstr="../../../../"; break;
		case 5: var cdupstr="../../../../../"; break;
		case 9: var cdupstr="/"; break;
		default:  var cdupstr=""; break;
	}
	
	var DefaultMyStyle;
	var MyStyle=DefaultMyStyle="dom.css";
		

	/* základní styly **/

	if (BWSdom || BWSie4) {MyStyle = "dom.css";}
	
	// alert(MyStyle);

	document.write ('<link rel="stylesheet" HREF="' + cdupstr + CSSpath + MyStyle + '" type="text/css">');
	

	/* doplňující styly **/

	if (BWSie && !BWSie4 && !OSmac) {MyStyle = "dom_ie5up.css";}
	else if (BWSopera) {MyStyle = "dom_opera6up.css";}
	else if (BWSns6) {MyStyle = "dom_gecko.css";}

	else if (BWSie4 && !OSmac) {MyStyle = "dom_ie4.css";}
	else if (BWSie && OSmac && !BWSie4) {MyStyle = "dom_ie5up_mac.css";}

	else if (OSmac) {MyStyle = "ns4_mac.css";}

	// alert(MyStyle);
	
	if (MyStyle != DefaultMyStyle) {
		document.write ("<link rel='stylesheet' HREF='" + cdupstr + CSSpath + MyStyle + "' type='text/css'>");
	}
}

// nove okno ***    (parametry: adresa, šířka okna, výška okna, umístění z leva, z hora, suffix)

function WinOpen1(theURL,w,h,lf,tp,sx) { // kompaktní
	window.open(theURL,'WinOpen1' + sx + '','width=' + w + ',height=' + h + ',left=' + lf + ',top=' + tp + ',scrollbars=0,resizable=0,toolbar=0,menubar=0,location=0,status=0,directories=0');
}
function WinOpen2(theURL,w,h,lf,tp,sx) { // kompaktní + scrollbar
	window.open(theURL,'WinOpen2' + sx + '','width=' + w + ',height=' + h + ',left=' + lf + ',top=' + tp + ',scrollbars=1,resizable=0,toolbar=0,menubar=0,location=0,status=0,directories=0');
}
function WinOpen3(theURL,w,h,lf,tp,sx) { // kompaktní + scrollbar + resizable
	window.open(theURL,'WinOpen3' + sx + '','width=' + w + ',height=' + h + ',left=' + lf + ',top=' + tp + ',scrollbars=1,resizable=1,toolbar=0,menubar=0,location=0,status=0,directories=0');
}
function WinOpen4(theURL,w,h,lf,tp,sx) { // normální bez adresy a statusbaru
	window.open(theURL,'WinOpen4' + sx + '','width=' + w + ',height=' + h + ',left=' + lf + ',top=' + tp + ',scrollbars=1,resizable=1,toolbar=1,menubar=1,location=0,status=0,directories=0');
}                                                                                                                                                       
function WinOpen5(theURL,w,h,lf,tp,sx) { // normální
	window.open(theURL,'WinOpen5' + sx + '','width=' + w + ',height=' + h + ',left=' + lf + ',top=' + tp + ',scrollbars=1,resizable=1,toolbar=1,menubar=1,location=1,status=1,directories=0');
}
function WinOpen6(theURL,sx){ // new fullscreen
	window.open(theURL,'WinOpen6' + sx + '',"fullscreen=1");
}
function WinOpen7(theURL,sx){ // make fullscreen
	window.open(theURL,'WinOpen7' + sx + '',"fullscreen=1");
	this.focus();
	openerwindow = window.self;
	openerwindow.opener = window.self;
	openerwindow.close();
}


// zoom obrázků v novém okně (pictview.php) ***

function PictView(nahled) {
	zoom=window.open('pictview.php?t='+nahled,'PictView','width=120,height=105,left=30,top=30,toolbar=0,location=0,scrollbars=0,resizable=1,status=0,directories=0,menubar=0');
	if(BWSok) {zoom.window.focus();}
}

// alert("test");

// mapa ***

function MapView(nahled) {
	mapa=window.open('mapview.php?t='+nahled,'mapView','width=120,height=105,left=30,top=30,toolbar=0,location=0,scrollbars=0,resizable=1,status=0,directories=0,menubar=0');
	if(BWSok) {mapa.window.focus();}
}

// operace s cookies ***

function ck_write(jmeno, hodnota, platnost_dni) {

	var datum= new Date();
	var dobaPlatnosti= platnost_dni*24*60*60*1000;
	var path="";
	datum.setTime(datum.getTime()+dobaPlatnosti);
	
	var curCookie = jmeno + "=" + escape(hodnota) +
	((datum) ? "; expires=" + datum.toGMTString() : "") +
	((datum) ? "; expires=" + datum.toGMTString() : "") +
	((domain) ? "; domain=" + domain : "");
  document.cookie = curCookie;
}

function ck_read(jmeno) { // načte cookie

	var UlozeneCookie= " "+document.cookie+";";
	
	var vysledek = null;
	var jmenoCookie = " "+jmeno+"=";
	
	var zacatekHodnoty = UlozeneCookie.indexOf(jmenoCookie);
	var konecHodnoty;
	
	if (zacatekHodnoty != -1) {
		zacatekHodnoty += jmenoCookie.length;
		konecHodnoty = UlozeneCookie.indexOf(";",zacatekHodnoty);
		vysledek = UlozeneCookie.substring(zacatekHodnoty, konecHodnoty);
		vysledek = unescape(vysledek);
	}
	return vysledek
}
	
function ck_delete(jmeno) { //smaže cookie
	 var Tridny=3*24*60*60*1000;
	 var datum=new Date();
	 
	 datum.setTime(datum.getTime()-Tridny);
	 document.cookie = jmeno+"=budeSmazano; expires="+datum.toGMTString();
}


// formatuj datum

function format_date() {
	var CalMonths = new Array(13);
	CalMonths[1] = "leden";
	CalMonths[2] = "únor";
	CalMonths[3] = "březen";
	CalMonths[4] = "duben";
	CalMonths[5] = "květen";
	CalMonths[6] = "červen";
	CalMonths[7] = "červenec";
	CalMonths[8] = "srpen";
	CalMonths[9] = "září";
	CalMonths[10] = "říjen";
	CalMonths[11] = "listopad";
	CalMonths[12] = "prosinec";
	
	var time=new Date();
	var month=CalMonths[time.getMonth() + 1];
	var date=time.getDate();
	var year=time.getYear();
	
	if((year > 0) && (year < 200)) year = 1900 + year;
	
	whatDate = new Date();
	var whatDay = new Array("Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota");
	var whatMonth = new Array("ledna","února","března","dubna","května","června","července","srpna","září","října","listopadu","prosince");
	
	date_today = (whatDay[whatDate.getDay()]+",  " + date + ". "+whatMonth[whatDate.getMonth()]+ " " + year);
	return date_today;
}


// rollover obrázků

function imgswap(imagename,objectsrc){
	if (document.images)
	  document.images[imagename].src=eval(objectsrc+".src")
}


// macromedia ***

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 MM_findObj(n, d) { //v4.01
	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);
	if(!x && d.getElementById) x=d.getElementById(n); 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_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


// zákaz zobrzení ve framesetu ***

function TopFrame() {
	if (top.length != self.length) { top.location.href = self.location.href;}
}

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage() {
  if (BWSdom || BWSns4) {
    window.print();
  } else if (BWSie4) {
    vbPrintPage();
  }
}


/*** společné příkazy specifické pro konkrétní web  ::::::::::::::::::::::::::::::::::::::::::::::::::: ***/

var functions=1;
var domain=location.href;
var SCRx=screen.availWidth;
ck_write("SCRx", SCRx, 30);







nsResizeFix(true);
if (BWSns4) {defaultStatus = "Pouzivivejte novejsi verzi prohlizece - min. Netscape 6 nebo Operu 6 (www.opera.com).";}
if (BWSopera) {defaultStatus = "Pro optimální funkci menu si prosím nastavte \"Accept popup windows\" a \"Identify as MSIE 5.0\" v menu Quick Preferences (F12).";}
