//<![CDATA[

var DEBUG_BASIC = true;
var avail_width = 800;
var avail_height = 600;
var scroll_bar_width = 16;
var browser_vendor = "";
var browser_full_name = navigator.appName;
var browser_version = parseFloat(navigator.appVersion);
var is_msie = false;
var user_agent = navigator.userAgent.toLowerCase();
var op_sys = "";

if (navigator.appName && navigator.appName.toUpperCase().indexOf("MICROSOFT")>-1) {
    is_msie = true;
    browser_vendor="MICR0SOFT";
}
else {
    is_msie = false;    
    if (navigator.appName.toUpperCase().indexOf("NETSCAPE")>-1)
        browser_vendor="NETSCAPE";
    else
	browser_vendor=navigator.appName.toUpperCase();
}
   
function getRawAvailHeight () {
    var h = -1;
    if (navigator.appName.toUpperCase().indexOf("MICROSOFT")>-1) {
	if (document.body)
	    return document.body.offsetHeight;
	else if (document.documentElement)
	    return document.documentElement.offsetHeight;
	else
	    return -1;
    }
    else {
	return window.innerHeight;
    }
}


function initBasic () {
    initBasicLib();
}

function initBasicLib () {
    var n = -1;
    if ((n=user_agent.indexOf("netscape/")) > -1) {
	is_msie = false;
	browser_vendor = "NETSCAPE";
	browser_version = parseFloat(user_agent.substring(n+9));
    }
    else if ((n=user_agent.indexOf("navigator/")) > -1) {
	is_msie = false;
	browser_vendor = "NETSCAPE";
	browser_version = parseFloat(user_agent.substring(n+10));
    }
    else if ((n=user_agent.indexOf("seamonkey/")) > -1) {
	is_msie = false;
	browser_vendor = "SEAMONKEY";
	browser_version = parseFloat(user_agent.substring(n+10));
    }
    else if ((n=user_agent.indexOf("galeon/")) > -1) {
	is_msie = false;
	browser_vendor = "GALEON";
	browser_version = parseFloat(user_agent.substring(n+7));
    }
    else if ((n=user_agent.indexOf("firefox/")) > -1) {
	is_msie = false;
	browser_vendor = "FIREFOX";
	browser_version = parseFloat(user_agent.substring(n+8));
    }
    else if ((n=user_agent.indexOf("iceape/")) > -1) {
	is_msie = false;
	browser_vendor = "ICEAPE";
	browser_version = parseFloat(user_agent.substring(n+7));
    }
    else if ((n=user_agent.indexOf("icecat/")) > -1) {
	is_msie = false;
	browser_vendor = "ICECAT";
	browser_version = parseFloat(user_agent.substring(n+7));
    }
    else if ((n=user_agent.indexOf("opera/")) > -1) {
	is_msie = false;
	browser_vendor = "OPERA";
	browser_version = parseFloat(user_agent.substring(n+6));
    }
    else if ((n=user_agent.indexOf("safari/")) > -1) {
	is_msie = false;
	browser_vendor = "SAFARI";
	browser_version = parseFloat(user_agent.substring(n+7));
    }
    else if ((n=user_agent.indexOf("msie")) > -1) {
	is_msie = true;
	browser_vendor = "INTERNET EXPLORER";
	browser_version = parseFloat(user_agent.substring(n+5));
    }
	
    if (user_agent.indexOf("linux")>=0)
	op_sys = "LINUX";
    else if (user_agent.indexOf("windows")>=0)
	op_sys = "WINDOWS";
    else if (user_agent.indexOf("mac os x")>=0)
	op_sys = "OSX";
    if (is_msie) {
	scroll_bar_width = 20;
	if (document.body && typeof document.body != "undefined") {
	    avail_height = document.body.offsetHeight;
	    if (document.body.offsetHeight && document.body.offsetHeight > scroll_bar_width) {
		avail_height = document.body.offsetHeight-scroll_bar_width;
	    }
	    avail_width = document.body.offsetWidth-scroll_bar_width;
	}
	else {
	    avail_height=document.documentElement.offsetHeight;
	    avail_width=document.documentElement.offsetWidth;
	}
    }
    else {
	scroll_bar_width=16;
	avail_height = window.innerHeight-scroll_bar_width;  // for the scroll bar
	avail_width = window.innerWidth-scroll_bar_width;
    }
}

function getAbsoluteWidth () {
    return avail_width+scroll_bar_width;
}

function getAbsoluteHeight () {
    return avail_height+scroll_bar_width;
}

function isMSIE() {
    return (is_msie);
}

resizeImages.img_sizes = new Array();

function resizeImages(no_resize_list, rel_screen_width) {
    var SCRN_WIDTH = 1250;
    if (rel_screen_width)
	SCRN_WIDTH = rel_screen_width;
    var w = getAvailWidth();
    if (document) {
	if (document.images){
	    //var resizeImages.img_sizes=[];
	    if (resizeImages.img_sizes.length==0) {
		// record orginal size of images
		for (var x=0; x<document.images.length; x++) {
		    resizeImages.img_sizes.push(parseInt(document.images[x].width));
		}
	    }
	    for (var x=0; x<document.images.length; x++) {
		var NewWidth = Math.round(resizeImages.img_sizes[x] * (w<SCRN_WIDTH?w/SCRN_WIDTH:1));
		var ImgName = document.images[x].name;
		var resize_ok = true;
		if (typeof no_resize_list != "undefined")
		    if (inList (ImgName, no_resize_list))
			resize_ok = false;
		if (resize_ok) {
		    if (ImgName && document.getElementById(ImgName) && NewWidth){
			// set any existing img span 
			document.getElementById(ImgName).style.width=(NewWidth)+"px";
		    }
		    document.images[x].width=(NewWidth);
		}
	    }
	}
    }
}

function inList (target, array_list) {
    if (array_list == null)
        return false;
    for (var x=0; x<array_list.length; x++) {
        if (target==array_list[x]) {
            return true;
        }
    }
    return false;
}

function getScreenWidth() {
     var n = 0;
     if (browser_vendor.indexOf("MICROSOFT") > -1 || browser_vendor.indexOf("MSIE")>-1) {
	 if (screen.AvailWidth)
	     n = screen.AvailWidth;
	else
	    n = document.body.clientWidth; //trunc(screen.availWidth*0.95,0);
    }
    else {
         n = screen.width;
    }
    if (n<200) {
       n = 500;
    }
    return n;
}

function getScreenHeight() {
     var n = 0;
     if (browser_vendor.indexOf("MICROSOFT") > -1 || browser_vendor.indexOf("MSIE")>-1) {
	 if (screen.AvailHeight)
	     n = screen.AvailHeight;
	 else 
		n =  document.body.clientHeight;
    }
    else {
         n = screen.height;
    }
    return n;
}
function getAvailWidth() {
    if (document && document.documentElement && document.documentElement.clientWidth)
	return (document.documentElement.clientWidth);

    if (navigator.appName.toUpperCase().indexOf("MICROSOFT")>-1) {
	scroll_bar_width = 20;
	try {
	    if (typeof document.body != "undefined") {
		avail_width = document.body.offsetWidth-scroll_bar_width;
	    }
	    else {
		avail_width=document.documentElement.offsetWidth;
	    }
	}
	catch (ex) {
	    if (DEBUG_BASIC)
		alert(ex);
	}
    }
    else {
	scroll_bar_width=16;
	avail_width = window.innerWidth-scroll_bar_width;
    }
    return avail_width;
}

function getAvailHeight() {
    if (document && document.documentElement && document.documentElement.clientHeight)
	return (document.documentElement.clientHeight);

    if (navigator.appName.toUpperCase().indexOf("MICROSOFT")>-1) {
	var scroll_bar_width="10";
	if (document.body && document.body.offsetHeight)
	    return (document.body.offsetHeight - scroll_bar_width);
	else if (document.documentElement.offsetHeight)
	    return (document.documentElement.offsetHeight - scroll_bar_width);
	else
	    return null;
    }
    else {
	scroll_bar_width=16;
	avail_height = window.innerHeight-scroll_bar_width;  // for the scroll bar
    }
    return avail_height;
}

function newWindow2(s,t,l,pcnt) {
    var w = Math.round(getAvailWidth() * (pcnt/100));
    var h = Math.round(getAvailHeight() * (pcnt/100));
    var pwin = this;
    var xpos=getLeftOffset();  
    var ypos=getTopOffset();
    this.setTimeout("window.scrollTo("+xpos+","+ypos+");",1000);
    try {
        var xwin = window.open(encodeURI(s),"","width="+w+",height="+h+",top=" + t + ",left=" + l + ",screenX="+l+",screenY=" + t + ",scrollbars=yes,menubar=yes,resizable=yes,toobar=yes,location=yes");
        if (!xwin) {
            alert ("You may have popup blocking enabled, preventing you from seeing this window.  Please disable popup blocking for this site and click the link again.");
        }
    }
    catch (ex) {
        alert (ex.toString());
    }
    return xwin;
}

function newWindow3(s,t,l,pcnt,frame_title) {
    var w = Math.round(getScreenWidth() * (pcnt/100));
    var h = Math.round(getScreenHeight() * ((pcnt-10)/100));
    var pwin = this;
    var xpos=getLeftOffset();  
    var ypos=getTopOffset();
    this.setTimeout("window.scrollTo("+xpos+","+ypos+");",1000);
    try {
        var xwin = window.open(encodeURI(s),"","width="+w+",height="+h+",top=" + (t) + ",left=" + (l) + ",screenX="+(l)+",screenY=" + (t) + ",scrollbars=yes,resizable=yes,location=no,toolbar=no");
        if (!xwin) {
            alert ("You may have popup blocking enabled, preventing you from seeing this window.  Please disable popup blocking for this site and click the link again.");
        }
	else {
	    if (!xwin.opener)
		xwin.opener=window;
	}
    }
    catch (ex) {
        alert (ex.toString());
    }
    return xwin;
}

function writeMessage (data) {
    try {
	if (writeMessage.ndx == "undefined" || !writeMessage.ndx)
	    writeMessage.ndx = 1;
	else
	    writeMessage.ndx++;
	this.div_id = "wm_"+(writeMessage.ndx);
	this.new_div = document.createElement("div");
	this.header_div = document.createElement("div");
	this.content_div = document.createElement("div");
	this.close_button_id="clbtn_"+(writeMessage.ndx);
	this.new_div.id=this.div_id;
	this.new_div.style.position="absolute"; 
	this.new_div.style.width="55%"; 
	this.new_div.style.height="60%"; 
	this.new_div.style.zIndex="4500";
	this.new_div.style.border="3px ridge green";
	this.new_div.style.overflow="hidden";
	this.new_div.style.marginLeft="25%";
	this.new_div.style.backgroundColor="rgb(225,225,255)";
	this.content_div.style.overflow="scroll";
	this.content_div.style.width="100%";
	this.content_div.style.position="relative"; 
	this.content_div.style.height="95%";
	this.header_div.style.position="relative"; 
	this.header_div.style.width="100%";
	this.header_div.style.height="16pt";
	this.header_div.style.backgroundColor="rgb(50,200,50)";
	var txt1='<div style="float:right;"><input id="'+this.close_button_id+'" type="button" value="Dismiss" style="background-color:black; color:white; font-size:8pt;" /></div>';
	setTimeout('document.getElementById("'+this.close_button_id+'").onclick=function(){var d = document.getElementById("'+this.div_id+'"); d.parentNode.removeChild(d);};',1500);
	this.header_div.innerHTML=txt1;
	this.content_div.innerHTML = data;
	this.new_div.appendChild(this.header_div);
	this.new_div.appendChild(this.content_div);
	document.body.appendChild(this.new_div);
    }
    catch (ex) {
	alert (ex);
    }
    return true;
}

/*
function writeExternWin (win,data) {
    try {
	var d = win.document;
	var new_div = d.createElement("div");
	new_div.style.position="absolute"; 
	new_div.style.width="100%"; 
	new_div.style.height="100%"; 
	new_div.style.backgroundColor="white";
	new_div.style.zIndex="4500";
	//new_div.innerHTML = data;
	d.writeln(data);
	//new_div.appendChild(d.createTextNode(data));
	//d.body.appendChild(new_div);
	d.close();
    }
    catch (ex) {
	alert (ex);
    }
}
*/

function writeXwin (win,data) {
    try {
	var d = win.document;
	var new_div = d.createElement("div");
	new_div.style.position="absolute"; 
	new_div.style.width="100%"; 
	new_div.style.height="100%"; 
	new_div.style.backgroundColor="white";
	new_div.style.zIndex="4500";
	//new_div.innerHTML = data;
	d.writeln(data);
	//new_div.appendChild(d.createTextNode(data));
	//d.body.appendChild(new_div);
	d.close();
    }
    catch (ex) {
	alert (ex);
    }
}


function increaseFont (id) {
    var d = document.getElementById(id);
    if (d) {
	try {
	    var n = parseFloat (d.style.fontSize);
	    d.style.fontSize=(n + 0.1)+"em";
	}
	catch (e) {
	    ;
	}
    }
}

function decreaseFont (id) {
    var d = document.getElementById(id);
    if (d) {
	try {
	    var n = parseFloat (d.style.fontSize);
	    d.style.fontSize=(n - 0.1)+"em";
	}
	catch (e) {
	    ;
	}
    }
}

//****************** cookies **********************
function getCookieVal(offset) {
    var endstr=document.cookie.indexOf(";",offset);
    if (endstr==-1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset,endstr));
}
function getCookie (name) {
    var arg=name+"=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i=0;
    while (i<clen) {
        var j = i+alen;
        if (document.cookie.substring(i,j)==arg) {
            return getCookieVal(j);
        }
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0)
            break;
    }
    return null;
}
function getCookie2 (name){return getCookie(name);}
function setCookie (name,value){setCookie2(name, value, null, "/", "umd.edu", false);}
function setCookie2 (name, value, expires, path, domain, secure) {
    document.cookie=name+"="+escape(value)+
    ((expires) ? "; expires="+expires : "")+
    ((path) ? "; path=" +path : "")+
    ((domain) ? "; domain="+domain : "")+
    ((secure) ? "; secure" : "");
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
	try {
	    document.cookie = name + "=" +
	    ((path) ? "; path=" + path :"") +
	    ((domain) ? "; domain=" + domain : "") +
	    "; expires=Sun, 01-Jan-70 00:00:01 GMT";
	    return true;
	}
	catch (ex) {
	    alert (ex);
	}
    }
    return false;
}

function setMysqlCookie (m_id, m_pw, m_server, m_def_db) {
    var k = "mysql_cookie="+escape(m_id+"!"+m_pw+"!"+m_server+"!"+m_def_db)+";path=/;domain=umd.edu;secure=true;";
    document.cookie=k;
    return k;
}

function getMysqlCookie (cookie_name) {
    if (document.cookie) {
        var s = getCookie(cookie_name);
        var ar = String(s).split('!');
        var obj = new Object();
        if (ar.length > 0)
            obj.mysql_id = ar[0];
        if (ar.length > 1)
            obj.mysql_pw = ar[1];
        if (ar.length > 2)
            obj.mysql_server = ar[2];
        if (ar.length > 3)
            obj.default_db = ar[3];
        return (obj);
    } // document.cookie
    return null;
}

function getElementWidth (ElemID) {
    var d = document.getElementById(ElemID);
    if (d) {
	if (d.style.pixelWidth)
	    return d.style.pixelWidth;
	else if (d.offsetWidth)
	    return d.offsetWidth;
    }
    return null;
}

function getElementHeight (ElemID) {
    var d = document.getElementById(ElemID);
    if (d) {
	if (d.style.pixelHeight)
	    return d.style.pixelHeight;
	else if (d.offsetHeight)
	    return d.offsetHeight;
    }
    return null;
}

function getElementPosition(ElemID) {
    var OffsetTrail = document.getElementById(ElemID);
    var OffsetLeft =0;
    var OffsetTop = 0;
    while (OffsetTrail) {
        OffsetLeft += OffsetTrail.offsetLeft;
        OffsetTop += OffsetTrail.offsetTop;
        OffsetTrail = OffsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") {
        OffsetLeft += document.body.leftMargin;
        OffsetTop += document.body.topMargin;
    }
    return {left:OffsetLeft, top:OffsetTop};
}

function setHTMLContent(Elem,text) {
    // assign text to an element
    var e = Elem;
    if ((typeof "Elem").toUpperCase() == "STRING")
        e = document.getElementById(Elem);
    if (e) {
        // remove current content
        while (e.childNodes.length > 0) {
            e.removeChild(e.firstChild);
        }
        // add new content
        e.innerHTML=text;
    }
}
        

function setText(Elem,text) {
    // assign text to an element
    var e = Elem;
    if ((typeof Elem).toUpperCase() == "STRING")
        e = document.getElementById(Elem);
    if (e) {
        var tnode = document.createTextNode(text);
        if (tnode) {
            while (e.childNodes.length > 0) {
		e.removeChild(e.firstChild);
            }
            e.appendChild(tnode);
        }
    }
}


function getTopOffset(){
    if (navigator.appName == "Microsoft Internet Explorer") {
        if (document.compatMode && document.compatMode == 'BackCompat') {
            if (document.body && typeof document.body.scrollTop != 'undefined') {
            return (document.body.scrollTop);
            }
        }
        else if (document.compatMode && document.compatMode == 'CSS1Compat') {
            if (document.documentElement && typeof document.documentElement.scrollTop != 'undefined')
                return (document.documentElement.scrollTop);
        }
    }
    else {
        return (window.pageYOffset);
    }
    return (0);
}

function getLeftOffset(){
    if (navigator.appName == "Microsoft Internet Explorer") {
        if (document.compatMode && document.compatMode == 'BackCompat') {
            if (document.body && typeof document.body.scrollLeft != 'undefined') {
                return (document.body.scrollLeft);
            }
        }
        else if (document.compatMode && document.compatMode == 'CSS1Compat') {
            if (document.documentElement && typeof document.documentElement.scrollLeft != 'undefined')
                return (document.documentElement.scrollLeft);
        }
    }
    else {
        return (window.pageXOffset);
    }
    return (0);
}

function freezeScreen(time_out) {
    var x=getLeftOffset();
    var y = getTopOffset();
    var delay=10;
    if (time_out)
	delay=time_out;
    window.setTimeout("window.scrollTo('"+x+"','"+y+"');",delay);
}

function getScrollPosition() {
    var x = getLeftOffset();
    var y = getTopOffset();
    return ({x:x, y:y});
}

function setScrollPosition (o) {
    window.scrollTo(o.x, o.y);
}

function moveTo (id, left, top) {
    if (document.getElementById(id)) {
        var d = document.getElementById(id);
        d.style.top = top+"px";
        d.style.left = left+"px";
    }
}


var debug_cnt  = 0;
function moveToRelative (id, left, top) {
    // adjusts for relative position on the visible area of the screen
    if (document.getElementById(id)) {
        var d = document.getElementById(id);
        var t = getTopOffset();
        var l = getLeftOffset();
        if (d!=null && t!=null && l!=null) {
            if (top!=null)
                d.style.top = (top+t)+"px";
            if (left!=null)
                d.style.left = (left+l)+"px";
        }
    }
}

function slideBlock (slide_div_id, direction, increment) {
    var mds = document.getElementById(slide_div_id);
    if (mds) {
        var cur_top = this.parseInt(mds.style.top);
        if (this.isNaN(cur_top))
            new_top=0;
        else
            new_top = cur_top;
        if (direction.toUpperCase()=="UP") 
            new_top -= increment;
        else
            new_top += increment;
        mds.style.top=(new_top)+"px";
    }
}


function toggleDisplay (elem) {
    var e = elem;
    var ret = false;
    if (typeof elem == "string")
        e = document.getElementById(elem);
    if (e) {
        if (e.style.display=="none") {
            ret = true;
            e.style.display = "block";
        }
        else
            e.style.display = "none";
    }
    return (ret);
}

function setDisplay (elem, dis) {
    var e = elem;
    var ret = false;
    if (typeof elem == "string")
        e = document.getElementById(elem);
    if (e) {
        e.style.display=dis;
        return true;
    }
    return false;
}

//*********************** string functions **********************
    function isDigit (c) {
	if (String("1234567890.").indexOf(c)>=0)
	    return true;
	else
	    return false;
    }
    
    function insertStr (s,pos,c) {
	alert (s.substring(0,pos)+c+s.substring(pos+1));
	return (s.substring(0,pos)+c+s.substring(pos+1));
    }

    function saveMoney(s) {
	var r = "";
	for (var x=0; x<s.length; x++) {
	    if (isDigit(s.charAt(x)))
		r = r+s.charAt(x);
	}
	return r;
    }
    
    function displayMoney(s) {
	/*
	try {
	    var n = s.indexOf(".");
	    var sx="";
	    if (n<0)
		sx=s+".00";
	    else if (n==s.length-1)
		sx=s+"00";
	    else if (n==s.length-2)
		sx=s+"0";
	    else
		sx=s;
	    var z = sx.substring(sx.indexOf("."));
	    var i=0;
	    for (var x=s.indexOf(".")-1; x>=0; x--) {
		if ((i % 3)==0 && x<s.indexOf(".")-2)
		    z=","+z;
		i++;
		z= sx.charAt(x)+z;
	    }
	    return (z);
	}
	catch (ex) {
	    ;
	}
	*/
	return (s);
    }



    function displayDate(s) {
	// convert yyyymmdd to mm/dd/yyyy
	if (s.length>=6 && s.indexOf("/")<0 && s.indexOf(".")<0) {
	    //verifycontains numbers only
	    try {
		var m = s.substring(4,6);
		var d = s.substring(6);
		if (d.length<2)
		    d="0"+d;
		var y = s.substring(0,4);
		return (m+"/"+d+"/"+y);
	    }
	    catch (ex) {
		return (ex);
	    }
	}
	return (s);
    }
    function saveDate(s) {
	// convert from mm/dd/yyyy to yyyymmdd
	if (s.length>=6 && s.indexOf("/")>=0) {
	    var n1 = s.indexOf("/");
	    var n2 = s.indexOf("/",n1+1);
	    /*
	    if (s.indexOf("-")>=0) {
		n1 = s.indexOf("-");
		n2 = s.indexOf("-",n1+1);
	    }
	    */
	    if (n1>-1 && n2>-1) {
		var y = (String(s)).substring(n2+1);
		if (y.length<4)
		    y="20"+y;
		var m = (String (s)).substring(0,n1);
		if (m.length<2)
		    m="0"+m;
		var d = (String(s)).substring(n1+1,n2);
		if (d.length<2)
		    d="0"+d;
		return ((y)+(m)+(d));
	    }
	}
	return (s);
    }
    function blankForm (form) {
	var prev_recid = form.RecID.value;
	for (var x=0; x<form.elements.length; x++) {
	    if (form.elements[x].type == "button")
		;
	    else if (form.elements[x].type=="checkbox")
		form.elements[x].checked = false;
	    else if (form.elements[x].type=="radio") {
		for (var i=0; i<form.elements[x].length; i++)
		    form.elements[x].checked = false;
	    }
	    else 
		form.elements[x].value="";
	}
	//showCurrentRecID();
	//form.RecID.value="-1";
	return prev_recid;
    }
    

function replaceStringAll(str, target, replacement) {
    var s = new String(str);
    var n = s.indexOf(target);
    while (n > -1) {
        var s1 = s.substring(0,n);
        var s2 = s.substring(n+target.length);
        s= new String(s1+s2);
        n=s.indexOf(target);
    }
    return (String(s));    
}

function trim (str) {
    // remove leading and trailing whitespaces
    var s = new String(str);
    while (s.charAt(0)==' ' || s.charCodeAt(0)==10 || s.charCodeAt(0)==13 || s.charCodeAt(0)==0x4 || s.charCodeAt(0)==0x5)
        s = String(s).substring(1);
    while (s.charAt(s.length-1)==' ' || s.charCodeAt(s.length-1)==10 || s.charCodeAt(s.length-1)==13 || s.charCodeAt(0)==0x4 || s.charCodeAt(0)==0x5)
        s = String(s).substring(0,s.length-2);
    return (s);
}

function chomp (str) {
    // remove leading and trailing cr+lf
    var s = new String("");
    for (var x=0; x<str.length; x++)
        if (str.charCodeAt(x)!=0x10 && str.charCodeAt(x)!=0x13)
            s += str.charAt(x);
    return (s==null?"":s);
}

    function printData (str) {
	if (typeof str != "undefined") {
	    var win = newWindow3("",0,-2000,2);
	    writeExternWin(win,str);
	    win.print();
	    win.close();
	}
    }

    function writeExternWin (win,data) {
	try {
	    var d = win.document;
	    var new_div = d.createElement("div");
	    new_div.style.position="absolute"; 
	    new_div.style.width="100%"; 
	    new_div.style.height="100%"; 
	    new_div.style.backgroundColor="white";
	    new_div.style.zIndex="4500";
	    new_div.innerHTML = data;
	    d.body.appendChild(new_div);
	}
	catch (ex) {
	    alert (ex);
	}
    }


//********************* MATH FUNCTIONS ***********************

function trunc(n,len) {
    var s = null;
    if (typeof n == "string")
        s = n;
    else
        s = Number(n).toString();
    return (parseInt(String(s).substr(0,len)));
}

function getPseudoRandom(max, exclude_list) {
    var places = Number(max).toString().length;
    var n = trunc(Math.random() * Math.pow(10,places),places);
    if (exclude_list) {
	do {
	    while (n  > max)
		n = trunc(Math.random() * Math.pow(10,places),places);
	} while (inList(n,exclude_list));
	exclude_list.push(n);
    }
    else {
	while (n  > max)
	    n = trunc(Math.random() * Math.pow(10,places),places);
    }
    return (n);
}

//************************** HTTP FUNCTIONS ********************
function getQueryString () {
    return (location.href.substring(location.href.indexOf("?")+1));
}

function getParameter (param_name) {
    var query_string = location.href.substring(location.href.indexOf("?")+1);
    var pname = null;
    if (query_string) {
        var plist = new Array();
    }
    return (pname);
}


function resizeDisplayImgWidth(ImgName,i) {
   var Span = document.getElementById(ImgName);
   var Img = document.images[ImgName];
   if (Span && Img) {
      Span.style.width= (i)+"px";
      Img.width=(i);
   }
}

// *************** browser functions ************

    function killEvent(evt) {
        evt = (evt)?evt:((window.event)?event:null);
	// msie
	evt.cancelBubble = true;
	evt.returnValue = false;

	// Firefox.
	if (evt.stopPropagation) {
	    evt.stopPropagation();
	    evt.preventDefault();
	}
	return false;
    }



function blockImgRCEvents(evt) {
    evt=(evt?evt:event);
    // var blockit=false;
    var elem = (evt.target?evt.target:(evt.srcElement?evt.srcElement:null));
    if (elem && elem.tagName && elem.tagName.toLowerCase()=="img") {
        if (evt.cancelBubble)
            evt.cancelBubble=true;
        return false;
    }
    else
	return true;
}
//document.oncontextmenu=blockImgRCEvents;


function webStats(java_path) {
    try {
	var param = "page_called="+window.location;
	ajaxCall(java_path+"/web_stats.jsp",param,"webStatsReturn");
    }
    catch (ex) {
	;
    }
}
function webStatsReturn() {
    if (webStatsReturn.xobj!=null && webStatsReturn.xobj.readyState==4){
	if (String(webStatsReturn.xobj.responseText).indexOf("ERROR::")==0)
	    alert (webStatsReturn.xobj.responseText);
    }
}

//************* object tag functions ************************
	/*
	 <div id="obj_1_div" style="position:absolute; width:100%; height:100%;">
	     <object name="content_obj_1" id="content_obj_1"  type="text/html" width="99%" height="99%" data="./welcome.html">
	    </object>
	</div>
	*/
function changeObjectData (obj_container, obj_id, url) {
    var err = "";
    try {
	var o;
	if (typeof obj_id == "string")
	    o= document.getElementById(obj_id);
	else
	    o=obj_id;
	var o_parent;
	if (typeof obj_id=="string")
	    o_parent= document.getElementById(obj_container);
	else
	    o_parent=obj_container;
	// var url_path = o.data.replace(/[^\/]*$/, "");
	if (o && o_parent) {
	    var dolly = o.cloneNode(true);
	    try {
		dolly.data = url;
		try {
		    o_parent.removeChild(o);
		}
		catch (ex) {
		    changeObjectData.last_error_1=ex;
		}
		o_parent.appendChild(dolly);
		if (dolly.body && dolly.body.scroll)
		    dolly.body.scroll="no";
	    }
	    catch (ex) {
		err += "changeObjectData():\n"+ex;
	    }
	}
	else
	    err += "changeObjectData():\nERROR:: changing object data\n"+(o==null?"obj_id invalid.":"obj_container invalid.");
    }
    catch (ex) {
	err += ex;
    }
    return err;
}


//]]>
