var pImg;
function setBild(feld, pfad)
{
    if(!document.images[feld.form.name]) return ''; //return alert('Bild existiert nicht: '+ feld.form.name);
    if(!pImg[feld.selectedIndex]) return '';
    window.status = (feld.options[feld.selectedIndex].value);
    document.images[feld.form.name].onerror = setErrorBild;
    document.images[feld.form.name].src = pImg[feld.selectedIndex].src;
    return '';
}
function setErrorBild()
{
    this.src = pImg[pImg.length - 1];
    return false;
}
function preload(feld, pfad)
{
    if(!feld || !feld.options) return;
    pImg = new Array();
    var text = "";
    for(var i = 0; feld.options[i];i++)
    {
           if(!feld.options[i].value)continue;
           pImg[i] = new Image();
           pImg[i].src = pfad + '/' + feld.options[i].value  + '.jpg';
           text += pImg[i].src + '\n';
    }
    pImg[pImg.length] = pfad + '/' + 'error.jpg';
    //alert('Preload:\n\n' + text);
}

function showSize()
{
    w = window;
    var width = w.innerWidth ? w.innerWidth : w.document.body.offsetWidth;
    var height = w.innerHeight ? w.innerHeight : w.document.body.offsetHeight;
//    window.status = 'W x H=' + width + 'x' + height;
};


///////////////////////////////////////////////////////////
// checkFrm(f)
function checkFrm(f)
{
    if(f.anzahl)
    {
        if(f.anzahl.value < 1 || f.anzahl.value > 999)
        {
            alert('Bitte ein Menge zwischen 1 und 19 eingeben!');
            return false;
        }
    }
    if(f.best_nr && f.best_nr.length)
    {
        if(!f.best_nr.selectedIndex)
        {
            alert('Bitte eine Farbe auswählen!');
            return false;
        }
    }
    if(f.groesse && f.groesse.length)
    {
        var check = false;
        for(var i = 0; f.groesse[i];i++) if(f.groesse[i].checked) check = true;
        if(!check)
        {
            alert('Bitte eine Größe auswählen!');
            return false;
        }
    }
    return true;
}


var button = null;
function button_laufschrift(b)
{
    var f = null;
    for(var i = 0; i < document.forms.length; i++)
    if( typeof document.forms[i][b] != 'undefined') f = document.forms[i];
    if(!f || !f[b]) return;
    button = f[b];
    setTimeout('lauf()', 500);
}
var on = ['#ccc', '#333', '#FF0'];
var on2 = ['#000', '#fff', '#f00'];
var l = 0;
function lauf()
{
    if(!button) return;
    button.style.backgroundColor = on[l];
    button.style.color = on2[l];
    button.style.fontWeight = 'bold';
    l++;
    if(l == on.length) l = 0;

    setTimeout('lauf()', 1000);
}

// ausblenden
function toggle(id)
{
    var obj;
    if(document.getElementById) obj = document.getElementById(id);
    else if (document.all) obj = document.all[id];

    if(!obj) return;
    obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
    // shrink(obj);
}

var shrink_obj;
function shrink(obj)
{
if(obj)
{
shrink_obj = obj;
}

if(!shrink_obj) return;

var size = {w:0, h:0};

if(shrink_obj .offsetWidth)
{
    size.w = parseInt(shrink_obj.offsetWidth) - 10;
    size.h = parseInt(shrink_obj.offsetHeight) - 10;
}
if(size.w <= 1 && size.h <= 1)
{
 shrink_obj .style.display = 'none';
 return;
}
if(size.w > 0) shrink_obj.style.width = (size.w - 2) + 'px';
if(size.h > 0) shrink_obj.style.height = (size.h - 2) + 'px';
window.setTimeout('shrink()', 50);
}