// menue
sfHover = function() {
	var sfEls = document.getElementById("menuList").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// social bookmarks
var bm_timeout;
function showBookmarks() {
  var e = document.getElementById('bookmarks');
  
  e.onmouseover = function() {
    clearTimeout(bm_timeout);
    document.getElementById('bm_container').style.left = 'auto';
  }
  e.onmouseout = function() {
    bm_timeout = setTimeout(function() {
      document.getElementById('bm_container').style.left = '-999px';
    }, 250);
  }
}
if (window.attachEvent) {
	window.attachEvent("onload", showBookmarks); // msie
} else if (window.addEventListener) {
	window.addEventListener("onload", showBookmarks, true); // real browsers
}

// popup
function winOpen(){
	f1=window.open('','popup1','scrollbars=yes,toolbar=0,titlebar=0,status=1,resizable=1,width=520,height=670,left=20,top=20');
	if (parseInt(navigator.appVersion)>2) {f1.focus()};
}

function winOpenVS(thewidth,theheight){
	f1=window.open('','popup1','scrollbars=yes,toolbar=0,titlebar=0,status=1,resizable=1,width='+thewidth+',height='+theheight+',left=20,top=20');
	if (parseInt(navigator.appVersion)>2) {f1.focus()};
}

function winOpenVS2(thewidth,theheight,themenubar){
	f1=window.open('','popup1','scrollbars=yes,menubar='+themenubar+',toolbar=0,titlebar=0,status=1,resizable=1,width='+thewidth+',height='+theheight+',left=20,top=20');
	if (parseInt(navigator.appVersion)>2) {f1.focus()};
}


// suche
var tpc_dropdown = function(element) {
  if(typeof(element) == 'string') {
    if(!document.getElementById(element)) return false;
  }
  this.element = typeof(element) == 'string' ? document.getElementById(element) : element;
  this.options = [];
  this.construct();
}
tpc_dropdown.prototype = {
  'construct': function() {
    var opts = this.element.getElementsByTagName('option');
    for(i=0; i < opts.length; i++) {
      var o = new Array();
      o['name'] = opts[i].innerHTML;
      o['value'] = opts[i].value;
      o['selected'] = opts[i].selected == true ? true : false;
      this.options.push(o);
    }
    //console.log(this.options.length);
    // create hidden value-holding form field
    this.element.parentNode.insertBefore(this.newElement('input', {
      'type': 'hidden',
      'id': 'tpc_dd_hidden_field',
      'name': this.element.name, 
      'value': ''
    }), this.element);
    
    // create container for active selection
    this.element.parentNode.insertBefore(this.newElement('span', {
      'class': 'tpc_dd_selected',
      'className': 'tpc_dd_selected',
      'id': 'tpc_dd_selected',
      'content': '<input type="text" readonly="readonly" />',
      'events': {
        'onmouseover': function() {
          var list = this.getElementsByTagName('ul')[0];
          list.style.display = '';
          list.onmouseover = function() {
            this.style.display = '';
          }
        },
        'onmouseout': function() {
          var list = this.getElementsByTagName('ul')[0];
          list.style.display = 'none';
        }
      }
    }), this.element);
    /*
    document.getElementById('tpc_dd_selected').appendChild(this.newElement('input', {
      'type': 'text'
    }));
    /**/
    
    var ul = this.newElement('ul', {
      'id': 'tpc_dd_list',
      'class': 'tpc_dd_list',
      'className': 'tpc_dd_list',
      //'style': 'display:none;',
      'ie_display': 'none'
    });
    for(i=0; i < this.options.length; i++) {
      if(this.options[i].selected) {
        document.getElementById('tpc_dd_hidden_field').value = this.options[i].value;
        document.getElementById('tpc_dd_selected').getElementsByTagName('input')[0].value = this.options[i].name;
      }
      var li = this.newElement('li', {
        'class': 'tpc_dd_list_selected',
        'className': 'tpc_dd_list_selected'
      });
      li.appendChild(this.newElement('a', {
        'href': '#',
        'rel': this.options[i].value,
        'content': this.options[i].name,
        'events': {
          'onclick': function() {
            document.getElementById('tpc_dd_hidden_field').setAttribute('value', this.rel);
            document.getElementById('tpc_dd_selected').getElementsByTagName('input')[0].value = this.innerHTML;
            document.getElementById('tpc_dd_list').style.display = 'none';
            return false;
          }
        }
      }));
      ul.appendChild(li);
    }
    document.getElementById('tpc_dd_selected').appendChild(ul);
    this.element.parentNode.removeChild(this.element);
    
  },
  'newElement': function(tag, options) {
    var e = document.createElement(tag);
    for(var o in options) {
      switch(o) {
        case 'events':
          for(var event in options['events']) {
            e[event] = options['events'][event];
          }
        break;
        case 'content':
          e.innerHTML = options[o];
        break;
        case 'ie_display':
          e.style.display = options[o];
        break;
        default:
          //if(o == 'style') {
          e.setAttribute(o, options[o]);
          //} else {
          //e[o] = options[o];
          //}
        break;
      }
    }
    return e;
  }
}
function makeDropdown() {
  new tpc_dropdown('tpc_dd');
}
if(window.attachEvent) { 
  window.attachEvent('onload', makeDropdown);
} else if(window.addEventListener) {
  window.addEventListener('load', makeDropdown, false);
} else {
  window.onload = makeDropdown;
}

function aufzu(id) {
  var hidden = document.getElementById(id);
  if (hidden.style.display == 'inline') {
    hidden.style.display = 'none';
  }
  else {
    hidden.style.display = 'inline';
  }
}

function aufzup(id) {
  var hidden = document.getElementById(id);
  if (hidden.style.display == 'block') {
    hidden.style.display = 'none';
  }
  else {
    hidden.style.display = 'block';
  }
}

function showOneHideOne(showID, hideID) {
	var show = document.getElementById(showID);
	var hide = document.getElementById(hideID);

	show.style.display = 'block';
	hide.style.display = 'none';
}

function showOne(showID) {
	var show = document.getElementById(showID);

	show.style.display = 'block';
}

function hideOne(hideID) {
	var hide = document.getElementById(hideID);

	hide.style.display = 'none';
}