<!--//--><![CDATA[//><!--
/*
*  Copyright Mirek Komárek aka Fred http://js-playground.blogspot.com
*  use as you want until this copyright notice stay here
*/
var poleSelectu = new Array( 'select1' );
var d = document,pltext;
var lastopened = null;
var out = 1;
var hv = 0;

function getId(id){
  return d.getElementById(id);
};

function CE(el){
  return d.createElement(el);
}

function SA(el,atrib,val){
  return el.setAttribute(atrib,val);
}

function kostra(id1){
  getId(poleSelectu[id1]).style.display = 'none';
  var sr = CE('div');
  sr.className = 'selectReplace';
  var cy = CE('div');
  cy.id = poleSelectu[id1]+'_box';
  sr.appendChild(cy);
  var pl = CE('p');
  var ul = CE('ul');
  var opt = getId(poleSelectu[id1]).getElementsByTagName('option');
  selectedOpt = 0;
  for(var i=0;i<opt.length;i++)
  {
    if (opt[i].selected) 
    {
      selectedOpt = i;
    } 
    var li = CE('li');
    ul.appendChild(li);
    var ah = CE('a');
    SA(ah,'href', '#')
    SA(ah,'rel', opt[i].value)
    li.appendChild(ah);
    ah.appendChild(d.createTextNode(opt[i].childNodes[0].nodeValue));
  }
  var inp = CE('input');
  SA(inp,'type','hidden');
  inp.value = '';
  inp.id = poleSelectu[id1]+'_cil';
  inp.name = poleSelectu[id1]+'_cil';
  getId(poleSelectu[id1]).parentNode.insertBefore(sr,getId(poleSelectu[id1]).nextSibling);
  cy.appendChild(pl);
  ul.onmouseover = function(){
    out = 0;
  }
  ul.onmouseout = function(){
    out = 1;
  }
  cy.appendChild(ul);
  cy.parentNode.insertBefore(inp,cy);
  pl.appendChild(d.createTextNode(opt[selectedOpt].childNodes[0].nodeValue));
}

function gv(){
d.onclick = function(){
  if(lastopened != null && out == 1 && hv != 1)
  {
    lastopened.parentNode.className = 'hd';
  }
  //lastopened = null;
}
for(var w=0; w<poleSelectu.length; w++)
{
  kostra(w);
  var kde = getId(poleSelectu[w]+'_box');
  var fC = kde.firstChild;
  if(kde.firstChild.nodeType==3) //gecko
  {
    fC = kde.firstChild.nextSibling;
  }
  fC.onclick = function(){
    if(lastopened != null && lastopened != this && out == 1)
    {
      lastopened.parentNode.className = 'hd';
    }
    this.parentNode.className = this.parentNode.className=='hd'?'':'hd';
    lastopened = this;
  }
  fC.onmouseover = function(){
    this.className = 'hv';
    hv = 1;
  }
  fC.onmouseout = function(){
    this.className = '';
    hv = 0;
  }
  kde.className = 'hd';
  var co = kde.getElementsByTagName('a');
  for(var i=0;i<co.length;i++)
  {
    co[i].z = w;
    co[i].i = i;
    co[i].onclick = function(){
      //select
      var obj = document.getElementById(poleSelectu[this.z]);
      obj.selectedIndex = this.i;
      
      if( this.getAttribute('rel') != 0 ) {
        getId(poleSelectu[this.z]+'_cil').value = this.getAttribute('rel');
        var ntext = d.createTextNode(this.childNodes[0].nodeValue);
        this.parentNode.parentNode.parentNode.firstChild.removeChild(this.parentNode.parentNode.parentNode.firstChild.childNodes[0]);
        this.parentNode.parentNode.parentNode.firstChild.appendChild(ntext);
        this.parentNode.parentNode.parentNode.className = 'hd';
        
        //send
        document.getElementById('form_profese').submit();
        return false;
      }
    }
  }
}
}

if(document.childNodes)
{
  var load = true;
  if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
  { //test for MSIE x.x;
    var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ieversion < 7)
      load = false;
  }
  if(load)
    window.onload=gv;
}
//--><!]]>

