function displayMenu( sElementId, iStatus )
{
    if( iStatus != 0 && (document.getElementById( sElementId ).style.display == 'none' || iStatus == 1) )
        document.getElementById( sElementId ).style.display = 'inline';
    else
        document.getElementById( sElementId ).style.display = 'none';
}

var iQuickMenuNum = 1;
var iQuickMenuFormFieldArt = 1;

function displayQuickMenu( iQuickMenuId )
{
    for( i = 1; i < 5; i++ )
    {
        if( i == iQuickMenuId )
        {
            if( i != 1 )
            {
                if( iQuickMenuFormFieldArt === null )
                    iQuickMenuFormFieldArt = document.getElementById( 'ddfa' ).selectedIndex;
                document.getElementById( 'ddfa' ).selectedIndex = 0;
            }
            else
            {
                document.getElementById( 'ddfa' ).selectedIndex = iQuickMenuFormFieldArt;
                iQuickMenuFormFieldArt = null;
            }

            document.getElementById( 'quicksearch' + i ).style.display = 'inline';
            document.getElementById( 'quicksearchbutton' + i ).className = 'quickSearchButtonActive';

            iQuickMenuNum = i;
        }
        else
        {
            document.getElementById( 'quicksearch' + i ).style.display = 'none';
            document.getElementById( 'quicksearchbutton' + i ).className = 'quickSearchButtonInactive';
        }
    }
}

function displayQuickMenuCategory( iCategory )
{
    if( iCategory === 0 )
        displayQuickMenu( 1 );
    else if( iCategory == 6 )
        displayQuickMenu( 4 );
    else if( iCategory == 7 )
        displayQuickMenu( 3 );
    else if( iCategory == 8 )
        displayQuickMenu( 2 );
}


function submitQuickMenu()
{
    document.getElementById( 'preisvergleich' + iQuickMenuNum ).submit();
}

function changeSearchRow( iSearchRowNum )
{
    iNewType = document.getElementById( 'formatart' + iSearchRowNum ).value;

    HideSearchRow( iSearchRowNum );

    if( iNewType == 0 )
    {
        document.getElementById( 'tdFormate0' + iSearchRowNum ).name = "bild[]";
        document.getElementById( 'tdFormate0' + iSearchRowNum ).style.display = 'inline';
        document.getElementById( 'tdArt0' + iSearchRowNum ).style.display = 'inline';
        changeValue( document.getElementById( 'selectFormate0' + iSearchRowNum ), iSearchRowNum );
    }
    else if( iNewType == 6 )
    {
        document.getElementById( 'tdFormate6' + iSearchRowNum ).name = "bild[]";
        document.getElementById( 'tdFormate6' + iSearchRowNum ).style.display = 'inline';
        document.getElementById( 'tdSeiten6' + iSearchRowNum ).style.display = 'inline';
        changeValue( document.getElementById( 'selectFormate6' + iSearchRowNum ), iSearchRowNum );
        document.getElementById( 'selectArt0' + iSearchRowNum ).selectedIndex = 0;
    }
    else if( iNewType == 7 )
    {
        document.getElementById( 'tdFormate7' + iSearchRowNum ).name = "bild[]";
        document.getElementById( 'tdFormate7' + iSearchRowNum ).style.display = 'inline';
        changeValue( document.getElementById( 'selectFormate7' + iSearchRowNum ), iSearchRowNum );
        document.getElementById( 'selectArt0' + iSearchRowNum ).selectedIndex = 0;
    }
    else if( iNewType == 8 )
    {
        document.getElementById( 'tdFormate8' + iSearchRowNum ).name = "bild[]";
        document.getElementById( 'tdFormate8' + iSearchRowNum ).style.display = 'inline';
        changeValue( document.getElementById( 'selectFormate8' + iSearchRowNum ), iSearchRowNum );
        document.getElementById( 'selectArt0' + iSearchRowNum ).selectedIndex = 0;
    }
}

function changeValue( oSelectBox, iSearchRowNum )
{
    document.getElementById( 'hidden' + iSearchRowNum ).value = oSelectBox.value;
}

function HideSearchRow( iSearchRowNum )
{
    document.getElementById( 'tdFormate0' + iSearchRowNum ).name = "bildtmp0[]";
    document.getElementById( 'tdFormate6' + iSearchRowNum ).name = "bildtmp6[]";
    document.getElementById( 'tdFormate7' + iSearchRowNum ).name = "bildtmp7[]";
    document.getElementById( 'tdFormate8' + iSearchRowNum ).name = "bildtmp8[]";

    document.getElementById( 'tdFormate0' + iSearchRowNum ).style.display = 'none';
    document.getElementById( 'tdArt0' + iSearchRowNum ).style.display = 'none';
    document.getElementById( 'tdFormate6' + iSearchRowNum ).style.display = 'none';
    document.getElementById( 'tdSeiten6' + iSearchRowNum ).style.display = 'none';
    document.getElementById( 'tdFormate7' + iSearchRowNum ).style.display = 'none';
    document.getElementById( 'tdFormate8' + iSearchRowNum ).style.display = 'none';
}

function enableDropdownMenuForIE()
{
    if (document.all)
    {
        uls = document.getElementsByTagName('UL');

        for(i = 0; i < uls.length; i++)
        {
            if (uls[i].className == 'dropdown')
            {
                var lis = uls[i].getElementsByTagName('li');

                for (j = 0; j < lis.length; j++)
                {
                    if(lis[j].lastChild.tagName == 'UL')
                    {
                        lis[j].onmouseover = function() { this.lastChild.style.display = 'block'; }
                        lis[j].onmouseout = function() { this.lastChild.style.display = 'none'; }
                    }
                }
            }
        }
    }
}

// -- suche form functions 

function preisvergleichKeyPress(event, form)
{
    if (event.keyCode == 13 ) { 
        document.forms['preisvergleich'+form].submit(); 
    } 
    if (event.keyCode == 0 && (event.which < 48 || event.which > 57)) {
        event.returnValue = false;
        return false;
    } else {
        return true;
    }
}

function plzKeyUp(form)
{
    form = document.forms['preisvergleich'+form];
    submit = document.getElementById('preisvergleichSubmit');
    if (form.plz.value.length > 0) {
        if (form.plz.value.length < 5) {
            form.plz.style.color='red';
            submit.disabled = true;
        } else {
            form.plz.style.color='black';
            submit.disabled = false;
        }
    } else {
        submit.disabled = false;
    }
}

function plzKeyUpNoId(form)
{
    form = document.forms['preisvergleich'+form];
    if (form.plz.value.length > 0) {
        if (form.plz.value.length < 5) {
            form.plz.style.color='red';
            form.Submit.disabled = true;
            form.umkreis.disabled = true;
        } else {
            form.plz.style.color='black';
            form.Submit.disabled = false;
            form.umkreis.disabled = false;
        }
    } else {
        form.Submit.disabled = false;
        form.umkreis.disabled = false;
    }
}

