


   // TODO - dalsi revize nutna



function HideIt(co1, co2)
{
 setTimeout("Hide('"+co1+"','"+co2+"')", 2000);
}

function Hide(co1, co2)
{
    document.getElementById(co2).style.display = "none";
    document.getElementById(co1).style.backgroundPosition = "0px 0px";
}

function HideAll() {

    kolik = 11;
    for (i=1;i<kolik+1;i++)
    {
    x1="menu"+i;

    document.getElementById(x1).style.display = "none";
    }
}


function ShowIt(co1, co2)
{
 HideAll();

document.getElementById(co2).style.display = "block";
document.getElementById(co1).style.backgroundPosition = "0px -23px";

}






  function ZmenHodnotu(e, f) {

    if (navigator.appName == "Microsoft Internet Explorer")
    {
      klik = event.button;
    } // end if
    else if (navigator.appName == "Netscape")
    {
      klik = f.which;
    } // end if

    h = parseInt(document.getElementById(e).value, 10);
    document.getElementById(e).value = h;

    if (isNaN(h))
    {
      document.getElementById(e).value = 0;
      return false;
    } // end if

    if (klik == 1)
    {
      h = eval(document.getElementById(e).value);
      document.getElementById(e).value = h+1;
    } // end if

    if (klik == 2 || klik == 3)
    {
      h = eval(document.getElementById(e).value);
      if (h > 0)
      {
        document.getElementById(e).value = h-1;
      } // end if
    } // end if

  } // end function




/*
  main.php js_custom
*/



function product_window(link) {
  window.open(link,'_blank','toolbar=no,menubar=no,location=no,directories=no, scrollbars=yes,resizable=no,status=no,width=660,height=570,top=0,left=0');
}

function Otevri_popup(sirka, vyska) {
  msg = window.open('/content/popup.php', 'nove_okno', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=no,resizable=yes,status=no,width='+sirka+',height='+vyska+',top=50,left=50')
}

function window_open(width, height, previewfile) {
  msg = window.open('/'+previewfile, 'email', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=no,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50')
}


function image_preview(imageurl, width, height, title) {
  msg = window.open('/index.php?ref=40&mode=image_preview&image_path='+imageurl+'&title='+title, 'image', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=no,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50')
}

function video_preview(imageurl, width, height, title) {
  msg = window.open('/index.php?ref=40&mode=video_preview&video_path='+imageurl+'&title='+title, 'video', 'toolbar=no,menubar=no,location=no,directories=no, scrollbars=no,resizable=yes,status=no,width='+width+',height='+height+',top=50,left=50')
}


function setMapVis(id, img) {
  obj = document.getElementById(id);
  ob2 = document.getElementById(img);
  //alert(id);
  if (obj) {
    if (obj.style.display == 'none') {
      ob2.src = 'http://www.mscomposit.com/images/minus.gif';
      obj.style.display = 'block';
    }
    else {
      ob2.src = 'http://www.mscomposit.com/images/plus.gif';
      obj.style.display = 'none';
    }
  }
}


function setVisibility(id, style_value)
{
 document.getElementById(id).style.display = style_value;
}

function changeVisibility(id, display_value, text_normal, text_change) {

  el_id = id + "_sp";
  el2 = document.getElementById(el_id);

  if (document.getElementById(id).style.display == 'none') {
    document.getElementById(id).style.display = display_value;
    el2.innerHTML = text_change;
  }
  else {
    el2.innerHTML = text_normal;
    document.getElementById(id).style.display = 'none';
  }
}


var menu_last_selected_el_id; // predchozi vybrany element
var menu_selected_el_id; // soucasny

// zmeni, u vybraneho elementu podle jeho id, hodnotu atributu stylu display, na opacnou, nez jaka je.
// tzn. budto ho zobrazni, nebo schova
function changeDisplay(el_id)
{
  if (document.getElementById(el_id) != null){
    my_el = document.getElementById(el_id);

    if (menu_selected_el_id == undefined){
      menu_last_selected_el_id = el_id;
    } else {
      menu_last_selected_el_id = menu_selected_el_id;
    } // end if

    menu_selected_el_id = el_id;

    el_sipka_id = el_id + "_sipka";
    el_sipka = document.getElementById(el_sipka_id);

    display_style = my_el.style.display;
    if (display_style == "none") {
      my_el.style.display = "inline";
      el_sipka.src = "/images/mine/arr_down2.gif";
      ret_val = 1;
    } else {
      el_sipka.src = "/images/mine/arr_right.gif";
      my_el.style.display = "none";
      ret_val = 0;
    } // end if else
  } // end if
  else
  {
    ret_val = 0;
  } // end else 

  return ret_val;
} // end function



function changeDisplay_last(el_id, hide){
  changeDisplay(el_id);

  if (el_id != menu_last_selected_el_id && hide && document.getElementById(menu_last_selected_el_id) != null){
    document.getElementById(menu_last_selected_el_id).style.display = "none";

    el_sipka_id = menu_last_selected_el_id + "_sipka";
    el_sipka = document.getElementById(el_sipka_id);
    el_sipka.src = "/images/mine/arr_right.gif";
  } // end if
} // end function



function init_menu(el_id){
  changeDisplay(el_id);
} // end function


function changeDisplayById(el_id)
{
  ret_val = -1;
  
  if (document.getElementById(el_id) != null){
    my_el = document.getElementById(el_id);
    display_style = my_el.style.display;
    if (display_style == "none") {
      my_el.style.display = "inline";
      ret_val = 1;
    } else {
      my_el.style.display = "none";
      ret_val = 0;
    } // end if else
  } // end if

  return ret_val;
} // end function






 /*
   byvale common.php

 */


function submit_form(form1){
  // changed by pf. 9.5.05 9:24 - zmena - nahrazeni evalu.
  document.getElementById(form1).submit();
  //eval("document."+form1+".submit();");
} // end function

  // funkce ktere zpristupnuji javacriptu promenne backendu


  // funkce vraci wwwroot()
  function get_wwwroot(){
    return "";
  } // end function

  // funkce vraci "{wwwroot}/images/" - staci tedy: [imageroot = get_imageroot(); img_el.src = imageroot + "checkbox.gif";]
  function get_imageroot(){
    return "/images/1/";
  } // end function

  // 20.09.05 ----------------------------------------------------------------------------------------------------------------------------------------------------------------

  // ---

  
  // eventy

  document.onkeydown = handlekeypress;
  var myKeycode = 0;

  function handlekeypress(evt){
    myKeycode;
    if (window.Event) myKeycode = evt.which;
    else myKeycode = event.keyCode;
    return true;
  } // end function

  /*
    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 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 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(el){
    el.style.display = "inline";
  } // 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(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 - // @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 "inline"
    // @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






// --- HEADER LOGIN

  // Validace header_login formulare
  function header_check_login_inputs()
  {
    if (document.getElementById("header_login_username_input").value == "") {window.alert("Please fill:  Your username"); return false;}
    if (document.getElementById("header_login_password_input").value == "") {window.alert("Please fill:  Password"); return false;}
    return true;
  } // end function

  // funkce se stara o zobrazeni, nebo ukryti header_login
  function header_display_login()
  {
    login_status = document.getElementById("header_login_form").style.visibility;
    if (login_status == "visible")
    {
      header_hide_login_form();
    }
    else
    {
      header_show_login_form();
    }
  } // end function


  // zobrazeni header_login
  function header_show_login_form()
  {
    document.getElementById("header_login_form").style.visibility = "visible";
  } // end function


  // skryti header_login
  function header_hide_login_form()
  {
    document.getElementById("header_login_form").style.visibility = "hidden";
  } // end function

// ---


  // --- HELPERS

  // zobrazeni pomocneho tlacitka (melo by se zobrazovat napriklad se pri zmene poctu kusu)
  // @package helpers // @access public // @see el_id_display_show // @author PF // @param element_id el_id - HTML element id // @return // @since 25.08.2005
  function helpers_chng_show_sav(el_id){
    el_id_display_show(el_id);
  } // end function


  // js_script pro osetreni udalosti onMouseDown, tzn. vlastni meneni poctu kusu mysi +1 / -1 s kontrolou, aby neslo jit do zaporu
  // @package helpers // @access public // @see helpers.php // @author PF // @param element el - HTML element // @return // @since 25.08.2005
  function helpers_chng_onMouseDown(el, mbclkl){
    if (mbclkl == 1)
    {
      el.value++;
    } // end if

    if (mbclkl == 2 || mbclkl == 3)
    {
      if((el.value - 1) > 0)
      {
        el.value--;
      } // end if
    } // end if

  } // end function

  // ---



  // funkce zobrazuje chybovou hlasku pokud zadany element formlare neni vyplneny
  function is_valid_formelement_empty(id_form, elem, alert_msg_common, alert_msg_input){

    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input))
    {
      retval = true;
    } // end if     
    else 
    {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function

  // 11.10.05 -------

  // funkce vraci true pokud je otrimovany retezec delsi nez (min_str_len - 1) znaku
  function is_valid_1(user_input, min_str_len){
    val = user_input.trim();
    val_len = val.length;
    if (val_len > (min_str_len - 1))
    {
      return true;
    }
    else
    {
      return false;
    } // end if
  } // end function


  // funkce vraci true pokud neni otrimovany retezec prazdny
  function is_valid_0(user_input){
    val = user_input.trim();
    val_len = val.length;
    if (val_len > 0){
      return true;
    } else {
      return false;
    } // end if
  } // end function


  // funkce zobrazuje chybovou hlasku pokud je "res_bool" false
  function is_valid_msgcontrol(id_el, res_bool, alert_msg_common, alert_msg_input, alert_msg_add){
    if (res_bool){
      return true;
    } else {
      window.alert(alert_msg_common + alert_msg_input + " \n \r " +  error_msg);
      return false;
    } // end if
  } // end function


  // funkce zobrazuje chybovou hlasku pokud je zadany element formlare kratsi
  // nez 3 znaky, nebo pokud je prazdny
  function is_valid_formelement(id_form, elem, alert_msg_common, alert_msg_input){

    char_min = 3;
    if (char_min == 1){
      char_min_msg = " character ";
    } else {
      char_min_msg = " characters ";
    }

    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input)){
      if (is_valid_1(user_input, char_min)){
        retval = true;
      } else {
        error_msg = "Input value is shorter than " + char_min + char_min_msg + "!";
        form_el_focus(id_form, elem);
        retval = false;
      } // end if

    } else {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function
  
  // funkce zobrazuje chybovou hlasku pokud je zadany element formlare kratsi
  // nez 2 znaky, nebo pokud je prazdny
  function is_valid_formelement_city(id_form, elem, alert_msg_common, alert_msg_input){

    char_min = 2;
    char_min_msg = " characters ";
    
    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input)){
      if (is_valid_1(user_input, char_min)){
        retval = true;
      } else {
        error_msg = "Input value is shorter than " + char_min + char_min_msg + "!";
        form_el_focus(id_form, elem);
        retval = false;
      } // end if

    } else {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function

  // funkce zobrazuje chybovou hlasku pokud je zadany element formlare neni validni email
  function is_valid_formelement_email(id_form, elem, alert_msg_common, alert_msg_input){

    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input)){
      if (isEmail(user_input)){
        retval = true;
      }
      else {
        error_msg = "Input value is not valid email address!!";
        form_el_focus(id_form, elem);
        retval = false;
      } // end if
    }
    else {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function

  
  
  // funkce zobrazuje chybovou hlasku pokud je zadany text prazdny
  // podle zadaneho elementu
  function is_valid_10(id_el, alert_msg_common, alert_msg_input){
    retval = false;
    error_msg = "";

    user_input = document.getElementById(id_el).value;

    if (is_valid_0(user_input)){
      retval = true;
    } else {
      error_msg = "Input value is empty!";
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_el, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function


  // funkce zobrazuje chybovou hlasku pokud je zadany text kratsi nez 3 znaky, nebo pokud je prazdny
  // podle zadaneho elementu
  function is_valid_11(id_el, alert_msg_common, alert_msg_input){

    char_min = 3;
    if (char_min == 1){
      char_min_msg = " character ";
    } else {
      char_min_msg = " characters ";
    }

    retval = false;
    error_msg = "";

    user_input = document.getElementById(id_el).value;

    if (is_valid_0(user_input)){
      if (is_valid_1(user_input, char_min)){
        retval = true;
      } else {
        error_msg = "Input value is shorter than " + char_min + char_min_msg + "!";
        retval = false;
      } // end if

    } else {
      error_msg = "Input value is empty!";
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_el, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function


  // funkce zobrazuje chybovou hlasku pokud je zadany text neplatny email
  // podle zadaneho elementu
  function is_valid_12(id_el, alert_msg_common, alert_msg_input){
    retval = false;
    error_msg = "";

    user_input = document.getElementById(id_el).value;

    if (isEmail(user_input)){
      retval = true;
    } else {
      error_msg = "Input value is not valid email address!";
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_el, retval, alert_msg_common, alert_msg_input, error_msg);

  } // end function



  //<http://liorean.web-graphics.com/>
  String.prototype.trim=function(){
       var
           r=/^\s+|\s+$/,
           a=this.split(/\n/g),
           i=a.length;
       while(i-->0)
           a[i]=a[i].replace(r,'');
       return a.join('\n');
  }

  //https://lists.latech.edu/pipermail/javascript/2004-January/006877.html
  function isEmail (p_sEmail)
  {
   var regEmail = /^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$/;
   return regEmail.test (p_sEmail);
  }

  
  

  // focus na nevybrane policko podle id_formu a element_name
  function form_el_focus(id_form, el_name){
    name_form = ge_n(id_form);

    if (name_form != null)
    {
      //s = "document." + name_form + "." + el_name;

      //document.forms[name_form].elements[el_name].focus();
      // eval(s).focus(); // -- na mozzile to bugugje
    } // end if

  } // end function
  
  // funkce zobrazuje chybovou hlasku pokud se hesla nerovnaji
  function is_valid_samepassword(id_form, elem1, elem2, alert_msg_common, alert_msg_input){

    retval = false;
    error_msg = "";

    s1 = eval("document.getElementById('"+id_form+"')."+elem1+".value");
    s2 = eval("document.getElementById('"+id_form+"')."+elem2+".value");

    if (s1 == s2) 
    {
      retval = true;
    }
    else 
    {
      error_msg = "Input passwords are not same!";     
      //form_el_focus(id_form, elem1);
      retval = false;
    }

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function
  // ---
  
  
  
  // pridani funkci na validaci UKpost - dle PEER - prepsani do js
  
  // funkce zobrazuje chybovou hlasku pokud je zadany element formlare neni validni UKpost
  function is_valid_formelement_UKpost(id_form, elem, alert_msg_common, alert_msg_input){

    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input)){
      if (isUKpostcode(user_input)){
        retval = true;
      }
      else {
        error_msg = "PSÈ není zadané správnì!!";
        form_el_focus(id_form, elem);
        retval = false;
      } // end if
    }
    else {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function
  
  // funkce zobrazuje chybovou hlasku pokud je zadany element formlare neni validni UKpost
  function is_valid_formelement_Phone(id_form, elem, alert_msg_common, alert_msg_input){

    retval = false;
    error_msg = "";

    s = "document.getElementById('"+id_form+"')."+elem+".value";

    user_input = eval(s);

    if (is_valid_0(user_input)){
      if (isPhone(user_input)){
        retval = true;
      }
      else {
        error_msg = "Inserted phone number is not valid!!";
        form_el_focus(id_form, elem);
        retval = false;
      } // end if
    }
    else {
      error_msg = "Input value is empty!";
      form_el_focus(id_form, elem);
      retval = false;
    } // end if

    return is_valid_msgcontrol(id_form, retval, alert_msg_common, alert_msg_input, error_msg);
  } // end function
  
  
  
  // Kontrola na UKpostcode, dle uPIRu
  // Copyright (c) 1997-2005 Michael Dransfield, Ian P. Christian
  function isUKpostcode(p_UKpostcode)
  {
    p_UKpostcode = strreplace(p_UKpostcode, ' ', '');
    p_UKpostcode = p_UKpostcode.toUpperCase();
    
    var regUKpostcode = /^((GIR0AA)|((([A-PR-UWYZ][0-9][0-9]?)|([A-PR-UWYZ][A-HK-Y][0-9][0-9]?)|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))[0-9][ABD-HJLNP-UW-Z]{2}))$/;
    
    return regUKpostcode.test(p_UKpostcode);
  } // end function 
  
  function isPhone(p_Phone)
  {
    p_Phone = strreplace(p_Phone, ' ', '');
    p_Phone = p_Phone.toUpperCase();
    
    var regPhone = /^(\+?)([0-9])+$/; // nova verze pro format s mezerama a plus // changed 07.04.2006 pf    
    // var regPhone = /^[0-9]+$/; // changed 07.04.2006 pf 
    
    return regPhone.test(p_Phone);
  } // end function 

  function strreplace(haystack,needle,str) {
    while(haystack.indexOf(needle)!=-1) 
    {
      haystack = haystack.replace(needle, str);
    }
    return haystack;
  }
  
   function movediv_general(el_id,x,y,cor_x,cor_y) {
    document.getElementById(el_id).style.left = x + cor_x + "px";
    document.getElementById(el_id).style.top = y + cor_y + "px" ;
    return true;
  } // end function
  

  function show_info(text, el, cas){
     // changed by pf. 9.5.05 9:28 - chyba ve funkci

     if (window.wait_till_close) { // detekce promenne ! window.var !!! - ale testovani na to jestli jiz neni spusteny timeout, pokud ano tak to resetuj
       clearTimeout(wait_till_close);
     } // end if

     movediv(getoffsetLeft(el), getoffsetTop(el));
     document.getElementById("info_text_data").innerHTML = text;
     document.getElementById("info").style.visibility = "visible";     
     
     wait_till_close = setTimeout("hide_info();", cas);
  } // end function


  function hide_info(){
     clearTimeout(wait_till_close); // zresetuj timeout
     document.getElementById('info').style.visibility = "hidden";
  } // end function


  function movediv(x,y) {
    // changed by pf. 9.5.05 9:58 - zmena - pridani + "px";

    cor_x = -280;
    cor_y = 0;

    document.getElementById("info").style.left = x + cor_x + "px";
    document.getElementById("info").style.top = y + cor_y + "px" ;

    return true;
  } // end function


  function getoffsetLeft(element){/* Calculate the offsetLeft sum of all offsetParents. The result is element.style.left */
    if(!element) return 0;
    return element.offsetLeft + getoffsetLeft(element.offsetParent);
  } // end function


  function getoffsetTop(element){/* Calculate the offsetTop sum of all offsetParents. The result is element.style.top */
    if(!element) return 0;
    return element.offsetTop + getoffsetTop(element.offsetParent);
  } // end function


// --- HEADER BE BANNERS

  // Validace header_login formulare
  function header_check_be_banners_inputs()
  {
    //if (document.getElementById("header_login_username_input").value == "") {window.alert("Please fill: Your username"); return false;}
    //if (document.getElementById("header_login_password_input").value == "") {window.alert("Please fill: Password"); return false;}
    return true;
  } // end function

  // funkce se stara o zobrazeni, nebo ukryti header_login
  function header_display_be_banners()
  {
    banners_status = document.getElementById("header_be_banners_form").style.visibility;
    if (banners_status == "visible" || banners_status == "")
    {
      header_hide_be_banners_form();
    }
    else
    {
      header_show_be_banners_form();
    }
  } // end function


  // zobrazeni header_login
  function header_show_be_banners_form()
  {
    document.getElementById("header_be_banners_form").style.visibility = "visible";
  } // end function


  // skryti header_login
  function header_hide_be_banners_form()
  {
    document.getElementById("header_be_banners_form").style.visibility = "hidden";
  } // end function

// ---




/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(
			parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
			parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"])
		);
		

		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};


