// <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1250>

var isPrepared = false;
var selectImage = null;

function preparePage () {

	new Image().src = 'images/prvek1-b.gif';
	new Image().src = 'images/prvek2-b.gif';
	new Image().src = 'images/prvek3-b.gif';
	new Image().src = 'images/prvek4-b.gif';
	new Image().src = 'images/prvek5-b.gif';
	new Image().src = 'images/prvek6-b.gif';
	new Image().src = 'images/prvek7-b.gif';
	
	new Image().src = 'images/hmenu_1b.png';
	new Image().src = 'images/hmenu_2b.png';
	new Image().src = 'images/hmenu_3b.png';
	new Image().src = 'images/hmenu_4b.png';
	new Image().src = 'images/hmenu_5b.png';
	new Image().src = 'images/hmenu_6b.png';
	
	new Image().src = 'images/hlmenu_1b.png';
	new Image().src = 'images/hlmenu_2b.png';
	new Image().src = 'images/hlmenu_3b.png';
	new Image().src = 'images/hlmenu_4b.png';
	
	new Image().src = 'images/hlmenu_1c.gif';
	new Image().src = 'images/hlmenu_2c.gif';
	new Image().src = 'images/hlmenu_3c.gif';
	new Image().src = 'images/hlmenu_4c.gif';
	
	new Image().src = 'images/hl2menu_1b_back.png';
	new Image().src = 'images/hl2menu_2b_back.png';
	new Image().src = 'images/hl2menu_3b_back.png';
	new Image().src = 'images/hl2menu_4b_back.png';
	
	isPrepared = true;
}

// otevře okno fotogalerie
function windowopen (htm_source) {
	window.open (htm_source,'foto','width=600,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0,top=1,scrollbars=0,resizable=0');
}

// vrací objekt kompatibilní s DOM a IE4
function ugetElementById(ename) {
	var x = null;
	if (document.getElementById) {
		x = document.getElementById(ename);
	} else if (document.all) {
		x =  document.all.item(ename);
	}
	return x;
}

// zobrazi/skryje zadany objekt
function ShowHelp(namez, stav) {
	var element = ugetElementById(namez);
	if(stav) {
		element.style.display="";
	} else {
		element.style.display="none";
	}
}

function windowopen (htm_source) {
	window.open (htm_source,'gabenfoto','width=294,height=218,toolbar=0,location=0,directories=0,status=0,menubar=0,top=1,scrollbars=0,resizable=0');
}

// rozdělí text do tří sloupců, obteče obrázek zleva
function fill3cText (strTx) {
	if (strTx.length < 3) return;
	
	var txIndex = 0;
	var strTx1 = "";
	var strTx2 = "";
	var strTx3 = "";
	
	// naplníme textem první sloupec až po dolní okraj obrázku vpravo s výškou 196 pixelů, mínus marginy stylů np1, np2 a tx1,
	// celkem 35 plus jeden řádek, tj. 11px. 192-35+11=172
	while ((txIndex < strTx.length) && ((ugetElementById('np1').offsetHeight + ugetElementById('np2').offsetHeight + ugetElementById('tx1').offsetHeight) < 172 )) {
		// přidáme slovo do tx1
		while ((txIndex < strTx.length) && (strTx.charAt(txIndex) != " ")) {
			strTx1 += strTx.charAt(txIndex);
			txIndex++;
		}
		// vložíme mezeru do tx1 a přešoupnem se za mezeru v tx
		strTx1 += " ";
		txIndex++;
		// vložíme tx1 do divu tx1 a zjistíme velikost ve while
		document.getElementById('tx1').innerHTML = strTx1;
	}
	
	// text je nyní zarovnán s obrázkem, každý ze tří DIVů naplníme cca třetinou zbývajících slov
	var txColumnRemain = Math.round((strTx.length - txIndex) / 3);
	var txStart = txIndex;
	
	// DIV 1
	while (txIndex < txStart+1*txColumnRemain+20) {
		// přidáme slovo do tx1
		while ((txIndex < strTx.length) && (strTx.charAt(txIndex) != " ")) {
			strTx1 += strTx.charAt(txIndex);
			txIndex++;
		}
		// vložíme mezeru do tx1 a přešoupnem se za mezeru v tx
		strTx1 += " ";
		txIndex++;
		// vložíme tx1 do divu tx1 a zjistíme velikost ve while
		document.getElementById('tx1').innerHTML = strTx1;
	}
	
	// DIV 2
	while (txIndex < txStart+2*txColumnRemain+10) {
		// přidáme slovo do tx2
		while ((txIndex < strTx.length) && (strTx.charAt(txIndex) != " ")) {
			strTx2 += strTx.charAt(txIndex);
			txIndex++;
		}
		// vložíme mezeru do tx2 a přešoupnem se za mezeru v tx
		strTx2 += " ";
		txIndex++;
		// vložíme tx2 do divu tx2 a zjistíme velikost ve while
		document.getElementById('tx2').innerHTML = strTx2;
	}
	
	// DIV 3
	while (txIndex < strTx.length) {
		// přidáme slovo do tx1
		while ((txIndex < strTx.length) && (strTx.charAt(txIndex) != " ")) {
			strTx3 += strTx.charAt(txIndex);
			txIndex++;
		}
		// vložíme mezeru do tx3 a přešoupnem se za mezeru v tx
		strTx3 += " ";
		txIndex++;
		// vložíme tx3 do divu tx3 a zjistíme velikost ve while
		document.getElementById('tx3').innerHTML = strTx3;
	}
}

// vyčte parametr z adresního řádku
function get() {
		var re = new RegExp( "menu" + "=([^\\&]*)", "i" );
		var a = re.exec( document.location.search );
		if (a) {
			var xp = a[1];
		} else {
			// var xp = "pracovni";
			var xp = "1"; // nebo jine defaultni menu, nejcasteji "1"
		}
		return xp;
}

// --------- levé menu -------------
// proměnné
var objIdOnOpen = false;
var objIdOffOpen = false;
var objSubIdOnOpen = false;
var objSubIdOffOpen = false;

// Fce pro zobrazení levého menu
function show_menu(namez) {
	if (!document.all && !document.getElementById) return;
	var objIdOn = null;
	var objIdOff = null;
			
	objIdOn = ugetElementById(namez + "-on");
	objIdOff = ugetElementById(namez + "-off");
											
	if (objIdOn) {									// otevírání menu na kliknutí
		if (objIdOnOpen) {									// je-li otevřeno staré menu, zavřeme ho
			objIdOnOpen.style.display="none";
			objIdOffOpen.style.display="";					// zde nemůže být block kvůli firefox TR
		}
		objIdOff.style.display="none";
		objIdOn.style.display="";				
	}

	objIdOnOpen = objIdOn;									// zapamatujeme si, které menu je otevřené
	objIdOffOpen = objIdOff;
}

// Fce pro zobrazení/skrytí levého submenu, level 1
function show_submenu(namez, determination) {
	if (!document.all && !document.getElementById) return;
	var objSubIdOn = null;
	var objSubIdOff = null;
			
	objSubIdOn = ugetElementById(namez + "-on");
	objSubIdOff = ugetElementById(namez + "-off");
											
	if (objSubIdOn.style && determination=="on") {									// otevírání menu na kliknutí
		objSubIdOff.style.display="none";
		objSubIdOn.style.display="";				
	}
	if (objSubIdOn.style && determination=="off") {									// zavření menu na kliknutí
		objSubIdOff.style.display="";
		objSubIdOn.style.display="none";				
	}	
}

// výměna fotografie v galerii datasheetu
function dts_chngPhoto (im, detail) {
	selectImage = detail;
	var element = ugetElementById('fotocka');
	element.src = "upfiles/" + im;
}

// otevře okno fotogalerie
function photoopen (im) {
	if(selectImage != null) im = selectImage;
	window.open ('foto.htm?f='+im,'foto','width=242,height=167,toolbar=0,location=0,directories=0,status=0,menubar=0,top=1,scrollbars=0,resizable=0');
}


//rozhodne, zda vyzadovat SN pri registraci SW dle compa SW
function decideRegistrationSerialAsk(source, hideId) {
    var hideRow = document.getElementById(hideId);
    selectedType = source.value;

    if (selectedType == "GABETI" || selectedType == "GBCTAG") {
        hideRow.className = "hidden";
    } else {
        hideRow.className = "";
    }

}
