/* Obecne funkce, ktere by se meli pouzivat namisto primeho pristupu z javascriptu @since 25.08.2005 PF TODO: // resolved -> 26.08.05_2 ... 25.08.05 - dodelat (domyslet) chybove hlasky -> tedy doplnit podminku "else" pro "document.getElementById(el_id) != null" 26.08.05 - otestovat funkce CHANGES: 26.08.05_1 - (+) fce tge, tgpe, tgpte - ktere vraci true/false podle toho, jestli dany element existuje. 26.08.05_2 - (*) fce ge, gpe, gpte - nyni vraci taky null, pokud element neexistuje, aby se daly pouzit k testovani 30.08.05_1 - (+) fce ge_v - zjisteni hodnoty elementu podle id 30.08.05_2 - (+) fce se_v - nastaveni hodnoty elementu podle id */ // funkce provede submit formulare podle jeho id na vybrany "target" a "action" // @package elements.js // @access public // @see - // @author PF // @param form_id - id formulare, @new_target - target, @new_action - action // @return // @since 25.08.2006 function submit_handle(form_id, new_target, new_action){ form_name = ge_n(form_id); document.forms[form_name].target = new_target; document.forms[form_name].action = new_action; document.forms[form_name].submit(); } // end function // funkce submitne formular po stiknuti klavesy enter. Vola se napriklad na keypress // @package main.js // @access public // @see - // @author PF // @param form ane form_name - nazev formu // @return // @since 01.09.2005 function submit_by_enter(form_name){ if (myKeycode == 13) { document.forms[form_name].submit(); } // end if } // end function // funkce vraci hodnotu elementu na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID // @return string | null // @since 30.08.2005 function ge_n(el_id){ if (document.getElementById(el_id) != null) { return document.getElementById(el_id).name; } // if(else) else { return null; } // end (if)else } // end if // funkce vraci hodnotu elementu na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID // @return string | null // @since 30.08.2005 function ge_s(el_id){ if (document.getElementById(el_id) != null) { form_el = ge(el_id); return form_el.options[form_el.selectedIndex].value; } // if(else) else { return null; } // end (if)else } // end if // funkce nastavuje obsah elementu na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID, @param string content - obsah // @return string | null // @since 30.08.2006 function se_c(el_id, content){ if (document.getElementById(el_id) != null) { document.getElementById(el_id).innerHTML = content; } // if(else) } // end if // funkce nastavuje hodnotu elementu na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID, @param string val - hodnota // @return string | null // @since 30.08.2005 function se_v(el_id, val){ if (document.getElementById(el_id) != null) { document.getElementById(el_id).value = val; } // if(else) } // end if // funkce vraci hodnotu elementu na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID // @return string | null // @since 30.08.2005 function ge_v(el_id){ if (document.getElementById(el_id) != null) { return document.getElementById(el_id).value; } // if(else) else { return null; } // end (if)else } // end if // test element - funkce vraci true/flase, jestli dany element existuje // @package main.js // @access public // @see - ge // @author PF // @param element_id el_id - HTMLelementID // @return boolean // @since 26.08.2005 function tge(el_id){ if (ge(el_id) != null){ return true; } // if(else) else { return false; } // end (if)else } // end function // funkce vraci element na zaklade jeho id pomoci funkce getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID // @return HTMLelement | null // @since 25.08.2005 function ge(el_id){ if (document.getElementById(el_id) != null) { return document.getElementById(el_id); } // if(else) else { return null; } // end (if)else } // end if // funkce vraci element na zaklade jeho id pomoci funkce parent.getElementById // @package main.js // @access public // @see - // @author PF // @param element_id el_id - HTMLelementID // @return HTMLelement // @since 25.08.2005 function gpe(el_id){ if (parent.document.getElementById(el_id) != null) { return parent.document.getElementById(el_id); } // if(else) else { return null; } // end (if)else } // end if // zobrazeni elementu - nastavenim atributu style.display na "inline" // @package main.js // @access public // @see - // @author PF // @param element eld - HTML element // @return // @since 25.08.2005 function el_display_show_inline(el){ el.style.display = "inline"; } // end function // zobrazeni elementu - nastavenim atributu style.display na "block" // @package main.js // @access public // @see - // @author PF // @param element eld - HTML element // @return // @since 25.08.2005 function el_display_show(el){ el.style.display = "block"; } // end function // zobrazeni elementu - nastavenim atributu style.display na "block" // @package main.js // @access public // @see el_display_show // @author PF // @param element_id el_id - HTML element id // @return // @since 25.08.2005 function el_id_display_show(el_id){ if (tge(el_id)) { el_display_show(ge(el_id)); } // end if } // end function // zobrazeni elementu - nastavenim atributu style.display na "inline" // @package main.js // @access public // @see el_display_show // @author PF // @param element_id el_id - HTML element id // @return // @since 25.08.2005 function el_id_display_show_inline(el_id){ if (tge(el_id)) { el_display_show_inline(ge(el_id)); } // end if } // end function // zobrazeni elementu - nastavenim atributu style.display na "block" // @package main.js // @access public // @see - // @author PF // @param element eld - HTML element // @return // @since 25.08.2005 function el_display_hide(el){ el.style.display = "none"; } // end function // zobrazeni elementu - nastavenim atributu style.display na "block" // @package main.js // @access public // @see el_display_hide // @author PF // @param element_id el_id - HTML element id // @return // @since 25.08.2005 function el_id_display_hide(el_id){ if (tge(el_id)) { el_display_hide(ge(el_id)); } // end if } // end function // getmouseclick -> e - event - vola se napriklad na udalosti onmousedown="gmc(event);" function gmc(e){ if (navigator.appName == "Microsoft Internet Explorer") { msbclick = event.button; } else if (navigator.appName == "Netscape") { msbclick = e.which; } return msbclick; } // end function // zmeni, u vybraneho elementu podle jeho id, hodnotu atributu stylu display, na opacnou, nez jaka je. // tzn. budto ho zobrazni, nebo schova function switchdisplay(el_id) { //alert(ge(el_id).style.display); if (ge(el_id).style.display == "none" ) // || ge(el_id).style.display == "" { el_id_display_show(el_id) } // end if else { el_id_display_hide(el_id); } // else } // end function // pro vyhledavani function switchdisplay_2(el_id) { //alert(ge(el_id).style.display); if (ge(el_id).style.display == "none" || ge(el_id).style.display == "") // { el_id_display_show(el_id) } // end if else { el_id_display_hide(el_id); } // else } // end function // zmeni, u vybraneho elementu podle jeho id, hodnotu atributu stylu display, na opacnou, nez jaka je. // tzn. budto ho zobrazni, nebo schova function switchdisplay_inline(el_id) { if (ge(el_id).style.display == "none" || ge(el_id).style.display == "") { el_id_display_show_inline(el_id) } // end if else { el_id_display_hide(el_id); } // else } // end function /* ************************************************************************ This code is from Dynamic Web Coding at http://www.dyn-web.com/ See Terms of Use at http://www.dyn-web.com/bus/terms.html regarding conditions under which you may use this code. This notice must be retained in the code as is! ************************************************************************ */ function getDocHeight(doc) { var docHt = 0, sh, oh; if (doc.height) docHt = doc.height; else if (doc.body) { if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight; if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight; if (sh && oh) docHt = Math.max(sh, oh); } return docHt; } function setIframeHeight(iframeName) { var iframeWin = window.frames[iframeName]; var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null; if ( iframeEl && iframeWin ) { iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous var docHt = getDocHeight(iframeWin.document); // need to add to height to be sure it will all show if (docHt) iframeEl.style.height = docHt + 30 + "px"; } } function loadIframe(iframeName, url) { if ( window.frames[iframeName] ) { window.frames[iframeName].location = url; return false; } else return true; } function getElementHeight(Elem) { yPos = Elem.offsetHeight; return yPos; } function getElementWidth(Elem) { xPos = Elem.offsetWidth; return xPos; } // quirks function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return [curleft,curtop]; } // end function