﻿var genreValidators = new Array();

function selectGenre( eel, did, hid )
{
    eel.className = "genreSelected";
    $get( did ).className = "genre";
    $get( hid ).value = eel.innerHTML;
}

function handleName( el, gid, txtid, wmt )
{
    var eel = $get( gid );
    var txt = null;
    
    if( txtid )
    {
        txt = $get( txtid );
    }

    if( eel )
    {
        if( el.value.length > 0 )
        {
            eel.style.visibility = "visible";
        }
        else if( !txt || (txt.value == wmt) )
        {
            eel.style.visibility = "hidden";
        }
    }
}

function addValidator( id, div, text, noValueText )
{
    var a = new Array();
    a.push( id );
    a.push( div );
    a.push( text );
    a.push( noValueText );
    
    genreValidators.push( a );
}

function ValidateAll()
{
    var text = "";

    if( validateRest )
    {
        text += validateRest();
    }
    
    for( var i = 0; i < genreValidators.length; i++ ) 
    {
        var a = genreValidators[i];
        var v = $get(a[0]).value;
        
        if( ( v.length == 0 || v == a[3] )
            && $get(a[1]).style.visibility != 'hidden' )
        {
            text += a[2] + "\n";
        }
    }
    
    if( text.length > 0 )
    {
        window.alert( validatePreffix + text );
        return false;
    }
    else
    {
        return true;
    }
}

