window.onerror=DispErr;
function DispErr(msg,url,linnbr,df$){
var winParm=makeWinParm(300,200,'no','no','no','auto','yes')
winOpen('errMsg= '+msg+'\n<br>URL= '+url+'\n<br>linNbr= '+linnbr+'\n<br>history.length= '+history.length+'\n<br>parent.length= '+parent.length+'\n<br>Desc= '+df$+'\n<br>pathName= '+location.pathname+'\n<br>name= '+ location.hash+'\n<br>host= '+ location.host+'\n<br>port= '+ location.port+'\n<br>href= '+ location.href,winParm)
alert('DispErr: '+msg)
return true;
}

var imgErr=false;
function existErr(){
imgErr=true;
return imgErr;
}

function browLev(){   
var i=navigator.appVersion.indexOf("MSIE ");
if (i>-1){i=parseFloat(navigator.appVersion.substr(i)+5);}
window.status=navigator.appVersion;
return i;
}
if(browLev()<5.5){alert('This page requires Internet Explorer 5.5 or up. Please upgrade and return.')}

function winOpen(msg,p) {
  msgWin=window.open("","winOpen",p);
  msgWin.document.open()
  msgWin.document.write("<HEAD><TITLE>Message Window</TITLE></HEAD>");
  msgWin.document.write("<font size=2>" + msg + " </font>");
return true;
}

var URLwin=null;
function winURL(url,inTitle) {
  if (URLwin==null||URLwin.closed) {
    var winParm=makeWinParm(300,200,'no','no','no','yes','yes');
    URLwin=window.top.open(url,'winURL',winParm);
    //URLwin.document.title=inTitle;
}
  else {URLwin.focus()}
}

function makeWinParm(width,height,status,toolbar,menubar,scrollbars,resizable) {
var s="top=".concat(String((screen.availHeight/2)-(height/2)));
s=s.concat(',left='+(String(screen.availWidth/2)-(width/2)));
s=s.concat(',width='+width);
s=s.concat(',height='+height);
s=s.concat(',status='+status);
s=s.concat(',toolbar='+toolbar);
s=s.concat(',menubar='+menubar);
s=s.concat(',scrollbars='+scrollbars);
s=s.concat(',resizable='+resizable);
return s
}

function getScpt(Stype, fileID) {
var getScptStr='';
if (Stype == 1) {
getScptStr='<link rel=stylesheet href=\"' + fileID + '\" type=\"text/css\">';
  }
else {
getScptStr='<S';
getScptStr+='CRIPT LANGUAGE=\"JavaScript1.2\" SRC=\"' + fileID + '\"></S';
getScptStr+='CRIPT>'; 
};
return getScptStr;
}

var loc=location.href;
function getCookieDomain() {
 var ds = ''; 
 if(loc.indexOf('lehigh') != -1) ds='; domain=.lehigh.edu';
 if(loc.indexOf('margush') != -1) ds='; domain=.margush.com';
 return ds;
}

function getCookieVal(nm) {
 var c=document.cookie;
 var x=c.indexOf(nm+'=');
 if(x==-1) return null;
 var y=x+nm.length;
 var z=c.indexOf(';',y);
 if(z==-1) z=c.length;
 var v=c.substring(y,z);
 if(v.charAt(0)=='=') v=v.substring(1,v.length);
 return v;
}

function setCookieVal(n,v) {
 var ds = getCookieDomain();
 var ty = new Date();
 ty.setFullYear(ty.getFullYear()+10);
 document.cookie=n+'='+v+';expires='+ty.toGMTString()+'; path=/'+ds;
}

function ckCookies() {
 setCookieVal(document.title,true);
 var c=getCookieVal(document.title);
 if(c!=null&&c.indexOf('true')!=-1) return true;   
 return false; 
}

function atIdx(inA,find){
/<[\s\S]*>/
rEx = new RegExp(find,"gi") 
var notFound=-1
var idx=0;
//alert(inA[idx]+ '*'+ find + '*' +rEx)
//alert('find: ' + find + ' in:'+inA+ ' length:' +inA.length)}
while((notFound==-1)&&(idx<inA.length)) {
  //if (parseInt(inA[idx])){inA[idx]=String(inA[idx]);}
  notFound=inA[idx++].search(rEx);
  }
if (notFound==-1) {idx=0}
return idx-1
}

var gRegBS = new RegExp("[\\\\]", "g");
function justFN(sPath) {
  return justFS(sPath).split('.')[0];
}

function justFE(sPath) {
  sPath = sPath.replace(gRegBS, "/")
  return sPath.substring(sPath.lastIndexOf('.')+1);
}

function justFS(sPath) {
  if (sPath==null) {sPath='not_a_fileSpec'} 
  sPath = sPath.replace(gRegBS, "/")
  return sPath.substring(sPath.lastIndexOf("/")+1);
}

function escApost(s){
var escRegS= new RegExp("[\\']", "g");
s = s.replace(escRegS, "\\'")
return s;
}

function getRest(s,cnt,d) {
var pos=0;
  for (var i=0;i<cnt;i++) {
    pos=s.indexOf(d,pos);  
    pos++
  }
if(!pos){s=''}
return s.substring(pos);
}

function aCapt(s) {
if (s==null) {s='';}
var i=s.indexOf(" ")+1;
if (!i) {s='unfound!'}
return s.substring(i);
}

function aFile(inStr) {
if (inStr==null) inStr='about:blank';
return inStr.split(' ')[0];
}

function fixPath(inStr) {
var RE = new RegExp("[/]", "g");
if (!RE.test(inStr)) {inStr=filePath.concat(inStr)};
return inStr;
}

function getField(inRec,fn,delim){
return inRec.split(delim)[fn]
}

function noSelect(){
var i=0;
while (i<arguments.length) {
  if (arguments[i]!=null){arguments[i].unselectable="on"}  
  i++
}
}

function doEnable(){
var i=0;
while (i<arguments.length) {
  if (arguments[i]!=null){arguments[i].disabled=false}  
  i++
}
}

function doDisable(){
var i=0;
while (i<arguments.length) {
  if (arguments[i]!=null){arguments[i].disabled=true}  
  i++
}
}

function doVisi(){
var i=0;
while (i<arguments.length) {
  if (arguments[i]!=null){arguments[i].style.visibility=""}  
  i++
}
}

function doHide(){
var i=0;
while (i<arguments.length) {
 if (arguments[i]!=null){arguments[i].style.visibility="hidden"}
 i++
}
}

function togVisable() {
var i=0;
while (i<arguments.length) { 
 var s=arguments[i].style.visibility;
 if (s=="hidden") {s='';}else{s='hidden';}
 arguments[i++].style.visibility=s;
 //arguments[i++].style.setExpression('visibility',now,'javascript');
}  
}

function togVis() {
var i=0;
while (i<arguments.length) { 
 var s=arguments[i].currentStyle.visibility;
 if (s=="hidden") {s='visible';}
 arguments[i++].style.visibility=s;
}  
}

function doHand(o,s){
 o.style.cursor='hand';
  window.status=s;
 return true;
}

function doGlass(o,s){
 o.style.cursor='wait';
  window.status=s;
 return true;
}

var oReImg = new RegExp("^(jpg|jpeg|gif)",'i'); 
function isImage(inStr){
var ddd=justFE(inStr);
return oReImg.test(justFE(inStr));
}

function hiByte(op1) {
if (op1==null||op1==NaN) op1=0;
return (op1/c-op1%c/c)
}

function loByte(op1) {
if (op1==null||op1==NaN) op1=0;
return (op1%c)
}

var c=Math.pow(2,8);
function enCode(hi,lo){
return hi*c+lo;
}

function layout$(x){
if (x) {return ' portrait';}
return ' landscape';
}

function nowMsec() {
d = new Date();    
return d.getTime();
}

function getMsec(inMs) {
return nowMsec()-inMs;
}

function elapSec(inMs) {
//alert((nowMsec()-inMs)/1000+' '+inMs )
return Math.round((nowMsec()-inMs)/1000);
} 

var hexTemp='0123456789ABCDEF';
function dec2hex(n) {
 var s=""; 
 var n=n;
 for (var i=0;i<8;i++) {
   s=hexTemp.charAt(Math.abs(n)%16)+s;
   n=Math.floor(n/16);
 }
 return s;
}

function giraffe(mag,range,scale){
var step=(scale/range)*(mag);
return step;
}

function getFontSize(strLen,portPixels) {
var pix2pt=Math.floor(pixPerChar*1.16);
  //alert(strLen + ' ' + pixPerChar+ ' ' +pix2pt);
return pix2pt+'px';
}

function getFileType(inStr){
var t=0;
switch (JustFE(inStr).toLowerCase()) {
  case 'pdf': t='image';break;
  case 'jpg': t='image';break;
  case 'jpeg': t='image';break;
  case 'gif': t='image';break;
  case 'htm': t='html';break;
  case 'html': t='html';break;
  case 'txt': t='text';break;
  default: t='unknown';break; 
}
return t;
}

function hasHTML(s){
var c=s.indexOf('>');
var o=s.indexOf('<');
if (c<0||o<0||o>c){return false;}
return true;
}
