//zobrazovani leveho stromu
function lm_strid_active(id){
  var idNone, idBlock, el, d
  if(id > 0){
    idNone = 0
    idBlock = 1
    d = new Date(2050, 12, 31)
  }else{
    idNone = 1
    idBlock = 0
    d = new Date(2000, 12, 31)
  }  
  document.cookie = "i6_lm_strid=" + idBlock + "; expires=" + d.toGMTString()  

  el = document.getElementById('div_strid_' + idNone)
  if(el){
    if(el.style.display != 'none'){
      el.style.display = 'none'
      document.getElementById('td_strid_' + idNone).setAttribute('className', 'td_strid_hide')
      document.getElementById('td_strid_' + idNone).setAttribute('class', 'td_strid_hide')
    }
  }
  el = document.getElementById('div_strid_' + idBlock)
  if(el){
    if(el.style.display != 'block'){
      document.getElementById('td_strid_' + idBlock).setAttribute('className', 'td_strid_block')
      document.getElementById('td_strid_' + idBlock).setAttribute('class', 'td_strid_block')
      el.style.display = 'block'
    }
  }
}

//Zmena nazvu z fulltext na fulltextsiv pro vyhledavani SivCide - pro ACI
function ChangeFullText(form){
  var fullt = form.elements[0]
  if(fullt.value.substring(0, 1) == "/"){
    fullt.name = "fulltextsiv"
    fullt.value = fullt.value.substring(1)
  }
} 

//Scripty pro toolbar tb
function tbClick(input){
  var form = input.form
  switch(input.name){
    case 'cmdNew':
      document.location = form.redirect.value + '-1' + '&u_tbClick=cmdNewWith'
      break;
    case 'cmdNewWith':
      tbCmdDis(true, form, 0, 1)
      form[form.PK_name.value].value = -1
      form.action.value = 'new'
      form.redirect.value = form.redirect.value + 'PRIMARY_KEY'
      break;
    case 'cmdChange':
      tbCmdDis(true, form, 1, 0)
      form.action.value = 'change'
      if(form.redirect.value.substr(form.redirect.value.length - form.PK_value.value.length) != form.PK_value.value) form.redirect.value = form.redirect.value + form.PK_value.value
      //form.redirect.value = form.redirect.value + form.PK_value.value
      break;
    case 'cmdDelete':
      if(DelConfirm()){
        document.location.href = '?cls=' + form.cls.value + '&' + form.PK_name.value + '=' + form.PK_value.value + '&action=delete&redirect=' + escape(form.redir_del.value)
      }
      break;
    case 'cmdSubmit':
      form.submit()
      break;
    case 'cmdReset':
      form.reset()
      tbCmdDis(false, form, 0, 2)
      break;
  }
}

function tbClick2(input){
  var form = input.form
  switch(input.name){
    case 'cmdNew':
      document.location = form.redirect.value + '-1' + '&u_tbClick=cmdNewWith'
      break;
    case 'cmdNewWith':
      tbCmdDis(true, form, 0, 1)
      form[form.PK_name.value].value = -1
      form.action.value = 'new'
      form.redirect.value = form.redirect.value + 'PRIMARY_KEY'
      break;
    case 'cmdChange':
      tbCmdDis(true, form, 1, 0)
      form.action.value = 'change'
      if(form.redirect.value.substr(form.redirect.value.length - form.PK_value.value.length) != form.PK_value.value) form.redirect.value = form.redirect.value + form.PK_value.value
      //form.redirect.value = form.redirect.value + form.PK_value.value
      break;
    case 'cmdDelete':
      if(DelConfirm()){
        document.location.href = '?cls=' + form.cls.value + '&' + form.PK_name.value + '=' + form.PK_value.value + '&action=delete&redirect=' + escape(form.redir_del.value)
      }
      break;
    case 'cmdSubmit':
	var regul = /^(\+421)? ?[0-9]{3} ?[0-9]{3} ?[0-9]{3}$/;
	if(document.getElementById('idcontel1')){
		if(!regul.test(document.getElementById('idcontel1').value)){
			if(document.getElementById('idcontel1').value != ''){
				alert("Pole 'Tel 1' není ve správném tvaru.");
				document.getElementById('idcontel1').focus();
				break;
			}
		}
	}
	if(document.getElementById('idcontel2')){
		if(!regul.test(document.getElementById('idcontel2').value)){
			if(document.getElementById('idcontel2').value != ''){
				alert("Pole 'Tel 2' není ve správném tvaru.");
				document.getElementById('idcontel2').focus();
				break;
			}
		}
	}
	if(document.getElementById('idcontelmob')){
		if(!regul.test(document.getElementById('idcontelmob').value)){
			if(document.getElementById('idcontelmob').value != ''){
				alert("Pole 'Mobil' není ve správném tvaru.");
				document.getElementById('idcontelmob').focus();
				break;
			}
		}
	}
      form.submit()
      break;
    case 'cmdReset':
      form.reset()
      tbCmdDis(false, form, 0, 2)
      break;
  }
}
        
function tbCmdDis(blnDisabled ,form, restricted, empty){
  form.cmdNew.disabled = blnDisabled
  form.cmdNewWith.disabled = blnDisabled
  form.cmdChange.disabled = blnDisabled
  form.cmdDelete.disabled = blnDisabled
  form.cmdSubmit.disabled = !blnDisabled
  form.cmdReset.disabled = !blnDisabled
  var tab
  if(blnDisabled) tab = 'tabedit' 
    else tab = 'tabform'
  //document.getElementById('tbfrm').className = tab
  
  for(var i = 0, e; i < form.elements.length; i++){
    e = form.elements[i]
    if(e.type == 'button'){         //jestlize je nazev butonu obsazen v hidden prvku TB_disabled potom je tento buton disabled
      if(form.TB_disabled.value.indexOf(form.elements[i].name) >= 0) form[form.elements[i].name].disabled = true
      tbStyle(form.elements[i])
    }else{
      if(e.type != 'hidden') if(e.name.indexOf("_disabled") == -1 || (e.name.indexOf("_null") != -1 && empty == 2)) if(e.value != "#NA#") if(form.restricted_fields.value.indexOf(e.name + ",") == -1 || restricted == 0) form.elements[i].disabled = !blnDisabled
      //nepredplnovani prijmeni a jmena firemniho kontaktu
      if(e.name.indexOf("_null") != -1 && empty == 1){
        form.elements[i].value = '';
        form.elements[i].disabled = !blnDisabled;
        if (form.elements[i].name.indexOf("con") != -1) form.elements[i].name = form.elements[i].name.substr(0, e.name.indexOf("_disabled")) //pro typ kontaktu
      }
    }
  }
  if(form.name == "frmordedit") form.comname.disabled = true
}

function tbInit(what){
  var dis = ''
  for(var i = 0; i < document.forms.length; i++){
    var f = document.forms[i]
    for(var j = 0; j < f.elements.length; j++){
      var input = f.elements[j]
      if(input.name == 'TB_disabled') dis = input.value                     //do promenne dis nazvy butonu, ktere maji byt disabled
      if(input.type == 'button'){
        if(dis != '' && dis.indexOf(input.name) >= 0) input.disabled = true   //jestlize nazev butonu je obsazen v promenne dis je tento buton disabled
        if(input.name == what){
          if(input.disabled == false) input.click()
            else alert(GetLng("lngzj2"))
        }
        tbStyle(input)
      }
    }
  }
}



function tbStyle(input){
    if(input.disabled == true){
      input.style.cursor = 'default'
      switch(input.name){
        case 'cmdNew':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
        case 'cmdNewWith':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
        case 'cmdChange':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
        case 'cmdDelete':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
        case 'cmdSubmit':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
        case 'cmdReset':
          input.className = 'toolbar toolbar_disable';
          input.style.background = 'url(img/BGtoolbar_dis.gif) 0 0 no-repeat'; 
          break;
      }
    }else{
      input.style.cursor = 'hand'
      switch(input.name){
        case 'cmdNew':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
        case 'cmdNewWith':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
        case 'cmdChange':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
        case 'cmdDelete':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
        case 'cmdSubmit':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
        case 'cmdReset':
          input.className = 'toolbar toolbar_active';
          input.style.background = 'url(img/BGtoolbar_act.gif) 0 0 no-repeat';
          break;
      }
    }
}

//Script pro ikony - mouseover
/*
var icos = new Array(2)
icos[0] = new Image(); icos[0].src = 'img/empty.gif';
icos[1] = new Image(); icos[1].src = 'img/ico_mnuover.gif';
function icoSet(imgName, setOver){
  document.images[imgName].src = icos[setOver].src;
}
*/


//Smaze zaznam v klientech, dod. adresach a parametrech
function DelItem(u_mode, id1, id2){
  var action = 'u_mode='
  var msg = ''
  switch(u_mode){
    case 'contact':
      if(DelConfirm()){
        document.location.href = '?cls=contact&conid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=contacts&catalogs=forcontact&concomid=' + id2)
      }
      break;
    case 'comshipto':
      if(DelConfirm()){
        document.location.href = '?cls=comshipto&cstid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=comshiptos')
      }
      break;
    case 'cps':
      if(DelConfirm()){
        document.location.href = '?cls=conparset&cpsid=' + id1 + '&action=delete&redirect=' + escape('?mtc=2&cls=contacts&xsl=xcontactsp&conparsets=1&catalog=scategorysys&conid=' + id2)
      }
      break;
    case 'offer':
      if(DelConfirm()){
        document.location.href = '?cls=orditem&oriid=' + id1 + '&action=delete&redirect=' + escape('?mtc=1&cls=orders&xsl=xofferdea&ordid=' + id2)
      }
      break;
    case 'offers':
      if(DelConfirm()){
        document.location.href = '?cls=orders&ordid=' + id1 + '&action=delete&redirect=' + escape('?mtc=1&cls=orderss&xsl=xofferdea')
      }
      break;
  }
  return false;
}



//Odkaz na dane adresy pomoci javascriptu
function g(where, id, tag){
  if(tag == null) tag = ''
  var addr = ''
  switch (where){
    case 'sti':
      addr = '?mtc=0&cls=stoitem&stiid=' + id
      break;
    case 'ord':
      addr = '?mtc=1&cls=orders&ordid=' + id
      break;
    case 'ords':
      addr = '?mtc=1&cls=orderss&items=1&ordid=' + id
      break;
    case 'inv':
      addr = '?mtc=1&cls=invoice&invid=' + id
      break;
    case 'del':
      addr = '?mtc=1&cls=deliveries&items=1&delid=' + id
      break;
    case 'offer':
      addr = '?mtc=1&cls=orders&xsl=xofferdea&ordid=' + id
      break;
    case 'com':
      addr = '?mtc=2&cls=company&catalogs=forcompany&comid=' + id
      break;
    case 'concom':
      addr = '?mtc=2&cls=company&catalogs=forcompany&concomid=' + id
      break;
    case 'con':
      addr = '?mtc=2&cls=contact&catalogs=forcontact&conid=' + id
      break;
    case 'ship':
      addr = '?mtc=2&cls=comshipto&catalog=country&cstid=' + id
      break;
      case 'rec':
      addr = '?mtc=1&cls=reclaim&recid=' + id
      break;
  }
  if(addr != '') document.location.href = addr
}



//Prevede produkt do kosiku nebo aktivni objednavky
//Je-li zadan argument tag typu objekt provadi vlozeni aktualniho radku, jinak projizdi vsechny formy a hleda zaskrtnute produkty
function buy(ordtype, ordid, callform){
  var stiids = new Array();
  var qtys = new Array();
  var n = 0
  var fs;
  var fsn = 0
  
  if(callform == null){
    fs = document.forms;
  }else{
    fs = new Array(0)
    fs[0] = callform;
  }
  
  fsn = fs.length
  for(var i = 0; i < fsn; i++){
    var f = fs[i]
    if(f.elements)
      if(f.qty && f.stiid)
        if(callform != null || (callform == null && f.stiid.checked))
          if(f.qty.value > 0)
            if(f.stiid.value > 0) {
      stiids[n] = (f.stiid.value - 0);
      qtys[n] = (f.qty.value - 0);
      n += 1
    }
  }
  
  if(n > 0){    
    var url = 'default.asp?';
    var prefqty = '';
    var prefstiid = 'stiid';
    //VEP - -3 = vlozit mezi oblibene produkty, -4 odstranit
    if ((ordtype == -1) || (ordtype == -2) || (ordtype == -3) || (ordtype == -4)){
      if (ordtype == -2){
        var url = 'print.asp?';
        url += 'cls=iisutil&action=stiparcomp'
      }else{
        if ((ordtype == -3) || (ordtype==-4))
        {
	        prefqty = 'qty'
	        if (ordtype == -3) {
	       	   url += 'cls=iisutil&action=stifavourites&method=add&redirect=%3Fcls%3Dstoitems%26stifavourites%3D1';
	        }else {
	           url += 'cls=iisutil&action=stifavourites&method=del&redirect=%3Fcls%3Dstoitems%26stifavourites%3D1';
	        }
        } else {
	        prefqty = 'orbqty'
	        url += 'cls=ordbaskets';
        }
      }
    }else{
      prefqty = 'oriqty'
      url += 'cls=orders&ordid=' + ordid + '&action=additem&redirect=' + escape('?mtc=1&cls=orders&ordid=' + ordid);
      if (ordtype == 2){
        url += escape('&xsl=xofferdea&u_edit=1')
      }else{
        url += escape('&xsl=xordersedit&blocations=1&catalogs=fororders&edititems=1&useraction=editnew' + (n == 1 ? '&useraction1=addnew' : '&usereditwhat=oriblock'));
      }
    }
    
    for(var i = 0; i < n; i++){
      if (ordtype == -2){
       url += '&stiid=' + stiids[i]
      }else{
       url += '&' + prefstiid + '=' + stiids[i] + '&' + prefqty + '=' + qtys[i];
      }
    }

    // porovnani produktu se otevira do noveho okna, ostatni veci do stejneho okna
    if (ordtype == -2){
      win = window.open(url, 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
      win.focus();
      return false;
    }else{
      document.location.href = url
    }

  }else alert(GetLng("lngzj3"))
  return false
}

//obsluha panelu pro vyber co s oznacenyma produktama udelat
//bylo by asi dobre to jeste upravit, jako je to v B2C
//POZOR panel co je v XINCSTOITEMS.XSL vola misto teto funkce funkci: buy(ordtype, ordid, callform)



function ProductsChooser(msg){

  var p=0;
  var act = document.getElementById("products_chooser").value;
  switch (act){
  case "-1": //do kosiku - ZATIM NEFUNKCNI!!!
    var url = '?mode=ZObList';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&ZObStiId=' + document.getElementById("choosed"+i).value + '&ZObQty=' + document.getElementById("choosedqty"+i).value;
        p += 1;
      }
    }
    break;
  case "-2": //porovnavani
    var url = 'print.asp?cls=iisutil&action=stiparcomp';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&stiid=' + document.getElementById("choosed"+i).value;
        p += 1;
      }
    }
    break;
  case "-4": //odebrat z kosiku (CHYBA - z kosiku se zde odebira jinak nez v B2C)
    var url = '?cls=ordbaskets';
    for (var i=1; document.getElementById("choosed"+i); i++){
      if (document.getElementById("choosed"+i).checked){
        url += '&stiid=' + document.getElementById("choosed"+i).value + '&orbqty=0';
        p += 1;
      }
    }
    // alert(url);
    break;
  default:
    alert('!!! zatím funkční pouze porovnávání !!!');
    return;
  }

  if (p == 0){
    alert(msg);
  } else {
    // porovnani produktu se otevira do noveho okna, ostatni veci do stejneho okna
    if (act == -2){
      win = window.open(url, 'ProductsCompare', 'toolbar=yes,scrollbars=yes,location=no,status=yes,resizable=yes,width=950,height=600,top=25,left=25');
      win.focus();
      return;
    }else{
      document.location.href = url
    }
  }
}

function PasteToFormX(argstr){
  var a = argstr.split(',');
  var openerFormName, index
  if(a.length > 0) openerFormName = a[0]
  if(a.length > 1) argstr = a[1]
  if(a.length > 2) index = a[2]
  PasteToForm(openerFormName, argstr, index)
}

function PasteToForm(openerFormName, argstr, index){
  var frm = self.opener.document.forms[openerFormName];
  var args = argstr.split('&');
  var sName, sValue, iPoz, inp, isA
  if(index == null) index = 0
  for (var i = 0; i < args.length; i++){
     iPoz = args[i].indexOf('=');
     sName = iPoz > -1 ? args[i].substring(0, iPoz) : '';
     sValue = iPoz > -1 ? args[i].substring(iPoz + 1, args[i].length) : '';
     inp = frm.elements[sName]
     if(inp){
       isA = (inp.length ? true : false)
       if(isA) isA = (inp.type ? false : true)
       if(isA){//pole elementu
         if(inp.length > index) inp[index].value = sValue
       }else{
         if(index == 0) inp.value = sValue
       }
     }
     //if(eval('frm.' + sName)) eval('frm.' + sName + '.value = \'' + sValue + '\'');
  }
 self.close();
}


function DelConfirm(){
  return confirm(GetLng("lngzj1"));
}


function FormClear(form){
  var input, it
  for(var i = 0; i < form.elements.length; i++){
    input = form.elements[i]
    it = input.type
    if(input.disabled == null) return true
    if(it == 'text' || it == 'checkbox'){
      if(input.value == '') input.disabled = true
    } else if(it == 'select-one'){
      if(input.selectedIndex < 0) input.disabled = true
      else if(input.options[input.selectedIndex].value == '') input.disabled = true
    }
  }
  return true
}

//pokud je firma zahranicni a neni vyplneno DIC, pak ComTax=0
function CheckComTax(form){
	if(form.comxcouid.value != 0 && form.comtaxnum.value == '') form.comtax.value = 0
}

function CheckFormVal(form){
  var EmptyVal = '';
  var ErrList = '';
  var ErrLine = '';

  //Firma
  //if(form.comregid) if(form.comregid.value == '') ErrList = ErrList + '   ' + GetLng("lngzj14") + '\n'; // jen pro ACI a BGS
  if(form.comregid) if(form.comregid.value.indexOf(" ") != -1) ErrList = ErrList + '   ' + GetLng("lngzj14") + '\n';
  // pokud nekdo chce kontrolovat ICO tak odremovat radek nize
  // if(form.comregid) if ((form.comregid.value == '') || (isNaN(form.comregid.value)) || ((isFinite(form.comregid.value)) && (((form.comregid.value) < 1) || ((form.comregid.value) > 99999999)))) ErrList = ErrList + '   ' + GetLng("lngzj14a") + '\n';
  if(form.comtaxnum) if(form.comtaxnum.value.indexOf(" ") != -1) ErrList = ErrList + '   ' + GetLng("lngzj15") + '\n';
  if(form.comstreet) if(form.comstreet.value == '') ErrList = ErrList + '   ' + GetLng("lngzj22") + '\n';
  if(form.comcity) if(form.comcity.value == '') ErrList = ErrList + '   ' + GetLng("lngzj8") + '\n';
  if(form.compostcode) if(form.compostcode.value == '') ErrList = ErrList + '   ' + GetLng("lngzj9") + '\n';

  //Kontakt
  if(form.conlname) if(form.conlname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj10") + '\n';
  if(form.confname) if(form.confname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj11") + '\n';
  if(form.conemail){
    if(form.conemail.value == '') ErrList = ErrList + '   ' + GetLng("lngzj12") + '\n';
    if (!CheckEmail(form.conemail.value))ErrList = ErrList + '   ' + "E-mail nemá správný formát" + '\n';
  }
  if(form.contel1) if(form.contel1.value == '') if(form.name == 'Registration') ErrList = ErrList + '   ' + GetLng("lngzj13") + '\n';

  //Je-li vyplněno IČO musí být i DIČ
  //if(form.comregid && form.comtaxnum) if((form.comregid.value != '' && form.comtaxnum.value == '') || (form.comregid.value == '' && form.comtaxnum.value != '')) ErrLine = '\n - ' + GetLng("lngzj16") + '\n';
 
  //Heslo
  if(form.ConLogPswdOld) if(form.ConLogPswdOld.value == '') ErrList = ErrList + '   ' + GetLng("lngzj17") + '\n';
  if(form.ConLogPswdNew) if(form.ConLogPswdNew.value == '') ErrList = ErrList + '   ' + GetLng("lngzj18") + '\n';
  if(form.ConLogPswdNewConfirm) if(form.ConLogPswdNewConfirm.value == '') ErrList = ErrList + '   ' + GetLng("lngzj19") + '\n';
  if(form.ConLogPswdNew && form.ConLogPswdNewConfirm) if(form.ConLogPswdNew.value != form.ConLogPswdNewConfirm.value) ErrLine ='\n - ' + GetLng("lngzj20") + '\n';
  
  //ComShipTo
  if(form.cstname) if(form.cstname.value == '') ErrList = ErrList + '   ' + GetLng("lngzj21") + '\n';
  if(form.cststreet) if(form.cststreet.value == '') ErrList = ErrList + '   ' + GetLng("lngzj22") + '\n';
  if(form.cstcity) if(form.cstcity.value == '') ErrList = ErrList + '   ' + GetLng("lngzj8") + '\n';
  if(form.cstpostcode) if(form.cstpostcode.value == '') ErrList = ErrList + '   ' + GetLng("lngzj9") + '\n';
 
 if(ErrList != '' || ErrLine != ''){
    if(ErrList != ''){
    EmptyVal = ' - ' + GetLng("lngzj5") + '\n\n'
    }
    ErrList = GetLng("lngzj6") + '\n' + EmptyVal + ErrList + ErrLine + '\n' + GetLng("lngzj4");
    alert(ErrList);
    return false;
  }else 
    if(form.comregid) if(form.comregid.value != '') form.comsname.value = (form.comname.value != '' ? form.comname.value : form.confname.value + ' ' + form.conlname.value);
    if(form.comname) if(form.comname.value == '') form.comname.value = form.conlname.value + ' ' + form.confname.value;
    return true;
}
//kontrola formatu emailu
function CheckEmail(email){
  re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,4}$/;
  return email.search(re) == 0;
}


function ShowQueues(stiid, queqtyrequired, quexqudid){
  window.open('print.asp?cls=queues&quedir=0&catalog=queuedefinition&queqtyrequired=' + queqtyrequired + '&stiid=' + stiid + (quexqudid == null ? "" : '&quexqudid=' + quexqudid), 'ShowQueues', 'toolbar=no,scrollbars=yes,location=no,status=no,width=500,height=280,top=100,left=150'); 
}

function SetPageT(){
  var objH1 = document.getElementsByTagName('h1');
  if(objH1.length > 0){
    //document.title = objH1[0].firstChild.nodeValue + ' - ' + document.title
    document.title = document.title + ' - ' + objH1[0].firstChild.nodeValue
  }
}

function SetPageTInit(){
  if(window.attachEvent){
    window.attachEvent("onload", SetPageT)
  }else if(window.addEventListener){
    window.addEventListener("load", SetPageT, false)
  }
}

// ===== AKTIVNI STROM - sbaleni/rozbaleni vetvi ve stromu kategorii =====
function tc_ch(node){
  if((document.getElementById('tc_n' + node)) && (document.getElementById('tc_nl' + node))){
    el = document.getElementById('tc_n' + node)
    ell = document.getElementById('tc_nl' + node)
    if(el.style.display == 'none'){
      el.style.display = 'block'
      ell.style.backgroundImage = "url('img/tc_nc.gif')"
    } else {
      el.style.display = 'none'
      ell.style.backgroundImage = "url('img/tc_no.gif')"
    }
  }
}
// ===== AKTIVNI STROM - pocatecni rozbaleni vetvi ve stromu kategorii =====
function tc_start_ch(nodes){
  if(document.getElementById('tc_code')){
    nodes += document.getElementById('tc_code').value;
  }
  node = '';
  for(var i = 0; i < nodes.length; i++){
    n = nodes.substring(i, i + 1);
    if(n == ','){
      if((document.getElementById('tc_n' + node)) && (document.getElementById('tc_nl' + node))){
        el = document.getElementById('tc_n' + node);
        ell = document.getElementById('tc_nl' + node);
        el.style.display = 'block';
        ell.style.backgroundImage = "url('img/tc_nc.gif')";
      }
      node = '';
      n = '';
    }
    node += n;
  }
}

function OperateTabs(id){
  var t=document.getElementById("tab"+id);
//  var o=document.getElementsByClassName('sti_htablesi sti_htablesa'); //zasrany IE
  var ixx=id;
  for(var i=0;i<6;i++){
    if(document.getElementById("tab"+i)){
      document.getElementById("tab"+i).className="sti_htablesi";
    }
  }
/*	if (o!=null ){
		for(var i=0;i<o.length;i++){
			if (o[i]!=t){
				o[i].className="sti_htablesi";
			}
		}
	}
*/
  if(ixx==1){
  t.className="sti_htablesa first";  
  } else {
  t.className="sti_htablesa";  
  }
//  var oBody=document.getElementsByName("bodytab");
  var tBody=document.getElementById("bt"+id);
  for(var i=0;i<6;i++){
    if(document.getElementById("bt"+i)){
      document.getElementById("bt"+i).style.display="none";
    }
  }  
/*	if (oBody !=null ){
		for(var i=0;i<oBody.length;i++){
			if (oBody[i]!=tBody){
				oBody[i].style.display="none";
			}
		}
	}
*/
  tBody.style.display="";
}
function obj_on(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    el.style.display = 'block'
  }
}
function obj_off(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    el.style.display = 'none'
  }
}
function obj_swap(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj)
    if(el.style.display == 'none' || el.style.display == ''){
      el.style.display = 'block'
    } else {
      el.style.display = 'none'
    }
  }
}

//SetPageTInit()


function set_cookie(c_name,value,expiredays){
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";path=/;expires="+exdate.toGMTString());
}
function get_cookie(c_name){
  if (document.cookie.length>0){
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1){
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function fcprcheckswitch_basic(id,idcheck1,idcheck2){
  var el, elcheck1, elcheck2
  if(document.getElementById(id)){
	el = document.getElementById(id);
	  if(document.getElementById(idcheck1)){
	  	elcheck1 = document.getElementById(idcheck1);
		  if(document.getElementById(idcheck2)){
		  	elcheck2 = document.getElementById(idcheck2);

		        if(elcheck1.checked == false) {
				el.style.background = "url('img/DECprCheckOn.gif') no-repeat 0 0";
				elcheck1.checked = true;
				elcheck2.checked = false;
	        	}else {
			      el.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
			      elcheck1.checked = false;
			      elcheck2.checked = true;
			} 
		  }
	  }
  }
}

// pro parametrické vyhledávání - průvodce nákupem
// po kliku na element vymění background a současně nastaví příslušný checkbox
// id=id klikacího elementu, idcheck=id přidruženého checkboxu, iid=id parametru
function fcprcheckswitch(id,idcheck,idd){
  var el, elcheck, elX, elcheckX
  if(document.getElementById(id)){
	el = document.getElementById(id);
	  if(document.getElementById(idcheck)){
	  	elcheck = document.getElementById(idcheck);

	        if(elcheck.checked == false) {
			el.style.background = "url('img/DECprCheckOn.gif') no-repeat 0 0";
			elcheck.checked = true;
			if(document.getElementById('prchX'+idd)){
				elX = document.getElementById('prchX'+idd);
				if(document.getElementById('prchObjX'+idd)){
					elcheckX = document.getElementById('prchObjX'+idd);
					elX.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
					elcheckX.checked = false;
				}
			}
        	}else {
		      el.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
		      elcheck.checked = false;
		} 
	  }
  }
}

// pro parametrické vyhledávání - průvodce nákupem
// nastaví se odpovídající checbox a jsou vynulovány všechny hodnoty daného parametru
// id=id parametru, count=počet možných hodnot
function fcprcheckoff(id,count){
  var el, elcheck
  if(document.getElementById('prchX'+id)){
    el = document.getElementById('prchX'+id);
    if(document.getElementById('prchObjX'+id)){
	elcheck = document.getElementById('prchObjX'+id);
	if(elcheck.checked == false) {
		el.style.background = "url('img/DECprCheckOn.gif') no-repeat 0 0";
		elcheck.checked = true;
			for (var i = 0; i<count; i++) {
			  if(document.getElementById('prch'+id+'x'+(i+1))){
				  if(document.getElementById('prchObj'+id+'x'+(i+1))){
				      document.getElementById('prch'+id+'x'+(i+1)).style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
				      document.getElementById('prchObj'+id+'x'+(i+1)).checked = false;
				  }
			  }
			} 
      	}else {
		el.style.background = "url('img/DECprCheckOf.gif') no-repeat 0 0";
		elcheck.checked = false;
	}
    }
  }
}

function cattreebold(id){
	if(document.getElementById('tc_a_' + id)){
    	document.getElementById('tc_a_' + id).className = 'tc_a tc_a_active'
	  }
}

function topmenuclick(thi,n,name,classn){
	if (n>=thi && thi>0){
		for(var i=1;i<(n+1);i++){
			if (document.getElementById(name+i)) {
			    el = document.getElementById(name+i)
				
			    el.style.display = 'none'
			  }
		}
		if (document.getElementById(name+thi)) {
		    el = document.getElementById(name+thi)
		    el.style.display = 'block'
		  }
		for(var i=1;i<(n+1);i++){
		if (document.getElementById(name+'X'+i)) {
  			document.getElementById(name+'X'+i).className = classn
		  }
		}
		if (document.getElementById(name+'X'+thi)) {
  			document.getElementById(name+'X'+thi).className = classn+" act"
		  }
	}
}

function ScrollImages(sDirection){
  if(!sEnabledScroll){return 0}
			var xMax = document.getElementById('scrollarea').scrollLeft;
			var yMax = document.getElementById('scrollarea').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollarea').scrollLeft = xMax + 10;
    xCurr = document.getElementById('scrollarea').scrollLeft;
    if(sEnabledScroll){setTimeout("ScrollImages('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollarea').scrollLeft = xMax - 10;
    xCurr = document.getElementById('scrollarea').scrollLeft;
    if(sEnabledScroll){setTimeout("ScrollImages('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollarea').scrollTop = yMax + 10;
    yCurr = document.getElementById('scrollarea').scrollTop;
    if(sEnabledScroll){setTimeout("ScrollImages('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollarea').scrollTop = yMax - 10;
    yCurr = document.getElementById('scrollarea').scrollTop;
    if(sEnabledScroll){setTimeout("ScrollImages('D')", 100);}
  }
}

function ScrollImages0(sDirection){
  if(!sEnabledScroll0){return 0}
			var xMax = document.getElementById('scrollarea0').scrollLeft;
			var yMax = document.getElementById('scrollarea0').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollarea0').scrollLeft = xMax + 30;
    xCurr = document.getElementById('scrollarea0').scrollLeft;
    if(sEnabledScroll0){setTimeout("ScrollImages0('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollarea0').scrollLeft = xMax - 30;
    xCurr = document.getElementById('scrollarea0').scrollLeft;
    if(sEnabledScroll0){setTimeout("ScrollImages0('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollarea0').scrollTop = yMax + 30;
    yCurr = document.getElementById('scrollarea0').scrollTop;
    if(sEnabledScroll0){setTimeout("ScrollImages0('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollarea0').scrollTop = yMax - 30;
    yCurr = document.getElementById('scrollarea0').scrollTop;
    if(sEnabledScroll0){setTimeout("ScrollImages0('D')", 100);}
  }
}

function ScrollImages1(sDirection){
  if(!sEnabledScroll1){return 0}
			var xMax = document.getElementById('scrollarea1').scrollLeft;
			var yMax = document.getElementById('scrollarea1').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollarea1').scrollLeft = xMax + 30;
    xCurr = document.getElementById('scrollarea1').scrollLeft;
    if(sEnabledScroll1){setTimeout("ScrollImages1('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollarea1').scrollLeft = xMax - 30;
    xCurr = document.getElementById('scrollarea1').scrollLeft;
    if(sEnabledScroll1){setTimeout("ScrollImages1('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollarea1').scrollTop = yMax + 30;
    yCurr = document.getElementById('scrollarea1').scrollTop;
    if(sEnabledScroll1){setTimeout("ScrollImages1('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollarea1').scrollTop = yMax - 30;
    yCurr = document.getElementById('scrollarea1').scrollTop;
    if(sEnabledScroll1){setTimeout("ScrollImages1('D')", 100);}
  }
}


function ScrollImages2(sDirection){
  if(!sEnabledScroll2){return 0}
			var xMax = document.getElementById('scrollarea2').scrollLeft;
			var yMax = document.getElementById('scrollarea2').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollarea2').scrollLeft = xMax + 30;
    xCurr = document.getElementById('scrollarea2').scrollLeft;
    if(sEnabledScroll2){setTimeout("ScrollImages2('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollarea2').scrollLeft = xMax - 30;
    xCurr = document.getElementById('scrollarea2').scrollLeft;
    if(sEnabledScroll2){setTimeout("ScrollImages2('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollarea2').scrollTop = yMax + 30;
    yCurr = document.getElementById('scrollarea2').scrollTop;
    if(sEnabledScroll2){setTimeout("ScrollImages2('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollarea2').scrollTop = yMax - 30;
    yCurr = document.getElementById('scrollarea2').scrollTop;
    if(sEnabledScroll2){setTimeout("ScrollImages2('D')", 100);}
  }
}

function ScrollImages3(sDirection){
  if(!sEnabledScroll3){return 0}
			var xMax = document.getElementById('scrollarea3').scrollLeft;
			var yMax = document.getElementById('scrollarea3').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollarea3').scrollLeft = xMax + 30;
    xCurr = document.getElementById('scrollarea3').scrollLeft;
    if(sEnabledScroll3){setTimeout("ScrollImages3('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollarea3').scrollLeft = xMax - 30;
    xCurr = document.getElementById('scrollarea3').scrollLeft;
    if(sEnabledScroll3){setTimeout("ScrollImages3('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollarea3').scrollTop = yMax + 30;
    yCurr = document.getElementById('scrollarea3').scrollTop;
    if(sEnabledScroll3){setTimeout("ScrollImages3('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollarea3').scrollTop = yMax - 30;
    yCurr = document.getElementById('scrollarea3').scrollTop;
    if(sEnabledScroll3){setTimeout("ScrollImages3('D')", 100);}
  }
}


function ScrollImagesgal(sDirection){
  if(!sEnabledScrollgal){return 0}
	var xMax = document.getElementById('scrollareagal').scrollLeft;
	var yMax = document.getElementById('scrollareagal').scrollTop;
  if(sDirection == 'L'){
    document.getElementById('scrollareagal').scrollLeft = xMax + 10;
    xCurr = document.getElementById('scrollareagal').scrollLeft;
    if(sEnabledScrollgal){setTimeout("ScrollImagesgal('L')", 100);}
  } else if(sDirection == 'R'){
    document.getElementById('scrollareagal').scrollLeft = xMax - 10;
    xCurr = document.getElementById('scrollareagal').scrollLeft;
    if(sEnabledScrollgal){setTimeout("ScrollImagesgal('R')", 100);}
  } else if(sDirection == 'U'){
    document.getElementById('scrollareagal').scrollTop = yMax + 10;
    yCurr = document.getElementById('scrollareagal').scrollTop;
    if(sEnabledScrollgal){setTimeout("ScrollImagesgal('U')", 100);}
  } else if(sDirection == 'D'){
    document.getElementById('scrollareagal').scrollTop = yMax - 10;
    yCurr = document.getElementById('scrollareagal').scrollTop;
    if(sEnabledScrollgal){setTimeout("ScrollImagesgal('D')", 100);}
  }
}

function obj_off_delay(obj){
  if (document.getElementById(obj)) {
    el = document.getElementById(obj);
    setTimeout("el.style.display = 'none'",1500);
  }
}