var clicked=""
var selstate="_on"


document.write("<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr>");
document.write("<td><img src=\"menu_obr/newmenu_top.jpg\" alt=\"\" width=\"147\" height=\"23\"></td>");
document.write("</tr>");
writeButton("uvod.htm","newmenu_b1","Návrat na úvodní stránku");
writeButton("14.htm","newmenu_b2","Hlavní dokumenty");
writeButton("0.htm","newmenu_b3","Školní personál");
writeButton("11.htm","newmenu_b4","Organizace školních tříd");
writeButton("17.htm","newmenu_b5","Školní vzdělávací program");
writeButton("3.htm","newmenu_b6","Termíny hlavně pro rodiče");
writeButton("5.htm","newmenu_b7","Kroužky, vedoucí a termíny");
writeButton("23.htm","newmenu_b8","Co je aktuální?  ");
writeButton("8.htm","newmenu_b9","Omluvte své dítě");
writeButton("9.htm","newmenu_b10","Co by měl ředitel vědet");
writeButton("10.htm","newmenu_b11","Nabídka školní jídelny");
writeButton("2.htm","newmenu_b12","Historie a současnost školy");
writeButton("24.htm","newmenu_b15","Informace pro rodiče o prospěchu");
document.write("<tr>");
document.write("<td><img src=\"menu_obr/newmenu_bottom.jpg\" alt=\"\" width=\"147\" height=\"20\"></td>");
document.write("</tr></table>")
pick("newmenu_b1");


function writeButton(url, name, alt)
{
	gname = name;
	while(typeof(document[name])!="undefined") name += "x";
	reg(gname, name);
	document.write("<tr>");
	document.write("<td>");
	alt = " alt=\"" + alt + "\"";
	var l = clicked!="" || !isCurrentFile(url);
	if (l) document.write("<a  href=\"" + url +"\"" + evs(name) + " target=\"rampd\"" + ">");
	else gname += selstate;
	gname += ".jpg";
	document.write("<img src=\"menu_obr/"+gname+"\" name=\"" + name + "\"" + " width=\"147\"" + " height=\"30\"" + alt + " border=\"0\" />");
	if (l) document.write("</a>");
	document.write("</td>");
	document.write("</tr>");
}


function turn_over(name) {
	if (document.images != null && clicked != name) {
		document[name].src = document[name+"_over"].src;
	}
}

function turn_off(name) {
	if (document.images != null && clicked != name) {
		document[name].src = document[name+"_off"].src;
	}
}

function pick(name) {
	if (document.images && name!="") document[name].src = document[name + "_on"].src;
	var t = clicked;
	clicked = name;
	if (t != "") turn_off(t);
}

function reg(gname,name)
{
if (document.images)
	{
	document[name+"_off"] = new Image();
	document[name+"_off"].src = "menu_obr/" + gname+".jpg";
	document[name+"_over"] = new Image();
	document[name+"_over"].src =  "menu_obr/" + gname+"_over"+".jpg";
	document[name+"_on"] = new Image();
	document[name+"_on"].src =  "menu_obr/" + gname+"_on"+".jpg";
	}
}

function evs(name){ return " onClick=\"pick('"+ name + "')\" onmouseover=\"turn_over('"+ name + "')\" onmouseout=\"turn_off('"+ name + "')\""}



function syncFile(f,nf)
{
	var matches = 'home.html*index.html*welcome.html*default.asp';
	var p = f.lastIndexOf('/');
	var sf = f;
	
	if (p >= 0) sf = f.substr(p+1, f.length-1);
	if (matches.indexOf(sf) == -1) return "";
	
	return sf;
}

function isCurrentFile(str)
{
	str = escape(str);
	str = str.toLowerCase();
	while (str.length > 3 && str.substring(0,3) == "../")
		str = str.substr(3, str.length-1);
	var fstr = str.indexOf(".htm");
	if (fstr == -1) fstr = str.indexOf(".asp");
	if (fstr < 1 && str.charAt(str.length-1) != '/') str += "/";
	var current = document.location.href.toLowerCase();
	var p = current.lastIndexOf('?');
	if (p > 0) current = current.substr(0, p);
	var fcurrent = current.indexOf(".htm");
	if (fcurrent == -1) fcurrent = current.indexOf(".asp");
	if (fcurrent < 1 && current.charAt(current.length-1) != '/') current += "/";	
	if (fstr != -1 && fcurrent == -1) current += syncFile(str, current);
	if (fstr == -1 && fcurrent != -1) str += syncFile(current, str);
		
	var currsize = current.length;
	var strsize = str.length;

	while (strsize >=0 && currsize >=0)
	{
		if (current.charAt(currsize) != str.charAt(strsize))
			return false;
			
		currsize = currsize -1;
		strsize = strsize -1;
	}
	
	return true;
}

