/*
 * HtmlEntities wrapper
 */
function HtmlEntities()
{
}
HtmlEntities.prototype.encode = function(string, quote_style)
{
  var hash_map = {}, symbol = '', tmp_str = '', entity = '';
  
  tmp_str=string.toString();
  if (false === (hash_map = this._get_html_translation_table('HTML_ENTITIES', quote_style))) {
    return false;
  }
  hash_map["'"] = '&#039;';
  for (symbol in hash_map){
    entity = hash_map[symbol];
    tmp_str = tmp_str.split(symbol).join(entity);
  }
  return tmp_str;
}
HtmlEntities.prototype.decode = function(string, quote_style)
{
  var hash_map = {}, symbol = '', tmp_str = '', entity = '';
  tmp_str = string.toString();
  
  if (false === (hash_map = this._get_html_translation_table('HTML_ENTITIES', quote_style))) {
    return false;
  }
  
  // fix &amp; problem
  delete(hash_map['&']);
  hash_map['&'] = '&amp;';
  
  for (symbol in hash_map) {
    entity = hash_map[symbol];
    tmp_str = tmp_str.split(entity).join(symbol);
  }
  tmp_str = tmp_str.split('&#039;').join("'");
  
  return tmp_str;
}
HtmlEntities.prototype._get_html_translation_table = function(table, quote_style)
{
  var entities={},hash_map={},decimal=0,symbol='';
  var constMappingTable={},constMappingQuoteStyle={};
  var useTable={},useQuoteStyle={};
  
  constMappingTable[0] = 'HTML_SPECIALCHARS';
  constMappingTable[1] = 'HTML_ENTITIES';
  constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
  constMappingQuoteStyle[2] = 'ENT_COMPAT';
  constMappingQuoteStyle[3] = 'ENT_QUOTES';
  useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
  useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style?quote_style.toUpperCase() : 'ENT_COMPAT';
  
  if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
    throw new Error("Table: "+useTable+' not supported');
  }
  entities['38'] = '&amp;';
  if (useTable === 'HTML_ENTITIES'){
    entities['160'] = '&nbsp;';
    entities['161'] = '&iexcl;';
    entities['162'] = '&cent;';
    entities['163'] = '&pound;';
    entities['164'] = '&curren;';
    entities['165'] = '&yen;';
    entities['166'] = '&brvbar;';
    entities['167'] = '&sect;';
    entities['168'] = '&uml;';
    entities['169'] = '&copy;';
    entities['170'] = '&ordf;';
    entities['171'] = '&laquo;';
    entities['172'] = '&not;';
    entities['173'] = '&shy;';
    entities['174'] = '&reg;';
    entities['175'] = '&macr;';
    entities['176'] = '&deg;';
    entities['177'] = '&plusmn;';
    entities['178'] = '&sup2;';
    entities['179'] = '&sup3;';
    entities['180'] = '&acute;';
    entities['181'] = '&micro;';
    entities['182'] = '&para;';
    entities['183'] = '&middot;';
    entities['184'] = '&cedil;';
    entities['185'] = '&sup1;';
    entities['186'] = '&ordm;';
    entities['187'] = '&raquo;';
    entities['188'] = '&frac14;';
    entities['189'] = '&frac12;';
    entities['190'] = '&frac34;';
    entities['191'] = '&iquest;';
    entities['192'] = '&Agrave;';
    entities['193'] = '&Aacute;';
    entities['194'] = '&Acirc;';
    entities['195'] = '&Atilde;';
    entities['196'] = '&Auml;';
    entities['197'] = '&Aring;';
    entities['198'] = '&AElig;';
    entities['199'] = '&Ccedil;';
    entities['200'] = '&Egrave;';
    entities['201'] = '&Eacute;';
    entities['202'] = '&Ecirc;';
    entities['203'] = '&Euml;';
    entities['204'] = '&Igrave;';
    entities['205'] = '&Iacute;';
    entities['206'] = '&Icirc;';
    entities['207'] = '&Iuml;';
    entities['208'] = '&ETH;';
    entities['209'] = '&Ntilde;';
    entities['210'] = '&Ograve;';
    entities['211'] = '&Oacute;';
    entities['212'] = '&Ocirc;';
    entities['213'] = '&Otilde;';
    entities['214'] = '&Ouml;';
    entities['215'] = '&times;';
    entities['216'] = '&Oslash;';
    entities['217'] = '&Ugrave;';
    entities['218'] = '&Uacute;';
    entities['219'] = '&Ucirc;';
    entities['220'] = '&Uuml;';
    entities['221'] = '&Yacute;';
    entities['222'] = '&THORN;';
    entities['223'] = '&szlig;';
    entities['224'] = '&agrave;';
    entities['225'] = '&aacute;';
    entities['226'] = '&acirc;';
    entities['227'] = '&atilde;';
    entities['228'] = '&auml;';
    entities['229'] = '&aring;';
    entities['230'] = '&aelig;';
    entities['231'] = '&ccedil;';
    entities['232'] = '&egrave;';
    entities['233'] = '&eacute;';
    entities['234'] = '&ecirc;';
    entities['235'] = '&euml;';
    entities['236'] = '&igrave;';
    entities['237'] = '&iacute;';
    entities['238'] = '&icirc;';
    entities['239'] = '&iuml;';
    entities['240'] = '&eth;';
    entities['241'] = '&ntilde;';
    entities['242'] = '&ograve;';
    entities['243'] = '&oacute;';
    entities['244'] = '&ocirc;';
    entities['245'] = '&otilde;';
    entities['246'] = '&ouml;';
    entities['247'] = '&divide;';
    entities['248'] = '&oslash;';
    entities['249'] = '&ugrave;';
    entities['250'] = '&uacute;';
    entities['251'] = '&ucirc;';
    entities['252'] = '&uuml;';
    entities['253'] = '&yacute;';
    entities['254'] = '&thorn;';
    entities['255'] = '&yuml;';
  }
  if(useQuoteStyle !== 'ENT_NOQUOTES') {
    entities['34'] = '&quot;';
  }
  if(useQuoteStyle === 'ENT_QUOTES') {
    entities['39'] = '&#39;';
  }
  entities['60'] = '&lt;';
  entities['62'] = '&gt;';
  for (decimal in entities) {
    symbol = String.fromCharCode(decimal);
    hash_map[symbol] = entities[decimal];
  }
  return hash_map;
}
var htmlEntities = new HtmlEntities();

/*
 * Simple Browser Sniffer
 */
function Sniffer()
{
  this.w3c = (document.getElementById);
  this.msie = (document.all);
  this.userAgent = navigator.userAgent.toLowerCase();
  this.macIE = ((this.userAgent.indexOf('msie') != -1) && (this.userAgent.indexOf('mac') != -1) && (this.userAgent.indexOf('opera') == -1));
  this.win95 = ((this.userAgent.indexOf("win95") != -1) || (this.userAgent.indexOf("windows95") != -1) || (this.userAgent.indexOf("windows 95") != -1));
  this.winme = ((this.userAgent.indexOf("win9x4.90") != -1) || (this.userAgent.indexOf("win9x 4.90")!=-1));
  this.win2k = ((this.userAgent.indexOf("windowsnt5.0") != -1) || (this.userAgent.indexOf("windows nt 5.0") !=- 1));
  this.win98 = ((this.userAgent.indexOf("win98") != -1) || (this.userAgent.indexOf("windows98") != -1) || (this.userAgent.indexOf("windows 98") != -1));
  this.winnt = ((this.userAgent.indexOf("winnt") != -1) || (this.userAgent.indexOf("windowsnt") != -1) || (this.userAgent.indexOf("windows nt") != -1));
}
Sniffer.prototype.getUserAgent = function()
{
  return this.userAgent;
}
Sniffer.prototype.getVersion = function()
{
  return $.browser.version;
}
Sniffer.prototype.isW3C = function()
{
  return this.w3c;
}
Sniffer.prototype.isMSIE = function()
{
  return $.browser.msie;
}
Sniffer.prototype.isSafari = function()
{
  return $.browser.safari;
}
Sniffer.prototype.isMozilla = function()
{
  return $.browser.mozilla;
}
Sniffer.prototype.isOpera = function()
{
  return $.browser.opera;
}
Sniffer.prototype.isMacIE = function()
{
  return this.macIE;
}
Sniffer.prototype.isWin95 = function()
{
  return this.win95;
}
Sniffer.prototype.isWinME = function()
{
  return this.winme;
}
Sniffer.prototype.isWin2K = function()
{
  return this.win2k;
}
Sniffer.prototype.isWin98 = function()
{
  return this.win98;
}
Sniffer.prototype.isWinNT = function()
{
  return this.winnt;
}
Sniffer.prototype.isOperaLEQ7 = function()
{
  return (this.isOpera() && this.getVersion() <= 7.0);
}
var sniffer = new Sniffer();

/*
 * Info Window (Error Messages, Tipps)
 */
function InfoWindow()
{
  this.event = null;
  this.text = '';
  this.xrel = 0;

    this.showError = function()
    {
      if (document.all||document.getElementById) {
      ref=document.getElementById("errorwin");
      iframe = frames["errorframe"];
      iframeDOM = document.getElementById("errorframe");
      span = iframe.document.getElementById("toggle");
      if (span == null) {
        setTimeout("infoWindow.showError()", 100);
        return;
      }
  
      x = 0;
      y = 0;
      if (this.xrel) {
        x += this.xrel.cx;
        y += this.xrel.cy;
      }
      if (rescueVar['mouseX']) {
        x += rescueVar['mouseX'];
      }
      if (rescueVar['mouseY']) {
        y += rescueVar['mouseY'];
      }
      if (rescueVar['scroll']) {
        if (window.pageYOffset){
          y += window.pageYOffset;
        }
        else if (document.body.scrollTop) {
          y += document.body.scrollTop;
        }
        else if (document.documentElement.scrollTop) {
          y += document.documentElement.scrollTop;
        }
      }        
      ref.style.left=x+'px';
      ref.style.top=y+'px';
  
      span.innerHTML = this.text;
      var h = 0;
      table = iframe.document.getElementById("errortab");
      h = table.scrollHeight + 2 + 'px';
      if (h) {
        iframeDOM.height = h;
      } 
      
      ref.style.visibility = "visible";
      }
    }
  
    this.showTip = function()
    {
      if(document.all || document.getElementById) {
      ref = document.getElementById("tooltip")
      iframe = frames["toolframe"];
      iframeDOM = document.getElementById("toolframe")
      span = iframe.document.getElementById("toggle")
      
      if (span == null) {
        setTimeout("showtip("+current+","+event+","+text+")", 1000);
        return;
      }

      x = 0;
      y = 0;
      cx = 0;
      cy = 0;
      if (window.pageYOffset) {
        cy += window.pageYOffset;
      }
      else if (document.body.scrollTop) {
        cy += document.body.scrollTop;
      }
      else if (document.documentElement.scrollTop) {
        cy += document.documentElement.scrollTop;
      }
      if (this.event != null) {
        if (this.event.clientX) {
          x = this.event.clientX + cx - 285;
          y = this.event.clientY + cy + 10;
        }
        else if (this.event.pageX) {
          x = this.event.pageX + cx - 285;
          y = this.event.pageY + cy + 10;
        }
      }

      ref.style.left=x+'px'
      ref.style.top=y+'px'
          
      span.innerHTML=this.text;
      var h = 0;
      table = iframe.document.getElementById("tooltab");
      h = table.scrollHeight+2+'px';
      if (h) {
        iframeDOM.height = h;
      } 
      
      ref.style.visibility = "visible";
      }
    }
}
var infoWindow = new InfoWindow();

/*
 * Info-I Layer
 */
function InfoILayer()
{
  var _idx = 0;
  var _self = this;
  // extract info-i's
  $('div.contentFrame').find('img').each(function(i) {
      src = this.src.substring(this.src.lastIndexOf('\/') + 1); 
      if (src == 'info-i.gif') {
        $(this).addClass('imgInfoI');
        $(this).attr('id', 'info_i_' + (_idx++));
        // set click event
        $(this)
          .click(function(event) {
            if (_self.show) {
              _self.show($(this), event);
            }
          }
        ).end();
      }
    }
  );
}
InfoILayer.prototype.hide = function(hideElem, closeElem) 
{
  $(hideElem).hide();
  closeElem.unbind('click');
  $('div.infoIText').removeClass('redBorder');
}
InfoILayer.prototype.show = function(elem, event) 
{
  var idx = elem.attr('id').replace(/info_i_/g, '');
  var infoILayer = $('div.infoI');
  if ($(infoILayer).length == 1) {
    var infoIText = $('div.infoIText');
    if ($(infoIText[idx]).html()) {
      var _self = this;
      var _text = $(infoIText[idx]).find('.txt').html();
      if (_text.length > 500) {
        var diff = _text.length - 500;
        var width = parseInt($('div.infoI').find('.fix').css('width').replace(/px/, ''));
        var max_width = parseInt($('div.infoI').find('.fix').css('max-width').replace(/px/, ''));
        width = (width + (diff / 4));
        if (width > max_width) {
          max_width = width;
        }
        $(infoILayer).css('width', width + 'px');
        //alert(document.body.offsetWidth);
      }
      else {
        $(infoILayer).css('width', '256px');
      }
      infoILayer.find('.content').html(_text);
      width = parseInt($(infoILayer).css('width').replace(/px/));
      height = infoILayer.height();
      cx = event.clientX - 20;
      /*if (cx + width + 80 > document.body.clientWidth) {
        cx -= (cx + width - document.body.clientWidth + 80);
      }*/
      if (cx + width + 80 > 1024) {
        cx -= (cx + width - 1024 + 80);
      }
      if (cx < 0) {
        cx = 200;
      }
      cy = event.clientY - height - 20;
      if (document.documentElement && document.documentElement.scrollTop) {
        cy += document.documentElement.scrollTop;
      }
      else if (document.body.scrollTop) {
        cy += document.body.scrollTop;
      }
      if (cy < 0) {
        cy = 10;
      }
      infoILayer.css('left', cx);
      infoILayer.css('top', cy);
      infoILayer.show();
      infoIText.removeClass('redBorder');
      $(infoIText[idx]).addClass('redBorder');
      infoILayer.find('.close').find('a').click(function() 
        {
          if (_self.show) {
            _self.hide(infoILayer, $(this));
            return false;
          }    
        }
      ).end();
    }
  }
}
var infoILayer;

/*
 * Callback Web
 */
function CallbackWeb()
{
}
CallbackWeb.prototype.load = function(sg)
{
  this.wait();
  loc = encodeURIComponent(window.location.pathname);
  $('#callback').show();
  $('#callback').load('/webapps/apps2/application/callback.php?loc=' + loc);
}; 
CallbackWeb.prototype.wait = function()
{
  $('#callback').html('<img src="/webapps/img/loading.gif" id="callbackwait" width="20" height="20" style="vertical-align:middle;"> Bitte warten...');
}; 
var callbackWeb = new CallbackWeb();

/*
 * Expand Image
 */
function ExpandImage()
{
  $('img.expand')
    .click(function() {
      src1 = $(this).attr('src');
      src2 = $($(this).next()[0]).attr('src');
      $(this).attr('src', src2);
      $($(this).next()[0]).attr('src', src1);
    }
  ).end();  
}
var expandImage;

/*
 * Expand Layer
 */
function ExpandLayer()
{
}
ExpandLayer.prototype.init = function()
{
  if ($('div').filter('.expandBoxWrapper').find('a').length == 1) {
    // if there's only 1 then show it
    //$('div').find('.expandBoxWrapper').find('.content').toggle();
  }
  $('div')
    // toggle expand box
    .find('.expandBoxWrapper .header')
      .find('a').click(function() {
        $($(this).parent().next()[0]).slideToggle('fast');
        //$($(this).parent().next()[0]).toggle();
        $($(this).parent()[0]).toggleClass('active');
      }
  ).end();
}
ExpandLayer.prototype.closeAll = function()
{
  $('div.expandBoxWrapper')
    .find('.header').each(function(i)
    {
      $($(this).next()[0]).removeClass('opened');
      if ($($(this)).attr('class').search(/active/) != -1) {
        $($(this)).toggleClass('active');
      }
    }
  ).end();
}
ExpandLayer.prototype.disableAll = function() 
{
  $('div').find('.expandBoxWrapper .header').find('a').unbind('click').end();
}
ExpandLayer.prototype.expandAll = function()
{
  $('div.expandBoxWrapper')
    .find('.header').each(function(i)
    {
      $($(this).next()[0]).addClass('opened');
      if ($($(this)).attr('class').search(/active/) == -1) {
        $($(this)).toggleClass('active');
      }
    }
  ).end();
}
ExpandLayer.prototype.openLayer = function(header)
{
  header = $.trim(header);
  header = htmlEntities.decode(header);
  $('div.expandBoxWrapper')
    .find('.header').each(function(i)
    {
      html = $.trim($(this).find('a').html());
      html = htmlEntities.decode(html);
      html = html.replace(/"/g, '');
      header = header.replace(/"/g, '');
      header = header.replace(/\\/g, '');
      if (html == header) {
        ancName = ($($(this).find('a')[0]).attr('name'));
        cy = $('a[name='+ancName+']').offset().top;
        $('html,body').animate({
          scrollTop: cy
        }, 500, function (){location.hash = '#'+ancName;});
        tab_binnen_id = ($($(this)).parent().parent().parent().attr('id'));
        if (typeof tab_binnen_id != 'undefined') {
          tab_binnen_id = tab_binnen_id.replace(/tabbinnen_/g, '');
          if (document.getElementById('tabbinnen_' + tab_binnen_id)) {
            showSubContent(tab_binnen_id);
          }
        }
        $($(this).next()[0]).addClass('opened');
        $($(this)).toggleClass('active');
      }
    }
  ).end();
}
ExpandLayer.prototype.foundLayer = function(header)
{
  found = false;
  header = $.trim(header);
  $('div.expandBoxWrapper')
    .find('.header').each(function(i)
    {
      html = $(this).find('a').html();
      html = html.replace(/&amp;/g, '&');
      if (html == header) {
        found = true;
      }
    }
  ).end();
  return found;
}
var expandLayer = new ExpandLayer();

/*
 * Font Size Setter
 */
function FontSize()
{
  this.base = 1;
  this.defSize = 101;
  this.defMinSize = 86;
  this.defIncSize = 5;
  this.prefSize = this.getPrefSize();
}
FontSize.prototype.getPrefSize = function() 
{
  var prefSize = cookieManager.getCookie('fontSize');
  if (prefSize) {
    return parseInt(prefSize);
  }
  else {
    return this.defSize;
  }
}
FontSize.prototype.setSize = function(direction) 
{
  this.prefSize = (direction) ? this.prefSize + (direction * this.defIncSize) : this.defSize;
  if (this.prefSize <= this.defMinSize) {
    this.prefSize = this.defMinSize;
    $('a.smallFont').css('cursor', 'default');
  }
  else {
    $('a.smallFont').css('cursor', 'pointer');
  }
  cookieManager.setCookie('fontSize', this.prefSize);
  window.name = this.prefSize;
  if (sniffer.isSafari()) {
    if (document.getElementsByTagName('body')[0]) {
      document.getElementsByTagName('body')[0].style.fontSize = this.prefSize + '%';
    }
  }
  else if (sniffer.isMozilla()) {
    window.location.reload();
  }
  else {
    if (document.getElementsByTagName('body')[0]) {
      document.getElementsByTagName('body')[0].style.fontSize = this.prefSize + '%';
    }
  }
}
var fontSize = new FontSize();

/*
 * URL (Uniform Resource Locator)
 */
function URL()
{
}
URL.prototype.getFragment = function()
{
  return window.location.hash;
}
URL.prototype.getHost = function()
{
  return window.location.hostname;
}
URL.prototype.getHref = function()
{
  return window.location.href;
}
URL.prototype.getQuery = function()
{
  query = decodeURIComponent(window.location.search.substring(1));
  query = query.replace(/alert/g, '');
  query = query.replace(/script/g, '');
  query = query.replace(/cookie/g, '');
  query = query.replace(/document/g, '');
  return query;
}
URL.prototype.getQueryValue = function(getName) 
{
  var i, pos, argName, argValue, queryString, pairs;

  // get the string following the question mark
  queryString = this.getQuery();
  queryString = queryString.replace(/alert/g, '');
  queryString = queryString.replace(/script/g, '');
  queryString = queryString.replace(/cookie/g, '');
  queryString = queryString.replace(/document/g, '');
  // split parameters into pairs, assuming pairs are separated by ampersands
  pairs = queryString.split("&");

  // for each pair, we get the name and the value
  for (i = 0; i < pairs.length; i++) {
    if (getName != '') {
      pos = pairs[i].indexOf('='); 
      if (pos == -1) {
        continue; 
      }
      argName = pairs[i].substring(0, pos);
      argValue = pairs[i].substring(pos + 1); 
       
      // Replaces "Google-style" + signs with the spaces
      // they represent
      if (argName == getName) {
        return unescape(argValue.replace(/\+/g, ' '));
      }
    }
    else {
      return unescape(pairs[0].replace(/\+/g, ' '));
    }
  }
  return false;
}
URL.prototype.getPathname = function()
{
  return window.location.pathname;
}
URL.prototype.getPort = function()
{
  return window.location.port;
}
URL.prototype.getProtocol = function()
{
  return window.location.protocol;
}
var url = new URL();

/*
 * QGO Search
 */
function QGO()
{
}
QGO.prototype.openExpandLayer = function(query)
{
  expandLayer.openLayer(query)
}
QGO.prototype.foundExpandLayer = function(query)
{
  expandLayer.foundLayer(query)
}
var qgo = new QGO();

/*
 * Web Application
 */
function WebApp()
{
  this.pilotWebApp = 'http://pilot.seb-bank.de';
  //window.focus();
}
WebApp.prototype.init = function(type)
{
  // init fontsize setter buttons
  if ((sniffer.isW3C() || sniffer.isMSIE()) && !sniffer.isOperaLEQ7() && !sniffer.isMacIE()) {
    $('div.fontSize')
      .find('a').click(function() {
        fontSize = new FontSize();
        if (this.hash == '#largeFont') {
          fontSize.setSize(1);
        }
        else if (this.hash == '#mediumFont') {
          fontSize.setSize(0);
        }
        else if (this.hash == '#smallFont') {
          fontSize.setSize(-1);
        }
      }
    ).end();
  }

  $('table').attr({'cellSpacing':'0', 'cellPadding':'0'});
  $('td').attr('height', '1');
  $('img').not('.A1, .A2, .A3').attr('title', '');

  /*if (cookieManager.getCookie('pollCounter2')) {
    pollMax = parseInt(cookieManager.getCookie('pollMax2'));
    pollCounter = parseInt(cookieManager.getCookie('pollCounter2')) + 1;
    if (pollCounter == pollMax) {
      window.open('http://survey.link.ch/mrIWeb/mrIWeb.dll?I.Project=DGE04871', '_blank');
      cookieManager.setCookie('pollCounter2', parseInt(pollCounter));
    }
    else if (pollCounter < pollMax) {
      cookieManager.setCookie('pollCounter2', parseInt(pollCounter));
    }
  }
  else {
    rnd = Math.ceil(Math.random() * 5) + 1;
    cookieManager.setCookie('pollCounter2', 1);
    cookieManager.setCookie('pollMax2', parseInt(rnd));
  }*/
}
WebApp.prototype.login = function(type)
{
  if (type == 'chipkarte') {
    win98me = cookieManager.getCookie('win98me');
    if (win98me != null && win98me == 'nohint') {
    }
    else if (typeof is_win98 != 'undefined' || typeof is_winme != 'undefined') {
      if (is_win98 || is_winme) {
        window.open("/webapps/ebanking/chipkarte/win98/hbci_win98me.html", "_blank", "left=0,top=0,scrollbars=1");
        return;
      }  
    } 
    window.open("https://karte.seb-bank.de", "_blank", "location=1,toolbar=1,resizable=1");
  }
  else if (type == 'pintan') {
    window.open("https://pintan.seb-bank.de", "_blank", "location=1,toolbar=1,resizable=1");
  }
}
WebApp.prototype.start = function(appname, appURL, openpage)
{
  if (appURL) {
    window.open(appURL,'_blank','width=690,innerWidth=690,height=680,innerHeight=680,menubar=0,toolbar=0,resizable=1,scrollbars=1');
    return;
  }
  var host = '';
  if (url.getHost() == 'kemiw020.atrivio.net' || url.getHost() == 'reddot.seb-bank.de') {
    host = this.pilotWebApp;
  }
  loc = encodeURIComponent(window.location.pathname);
  if (!openpage) {
    openpage = '';
  }
  appname = appname.replace(/\?/, '&');
  window.open(host + '/webapps/start.php?appname=' + appname + '&loc=' + loc + '&openpage=' + openpage,'_blank','width=690,innerWidth=690,height=680,innerHeight=680,menubar=0,toolbar=0,resizable=1,scrollbars=1');
}
WebApp.prototype.startONW = function(href, width, height)
{
  var host = '';
  if (url.getHost() == 'kemiw020.atrivio.net' || url.getHost() == 'reddot.seb-bank.de') {
    host = this.pilotWebApp;
  }
  window.open(href,'_blank','width='+width+',innerWidth='+width+',height='+height+',innerHeight='+height+',menubar=0,toolbar=0,resizable=0,scrollbars=0');
}
WebApp.prototype.resizeFrame = function(height)
{
  if ($('iframe').attr('height')) {
    $('iframe').attr('height', height);
  }
}
WebApp.prototype.tabFunc = function(id)
{
  if (window.tabFunc) {
    tabFunc(id);
  }
}
WebApp.prototype.setTitle = function(group_name, title)
{
  if (group_name == 'SEB Assekuranz') {
    return;
  }
  title = title.replace(/&amp;/g, '&');
  if (title.indexOf("Main_Navigation") != -1) {
  }
  else if (title.indexOf("Mainnavigation") != -1) {
  }
  else if (title.indexOf("nav_menu_level") != -1) {
  }
  else {
    document.title = title;
  }
}

/*
 * begin: WirdedMinds Hack
 * instantiate 'webApp' object before onload event
 */
var webApp = new WebApp(); 
/*
 * end: WirdedMindes Hack
 */


/*
 * ExtLinkAlert: 
 * throws a notice when leaving the 
 * website by an external link
 */
function ExtLinkAlert() 
{
    var _self = this;
    if (cookieManager.getCookie('turnOff') != 1) {
        $('a').each(function(i) {
                _self.filter(this);
            }
        );  
        $('iframe').contents().find('a').each(function(i) {
                _self.filter(this);
            }
        );
    }
}
ExtLinkAlert.prototype.filter = function(elem)
{
    var _self = this;
    if (cookieManager.getCookie('turnOff') != 1) {
        prot = elem.href.substring(0,7); 
        if (prot == 'http://') {
            if (
                 elem.href.indexOf('pilot.seb') > -1 ||
                 elem.href.indexOf('finanzen.net/bankentest2010/') > -1 ||
                 elem.href.indexOf('seb-bank') > -1 ||
                 elem.href.indexOf('vv.sebank.se') > -1 ||
                 elem.href.indexOf('seb-merchant') > -1 || 
                 elem.href.indexOf('seb-assekuranz') > -1 || 
                 elem.href.indexOf('sebassetmanagement') > -1 || 
                 elem.href.indexOf('sebgroup') > -1
               )
            {
            } else if (
                 elem.href.indexOf('212.125.40.226') > -1 ||
                 elem.href.indexOf('212.125.40.227') > -1 ||
                 elem.href.indexOf('212.125.40.228') > -1 || 
                 elem.href.indexOf('212.125.40.229') > -1
               )
            {
            } else if (
                 elem.href.indexOf('www.seb.se') > -1 ||
                 elem.href.indexOf('seb-financial-services') > -1
               )
            {
            } else {
                //alert("externes atag mit http:// gefunden! href= "+elem.href+" checksum "+isIntLink);
                // set click event
                $(elem).click(function(event,href) {
                        _self.show(this);
                    }
                ).end();
            }
        }
    }
}
ExtLinkAlert.prototype.show = function(elem)
{
    var _self = this;
    if (cookieManager.getCookie('turnOff') != 1) {
        var t = elem.title || elem.name || null;
        var tar = elem.target;
         var a = elem.href || elem.alt;
         var g = elem.rel || false;
         $(elem).attr('target', '');
        $(elem).attr('href', '#');
    //if (a == '#') {
       //    a = elem.alt;
    //}
    //else {
      $(elem).attr('alt', a);
    //}
        tb_show(t, '/de/tpl/extLinkAlert.html?extLink='+a+'&KeepThis=true&TB_iframe=true&height=260&width=400&modal=true', g);
        
        return false;
    }
}
ExtLinkAlert.prototype.followLink = function()
{
    self.parent.tb_remove();
    return true;
}
ExtLinkAlert.prototype.deactivate = function()
{
    self.parent.tb_remove();
    return true;
}




/*
 * Preload Scripts
 */
document.writeln('<script src="/de/js/thickbox.js"></script>');


/*
 * Buffer
 */
var rescueVar = 0;

/*
 * onload Settings
 */
$(document).ready(function()
{
  webApp.init();

  infoILayer = new InfoILayer();
  expandImage = new ExpandImage();
  expandLayer.init();

  host = (url.getHost());
  if (
       host.indexOf('jobs') == 0 ||
       host.indexOf('karrierecenter') == 0
     )
  {
  }
  else {
    extLinkAlert = new ExtLinkAlert();
    tb_init('a.thickbox');
    imgLoader = new Image();
    imgLoader.src = tb_pathToImage;
  }

  qgoFragment = url.getQuery();
  if (qgoFragment != '') {
    qgo.openExpandLayer(qgoFragment);
    if (qgoFragment == 'termin') {
      h = Math.max(document.body.clientHeight, document.documentElement.clientHeight) - 70;
      tb_show(null, '/webapps/apps/reqssl4/app.php?produkt=&openid=general&appname=Terminanfrage&tb=true&KeepThis=true&TB_iframe=true&height='+h+'&width=690&modal=true&close=true&top=10', false, '_white_border');
      $('#fla751C73CA847A4B4396F78BB80EFAFA31AW').hide();
    }
  }
  if (url.getFragment()) {
    /*if (url.getFragment() == '#print') {
      expandLayer.expandAll();
      expandLayer.disableAll();
    }*/
  }  
  if (typeof(onloadPage) == 'function') {
    onloadPage();
  }
}
);

/*
 * beforeload Settings
 */
// Set Font size
if (cookieManager.getCookie('fontSize') && !isNaN(cookieManager.getCookie('fontSize'))) {
  document.writeln('<style>body {font-size: ' + cookieManager.getCookie('fontSize') + '%;}</style>');
}
else if (!isNaN(window.name)) {
  document.writeln('<style>body {font-size: ' + parseInt(window.name) + '%;}</style>');
}