    Array.prototype.singleSelection = function() {
        for (var i=0; i<this.length; i++) {
            if ($(this[i]).hasClassName('current')) $(this[i]).removeClassName('current');
            if (!($(this[i]).hasClassName('selectable'))) $(this[i]).addClassName('selectable');
        }
    }
    Array.prototype.countSelections = function() {
        var c = 0;
        for (var i=0; i<this.length; i++) {
            if ($(this[i]).hasClassName('current')) c++;
        }
        return c;
    }
    
    var scroller        = null;
    var scrollerdelay   = 250;
    Event.observe(window, 'scroll', function(){
        window.clearTimeout(scroller);
        scroller = window.setTimeout(function() {
            if ($('rbox') != null) {
            var pos = document.viewport.getScrollOffsets().top - scrolltopoffset;
            var max = $('content').getDimensions().height - 5;
            var box = $('rbox').getDimensions().height ;
            //alert (max + ":" + pos);
            if (pos < 0 ) pos = 0; else if (pos > (max - box - scrolltopoffset)) pos = (max - box - scrolltopoffset);
            new Effect.Move($('rbox'), {x:0,y:pos,duration:0.1, mode: 'absolute'})
            }
        },scrollerdelay);
    });
    
    var MouseLeaveCallback = function (scope, me) {
        if (! ((scope.relatedTarget.id == 'highlightmoreico') || (scope.relatedTarget.id == 'highlight')) ) {
            fHighlightOff(me);
        }
    };
    (function(){var events=Prototype.Browser.IE?{"bindAsMouseEnter":"fromElement","bindAsMouseLeave":"toElement"}:{"bindAsMouseEnter":"relatedTarget","bindAsMouseLeave":"relatedTarget"};for(var eventName in events){(function(relTargetProperty){Function.prototype[eventName]=function(){var __method=this,args=$A(arguments),object=args.shift();return function(event){event=event||window.event;try{var relatedTarget=$(event[relTargetProperty]);if(relatedTarget&&relatedTarget!=this&&!relatedTarget.descendantOf(this)){__method.apply(object,[Event.extend(event)].concat(args));}}catch(e){}};};})(events[eventName]);}})();

    function initStage2() {
        $('highlight').observe('mouseout', MouseLeaveCallback.bindAsMouseLeave(null, this));    
        $('highlightmore').observe('mouseout', MouseLeaveCallback.bindAsMouseLeave(null, this));    
    }
    
    function fSelectMenu(me, url) {
        window.location.href = urlprefix+url
    }
    function fLangSelect(me) {
            new Ajax.Request(urlprefix+'/ajax/language/'+me.value, {
              method: 'post',
              onSuccess: function(transport) {
                
                if (transport.responseText == 'OK') {
                  window.location.reload();
                } else {
                  alert('hmm: ' + transport.responseText);
                }
              }
            });
    }
    function changeHeaderLogo() {
        $("headerlogo").src = imgprefix+"/banners/"+headerlogos[headerlogo];
        headerlogo++;
        if (headerlogo > (headerlogos.length-1)) headerlogo = 0;
        return false;
    }
    function fHighlightMore(me) {
            if ($("highlightmore").style.display == 'block') {
                $("highlightmore").style.display = "none";
                
            } else {
                new Ajax.Updater('highlightmore', urlprefix+'/ajax/'+highlightinfo+'/'+me.id);
                
                $("highlightmore").style.top = ($(me.id).cumulativeOffset().top -24) + "px";
                $("highlightmore").style.left = ($(me.id).cumulativeOffset().left -24) + "px";
                $("highlightmore").onclick = function(){fSelectThis(me);fHighlightOff(me)};
                $("highlightmore").style.display = "block";
            }
    }
    function fHighlight(me,title) {
        if ($(me.id).hasClassName('current') == false) {
            $("highlightmore").style.display='none'; 
            $("highlightmore").update('');
            $("highlight").update(title);
            $("highlight").style.display = "block";
            $("highlight").style.top = ($(me.id).cumulativeOffset().top -24) + "px";
            $("highlight").style.left = ($(me.id).cumulativeOffset().left -24) + "px";
            $("highlight").style.backgroundImage = $(me.id).style.backgroundImage;
            $("highlight").onclick = function(){fSelectThis(me);fHighlightOff(me);};

            $("highlightmoreico").style.display = "inline";
            $("highlightmoreico").style.top = ($(me.id).cumulativeOffset().top - 17) + "px";
            $("highlightmoreico").style.left = ($(me.id).cumulativeOffset().left + 138) + "px";
            $("highlightmoreico").onmouseover = function(){fHighlightMore(me);};
            $("highlightmoreico").onmouseout = function(){fHighlightMore(me);};
            
        }
    }
    function fHighlightOff(me) {
        $("highlightmore").update('');
        $("highlight").style.display='none'; 
        $("highlightmore").style.display='none'; 
        $("highlightmoreico").style.display='none'; 
    }
    function fStep(me, name) {
        if (name == 'previous') {
            new Ajax.Request(urlprefix+'/ajax/previous/'+me.id, {
              method: 'post',
              onSuccess: function(transport) {
                //alert(transport.responseText);
                if (transport.responseText == 'OK') {
                  window.location.href = urlprefix + '/configurator/' + gotoprevious;
                }
              }
            });
        } else {
            new Ajax.Request(urlprefix+'/ajax/next/'+me.id, {
              method: 'post',
              onSuccess: function(transport) {
                //alert(transport.responseText);
                if (transport.responseText == 'OK') {
                  window.location.href = urlprefix + '/configurator/' + gotonext;
                }
              }
            });
            
        }
    }
    
