function otazka(text) {
    var is_confirmed = confirm(text);
    return is_confirmed;
}

function odesliForm(jmeno,url, dotaz) {
	if (dotaz != '') {
		if (!otazka(dotaz)) return false;
	}
    document.getElementById(jmeno).action=url;
    document.getElementById(jmeno).submit();      
}
function hiddeAllTopSubmenu() {
      for (var i = 0; i < top_menu_arr.length; i++) {
            el = document.getElementById(top_menu_arr[i]+'_submenu');
            el1 = document.getElementById(top_menu_arr[i]);
            if (el) {
                  el.style.display='none';
            }
            if (el1) {
                  el1.style.backgroundColor='transparent';
            }
      }
}

function CheckAll(the_form, elname, do_what)
{
    var elts      = (typeof(document.forms[the_form].elements[elname]) != 'undefined')
                  ? document.forms[the_form].elements[elname]
                  : (typeof(document.forms[the_form].elements[elname]) != 'undefined')
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_what;
        } // end for
    } else {
        elts.checked        = do_what;
    } // end if... else

    return true;
}

function showTopSubmenu(id) {
    hiddeAllTopSubmenu();
    el = document.getElementById(id+'_submenu');
    el1 = document.getElementById(id);
    elM = document.getElementById('top_menu_2');
    
    if (elM) {
        elM.style.display='block';
    }
    if (el) {
        el.style.display='block';
    }
    if (el1) {
          el1.style.backgroundColor='#000';
    }
}
function skrytNaseptavac(id) {
	el = document.getElementById(id);
	if (el) el.style.display='none';
}


function vyplnitTextInput(id,obsah,id_naseptavace) {
	el = document.getElementById(id);
	if (el) {
		el.value=obsah;
		el2 = document.getElementById(id_naseptavace);
		if (el2) {
			skrytNaseptavac(id_naseptavace);
		}
	}
}

function vybratSchema(id,schema) {
	el = document.getElementById(id);
	if (el) {
		el.innerHTML='&lt;!-- MOTOMIX START --&gt;<br />&lt;div&gt;&lt;script src="http://www.motomix.cz/se_form/search.js.php?styl='+schema+'" type="text/javascript"&gt;&lt;/script&gt;&lt;a href="http://www.motomix.cz" class="motomix-link" title="Motomix.cz - inzerce, magazín, motocykly, skútry a čtyřkolky"&gt;Motomix.cz: Motoinzerce, magazín o motocyklech&lt;/a&gt;&lt;/div&gt;<br />&lt;!-- MOTOMIX END --&gt;';
	}
}

function zobrazOstatniZnacky() {
	arrElements = document.getElementsByTagName("li");
	for(var i=0; i<arrElements.length; i++) {
		oElement = arrElements[i];
		if (oElement.className=="dalsiZnacka") {
			oElement.style.display='block';
		}
	}
	document.getElementById('dalsiZnackyOdkaz').style.display='none';
}

function skrytOstatniZnacky() {
    	arrElements = document.getElementsByTagName("li");
    	for(var i=0; i<arrElements.length; i++) {
    		oElement = arrElements[i];
    		if (oElement.className=="dalsiZnacka") {
    			oElement.style.display='none';
    		}
    	}
}

function vyhledavaciFormular(id_form, id_link1, id_link2) {
	f = document.getElementById(id_form);
	l1 = document.getElementById(id_link1);
	l2 = document.getElementById(id_link2);

    if (f.style.display == 'none') {
    	f.style.display='block';
    	l1.style.display='block';
    	l2.style.display='none';
    } else {
    	f.style.display='none';
    	l1.style.display='none';
    	l2.style.display='block';	
    }
}

function zobrazNahled(id, stav) {
    el = document.getElementById(id);

    if (el) {
    	if (stav) {
    		el.style.display='block';
    	} else {
    		el.style.display='none';
    	}
    }
}

function bodyOnLoad(default_top_submenu) {
      hiddeAllTopSubmenu();
      showTopSubmenu(default_top_submenu);
}

function popup(theURL,winName,features) {
	  window.open(theURL,winName,features);
	} 


function nahledova_fotka(fotka,cont) {
	el = document.getElementById(cont);
	if (el) {
		el.innerHTML = '<img src="'+fotka+'" alt=""/>';
	}
}

function preloadImage(img) {
	heavyImage = new Image(); 
	heavyImage.src = img;
}

function correctPNG() { // correctly handle PNG transparency in Win IE 5.5 & 6.
        var arVersion = navigator.appVersion.split("MSIE")
        var version = parseFloat(arVersion[1])
        if((version >= 5.5) && (document.body.filters)) {
          for(var i=0; i<document.images.length; i++) {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if(imgName.substring(imgName.length-3, imgName.length) == "PNG") {
              var imgID = (img.id) ? "id='" + img.id + "' " : ""
              var imgClass = (img.className) ? "class='" + img.className + "' " : ""
              var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
              var imgStyle = "display:inline-block;" + img.style.cssText
              if (img.align == "left") imgStyle = "float:left;" + imgStyle
              if (img.align == "right") imgStyle = "float:right;" + imgStyle
              if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
              var strNewHTML = "<span " + imgID + imgClass + imgTitle
              + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
              + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
              + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
              img.outerHTML = strNewHTML
              i = i-1
            }
          }
        }
      }
