// alert("This is scripts.js"); //DEBUG

var userAgent = navigator.userAgent;
var isFirefox = userAgent.match(/Firefox/i)? 1 : 0;
var isMSIE    = userAgent.match(/MSIE/)? 1 : 0;
var isOldNetscape = userAgent.match(/Mozilla\/4.7/)? 1 : 0;
var BaseFontSize = (isFirefox)? "1.3em" : "1.0em"; // needs work!
BaseFontSize = "12pt";
var SymRealWinOpen = window.open;

function Obj(element_id) {
    // This method returns the element corresponding to the id
    if (document.getElementById) {
      return document.getElementById(element_id);
    }
    else if (document.all) {
      return document.all[element_id];
    }
    else if (document.layers) {
      return document.layers[element_id];
    } else {
      return undefined;
    }
}  

function RefreshIf() {
    if(isOldNetscape)
	window.location.href=unescape(window.location.pathname);
}

//From Paul Tukey
function PopUp (URL,width,height,wname) {
    if(width  == null) { width  = "500" }
    if(height == null) { height = .6*width }
    if(wname  == null) { wname = "PopUp" }
    win = window.open (
	    URL, wname,
	    "scrollbars,menubar,resizable," + 
	    "width=" + width + ",height=" + height );
    WinFocus(win);
}

function WinFocus(win) {
    // assume win.focus works, unless broken old msoft browser
    if ( (navigator.appName.search (/^microsoft/i) == -1) ||
         (navigator.appName == "Microsoft Internet Explorer" &&
          navigator.appVersion.indexOf("Windows", 0) != -1   &&
          navigator.appVersion.substring(0,1) >= 4) ) {
		win.focus()
    }
}

var winWidth=100;
var winHeight=100;

function getWindowSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winWidth = document.documentElement.clientWidth;
    winHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winWidth = document.body.clientWidth;
    winHeight = document.body.clientHeight;
  }
//  window.alert( 'winWidth = ' + winWidth + '  winHeight = ' + winHeight );
}

function valFirstChecked(list) {
// Use with radio buttons
    for (i=0;i<list.length;i++){
        if (list[i].checked)
            return list[i].value;
    }
    return "";
}
function indFirstChecked(list) {
// Use with radio buttons or checkboxes
    for (i=0;i<list.length;i++){
        if (list[i].checked)
            return i;
    }
    return -1;
}
function show_props(el,k) {
    var s='';
    if(!k || k==null || k==undefined)
	k = 1;
    var n=0;
    for(i in el) {
	var ii = i+"";
        if(ii.match(/^on/)) continue;
        if(ii.match(/^[A-Z][A-Z]/)) continue;
	if(!ii.match(/height|width/i)) continue;
        try{
	    var eli = el[i]+'';
	    if(eli.match(/function/)) continue;
	    if(eli.match(/<.*>/)) eli = "[HTML code]";
	    s += '>> '+i+'='+eli+'\t\t';
	    if(++n%k==0) s += "\n";
        } catch(e) {}
    }   
    return s;
}
function sb(s){
var r=/\[([0-9A-F]{2})\]/g;s=s.replace(r,'%$1');
document.write(unescape(s))}
