// Open HTML Editor
var editor_win = null ;
function OpenEditor(url){
    if (editor_win==null || editor_win.closed) {
        // open window and assign to global variable
        editor_win = window.open(url ,'editor','width=710,height=520,menubar=0,resizable=1,status=0,titlebar=0,toolbar=0');
    }
    else {
        // if window already open, load url again
        editor_win.location.href = url;
    }
    // give window the focus
    if (editor_win.focus) editor_win.focus()
    return false;
}



//------------
// standard popup ( href, width, height, features )
// args are optional
//------------
var popup_win ;

function popup( ) {

    var features = "location=0,menubar=0,resizable=1,scrollbars=0,status=0,titlebar=0,toolbar=0";

    // set default width and height
    // Note: comparison of undefined element to null will fail in Netscape

    if ( !arguments[0] )  url="";  else url = arguments[0]
    if ( !arguments[1] )  width = 710 ;  else width = arguments[1]
    if ( !arguments[2]  ) height = 560 ; else height = arguments[2]
    if ( !arguments[3]  ) ; else features = arguments[3] ;
	features += ",width=" + width + ",height=" + height ;

    if (popup_win==null || popup_win.closed) {
        // open window and assign to global variable
        // NOTE : help pages target this window by name
        popup_win = window.open( url , "window", features );
    }
    else {
        // if window already open, load new url
        popup_win.location.href = url;
        // when resizing, have to take titlebar into consideration
        popup_win.resizeTo ( width, height+30 );
    }

    // give popup the focus
    if (popup_win.focus) popup_win.focus()

    return false;
}



//-----------
// confirm delete
//-----------
function ConfirmDelete( title ) {
    var msg = "Do you really want to delete  '" + title + "' ?"
    if ( confirm(msg) )
        return true;
    else
        return false ;
}


//-----------
// EmptyField - form validation
// if a field is empty, output warning and return true
//-----------
function EmptyField( input ) {
    if ( isEmpty( input.value ) ) {
        input.focus() ;
        alert ("You did not enter a value for '" + input.name  +
            "'\n\nThis is a required field. Please enter it now.");
        return true ;
    }
    return false ;
}

// return true if the string is null or its length = 0
function isEmpty(str) {
    return ((str == null) || (str.length == 0))
}


//------------
// isValidNumber - true if number between 0...999
function isValidNumber( input ) {
  var val = parseInt(input);
  if (isNaN(val) || val < 0 || val > 999) { return false; }
  return true;
}


function find_obj(name) {

    if (document.getElementById) {
        if (document.getElementById(name) ) return document.getElementById(name);

    } else if (document.all) {
        if ( document.all[name] ) return document.all[name];

    } else if (document.layers) {
        if (document.layers) return document.layers[name];
    }
    return null;
}




