// ---------------------------------------------------------------------------------

// Project: Bittere Pillen 
// Version: 1.0
// Author: I. Blenke / S. Hilbig
// URI: www.id-on.de / www.gorilla-concept.de

// Prototype required!

// ---------------------------------------------------------------------------------

// make faked select boxes work in meds-list

    var dropEntryList = $$('.drop-entry');
    for (var i = dropEntryList.length - 1; i >= 0; i--) {
        dropEntryList[i].observe('click', respondToClick);
    };

    function respondToClick(event) {
      var element = event.element();
      if (element.match('img')) { // falls auf das Icon geklickt wird...
      	element = element.up(0);
      }
      // console.log(element);

      var strongEl = element.up(1).previous('strong');
      strongEl.update(element.innerHTML);
    }

    // Make faked selectbox and hover effect on tables work in IE

    // Check if it's IE
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion=new Number(RegExp.$1)
        if (ieversion<7) {
            fakeSelect();
            hoverTable();
        }
        function fakeSelect() {
            if (document.all && document.getElementById && document.getElementById('selectbox')) {
            navRoot = document.getElementById("selectbox");
                for (i=0; i<navRoot.childNodes.length; i++) {
                    node = navRoot.childNodes[i];
                    if (node.nodeName=="LI") {
                        node.onmouseover=function() {
                            this.className+=" hover";
                        }
                        node.onmouseout=function() {
                            this.className=this.className.replace(" hover", "");
                        }
                    }
                }
            }
        }
        function hoverTable() {
            trElements = $$('tr');
                for (i=0; i<trElements.length; i++) {
                    node = trElements[i];
                    node.onmouseover=function() {
                        this.className+=" hover";
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" hover", "");
                    }
                }
        }
    }

// The Search Script

    function valueToggle() {
        if (!document.getElementById) return;

        var feld = document.getElementById('searchfield');
        var ov = feld.value;

        feld.onfocus = function () {
            if (this.value == ov) {
                this.value = "";
                this.style.color = '#000';
            }
        }
        feld.onblur = function () {
            if (this.value == "") {
                this.value = ov;
                this.style.color = '';
            }
        }
    }
    valueToggle();
    
// The Medilist Scroll Script

	function scrollToIndex(id,letter) {
		h = 0;
		obj = $(id);
		found = false;
		items = obj.childElements();
		for (i=0; i<items.length; i++) {
			text = items[i].childElements()[1].childElements()[0].childElements()[0].firstChild.nodeValue;
			if (text.charAt(0) == letter) {
				found = true;
				break;
			}
			h += items[i].getHeight();
		}	
		if (found) obj.scrollTop = h;
	}


    
    
    
    
    
    
    
    
    
    
    
    
    
    
