jQuery.noConflict();
/*
 * Tools für RWE
 */
/* Crypt email addresses */
function processEmail(element,encrypt)
{var temp;var enc_temp;var dec_temp;if(encrypt)
{temp=element.href.substring(7,element.href.length)
enc_temp=b64d2t(utf8t2d(temp));element.href="mailto:"+enc_temp;return element.href;}
else
{temp=element.href.substring(7,element.href.length);dec_temp=utf8d2t(b64t2d(temp));element.href="mailto:"+dec_temp;return element.href;}}
function b64t2d(t)
{var b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';b64=new Array();f64=new Array();for(var i=0;i<b64s.length;i++)
{b64[i]=b64s.charAt(i);f64[b64s.charAt(i)]=i;}
var d=[];var i=0;t=t.replace(/\n|\r/g,"");t=t.replace(/=/g,"");while(i<t.length)
{d[d.length]=(f64[t.charAt(i)]<<2)|(f64[t.charAt(i+1)]>>4);d[d.length]=(((f64[t.charAt(i+1)]&15)<<4)|(f64[t.charAt(i+2)]>>2));d[d.length]=(((f64[t.charAt(i+2)]&3)<<6)|(f64[t.charAt(i+3)]));i+=4;}
if(t.length%4==2)
d=d.slice(0,d.length-2);if(t.length%4==3)
d=d.slice(0,d.length-1);return d;}
function b64d2t(d)
{var b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';b64=new Array();f64=new Array();for(var i=0;i<b64s.length;i++)
{b64[i]=b64s.charAt(i);f64[b64s.charAt(i)]=i;}
var r=new Array;var i=0;var dl=d.length;if((dl%3)==1)
{d[d.length]=0;d[d.length]=0;}
if((dl%3)==2)
d[d.length]=0;while(i<d.length)
{r[r.length]=b64[d[i]>>2];r[r.length]=b64[((d[i]&3)<<4)|(d[i+1]>>4)];r[r.length]=b64[((d[i+1]&15)<<2)|(d[i+2]>>6)];r[r.length]=b64[d[i+2]&63];if((i%57)==54)
r[r.length]="\n";i+=3;}
if((dl%3)==1)
r[r.length-1]=r[r.length-2]="=";if((dl%3)==2)
r[r.length-1]="=";var t=r.join("");return t;}
function utf8t2d(t)
{var b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';b64=new Array();f64=new Array();for(var i=0;i<b64s.length;i++)
{b64[i]=b64s.charAt(i);f64[b64s.charAt(i)]=i;}
t=t.replace(/\r\n/g,"\n");var d=new Array;var test=String.fromCharCode(237);if(test.charCodeAt(0)<0)
for(var n=0;n<t.length;n++)
{var c=t.charCodeAt(n);if(c>0)
d[d.length]=c;else
{d[d.length]=(((256+c)>>6)|192);d[d.length]=(((256+c)&63)|128);}}
else
for(var n=0;n<t.length;n++)
{var c=t.charCodeAt(n);if(c<128)
d[d.length]=c;else if((c>127)&&(c<2048))
{d[d.length]=((c>>6)|192);d[d.length]=((c&63)|128);}
else
{d[d.length]=((c>>12)|224);d[d.length]=(((c>>6)&63)|128);d[d.length]=((c&63)|128);}}
return d;}
function utf8d2t(d)
{var b64s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';b64=new Array();f64=new Array();for(var i=0;i<b64s.length;i++)
{b64[i]=b64s.charAt(i);f64[b64s.charAt(i)]=i;}
var r=new Array;var i=0;while(i<d.length)
{if(d[i]<128)
{r[r.length]=String.fromCharCode(d[i]);i++;}
else if((d[i]>191)&&(d[i]<224))
{r[r.length]=String.fromCharCode(((d[i]&31)<<6)|(d[i+1]&63));i+=2;}
else
{r[r.length]=String.fromCharCode(((d[i]&15)<<12)|((d[i+1]&63)<<6)|(d[i+2]&63));i+=3;}}
return r.join("");}
/* End crypt email addresses */
/* OpenWindow */
function OpenCustomWindow(sUrl, sName, nWidth, nHeight, bScrollBars, bToolBar, bLocation, bResizable, bMenuBar, bStatus, nX, nY) {
  if ((typeof nWidth == 'undefined') || (nWidth == null) || (nWidth == '0')) nWidth = 800;
  if ((typeof nHeight == 'undefined') || (nHeight == null) || (nHeight == '0'))  nHeight = 600;
  if ((typeof bScrollBars == 'undefined') || (bScrollBars == null)) bScrollBars = false;
  if ((typeof bToolBar == 'undefined') || (bToolBar == null)) bToolBar = false;
  if ((typeof bLocation == 'undefined') || (bLocation == null)) bLocation = false;
  if ((typeof bResizable == 'undefined') || (bResizable == null)) bResizable = false;
  if ((typeof bMenuBar == 'undefined') || (bMenuBar == null)) bMenuBar = false;
  if ((typeof bStatus == 'undefined') || (bStatus == null)) bStatus = false;
  if ((typeof nX == 'undefined') || (nX == null)) nX = -1;
  if ((typeof nY == 'undefined') || (nY == null)) nY = -1;
  var param = "width=" + nWidth + ",height=" + nHeight
        + ",scrollbars=" + (bScrollBars ? "yes" : "no")
        + ",toolbar=" + (bToolBar ? "yes" : "no")
        + ",menubar=" + (bMenuBar ? "yes" : "no")
        + ",location=" + (bLocation ? "yes" : "no")
        + ",resizable=" + (bResizable ? "yes" : "no")
        + ",status=" + (bStatus ? "yes" : "no")
        + ((nX != -1) ? ",left=" + nX : "" )
        + ((nY != -1) ? ",top=" + nY : "" );
  var win = window.open(sUrl, sName == null ? "" : sName, param);
  try {
    win.resizeTo(nWidth, nHeight);
  }
  catch(err) {
  }
  win.focus();
  return win;
}
/* End OpenWindow */
/* Tooltip */
function showTooltip(areaId) {
  xOffset = -20;
  yOffset = 20;
  areaId.content = jQuery('div.' + areaId.getAttribute("id")).html();
  jQuery("body").append("<div id='tooltip'>" + areaId.content + "</div>");
  jQuery('map').mousemove(function(e) {
    varTop = e.pageY - xOffset - jQuery('#tooltip').height();
    varLeft = e.pageX + yOffset;
    jQuery("#tooltip").css("top", (varTop) + "px").css("left", (varLeft) + "px");
  });
};
function hideTooltip(areaId) {
  jQuery("#tooltip").remove();
};
/* End tooltip */
/* Shadowbox Initialisierung */
jQuery(window).load(function() {
  var options = {
    handleOversize: 'resize',
    handleUnsupported:  'remove',
    counterType:  'skip',
    autoplayMovies:true
  };
  Shadowbox.init(options);
});
/* End Shadowbox */
/* Funktion zum Weiterleiten auf eine andere Seite per JavaScript (z.B. aus Flash) */
function openURL(url) {
  if ((url != "") && (url != null) && (url != "undefined")) {
    location.href = url;
  }
}
/* End Weiterleiten */
/* Startseiten-Flashvideo */
jQuery(document).ready(function() {
  jQuery('.startvideo').click(function(){
    ET_Event.videoStart('Infotour starten','');
    Shadowbox.open({
      content: '/web/cms/contentblob/313170/data/51654/blob.flv',
      player: 'flv',
     width: 984,
     height: 368,
    title: 'Info-Tour'
    });
    return false;
  });
});
/* / Startseiten-Flashvideo */

/* Shadowbox per JS oeffnen, z.B. aus Flash */
function openShadowbox(content, player, title, width, height) {
  Shadowbox.open({
    content:   content,
    player:    player,
    title:    title,
    width: width,
    height: height
  });
}
/* End Shadowbox per JS oeffnen */
/* Get height of viewport
 * wird von jQuery-Plugins benötigt
 */
function getWindowHeight() {
  var myWidth = 0, myHeight = 0;
  if (typeof( window.innerWidth ) == 'number') {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  }
  else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if (document.body && ( document.body.clientWidth || document.body.clientHeight )) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return (myHeight);
}
/* End get height of viewport */
/* OpenPopup */
function openPopup(u, n, w, h) {
  var l = (screen.width - w) >> 1;
  var t = (screen.height - h) >> 1;
  var p = 'width=' + w + ',height=' + h + ',left=' + l + ',top=' + t + ',resizeable=no,scrollbars=yes,dependent=yes,menubar=no,location=no,toolbar=no,status=yes';
  window.open(u, n, p);
  return false;
}
/* End OpenPopup */
/* Pulldown */
function pulldownLinkChanged(list) {
  var val = list.options[list.selectedIndex].value;
  if (!val)
    return;
  var parts = val.split('#|#');
  var url = parts[0];
  var target = parts[1];
  var script = parts[2];
  if (target == '_blank')
    window.open(url);
  else if (script)
  {
    eval(script);
  }
  else
    location.href = url;
  list.selectedIndex = 0
}
/* End Pulldown */
/* Focus the first input field on page with class focusMe */
jQuery(document).ready(function() {
  jQuery('input.focusMe').eq(0).focus();
});
/* End focus */
/** Bereich für direkt ausgeführte Funktionen
 * z.B. mittels jQuery(document).ready oder livequery
 */
/* Flyout-Funktionen */
jQuery(document).ready(function() {
  jQuery('.dynamic > li > ul').toggle();
  jQuery('.dynamic > li.open > ul').toggle();
  jQuery('.dynamic > li > a').click(function() {
    jQuery(this).parent().find('ul').slideToggle();
  });
  jQuery("#flyout").accordion({ header: 'dt', selectedClass: 'active', active: '.selected', autoHeight: false});
});
/* Layernavi */
jQuery(document).ready(function() {
  /* Gibt es eine Layernavi? */
  if (jQuery('.layernav').length) {
    var currentActivated = null;
    /* Select all lis with clp and register hover */
    jQuery('li[class*=clp_]').hover(function() {
      /* Merken des aktuellen Objekts */
      currentActivated = jQuery(this);

      /* Remove class 'activated' from LIs */
      jQuery('#primNav li').removeClass('activated');
      /* Add class 'activated' and get the selected class name of first class (is 'clp_...') */
      currentLI = jQuery(this).addClass('activated').attr('class').split(' ').slice(0, 1);
      /* Select the corresponding layernavi and show it (hide all others) */
      jQuery('.layernav').addClass('hidden');
      jQuery('.layernav.' + currentLI).removeClass('hidden');
      /* Show the iframe behind it with the same dimensions, -12px for transparency below menu items */
      if (jQuery('.layernav.' + currentLI).length) {
        var frameHeight = jQuery('.layernav.' + currentLI).height();
        frameHeight=frameHeight-24;
        jQuery('.layernavFrame').height(frameHeight).removeClass('hidden');
      }

      var p=jQuery(currentActivated);
      var position=p.position();
      jQuery('.layernav.' + currentLI).add('.layernavFrame').css('left',position.left+165);

      /* Remember the activated item */
    });
    /* Hide all layernav divs and remove class 'activated' from li when leaving the primNav or layernavi div */
    jQuery('li[class*=clp_] a, .layernav').mouseleave(function() {
      jQuery('.layernav,.layernavFrame').addClass('hidden');
      jQuery(currentActivated).removeClass('activated');
    });
    /* Remove class 'activated' from li when leaving layernavi div */
    jQuery('.layernav').mouseleave(function() {
      jQuery('#primNav li').removeClass('activated');
      jQuery('.layernavFrame').addClass('hidden');
    });
    /* Trick to keep 'activated' status and layernavi visible when leaving LIs to hover layernavi */
    jQuery('.layernav').mouseenter(function() {
      jQuery(this).removeClass('hidden');
      jQuery('.layernavFrame').removeClass('hidden');
      jQuery(currentActivated).addClass('activated');
    });
  };
});
/* End Layernavi */
/* divLayer like login */
jQuery(document).ready(function() {
  var zwischenspeicher = "";
  jQuery('.opendivlayer').click(function() {
    if (jQuery(this).attr('rel') != '') {
      /* Breite und Hoehe aus rel Attribut lesen, Format: x,x */
      var dimensions = jQuery(this).attr('rel');
      /* Breite und Hoehe aus dem String extrahieren */
      var trenner = dimensions.indexOf(",");
      var newWidth = parseInt(dimensions.substring(0, trenner));
      var newHeight = parseInt(dimensions.substring(trenner + 1, dimensions.length));
      /* Breite und Hoehe an das iframe und div schreiben */
      jQuery('.divLayer,#divLayer').css("width", newWidth).css("height", newHeight).center({
        vertical: false
      });
    }
    /* OverlayDiv und darunterliegenden IFrame einblenden */
    jQuery('.divLayer,#divLayer').removeClass('hidden');
    /* Viewport verschieben */
    jQuery('#divLayer').intoViewport();
    /* Vorhandenen Inhalt zwischenspeichern */
    zwischenspeicher = jQuery('#divLayer #divLayerInner').html();
    /* Gewuenschte Seite per ajax nachladen */
    var ajaxTarget = jQuery(this).attr('href');
    jQuery('#divLayerInner').load(ajaxTarget);
    return false;
  });
  jQuery('.closedivlayer').click(function() {
    jQuery('#divLayer #divLayerInner').html(zwischenspeicher);
    jQuery('.divLayer,#divLayer').addClass('hidden');
  });
});
/* End divLayer */
/* Leeren der Input-Felder mit der ID pq beim Klick
 * Initialwert wird zwischengespeichert und wieder in das
 * Feld geschrieben, wenn der Cursor das leere Feld verlässt
 */
jQuery(document).ready(function() {

  var initial = 'Ihr Suchbegriff';
  jQuery('.qSearch .autovalue').attr('value',initial);

  jQuery('.qSearch .autovalue').click(function() {
    if (jQuery('.qSearch .autovalue').attr('value') == initial) {
      jQuery('.qSearch .autovalue').attr('value', '');
    }
    jQuery('.qSearch .autovalue').blur(function() {
      if (jQuery('.qSearch .autovalue').attr('value') == '') {
        jQuery('.qSearch .autovalue').attr('value', initial);
      }
    });
  });
});
/* End Input-Felder */
