
function getSelectVal(theElem) {
var idx = theElem.selectedIndex;
var val = theElem.options[idx].value
//alert("SelectedIndex is: " + idx);
//alert("Val is: " + val);
return(val);
}



function getRadioVal(theElems) {
var elem;
var val = "";
var idx;
var numElems = theElems.length;

for (idx=0;idx<numElems;idx++) {
	var theElem = theElems[idx];
	if (theElem.checked == true) {
		val = theElem.value;	
	}
}

return(val);
}



function checkRadio(theElem, elemVal) {
var item;
var elemLength = theElem.length;
var i;
for (i=0;i<elemLength;i++) {
	if (theElem[i].value == elemVal) {
		theElem[i].checked = true;
	}
}


}




function redirectFromSelect(theElem) {
var theURL = getSelectVal(theElem);
document.location.href=theURL;
return(false);
}




function popFromSelect(theElem) {
var theURL = getSelectVal(theElem);
var today = new Date();
var windowName = ("popFromSelect" + today.getTime());
popWindow(windowName, this.window, theURL);
return(false);
}






function fillTodaysDate(theElem) {
var today = new Date();
var theYear = today.getYear();
if (theYear < 1000) {
	theYear += 1900;
}
var theMonth = (today.getMonth() + 1);
var dateval = (theYear + "-" + theMonth + "-" + today.getDate());

theElem.value = dateval;
return(false);
}



function fillCurrentTime(theElem) {
var today = new Date();
var theHour = today.getHours();
var theMinute = (today.getMinutes());
var dateval = (theHour + ":" + theMinute);

theElem.value = dateval;
return(false);
}




function writeWindow(windowname, opener, htmltext, params, focus) {
sWindow = window.open('',windowname,params);
sWindow.document.open();
sWindow.document.write(htmltext);
sWindow.document.close();
if (!focus)  opener.focus(); 
if (focus) sWindow.focus();
return (sWindow);
}

function relocateOpener(targetwindow, newurl) {
targetwindow.document.location.href=newurl;
targetwindow.focus();
return (false);
}

function relocDisplayFrame (theURL) {
//alert("relocating frame to " + theURL);
parent.frames['display'].document.location.href = theURL;
return(false);
}



function popWindow(inWindowname, opener, URL, inParams) {
var defaultParams = "width=740,height=500,scrollbars=yes,menubar=0,location=0,status=1,resizable";
var defaultWindowname = "Popup Window";
var params;
var windowname;

if (!inParams) {
 params = defaultParams;
} else {
 params = inParams;
}
if (!inWindowname) {
 windowname = defaultWindowname;
} else {
 windowname = inWindowname;
}
var uWindow = window.open(URL,windowname,params);
return(false);
}



function popSendEmail(emailaddress) {
var params = ("width=700,height=400,location,resizable,status");
var theURL = ("mailto:" + emailaddress);
//popWindow = window.open(theURL,'EmailSender',params);
//popWindow.opener = this.window;
//popWindow.close();
document.location.href = theURL;
return (false);
}





// UTILITY FOR GETTING JSDATA FROM A POPUP WINDOW.  
// page_jsdata.html contains an init() function that is called onLoad.
//   the jsdata page calls the function loadJSData(dataArray, dataset, datagroup),
//   passing in the array of data, and the dataset/datagroup requested
//   ** it is the responsibility of this page to the call to loadJSData appropriately for this page context

function dataPop(startHTML, theURL, inParams) {
var defaultParams = "top=0,left=0,screenX=0,screenY=0,fullscreen=yes,scrollbars=no,menubar=0,location=0,status=0";
defaultParams += (",width=" + screen.width);
defaultParams += (",height=" + screen.height);
var windowname = "CustomerDataPop";
var params;

if (!inParams) {
 params = defaultParams;
} else {
 params = inParams;
}

var dataPop;

//dataPop = window.open('/html/eng/man/blank.html',windowname,params);
//dataPop.document.open();
//dataPop.document.write(startHTML);
//dataPop.document.close();
//dataPop.document.location.href = theURL;

dataPop = window.open(theURL,windowname,params);

dataPop.opener = this.window;
}




function fixDecimals(value) {
var rv = value;
if (rv == 0) {
	return("0.00");
}
  rv = (rv * 100) + .05;
  rv = parseInt(rv);
  rv = rv / 100;
  rv = "" + (rv);
  var idx = rv.indexOf(".");
  if (idx == (-1)) {
    rv = rv + ".00";
  } else {
  	if (idx == (rv.length-2)) {
    rv = rv + "0";
  	}
  }
return(rv);
}




function confirmWindowClose(msg) {
var retval = true;
var message = "Are you sure you want to close this window?";
if (msg != "") {
	message = msg;
}
retval = confirm(message);
if (retval) {
	if (window.top == window) {
		window.close();
	} else {
		retval = confirm("This window is part of a frameset, Are you sure you want to close the whole frameset?  (cancel to send ONLY THIS FRAME to a blank page)");
		if (retval) {
			top.window.close();
		} else {
			document.location.href = "/html/eng/man/blank.html";
		}
	}
}
return(retval);
}


function writeDumper(theObject) {
var i;
for (i in theObject) {
	document.writeln(i + "=" + theObject[i] + "<br>");
}

}