// make it nice to prototype
jQuery.noConflict();

/* Crypt emails */
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 emails */

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);
}

/* Pressesuche in den Presse-Crossteasern */
function SearchPresse(languageVar)
{
  if (languageVar == 'de') {
    window.location.href = '/web/cms/de/113452/presse-news/pressearchiv/?suchbegriff=' + jQuery('#pq').val();
  }
  else if (languageVar == 'en') {
    window.location.href = '/web/cms/en/113452/presse-news/pressearchiv/?suchbegriff=' + jQuery('#pq').val();
  }
  return false;
}
//Shadowbox_load
jQuery(window).load(function(){
    var options = {
        handleOversize: 'resize',
        handleUnsupported:  'remove',
        counterType:  'default',
        autoplayMovies:true
    };
    Shadowbox.init(options);
});

/* Tooltip-Funktion */
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();
};

/* 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 = jQuery('#pq').attr('value');
jQuery('#pq').click(function() {
  if (jQuery('#pq').attr('value')==initial) {
    jQuery('#pq').attr('value','');
  }
  jQuery('#pq').blur(function() {
    if (jQuery('#pq').attr('value')=='') {
      jQuery('#pq').attr('value',initial);
    }
  });
});
/* Funktion zur Darstellung von Flash, das die Seite überlagert. Das entsprechende Div wird sichtbar / unsichtbar gesetzt */
jQuery('#startOverlayFlash').click( function() {
 jQuery('#flashContainer').removeClass('hidden');
});
jQuery('#stopOverlayFlash').click( function() {
 jQuery('#flashContainer').addClass('hidden');
});

/*
*  jQuery('#CompanyList').bind('mouseenter',function(){
*  jQuery('ul',this).removeClass('hidden');
*   }).bind('mouseleave',function(){
*   jQuery('ul',this).addClass('hidden');
* });
*/
jQuery("#flyout").accordion({ header: 'dt', animated: 'easeslide', selectedClass: 'active', active: '.selected', autoHeight: false, clearStyle: true});
// Fade 
jQuery('.fadelink').click( function() {

// die erste CSS-Klasse ermitteln
var cssclass = jQuery(this).attr("class").split(" ")[0];
//jQuery()this) ist das aufrufende Element (Link in einer ImageMap oder Link im CAP-Text)
//jQuery('#'+cssclass) ist Das Ziel-Element, eine ContentCollection.
if (jQuery(this).hasClass('active')){
//   Zeil ist es das eine ContentCollection nicht geschlosssen wird, wenn der aufrufende Link, die Klasse 'active' beinhaltet.    
    jQuery('#'+cssclass).removeClass('fadecontainer')
}
jQuery('div[class*="fadecontainer"]').hide();

if (jQuery('#'+cssclass).is(":hidden")) {
   jQuery('#'+cssclass).slideDown(700);
}
else {
	jQuery('#'+cssclass).hide();
}
 });
//Document.ready ENDE


});
/*
*
* Typische RWE-Funktionen
*
*
*/
/* OpenWindow*/
function OpenCustomWindow(sUrl, sName, nWidth, nHeight, bScrollBars, bToolBar, bLocation, bResizable, bMenuBar, bStatus, nX, nY) {
 if ((typeof nWidth == 'undefined') || (nWidth == null) || (nWidth=='0')) nWidth = 1024;
 if ((typeof nHeight == 'undefined') || (nHeight == null)|| (nHeight=='0'))  nHeight = 768;
 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;
}
/* 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
}
/* flash öffnet eine Shadowbox */
function openPopup( link, thisWidth, thisHeight )
{
  Shadowbox.open( {
     content:    link,
     player:     "iframe",
     title:      "Statement",
     width: thisWidth,
     height: thisHeight
 })
}

function startOverlayFlash() {
   //alert('new' + jQuery('#flashmove').css("height"));
jQuery('#flashmove').data('smallHeight',jQuery('#flashmove').css("height"))
   jQuery('#flashmove').animate ({
        height: jQuery('#flashmove').data('bigHeight') }, 600); 
}

function closeOverlayFlash(){
    //alert('old' + jQuery('#flashmove').data('smallHeight'));
    jQuery('#flashmove').animate ({
      height: jQuery('#flashmove').data('smallHeight') }, 600); 
}




