    var oldh = 1;
    var hslide = 1;
    var hnext = 2;
    var delay = 3000;
    var foo = '';
    function autohighlight(delay) {
        setTimeout(highlightit(hnext,delay), delay);
    }
    function highlight(id,hstop){
        setTimeout(highlightit(id,hstop), 0);
    }
    function highlightit(id,hstop){
        return (function() {
            //alert('ja');
            if(hstop == 1){ hslide = 0; clearTimeout(foo); }
            if(id != oldh){
                $('hi_'+oldh).fade({ duration: 0.3, from: 1, to: 0 });
                $('hi_'+id).appear({ duration: 0.3, from: 0, to: 1 });
                $('ht_'+oldh).fade({ duration: 0.3, from: 1, to: 0 });
                $('ht_'+id).appear({ duration: 0.3, from: 0, to: 1 });
                $('hl_'+oldh).className = 'highlight_link';
                $('hl_'+id).className = 'highlight_link_on';
                oldh = id;
            }
            if(hslide == 1){
                if(id == hmax){ hnext = 1; }else{ hnext = id + 1; }
                foo = setTimeout(highlightit(hnext,hstop), hstop);
            }
            return false;
        })
    }
    
    
    function switch_brands(bdelay) {
        return (function() {
            if(bst == 0){
                bz++;
                if(bz == bpz){
                    brandslides_back();
                } else {
                    setTimeout("new Effect.Move('brandscroll', { x: 300, y: 0 });", 3000);
                    setTimeout(switch_brands(bdelay), bdelay + 2000);
                }
            }
        })
    }

    sfHover = function() {
        var sfEls = document.getElementById("topnavi").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);


    function ajax(t,a,v1,v2){
      var params = '&t='+t+'&a='+a+'&v1='+v1+'&v2='+v2;
      new Ajax.Updater( t,
                                'front_content.php?idart=19',
                                {   method: 'post',
                                    parameters: params,
                                    onLoading: $(t).innerHTML = '<img src="upload/layout/ajax-loader.gif" class="ajaxloader" />'
                                    
                                }
                                );
    }
    
    function ajaxform(f,a){
        var params = '&f='+f+'&a='+a;
        var form = $(f);   
        var arr = form.getInputs(); 
        arr.each(function(item) {            
           params += '&'+ $(item).id +'='+ urlencode($(item).value);
        });
        //alert(params);
        new Ajax.Request('front_content.php?idart=19',
        {
         method:'post',
         parameters: params,
         onLoading: $(a).innerHTML = '<img src="upload/layout/ajax-loader.gif" class="ajaxloader" />',
         onSuccess: function(transport){
           var response = transport.responseText;
           var res = response;
           response = response.substr(0,2);
               
               //alert(res);
               if(response == 'ok'){
                   window.location.href = etarget;
               }else if(response == 'do'){
                   res = res.substr(2,res.length);
                   $(a).innerHTML = res;
               }else if(response == 'de'){
                   res = res.substr(2,res.length);
                   $(a).innerHTML = res;
                   $(f).innerHTML = '';  
               }else{
                   alert(res);
                   $(a).innerHTML = '';
               }
           }
        });
    }
    
    function pagesize() {
            
         var xScroll, yScroll;
        
        if (window.innerHeight && window.scrollMaxY) {  
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ 
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { 
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        
        var windowWidth, windowHeight;
        
        if (self.innerHeight) { 
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth; 
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { 
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { 
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }   
        
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else { 
            pageHeight = yScroll;
        }
    
        if(xScroll < windowWidth){  
            pageWidth = xScroll;        
        } else {
            pageWidth = windowWidth;
        }

        return [pageWidth,pageHeight,windowWidth,windowHeight];
    }
    function toggleit(id){
        Effect.toggle(id, 'slide');
    }
    
    
    function toggleh3(nr){
        Effect.toggle('conlay'+nr, 'slide');
        //alert($('arrow'+nr).src);
        if($('arrow'+nr).className == 'auf'){
            $('arrow'+nr).src = 'upload/layout/arrow.png';
            $('arrow'+nr).className = '';
        }else{
            $('arrow'+nr).className = 'auf';
            $('arrow'+nr).src = 'upload/layout/arrow2.png';
        }
    }
    
    function info_box(show){
        var arrayPageSize = pagesize();
        $('loader').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
        /*var arrayPageScroll = document.viewport.getScrollOffsets();
        var oben = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
        var links = arrayPageSize[2] / 2 - 200;
        $('info_box').setStyle({ left: links + 'px', top: oben + 'px' });*/
        if(show == 1){
            new Effect.Appear($('loader'), { duration: 0.2, from: 0.0, to: 0.5 });
            new Effect.Appear($('info_box'), { duration: 0.2, from: 0.0, to: 1.0 });
        }else{
            new Effect.Fade($('loader'), { duration: 0.2, from: 0.5, to: 0.0 });
            $('info_box').hide();
        }
    }
    function flip_box(show){
        var arrayPageSize = pagesize();
        $('loader').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
        /*var arrayPageScroll = document.viewport.getScrollOffsets();*/
        $('flip_box').setStyle({ left: '5%', top: '5%' });
        if(show == 1){
            new Effect.Appear($('loader'), { duration: 0.2, from: 0.0, to: 0.5 });
            new Effect.Appear($('flip_box'), { duration: 0.2, from: 0.0, to: 1.0 });
        }else{
            new Effect.Fade($('loader'), { duration: 0.2, from: 0.5, to: 0.0 });
            $('flip_box').hide();
        }
    }
    
    function checkthebox(id){
        if($(id).checked == false){
            $(id).checked = false;
            $(id).value = 0;            
        }else{
            $(id).checked = true;
            $(id).value = 1;   
        }
    }
    
    
    function urlEncodeCharacter(c) { return '%' + c.charCodeAt(0).toString(16); }
    function urlDecodeCharacter(str, c) { return String.fromCharCode(parseInt(c, 16)); }
    function urlencode(s) { return encodeURIComponent( s ).replace( /\%20/g, '+' ).replace( /[!'()*~]/g, urlEncodeCharacter ); }
    function urldecode(s) { return decodeURIComponent(s.replace( /\+/g, '%20' )).replace( /\%([0-9a-f]{2})/g, urlDecodeCharacter); }

    
    function containsDOM (container, containee) {
      var isParent = false;
      do {
        if ((isParent = container == containee))
          break;
        containee = containee.parentNode;
      }
      while (containee != null);
      return isParent;
    }

    function checkMouseEnter (element, evt) {
      if (element.contains && evt.fromElement) {
        return !element.contains(evt.fromElement);
      }
      else if (evt.relatedTarget) {
        return !containsDOM(element, evt.relatedTarget);
      }
    }

    function checkMouseLeave (element, evt) {
      if (element.contains && evt.toElement) {
        return !element.contains(evt.toElement);
      }
      else if (evt.relatedTarget) {
        return !containsDOM(element, evt.relatedTarget);
      }
    }
