
var submenu_active_id = 0;
var submenu_active_parent = null;

/*

var timer, i, menuId, menuId2;
var dom = document.getElementById ? true : false;
var ie4 = ((document.all) && (!dom)) ? true : false;
var ns4 = document.layers ? true : false;
var opera = navigator.userAgent.indexOf('Opera') != -1 ? true : false;
var dhtml = dom ? true : false;
var last_view1 = 0; // posledni zobrazene menu
var last_view2 = 0; // posledni zobrazene menu (vzdy se najednou zobrazuji pouze dve,
var elm = ''; // sem se uklada nazev elementu statickeho menu

if (dhtml) {
	var hmt = '53px'; // souradnice prvniho linie vyskakovaciho menu (top)
	var hmx = 3; // souradnice prvniho menu prvni line (left);
	var hmw = 94.5; // sirka - odstup jednotlivych menu - dle pevneho menu

	var vmt = '22px'; // souradnice statickeho menu (top)
	var vmx = 3; // souradnice prvniho statickeho menu (left);
	var vmw = 94.5; // sirka - odstup jednotlivych pevnych menu

	// III. uroven
	var startx = 3; // leva pozice menu
	var starty = 53; // vrchni pozice menu
	var rowhei = 25; // vyska radku
	var rowwid = 204; // sirka radku pevne polozky menu
	var lastcol = 113; // posunuti u posledniho sloupce

	var j = 0;
	document.write('<style type="text/css"><! -- #scriptSupport {display: none;}');
	document.write('#menuHolder {position: absolute; top:95px; left:311px; visibility: hidden;');
	document.write(' z-index: 1; background:transparent url("/images/css/dhtml.gif") no-repeat 0px 0px;');
	document.write(' height:71px; width:569px; _background-position: 0px 0px;_left:311px;}');

	for (j = 1; j <= 6; j++) {
		if (j == 4) j ++;
		var lft = ((j - 1) * vmw) + vmx; // style - left
		document.write ('#visibleMenu' + j + ' {position: absolute; left:' + Math.round(lft) + 'px; top:' + vmt + '; }');
	}

	for(j = 1; j <= 6; j++) {
		if (j == 4) j ++;
		var lft = ((j - 1) * hmw) + hmx; // style - left
		if(j >= 5) lft = lft - lastcol;
		document.write ('#hiddenMenu' + j + ' {position: absolute; left:' + Math.round(lft) + 'px; top:' + hmt + '; visibility: hidden;' + ( j >= 5 ? 'text-align:right;' : '') + '} ' + ( j == 6 ? '#hiddenMenu' + j + ' a{padding-right:5px;}' : ''));
	}

	// zakladni pocet polozek v menu (6)
	for(mainmenu = 1; mainmenu <= 6; mainmenu ++) {
		if (mainmenu == 4) mainmenu ++;
		// maximalni pocet radku v prvni linii menu (20)
		for(icss = 1; icss <= 20; icss ++) {
			idel = (mainmenu * 100) + icss;
			lft = startx + (hmw * (mainmenu - 1)) + rowwid;
			if(mainmenu >= 5) lft = lft - lastcol - (2 * rowwid) + 1;
			tp = starty + (rowhei * (icss - 1));
			document.write ('#hiddenMenu' + idel + ' {position:absolute; left: ' + lft + 'px; top: ' + tp + 'px; visibility:hidden; ' + (mainmenu >= 5 ? 'text-align:right;' : '') + ';}');
		}
		document.write('\n\r');
	}

	document.write ('</style>');
}


function chCl(element, newClass)
{
	if(dom) document.getElementById(element).className = newClass;
}

function setVisibility(element,newVisibility)
{
  if(dhtml) document.getElementById(element).style.visibility = newVisibility;
}

function menu()
{
  if(dhtml)  setVisibility('menuHolder','visible');
}

function Smen(id,id2)
{
	if (dhtml)
	{
		clearTimeout(timer);
		if(last_view1 != id && last_view1 != id2 && last_view1 != 0) {
			setVisibility((ns4 ? 'menuHolder.document.' : '') + 'hiddenMenu' + last_view1,'hidden');
		}
		if(last_view2 != id && last_view2 != id2 && last_view2 != 0) {
			setVisibility((ns4 ? 'menuHolder.document.' : '') + 'hiddenMenu' + last_view2,'hidden');
		}
		for (i = 1; i <= 6; i++) {
			if ((i != id) && (i != id2) && i != 4) {
				setVisibility('hiddenMenu' + i,'hidden');
				chCl('visibleMenu' + i, 'main-menu');
			}
		}
		if(id > 99) chCl('Hmn' + id, 'hlp-a');
		if(id2 > 99) chCl('Hmn' + id2, 'hlp-a');
		// všechna nepotřebná menu skryjeme1
		setVisibility('hiddenMenu' + id,'visible');
		if(id2 != 0) setVisibility('hiddenMenu' + id2,'visible');
		last_view1 = id;
		last_view2 = id2;
		if(id < 100 && id != 0) chCl('visibleMenu' + id, 'main-active-menu');
		if(id2 < 100 && id2 != 0) chCl('visibleMenu' + id2, 'main-active-menu');
	}
}

function Hid(id,id2)
{
	var str = '';
  if (dhtml)
  {
	if((id == 0 || id > 99) && (id2 == 0 || id2 > 99)) {
		if((id > 99) && (id2 > 99 || id2 == 0)) {
			setVisibility('hiddenMenu' + id,'hidden');
			chCl('Hmn' + id, 'Hmn');
		}
		//pokud máme zneviditelnit jen podmenu, uděláme to bez časovače
		if((id2 > 99) && (id > 99 || id == 0)) {
			setVisibility('hiddenMenu' + id2,'hidden');
			chCl('Hmn' + id2, 'Hmn');
		}
	}
    else {
		if(id != 0 && id < 100) str = "; chCl('visibleMenu" + id + "', 'main-menu')";
      menuId = 'hiddenMenu' + id;
      if (id2 != 0)
      {
        menuId2 = 'hiddenMenu' + id2;
        timer = setTimeout("setVisibility(menuId,'hidden'); setVisibility(menuId2,'hidden')" + str,(ns4 ? 150 : 50)); //v NS4 je kvůli špatné interpretaci CSS třeba použít delší čas
      }
      else timer = setTimeout("setVisibility(menuId,'hidden')" + str,(ns4 ? 150 : 50));
    }
  }
}

function noHid()
{
  if (dhtml) clearTimeout(timer);
}

/**/

function ShowSubmenu(id, parent, selected_main_menu)
{
	if (submenu_active_id != 0)
	{	
		submenu_active = document.getElementById('submenu-'+submenu_active_id);
		submenu_active.style.visibility = 'hidden';
	}
	
	if (submenu_active_parent != null) {
		submenu_active_parent.className = '';
	}
	
	
	if (selected_main_menu != null && selected_main_menu != 0) {
		active = document.getElementById('menu-'+selected_main_menu);
		active.className = '';
	}
	
	submenu = document.getElementById('submenu-'+id);
	submenu.style.visibility = 'visible';

	submenu_active_id = id;		
	submenu_active_parent = parent;	
	
	if (parent) {
		parent.className = "selected";
	}
	
	//alert(submenu_active_id);
}

function AddFavorite(linkObj,addUrl,addTitle)
{
 if (document.all && !window.opera)
  {
    window.external.AddFavorite(addUrl,addTitle);
    return false;
  }
  else if (window.opera && window.print)
  {
    linkObj.title = addTitle;
    return true;
  }
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
  {
    if (window.confirm('Pridat oblibenou stranku jako novy panel?'))
    {
      window.sidebar.addPanel(addTitle,addUrl,'');
      return false;
    }
  }
  window.alert('Po potvrzeni stisknete CTRL-D,\nstránka bude pridana k Vasim oblibenym odkazum.');
  return false;
}

function adv(uri)
{
	window.open(uri, "page", "menubar=yes, location=yes, status=no, toolbar=no, scrollbars=yes, resizable=yes");
	return false;
}

function w(uri)
{
	var result = adv(uri);
	return result;
}

function wf(url, width, height)
{
	width += 50; height += 50;
	window.open(url, 'foto', 'width='+width+', height='+height+', toolbar=no, location=no, resizable=yes, scrollbars=yes, top=100, left=100');
	return false;
}

function pop_adv(uri, width, height)
{
	xPos = window.innerWidth;
	if (isNaN(xPos))
	{
		xPos = document.body.offsetWidth;
	}

	xPos = xPos - width  - 70;
	window.open(uri, "advertising", "width=" + width + ", height=" + height + ",menubar=no, location=no, status=no, toolbar=no, scrollbars=yes, resizable=no, left=" + xPos + ", top=70");
	return false; 
}


function trim(hodnota)
{
	if (hodnota.charAt(0) == " ") {
		hodnota = hodnota.substring(1,hodnota.length);
		hodnota = trim(hodnota);
	}
	if (hodnota.charAt(hodnota.length-1) == " ") {
		hodnota = hodnota.substring(0,hodnota.length-1);
		hodnota=trim(hodnota);
	}
	return hodnota;
}


function zkontroluj_email(adresa)
{
    var pozice_zavinace = adresa.indexOf("@");
    if (pozice_zavinace < 0)
        return false;
    var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);
    var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);
    if (cast_po_zavinaci.indexOf("@") >= 0)
        return false;
    if (cast_pred_zavinacem.length <= 0)
        return false;
    if (cast_po_zavinaci.length <= 0)
        return false;
    return true;
}

function check_form()
{
	var error = false;
	var report ='';

	var firma = document.getElementById('firma').value;
	firma = trim(firma);
	if (firma.length == 0) {
		error = true;
		report += 'Nebylo zadáno jméno firmy!\n';
	}

	var jmeno = document.getElementById('jmeno').value;
	jmeno = trim(jmeno);
	if (jmeno.length == 0) {
		error = true;
		report += 'Nebylo zadáno jméno kontaktní osoby!\n';
	}

	var mail = document.getElementById('mail').value;
	mail = trim(mail);
	if (mail.length == 0) {
		error = true;
		report += 'Nebyl zadán mail!\n';
	} else {
		if (!zkontroluj_email(mail)) {
			error = true;
			report += 'E-mail nemá správný formát!\n';
		}
	}

	var telefon = document.getElementById('telefon').value;
	telefon = trim(telefon);
	if (telefon.length == 0) {
		error = true;
		report += 'Nebyl zadán telefon!\n';
	}

	var poptavka = document.getElementById('poptavka').value;
	poptavka = trim(poptavka);
	if (poptavka.length == 0) {
		error = true;
		report += 'Nebyla zadána poptávka!';
	}

	if (error) {
		window.alert(report);
		return false;
	}

	var check_value = document.getElementById('check_value');
	check_value.value = 1;
}
