// kontrola vyplnění údajů ve formuláři
function ValidateForm(theForm) {
    for( var i=0; i<theForm.length; i++ ) {
     with(theForm.elements[i]) { 
      if( type=="text" ) {
        if( name.indexOf("num")==0 ) {
            if( (value.length==0) || isNaN(parseInt(value)) ) {
                alert('Vyplňte prosím číselnou hodnotu do pole"' + name.slice(3) + '".');
                focus();
                return false;        
            }
        } else {
            if( value.length==0) {
                alert('Vyplňte prosím hodnotu do pole"' + name + '".');
                focus();
                return false;        
            }
        }
      }
     }
    }
    return true;
}

// Internethity2009-Playlist
var InternetHitPlayList = new Array()
InternetHitPlayList[0] = new MeSelect("InternetHit2009-Karvina", 1 )
InternetHitPlayList[1] = new MeText( "Login", false )
InternetHitPlayList[2] = new MeText( "Příjmení a jméno", false )  
InternetHitPlayList[3] = new MeText( "E-mail", false )  
 
function MeText( strName, fAllowEmpty ){
    this.strName = strName    
    this.fAllowEmpty = fAllowEmpty
    this.Validate = function( field ) {
        if ( (!this.fAllowEmpty) && (field.value=="") ) {
            alert('Vyplňte prosím hodnotu do pole "' + this.strName + '".')
            field.focus()
            return false     
        }
        return true
    }
} 

function MeSelect( strName, iFirstIndex ){
    this.strName = strName    
    this.iFirstIndex = iFirstIndex
    this.Validate = function( field ) {
        if (field.selectedIndex<this.iFirstIndex) {
            alert('Vyberte prosím hodnotu v poli "' + this.strName + '".');
            field.focus()
            return false     
        }
        return true
    }
} 

function ValidateFormFromArray(theForm,arr) {
    for( var i=0; i<theForm.length; i++ ) {
        if( arr[i] ) {
            if( !arr[i].Validate(theForm.elements[i]) )
                return false
        }
    }
    return true;
} 