// 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 nove_okno(theURL) {
	window.open(theURL,"nove_okno","scrollbars=1,resizable=1,toolbar=1,menubar=1,location=1,status=1,directories=0");
}
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 WinOpen1c(theURL,w,h) { // kompaktní vycentrované
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2; if (BWSopera) {var wint = wint - 120;}
	if (BWSopera) {var w = w + 1; var h = h + 1;}
	window.open(theURL,'WinOpen1','width=' + w + ',height=' + h + ',left=' + winl + ',top=' + wint + ',toolbar=0,location=0,scrollbars=0,resizable=0,status=0,directories=0,menubar=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();}
}

// 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]+"'");
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL+'&scrx='+screen.availWidth+'&scry='+screen.availHeight;
}

// mailform

function Check_Mailform_cz(form) {
	if (BWSdom) {
		if ((document.getElementById('Zprava').value=="") || (document.getElementById('Jmeno').value=="")) {
			alert("Chybí povinné údaje: jméno a kontakt nebo text zprávy...");
		} else if ((document.getElementById('Telefon').value=="") && (document.getElementById('Email').value=="")) {
			alert("Chybí povinné údaje: jméno a kontakt nebo text zprávy...");
 		} else {
 			if (document.getElementById('Email').value!="") {odesilatel=document.getElementById('Email').value};
 			document.mailform.submit();
  		}
  	} else {
		return true;
		document.mailform.submit();
	}
}

function Check_Mailform_en(form) {
	if (BWSdom) {
		if ((document.getElementById('Zprava').value=="") || (document.getElementById('Jmeno').value=="")) {
		alert("Please, enter at least one contact and message body.");
		} else if ((document.getElementById('Telefon').value=="") && (document.getElementById('Email').value=="")) {
		alert("Please, enter at least one contact and message body.");
 		} else {
		alert("Message sent.");
		document.mailform.submit();
  		}
  	} else {
  		alert("Message sent.");
		return true;
		document.mailform.submit();
	}
}

function Check_Mailform_it(form) {
	if (BWSdom) {
		if ((document.getElementById('Zprava').value=="") || (document.getElementById('Jmeno').value=="")) {
		alert("Please, enter at least one contact and message body.");
		} else if ((document.getElementById('Telefon').value=="") && (document.getElementById('Email').value=="")) {
		alert("Please, enter at least one contact and message body.");
 		} else {
		alert("Message sent.");
		document.mailform.submit();
  		}
  	} else {
  		alert("Message sent.");
		return true;
		document.mailform.submit();
	}
}

// zákaz zobrzení ve framesetu ***

function TopFrame() {
	if (top.length != self.length) { top.location.href = self.location.href;}
}

// print ***

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="dunumba.cz";
var SCRx=screen.availWidth;
var SCRy=screen.availWidth;
ck_write("SCRx", SCRx, 30);
ck_write("SCRy", SCRy, 30);
TopFrame();
MM_reloadPage(true);

defaultStatus="Dunumba Sound System";
