function setdiv2(elementname1, message1, elementname2, message2) {
	document.getElementById(elementname1).innerHTML = message1;
	document.getElementById(elementname2).innerHTML = message2;
}

function setdiv(elementname, message) {
	document.getElementById(elementname).innerHTML = message;
}

function popup_message($msg) {
	alert($msg);
	return true;
}

function DetectBrowser() {
	var temp = navigator.appName;
		temp = temp.toLowerCase();
	if (temp == 'microsoft internet explorer') return 'IE' + navigator.appVersion
	else return 'NS' + navigator.appVersion;
}
//
// Reload the page with the given parameters instead of the current ones
//
function reloadme() {
	document.location.replace("<?php echo $_SERVER['PHP_SELF']; ?>");
}
//
// Reload the page with the given parameters instead of the current ones
//
function reloadmewith(params) {
	document.location.replace("<?php echo $_SERVER['PHP_SELF']; ?>?" + params);
}
//
// Change the source picture of a given image
//
function rollover(imagename, newimage, statusmessage) {
		if(document.images != null) {
				document[imagename].src = newimage;
				window.status = statusmessage;
		}
		return true;
}
//
// Change the value of the userform field "action" to the given value and submit the form
//
function changeactionandsubmit(newaction) {
	document.userform.action.value = newaction;
	document.userform.submit();
}
function togglecheckbox(boxName) {
	document.userform.elements[boxName].checked =
		!document.userform.elements[boxName].checked;
}
//
// Sets the given userform's field to the given value
//
function setformvalue(name, value, caseSensitive) {
	var oList = document.userform.elements[name];
	var sTestValue = (caseSensitive ? value : value.toLowerCase());
	var sListValue;
	// Ok, it's not a SELECT so just try to set the.value property
	if(oList.type!="select-one") {
		oList.value = value;
		return;
	}
	for (var i = 0; i < oList.options.length; i++)
	{
		sListValue = (caseSensitive ? oList.options[i].text :
		// Change text to value if you wish to compare by value of listbox.
		oList.options[i].text.toLowerCase());
		if (sListValue == sTestValue) {
			oList.selectedIndex = i;
			break;
		}
	}
}
//
// Confirm the request to reset the form before actually resetting it
//
function confirmreset() {
	if(confirm("Are you sure you want to reset the values on this form?\n" +
		"ALL CHANGES WILL BE LOST!"))
		document.userform.reset();
}

//-------------------------------------------------------------------------------------
//
// Julian Date conversion routines
//
//-------------------------------------------------------------------------------------
function calculateJD(calendarDate) {
   cdDate = new Date(calendarDate)
   year = cdDate.getYear()          //added + 1900 10/03/2003
   if (year < 1000 ) {year+=1900}  // modified 10/03/2003
   //year = 1900+cdDate.getYear()
   month = cdDate.getMonth() + 1 //getMonth() returns 0-11
   day = cdDate.getDate()
   hour = cdDate.getHours()
   min = cdDate.getMinutes()
   sec = cdDate.getSeconds()
   univTime = hour+(min/60)+(sec/3600)
   if ((100*year+month-190002.5) >= 0) {sign = 1}
      else {sign = -1}
   with (Math) {
      part1 = 367 * year
      part2 = floor((7*(year+floor((month+9)/12)))/4)
      part3 = day+floor((275*month)/9)
      part4 = 1721013.5+(univTime/24)
      part5 = 0.5*sign
      jd = part1-part2+part3+part4-part5+0.5
   }
   return jd
}

function calculateCD(julianDate) {
   with (Math) {
      X = parseFloat(julianDate)+0.5
      Z = floor(X)
      F = X - Z
      Y = floor((Z-1867216.25)/36524.25)
      A = Z+1+Y-floor(Y/4)
      B = A+1524
      C = floor((B-122.1)/365.25)
      D = floor(365.25*C)
      G = floor((B-D)/30.6001)
      month = (G<13.5) ? (G-1) : (G-13)
      year = (month<2.5) ? (C-4715) : (C-4716)
      month -= 1 // month in JavaScript is from 0 to 11
      UT = B-D-floor(30.6001*G)+F
      day = floor(UT)
      UT -= floor(UT)
      UT *= 24;
      hour = floor(UT)
      UT -= floor(UT)
      UT *= 60
      minute = floor(UT)
      UT -= floor(UT)
      UT *= 60
      second = round(UT)
   }
   cdDate = new Date(Date.UTC(year, month, day, hour, minute, second))
   return cdDate.toGMTString()
}

