//
// Diese Funktion oeffnet ein Popup-Fenster. Als Parameter wird die URL,
// die Breite und Hoehe des zu oeffnenden Fensters benoetigt, optional sind 
// 'yes' oder 'no' fuer Scrollbar sowie eine numerische Angabe fuer padding
// moeglich. 
//
function popup(url, width, height) {
  if (window.win && !window.win.closed) {//
    //  wenn es ein Fenster gibt, muss es erst geschlossen werden,
    //  weil dessen Hoehe und Breite nicht angepasst werden kann. 
    //
    win.close();
  }
  var scroll = 'yes';
  if (popup.arguments.length > 3) {
    scroll = popup.arguments[3];
  }
  var padding = 0;
  if (popup.arguments.length > 4) {
    padding = popup.arguments[4];
    var pUrl = url;
    url = '';
  }
  width = parseInt(width) + 2 * padding;
  height = parseInt(height) + 2 * padding;

  win = window.open(url, "PopupWindow", "width="+width+",height="+height+",status=yes,location=no,scrollbars="+scroll+",resizable=no");
  if (win) {
    if (padding > 0) {
      win.document.open();
      win.document.write('<html><body style="margin:0; padding:0;"><div style="margin:0; padding:'+padding+'px;"><img src="'+pUrl+'" border="0" /></div></body></html>');
      win.document.close();
    }
    win.focus();
  }
}

fenster = 0;

function popup_window(url, pos_x, pos_y, breite, hoehe, resize) {
  if(!resize)
    resize = 'no';
  if(fenster != 0) {
    if(!fenster.closed) {
      fenster.close();
    }
    fenster = 0;
  }
  masse = "dependent=no,left=" + pos_x + ",top=" + pos_y + ",width=" + breite + ",height=" + hoehe + ",scrollbars=" + resize + ",resizable=" + resize;
  fenster = open(url, "_blank", masse);
};
function drebaState() {
  window.status = 'Dresdner Bank';
  return true;
};
function bildwechsel(bildid, bildname){
  if(bildname.substr(0,2) == "b_")
    document.images[bildid].src = "img/" + bildname + ".gif";
  else
    document.images[bildid].src = eval(bildname).src;
};
function Go(x) {
  window.open(x, 'newwindow','toolbar=0,location=0,status=0,directories=0,scrollbars=0,resizable=no,menubar=0,width=800,height=300');
}
function print_view() {
  var tmp = document.location.pathname;
  tmp = tmp.slice(1);
  tmp = "/cgi-bin/dma/print/print_view.cgi?" + tmp; 
  newwindow = window.open(tmp, 'newwindow','toolbar=0,location=0,status=0,directories=0,scrollbars=yes,resizable=yes,menubar=0,width=640,height=600');
}
function submitSearch(formular) {
  var query = formular.query.value;
  if (query=="Stichwort, WKN ...") {
    document.location.href="/_meta/sia-suche.php";
    return false;
  } else {
    var reg1 = /^\d{6}$/;
    var reg2 = /^([a-zA-Z]{2})[ ]*(\d{10})[ ]*$/;
    var reg3 = /[wW][kK][nN]/;
    var reg4 = /([0-9]{6})/;
    var reg5 = /^[a-zA-Z]{2,3}(\d{1,4})/;
    //alert(reg5.test(query));
    var url = "https://www.dresdner-privat.de/servlet/P/forwardtoindexbody.do?nav=39&con=/mis/pkportal/pk/wpsuche.mis?&itype=&iadd=x&sstring="
    if (reg1.test(formular.query.value)) {
      url += query;
      newwindow = window.open(url, 'wknsuche','');
      return false;
    }
    else if (reg2.test(formular.query.value)) {
      url += query.replace(reg2, "$1") + query.replace(reg2, "$2") ;
      newwindow = window.open(url, 'wknsuche','');
      return false;
    }
    else if (reg3.test(query) && reg4.test(query)) {
      url += query.match(reg4)[0];
      newwindow = window.open(url, 'wknsuche','');
      return false;
    }
    else if (reg5.test(query)) {
      url += query;
      newwindow = window.open(url, 'wknsuche','');
      return false;
    }
    else {
      return true;
    }
  }
}
  
// Schrift-Skalierung  

var init = false;

function setFontSize(size) {
  var FACTOR = 10;
  var bodyElem = document.getElementsByTagName("body"); 

  if (!init) {
    bodyElem[0].style.fontSize = "100.1%";      
    init = true;
  }
  currSize =  parseInt(bodyElem[0].style.fontSize);
  if (size == "Larger") {
    bodyElem[0].style.fontSize = currSize + FACTOR + "%";
  }
  else if (size == "Smaller") {
    bodyElem[0].style.fontSize = currSize - FACTOR + "%";
  }
}

// Links aus den Auswahlfeldern in neuem Fenster öffnen

function pulldownWindow(formName,menuName) {
  var targetUrl = eval("formName.form." + menuName
                  + ".options[formName.form." + menuName
                  + ".options.selectedIndex].value");
  if (targetUrl != '' && targetUrl.indexOf('external:') < 0) {
    formName.form.action='';
    new_window = window.open(targetUrl, 'newwindow');
    new_window.focus();
  }
  return false;
}
