/* skripty pro všechny prohlížeče */

var PoNacteni = null;
var cSTEP = 1;
var cDELAY = 40;
//var cDELAY = 24;
//var cDELKA = 50;
//var cPAUZA = 0;

//var gPocitani = 0; // tato proměnná má význam, jen když dochází k zastavování posunu po určité době

var gRunText1, gRunText2;
var gTextWidth;
var gFirstText, gPosition;
var gHandlerRunText;
var gTextRuns = false;

var g_disableScripts = false;
var g_enableScripts = true;
var g_Zamereni = false;
var g_nastroj = "";
var g_popiska = "";
var g_zobrazeny = 0;
var g_minsirka = 780;

window.onload = Nacteno;
window.onresize = ZmenaVelikosti;

function Nacteno()
{
	if (g_disableScripts)
	{
		return;
	}
	ZmenaVelikosti();
	if (PoNacteni != null)
	{
		PoNacteni();
	}
//	if (g_Zamereni)
//	{
//	    ProZamereni(0);
//	}
}

function Konec()
{
	if (g_disableScripts) return;
	gFirstText = 0;
	window.clearTimeout(gHandlerRunText);
	window.onunload = null;
	document.getElementsByTagName("body").item(0).onclick = null;
}

function Pauza()
{
	if (g_disableScripts) return;
	window.clearTimeout(gHandlerRunText);
}

function PauzaB()
{
    if (gTextRuns)
    {
        window.clearTimeout(gHandlerRunText);
        gTextRuns = false;
    }
    else
    {
        gTextRuns = true;
        RunTextRun();
    }
}

function RunTextInit()
{
	if (g_disableScripts) return;
	var runTextBorder, borderWidth, position;
	window.onunload = Konec;
	runTextBorder = document.getElementById("ctl00_obsah_rngtext");
	gRunText1 = document.getElementById("ctl00_obsah_rngtext1_obsah");
	gRunText2 = document.getElementById("ctl00_obsah_rngtext2_obsah");
	borderWidth = runTextBorder.offsetWidth;
	gTextWidth = gRunText1.offsetWidth;
	//gPosition = Math.floor(borderWidth / 4);
	gPosition = 0;
	gFirstText = 1;
	gRunText1.style.left = gPosition.toString() + "px";
	gRunText2.style.left = (gPosition + gTextWidth).toString() + "px";
	document.getElementsByTagName("body").item(0).onclick = PauzaB;
    gHandlerRunText = window.setTimeout("RunTextRun();", 1000);
    //RunTextRun();
}



function RunTextRun()
{
	if (g_disableScripts) return;
	gTextRuns = true;
	gPosition = gPosition - cSTEP;
	if (gPosition + gTextWidth < 1)
	{
		gPosition = 0;
		if (gFirstText == 1)
		{
			gFirstText = 2;
			gRunText2.style.left = "0";
			gRunText1.style.left = gTextWidth.toString() + "px";
		}
		else
		{
			gFirstText = 1;
			gRunText1.style.left = "0";
			gRunText2.style.left = gTextWidth.toString() + "px";
		}
	}
	else
	{
		if (gFirstText == 1)
		{
			gRunText1.style.left = gPosition.toString() + "px";
			gRunText2.style.left = (gPosition + gTextWidth).toString() + "px";
		}
		else
		{
			gRunText2.style.left = gPosition.toString() + "px";
			gRunText1.style.left = (gPosition + gTextWidth).toString() + "px";
		}
	}
	if (gFirstText > 0)
	{
//        gPocitani++;
//        if (gPocitani > cDELKA) gPocitani = 0;
        window.clearTimeout(gHandlerRunText); //nove pridane, vliv na zatizeni v IE to nema
        gHandlerRunText = window.setTimeout("RunTextRun();", cDELAY);
//        if (gPocitani > cDELKA)
//        {
//            gPocitani = 0;
//            gHandlerRunText = window.setTimeout("RunTextRun();", cDELAY + cPAUZA);
//        }
//        else
//            gHandlerRunText = window.setTimeout("RunTextRun();", cDELAY);
	}
}

function WriteAddress(box, domain, popis, vyrazne, alias)
{
	if (domain == "")
		domain = "konzkm.cz";
	var adresa = box + '@' + domain;
	if (alias == "")
		alias = adresa;
	var txt = '<a class="nastroj" href="mailto:' + adresa + '">'
	if (vyrazne)
		txt += '<em>' + alias + '</em></a>';
	else
		txt += alias + '</a>';
	if (popis != "")
		txt += ' (' + popis + ')';
	document.write(txt);
}

function WriteAdressB(domain, box)
{
    var adresa = "";
    adresa = box + '@' + domain;
    document.write(adresa);
}

//function ViewPicture(popiska, rocnik, obrazek)
//{
//	var imgsrc = "images/abs_" + rocnik + "/b_" + obrazek + ".jpg";
//	var ebigfoto = document.getElementById("ctl00_obsah_bigfoto");
//	var epopiska = document.getElementById("ctl00_obsah_popiska");
//	ebigfoto.title = popiska;
//	ebigfoto.src = imgsrc;
//	epopiska.innerText = "Loading...";
////	ViewDescription();
//}

function ViewDescription()
{
	var ebigfoto = document.getElementById("ctl00_obsah_bigfoto");
	var epopiska = document.getElementById("ctl00_obsah_popiska");
	epopiska.innerText = ebigfoto.title;
	//epopiska.innerHTML = ebigfoto.title;
}

function NewPage(incr)
{
	var frm, v, p;
	frm = document.getElementById("aspnetForm");
	frm.reset();
	v = frm.ctl00$obsah$strana.value;
	p = parseInt(v, 0);
	p += incr;
	frm.ctl00$obsah$strana.value = p;
	frm.submit();
}

function Hledani()
{
	var frm, v, p;
	frm = document.getElementById("aspnetForm");
	frm.ctl00$obsah$strana.value = "1";
	return true;
}

function noimg(o)
{
	o.src = "images/s_fotokryt.jpg";
}

function nobigimg()
{
	var ebigfoto = document.getElementById("ctl00_obsah_bigfoto");
	ebigfoto.src = "images/fotokryt.jpg";
	ebigfoto.title = "fotografie chybí";
}

function ZmenaVelikosti()
{
	if (g_disableScripts)
	{
		return;
	}
    var sirka_okna, levy, pravy, stred, vrsek2, vrsek;
    sirka_okna = document.body.offsetWidth;
//    window.alert(sirka_okna.toString());
    levy = document.getElementById("ctl00_levy");
    pravy = document.getElementById("ctl00_pravy");
    stred = document.getElementById("ctl00_stred");
    vrsek = document.getElementById("ctl00_vrsek");
    vrsek2 = document.getElementById("ctl00_vrsek_2");
    vrsek2.style.width = (vrsek.offsetWidth).toString() + "px";
    if (sirka_okna < g_minsirka)
    {
        levy.style.display = "none";
        pravy.style.display = "none";
        stred.style.marginLeft = "0px";
        stred.style.marginRight = "0px";
    }
    else
    {
        document.body.style.width = "auto";
        stred.style.marginLeft = "160px";
        stred.style.marginRight = "160px";
        levy.style.display = "block";
        pravy.style.display = "block";
        var stred_obsah;
        stred_obsah = document.getElementById("ctl00_stred_obsah");
        if (stred_obsah.offsetHeight < levy.offsetHeight)
        {
            stred_obsah.style.height = (levy.offsetHeight - 70).toString() + "px";
        }
    }
}

function Obrazek(styl, zdroj, sirka, vyska, popis)
{
	if (g_disableScripts)
	{
		return;
	}
	var txt;
	txt = '<img class="' + styl + '" src="' + zdroj + '" width="' + sirka + '" height="'
	+ vyska + '" alt="' + popis + '" />';
	document.write(txt);
}

//function ProZamereni(kdy)
//{
//	if (g_disableScripts)
//	{
//		return;
//	}
//	var id_vrsek, sirka, id_prozam, zleva, shora, id_konec, id_nadpis ;
//	id_vrsek = document.getElementById("vrsek");
//	id_nadpis = document.getElementById("nadpis");
//	id_konec = document.getElementById("konec_zam");
//	shora = id_vrsek.offsetHeight;
//	if (id_nadpis.offsetTop > shora)
//		id_vrsek.style.height = (id_nadpis.offsetTop + id_nadpis.offsetHeight + 10).toString() + "px";
//	if (shora < 122)
//	{
//		shora = 122;
//		id_vrsek.style.height = "122px";
//	}
//	sirka = document.body.offsetWidth;
//	id_prozam = document.getElementById("prozam");
//	if (sirka < 620) zleva = 0; else zleva = (sirka - 600) / 2;
//	id_prozam.style.left = zleva.toString() + "px";
//	id_prozam.style.top = (shora + 20).toString() + "px";
//	id_konec.style.left = zleva.toString() + "px";
//	id_konec.style.top = (shora + 510).toString() + "px";
//	if (kdy == 0) {
//		g_nastroj = "";
		//init_zam();
//	}
	//id_prozam.style.visibility = "visible"
//}

function ObrazekId(id, zdroj, sirka, vyska, popis)
{
	if (g_disableScripts)
	{
		return;
	}
	var txt;
	txt = '<img id="' + id + '" src="' + zdroj + '" width="' + sirka + '" height="'
	+ vyska + '" alt="' + popis + '" title="' + popis + '" />';
	document.write(txt);
}

function init_zam() {
	if (g_disableScripts)
	{
		return;
	}
	var id_nastroj, id_polozka, i, nastroj, kotva;
	document.getElementById("prozam").onmouseover = hideMenu;
	for (i = 0; i < 19; i++) {
		switch (i) {
			case 0: nastroj = "vno"; break;
			case 1: nastroj = "vla"; break;
			case 2: nastroj = "vcl"; break;
			case 3: nastroj = "cbs"; break;
			case 4: nastroj = "arp"; break;
			case 5: nastroj = "klav"; break;
			case 6: nastroj = "varh"; break;
			case 7: nastroj = "fl"; break;
			case 8: nastroj = "hob"; break;
			case 9: nastroj = "clar"; break;
			case 10: nastroj = "fag"; break;
			case 11: nastroj = "trb"; break;
			case 12: nastroj = "hor"; break;
			case 13: nastroj = "trom"; break;
			case 14: nastroj = "tuba"; break;
			case 15: nastroj = "akor"; break;
			case 16: nastroj = "kyta"; break;
			case 17: nastroj = "cimb"; break;
			case 18: nastroj = "bici"; break;
		}
		id_nastroj = document.getElementById("ctl00_obsah_" + nastroj);
		id_nastroj.onmouseover = showMenu;
		id_nastroj.onclick = hideMenu;
	}
	for (i = 0; i < 3; i++) {
		switch (i) {
			case 0: kotva = "i_uplat"; break;
			case 1: kotva = "i_vyuc"; break;
			case 2: kotva = "i_prijm"; break;
		}
		id_polozka = document.getElementById(kotva);
		id_polozka.onmouseover = makeHref;
	}
	document.getElementById("menu").onmouseover = oznac;
}

function PaintMenu() {
	if (g_disableScripts)
	{
		return;
	}
	var txt;
	txt = '<table col="1" id="menu">'
	+ '<tr><td><a id="i_uplat" class="menuitem" href="#">uplatnění absolventů</a></td></tr>'
	+ '<tr><td><a id="i_vyuc" class="menuitem" href="#">vyučující</a></td></tr>'
	+ '<tr><td><a id="i_prijm" class="menuitem" href="#">přijímací zkouška</a></td></tr>'
	+ '</table>';
	document.write(txt);
}

function nove(zdroj, konec)
{
	adresa = window.location.href;
	poz1 = adresa.indexOf("?", 0);
	poz2 = adresa.indexOf("#", 0);
	delka = adresa.length;
	if (poz1 > -1)
	    delka = poz1;
	if (poz2 > -1)
	{
	    if (poz1 > -1)
	    {
	        delka = Math.min(poz1, poz2);
	    }
	    else
	    {
	        delka = poz2;
	    }
	}
	adresa = adresa.substring(0, delka - konec.length) + zdroj;
//	window.alert(adresa);
	prop = "scrollbars=yes,menubar=yes,resizable=yes";
	u_okno = window.open(adresa, "nove", prop);
	u_okno.focus();
}

