/*
Vergewaltigtes Script für Produktmenü
Einfaches auf-/zuklappen mit max. 2 Unterebenen

Autor: Carsten Ruppert - 28.02.2005
Mod: 23.03.2005 -> 3. Ebene

Copyright: HEAD. MARKETING-PARTNER - EINFACH ERFOLGREICH
*/

      var activeItem = null;

      function menuItem (elem, openid, opensub) {

            // Menü Objekt

            var mitem = this;

            this.elem = elem;
            this.subitem;

            this.foldOutIn = function () {
                  // Auf-/Zuklappen
                  switch ( mitem.subitem.style.display ) {
                        case 'none' :
                              if ( activeItem != null ) {
                                    activeItem.subitem.style.display = 'none';
                                    activeItem.elem.className = (activeItem.elem.className == 'big') ? 'big' : 'productnavi';
                                    } // aktives menü verbergen

                              mitem.elem.className = (mitem.elem.className == 'big') ? 'big' : 'activeProductnavi';

                              mitem.subitem.style.display = '';
                              activeItem = mitem;
                        break;
                        case '' :
                              mitem.elem.className = (mitem.elem.className == 'big') ? 'big' : 'activeProductnavi';

                              mitem.subitem.style.display = 'none';
                              if ( activeItem.subitem == mitem.subitem ) { activeItem = null; }
                        break;
                        }
                  return;
                  }

            if ( this.elem ) {
                  var subid = 'sub' + mitem.elem.id.substring(4,mitem.elem.id.length);
                  this.subitem = document.getElementById(subid);

                  var sc = 0;
                  this.subsub = document.getElementById(subid + '.' + sc);

                  // Spagetticode für Ebene 3
                  while ( this.subsub ) {
                        var z = this.subsub.previousSibling;
                        var y = z.previousSibling; // IE
                        var x = z.previousSibling; // Standard

                        if ( x.href ) {
                              x.href = x.href + '&opensub=' + this.subsub.id;
                              if ( this.subsub.id == opensub ) {
								x.className = 'activeProductnavi';  
							  	}
							  
							  }
                        else {
                              x = y.previousSibling
                              if (x.href) {
                                    x.href = x.href + '&opensub=' + this.subsub.id;
									if ( this.subsub.id == opensub ) {
										x.className = 'activeProductnavi';  
									  	}
									}
                              }

                        for ( i = 0; i < this.subsub.childNodes.length; i++ ) {
                              ssc = this.subsub.childNodes[i];
                              if ( ssc.href ) {
                                    ssc.href = ssc.href + '?open=' + this.elem.id + '&opensub=' + this.subsub.id;
                                    }
                              }
                        this.subsub = document.getElementById(subid + '.' + (++sc));
                        }


                  if ( !this.subitem ) { return false; }

                  if ( this.elem.attachEvent ) {
                        this.elem.attachEvent('onclick',mitem.foldOutIn); // MS JScript
                        }
                  else {
                        this.elem.addEventListener('click',this.foldOutIn,false); // W3 DOM
                        }

                  if ( openid == this.elem.id ) {
                        void ( mitem.foldOutIn() );

                        if ( opensub != false ) {
                             // x.className = 'activeProductnavi';
                              document.getElementById(opensub).style.display = '';
                              }
                        }
                  }
            }

      function menu () {
            // Init Menü Objekte

            var menuitem;
            var omitem;
            var counter = 0;

            var ustr = self.location.href;

            var opensub = false;
            var openid = ustr.indexOf('?open') ? ustr.substring(ustr.indexOf('?open=') + 6, ustr.length) : false;
            if ( openid.indexOf('&') > -1 ) {
                  opensub = openid.substring(openid.lastIndexOf('=') + 1, openid.length);
                  openid = openid.substring(0, openid.indexOf('&'));
                  }

            while ( menuitem = document.getElementById('main'+counter) ) {

                  omitem = new menuItem(menuitem, openid, opensub);

                  ++counter;
                  }
            }


/************************************ für menu_audience.inc.php *********************************************/

function switchImage(imgNode) {
      /*
      switchImage 2005.1 - 050318
      By CaRu - carsten.ruppert-at-web.de
      */

      var swimg = this;
      this.img = imgNode;
      this.preimg;

      this.changeSource = function () {
            if ( swimg.img.src == swimg.offsrc ) {
                  swimg.img.src = swimg.onsrc;
                  }
            else {
                  swimg.img.src = swimg.offsrc;
                  }
            }

      this.appendEvents = function () {
            if ( swimg.img.attachEvent ) {
                  swimg.img.attachEvent('onmouseover',swimg.changeSource);
                  swimg.img.attachEvent('onmouseout',swimg.changeSource);
                  }
            else {
                  swimg.img.addEventListener('mouseover',swimg.changeSource,false);
                  swimg.img.addEventListener('mouseout',swimg.changeSource,false);
                  }
            }

      if ( this.img ) {
            this.offsrc = this.img.src;
            this.onsrc = this.img.getAttributeNode('onsrc').value;

            this.preimg = document.createElement('img');
            this.preimg.src = this.onsrc;

            /* Aktiv */
            this.active = self.location.href;
            if ( this.active.indexOf('swi=') ) {
                  this.active = this.active.substring(this.active.indexOf('swi=') + 4, this.active.length);
                  if ( this.img.id == this.active ) {
                        this.img.src = this.onsrc;
                        }
                  else { this.appendEvents() }
                  }
            else {
                  this.appendEvents()
                  }
            return;
            }
}

function initSwImages() {
      var counter = 0;
      var img = document.getElementsByTagName('img')[counter];
      var swimg;

      while ( img ) {
            if ( img.getAttributeNode('onsrc') ) {
                  swimg = new switchImage(img);
                  }
            ++counter;
            img = document.getElementsByTagName('img')[counter];
            }
}



/* SPRACHE UMSCHALTEN */

function switchLanguage() {
	
	var path = self.location.href;
	var gto; 
	var fname = path.substring(path.lastIndexOf('/') + 1,path.length);
	if ( path.indexOf('/de/') > -1 ) {
		gto = path.substring(0, path.indexOf('/de/')) + '/en/' + fname;
		}
	else {
		gto = path.substring(0, path.indexOf('/en/')) + '/de/' + fname;
		}
	top.location.href = gto;
}

/* ROUTE PLANEN NACH HINTERNAH */

							function route () {
							
								var str = document.getElementsByName('sstreetA')[0];
								var zip = document.getElementsByName('szipA')[0];
								var ort = document.getElementsByName('scityA')[0];
							
								var query = "http://194.25.187.91/radarfalle/radarrouting.asp?LNG=D&AD=&SP="+zip.value+"&SO="+ort.value+"&STO=&SS="+str.value+"&ZP=98553&ZO=Hinternah&ZTO=&ZS=Remy-Geiser-Strasse+1&Image1=Suchen&SPD=PKWS&OPT=WW&POI=RADARD&V1P=&V1O=&V1TO=&V1S=&BUTTON=SEARCH";

								window.open(query);
							
								}
