function popup_now(popuplink) {
  popup = window.open(popuplink,"SiteWindow","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=250,height=300,copyhistory=0");
}
name = "hauptfenster";

function openwin(verweis) {
  fenster = open(verweis,"Shopinfo","toolbar=no,scrollbars=yes,location=no,status=no,menubar=no,height=450,width=430");
}
function picwin(verweis) {
  fenster = open(verweis,"Detail","toolbar=no,scrollbars=yes,location=no,status=no,menubar=no,height=450,width=450");
}
function infowin(verweis) {
  fenster = open(verweis,"Detail","toolbar=no,scrollbars=yes,location=no,status=no,menubar=no,height=450,width=560");
}
function wk_weiter(verweis) {
  fenster = open(verweis,"WKInfo","toolbar=no,scrollbars=0,location=no,status=no,menubar=no,height=150,width=200");
}
function wk_aktual(verweis) {
  fenster = open(verweis,"WKInfo","toolbar=no,scrollbars=0,location=no,status=no,menubar=no,height=150,width=200");
}
function popup() {
  alert(shoptext_119);
}
function open_zs_popup(seite) { // Zusatzseiten-Popup
  f_url = seite;
  f_name = "zs_popup";
  f_props = "width=644,height=550,left=100,top=100,scrollbars=yes,resizable=yes";
  f = open(f_url,f_name,f_props);
  f.focus();
  if (open_zs_popup.arguments[1]) f.print();
}
function open_versandkosten_popup(seite) { // Versandkosten-Popup
  f_url = seite;
  f_name = "versandkosten_popup";
  f_props = "width=500,height=540,left=200,top=200,scrollbars=yes,resizable=yes";
  f = open(f_url,f_name,f_props);
  f.focus();
  if (open_versandkosten_popup.arguments[1]) f.print();
}
function wk_check(form) {
    if ((form.wkausf_1 && form.wkausf_1.value == "xxnoinputxx") || (form.wkausf_1 && form.wkausf_1.value == "xxnoinputxx2")) {
    alert(shoptext_19);
    return false;
  }
    if ((form.wkausf_2 && form.wkausf_2.value == "xxnoinputxx") || (form.wkausf_2 && form.wkausf_2.value == "xxnoinputxx")) {
    alert(shoptext_19);
    return false;
  }
}
function feld_not_ok(feld,msg) {
  alert(msg);
  feld.select();
   feld.focus();
}
function format_price(price){
  price = parseFloat(price);
  price *=100;
  price = Math.round(price);
  price /= 100;
  strP = new String(price);
  var tmp = strP.split(".");
  if(!tmp[1])
    tmp[1] = "00";    
  else
    if(tmp[1].length==1)tmp[1]*=10;
  strP = tmp[0] + "," + tmp[1];
  return strP;
}
function show_lieferblock (value) {
  var lieferblock = el('lieferblock');
  if(!lieferblock)return;
  if (value == true) 
    lieferblock.style.display='inline';
  else
    lieferblock.style.display='none';
}
function show_packstation (value) {
  LiefFields = new Array("land_lief", "land_lief_stern", "firma_lief_label", "firma_lief_value", "firma_lief_stern", "strasse_lief_label", "strasse_lief_value", "strasse_lief_stern");
  PackFields = new Array("land_pack", "firma_pack_label", "firma_pack_value", "firma_pack_stern", "strasse_pack_label", "strasse_pack_value", "strasse_pack_stern");
  if (value == true) {
    for (i = 0; i < LiefFields.length; i++)
      el(LiefFields[i]).style.display='none';
    for (i = 0; i < PackFields.length; i++)
      el(PackFields[i]).style.display='inline';
  } else {
    for (i = 0; i < LiefFields.length; i++)
      el(LiefFields[i]).style.display='inline';
    for (i = 0; i < PackFields.length; i++)
      el(PackFields[i]).style.display='none';
  }
}
function find_blz (blzfeld, errorstring) {
    var blz = blzfeld.value;
    blzfeld.value = blzfeld.value.replace(/\\D/, "");
    if (blz.length > 8)
	blzfeld.value = blzfeld.value.substring(0,8);
    if (document.all && (blz) && (blz.length == 8)) {
	document.all.Bankleitzahlen.object.Filter = 'BLZ = '+blz;
	document.all.Bankleitzahlen.Reset();
	document.all.Anzeigetabelle.dataSrc = "\#Bankleitzahlen";
        el('Bankplatzhalter').style.display = 'none';
        if (document.all.Bankleitzahlen.recordset && document.all.Bankleitzahlen.recordset.recordCount > 0)	{
 	    document.all.Anzeigetabelle.style.display = "inline";
       } else {
	    el('Bankplatzhalter').innerHTML = '<font color="red">'+errorstring+'</font>';
	    el('Bankplatzhalter').style.display = 'inline';
	}
    }
}
function toggle_zahlart(za_id)  {
    top.za_id = za_id;
    if (el('bankdaten_tabelle')) {
	if ((zahlart_kennung[za_id] != "Einzug") && (zahlart_kennung[za_id] != "Sofortueberweisung"))
	    el('bankdaten_tabelle').style.display = 'none';
        else
	    el('bankdaten_tabelle').style.display = 'inline';
    }
    if (el('kkdaten_tabelle')) {
	if ((zahlart_kennung[za_id] != "Kreditkarte") && (zahlart_kennung[za_id] != "CC-Bank"))
	    el('kkdaten_tabelle').style.display = 'none';
        else
	{
	    el('kkdaten_tabelle').style.display = 'inline';
	    if ((zahlart_namen[za_id].search(/visa/ig) >= 0) || ((zahlart_namen[za_id].search(/master/ig) >= 0) && (zahlart_namen[za_id].search(/card/ig) >= 0)))
	    {
		el('best_kknummer_block1').style.width = "40px";
		el('best_kknummer_block2').style.display = "inline";
		el('best_kknummer_block3').style.display = "inline";
		el('best_kknummer_block4').style.display = "inline";
	    }
	    else
	    {
		el('best_kknummer_block1').style.width = "175px";
		el('best_kknummer_block2').style.display = "none";
		el('best_kknummer_block3').style.display = "none";
		el('best_kknummer_block4').style.display = "none";
	    }
	}
    }
    
    //Zusatzinfos zur Zahlung:
    var zusatzInfoCont =  el('za_zusatzinfo');
    if(registeredZAInfo[zahlart_kennung[za_id]]){
          zusatzInfoCont.innerHTML =  registeredZAInfo[zahlart_kennung[za_id]];
    }else{
         zusatzInfoCont.innerHTML = '';
    }
} 
function toggle_versandart(va_id) {
    for (i=0; i < zahlart_namen.length; i++) {
	if (va_id && zahlart_namen[i]) {
	    key = (100 * i) + Math.floor(va_id);
	    if (el('zahlart_'+i)) {
		if (zahl_versand_kombi[key] == true)
		    el('zahlart_'+i).style.display='inline';
		else
		    el('zahlart_'+i).style.display='none';
	    }
	}
    }
}

/*ermöglicht mehrfaches, voneinander unabhängiges Setzen von onload-Handlern */ 

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/*wrapper um document.getElementById
    aufruf á la: el('preisanzeige').innerHTML='xxx'; */ 
function el(id){
    return document.getElementById(id);
}

function check_kk_feld (feld, naechstes)
{
    if ((zahlart_namen[top.za_id].search(/visa/ig) >= 0) || ((zahlart_namen[top.za_id].search(/master/ig) >= 0) && (zahlart_namen[top.za_id].search(/card/ig) >= 0)))
    {
	feld.value = feld.value.replace(/\\D/, "");
	if (feld.value.length > 4)
	    feld.value = feld.value.substr(0,4);
	if (feld.value.length == 4)
	    document.getElementById(naechstes).focus();
    }
}

function changePicQuicktime () {
    document.getElementById("quicktime").style.display = 'inline';
    document.getElementById("quicktime_icon").style.display = 'none';
    document.getElementById("flash").style.display = 'none';
    document.getElementById("flash_icon").style.display = 'inline';
    document.getElementById("hbildcontainer").style.display = 'none';
    if (document.getElementById("hbildsmall"))
      document.getElementById("hbildsmall").style.display = 'inline';
}

function changePicFlash () {
    document.getElementById("flash").style.display = 'inline';
    document.getElementById("flash_icon").style.display = 'none';
    document.getElementById("quicktime").style.display = 'none';
    document.getElementById("quicktime_icon").style.display = 'inline';
    document.getElementById("hbildcontainer").style.display = 'none';
    if (document.getElementById("hbildsmall"))
      document.getElementById("hbildsmall").style.display = 'inline';
}

function changePicFlashZoomer () {
    document.getElementById("flashzoomer").style.display = 'inline';
    document.getElementById("flashzoomer_icon").style.display = 'none';
    document.getElementById("hbildcontainer").style.display = 'none';
    if (document.getElementById("hbildsmall"))
      document.getElementById("hbildsmall").style.display = 'inline';
}

function open_newsletter(form){
  var email = form.email.value
  if(!email || email==form.email.defaultValue ) return false;
  f_url = "";
  f_name= "newsletter";
  f_props = "left=500,top=300,width=200,height=200,resizable=yes";
  f = open(f_url,f_name,f_props);
  f.focus();
  return true;
}


var bundeslaender_definition = {};
function toggleBLandDropdown(land_select,bland_sel_name){
    
    var sel_land = land_select.options[land_select.selectedIndex].value;

    //das JS-Array bundeslaender_definition muss auf der seite definiert sein
    var bundeslaender = bundeslaender_definition[sel_land];
    
    var bland_select =    el(bland_sel_name);
    //var bland_container = el(bland_sel_name + '_container');
    var bland_container = jQuery('#'+bland_sel_name + '_container');
    if(bundeslaender){
        //bland_container.style.display = 'table-row';
        bland_container.show();
        formLib_setOptions(bland_select,formLib_getOptionHashFromArray(bundeslaender));
    }else{
        //bland_container.style.display = 'none'; 
        bland_container.hide();
    }
       
}
