function ApplyFilter(index,url){
   if (index!=0) url=url+"?page="+index;
   document.location.replace(url);
}

function GoToManager() {
   open ('https://www.tpd.tno.nl/manager.html','SmartSiteManager','left=0,top=0,resizable=yes,status=yes,scrollbars=yes');
}

function init() {
   document.cookie="resolution="+screen.width+"x"+screen.height;
   document.cookie="colordepth="+screen.colorDepth;
   document.cookie="timezone=" + Math.round (new Date ().getTimezoneOffset()/60);
   document.cookie="javaEnabled=" + (navigator.javaEnabled() ? "yes" : "no");
}

// Added DOM detection for Opera which doesn't handle the length property of
// an array of form elements.
isDOM = document.getElementById ? 1:0; 
    
function stripSpaces(x) {
    while (x.substring(0,1) == ' ') x = x.substring(1);
    return x;
}

function empty(x) { if (x.length > 0) return false; else return true; }
    
function chkForChecked (f,fld,msg) {
    
    var frm = f ;
    var e ;
    var j = 0 ; // This is so that we know which RADIO/CHECKBOX element to return to.
    
    if(isDOM) {
    // Added the DOM part for Opera which seems to choke on the length
    // property of an array of elements.    
        e = document.getElementsByTagName('INPUT'); // returns a Node List
        
        for (var i=0; i<=e.length-1; ++i){
        
            if(e[i].name == fld) {
                if(j==0)j=i;
                if ( e[i].checked ) return true;  // one is checked after all!
            }
        }
        
    }else{
    
        e = f.elements[fld] ; // returns an array of elements
        
        for( var i=0; i < e.length; ++i ) { 
	    	if ( e[i].checked ) 
	    	{ 
	    	    return true;  // one is checked after all! 
	    	    break; 
	    	} 
	    }
    }
    
    alert( msg );
    e[j].focus() ;
    return false; 
}

function chkForNonblank (f,fld,msg) {

    var frm = f ;
    var e = f.elements[fld];
    
    if ( ! empty(stripSpaces(e.value))  ) return true; 
    alert( msg );
    e.focus() ;
    return false;
}

function chkForIsSelected (f,fld,msg) {

    var frm = f ;
    var e = f.elements[fld];
    
    if ( ! e.selectedIndex == 0 ) return true; 
    alert( msg );
    e.focus() ;
    return false;
}

function chkNumeric (f,fld,msg) {

    var frm = f ;
    var e = f.elements[fld];
    
    if ( !isNaN(parseInt(e.value)) ) return true; 
    alert( msg );
    e.focus() ;
    return false;
}

function validate(f) { 

    for( var i=0; i < fieldsToCheck.length; ++i ) { 
        if (! fieldsToCheck[i][1] (f,fieldsToCheck[i][0],fieldsToCheck[i][2]) ) {
            return false;
        }
    }
    return true;
}

function chkForValidEmail(f,fld,msg) {

    var frm = f ;
    var e = f.elements[fld];
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

    if (filter.test(e.value)) return true;
    alert( msg );
    e.focus();
    return false;
}

function MM_controlSound(x, _sndObj, sndFile) { //v3.0
    var i, method = "", sndObj = eval(_sndObj);
    if (sndObj != null) {
        if (navigator.appName == 'Netscape') method = "play";
        else {
            if (window.MM_WMP == null) {
                window.MM_WMP = false;
                for(i in sndObj) if (i == "ActiveMovie") {
                    window.MM_WMP = true; break;
                } 
            }
            if (window.MM_WMP) method = "play";
            else if (sndObj.FileName) method = "run";
        } 
    }
    if (method) eval(_sndObj+"."+method+"()");
    else window.location = sndFile;
}

