function setItemValue(listObject){

	// gets the value of the item
	var toObj = replaceCharacters(listObject.name,"FROM_","TO_");
	var ind = listObject.options.selectedIndex;
	var val = listObject.options[ind].value;
	document.forms["EVENT"].elements[toObj].options[ind].selected =true;
	getTotalPrice();
	return val;
}

function replaceCharacters(conversionString,inChar,outChar)
{
  var convertedString = conversionString.split(inChar);
  convertedString = convertedString.join(outChar);
  return convertedString;
}




<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

function getTotalPrice() {
		var FREQUENCY = document.forms["EVENT"].elements["FREQUENCY"].value; // day, week, month
		var date = new Date();
		var todayMonth = (date.getMonth()+1);
		var todayDay = date.getDate();
		var todayYear = (date.getYear());

		var ems = document.forms["EVENT"].elements["TO_MONTH"].options.selectedIndex;	// month index
		var eds = document.forms["EVENT"].elements["TO_DAY"].options.selectedIndex;	// day index
		var eys = document.forms["EVENT"].elements["TO_YEAR"].options.selectedIndex;	// year index
		var endMonth = 	document.forms["EVENT"].elements["TO_MONTH"].options[ems].value;
		var endDay = 	document.forms["EVENT"].elements["TO_DAY"].options[eds].value;
		var endYear = 	document.forms["EVENT"].elements["TO_YEAR"].options[eys].value;	
		var package = document.forms["EVENT"].elements["PACKAGE"].options.selectedIndex;

		var myToday = todayMonth+"/"+todayDay+"/"+todayYear;
		var myEndDate = endMonth+"/"+endDay+"/"+endYear;
		var myTime = "12:12:12pm";
		
	date1 = new Date();
	date2 = new Date();
	diff  = new Date();

	if (isValidDate(myToday) && isValidTime(myTime)) { // Validates first date 
		date1temp = new Date(myToday + " " + myTime);
		date1.setTime(date1temp.getTime());
	}
	else return false; // otherwise exits

	if (isValidDate(myEndDate) && isValidTime(myTime)) { // Validates second date 
		date2temp = new Date(myEndDate + " " + myTime);
		date2.setTime(date2temp.getTime());
	}
	else return false; // otherwise exits

	// sets difference date to difference of first date and second date

	diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

	timediff = diff.getTime();

	weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
	timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

	days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 
	timediff -= days * (1000 * 60 * 60 * 24);

	hours = Math.floor(timediff / (1000 * 60 * 60)); 
	timediff -= hours * (1000 * 60 * 60);

	mins = Math.floor(timediff / (1000 * 60)); 
	timediff -= mins * (1000 * 60);

	secs = Math.floor(timediff / 1000); 
	timediff -= secs * 1000;

	if(FREQUENCY == "month"){
		var totalDays =  Math.round(((weeks * 7) + days));
		var totalMonths = Math.round((totalDays/30));
		var ramainingDays = totalDays - (Math.round(totalMonths) * 30);
		var dailyPrice = ((PRICES[package] / 30) * ramainingDays);
		var	totalPrice = Math.round(((PRICES[package] * totalMonths) + dailyPrice));
		var priceDetail = "for "+totalMonths + " months, " + days + " days from today";
		document.forms["EVENT"].elements["TOTAL"].value = "$"+ totalPrice;
		document.forms["EVENT"].elements["TOTAL2"].value = priceDetail;	
		document.forms["EVENT"].elements["PRICE_DETAIL"].value = priceDetail;	
		document.forms["EVENT"].elements["TOTAL_PRICE"].value = totalPrice;			
	}else if(FREQUENCY == "day"){
		var totalDays =  Math.round(((weeks * 7) + days));
		var	totalPrice = Math.round(PRICES[package] * totalDays);
		var priceDetail = "for " + totalDays + " days from today";
		document.forms["EVENT"].elements["TOTAL"].value = "$"+ totalPrice;
		document.forms["EVENT"].elements["TOTAL2"].value = priceDetail;	
		document.forms["EVENT"].elements["PRICE_DETAIL"].value = priceDetail;	
		document.forms["EVENT"].elements["TOTAL_PRICE"].value = totalPrice;			
	}else{ // default to weeks
		var dailyPrice = ((PRICES[package] / 7) * days);
		var	totalPrice = Math.round(((PRICES[package] * weeks) + dailyPrice));
		var priceDetail = "for "+weeks + " weeks, " + days + " days from today";
		document.forms["EVENT"].elements["TOTAL"].value = "$"+ totalPrice;
		document.forms["EVENT"].elements["TOTAL2"].value = priceDetail;	
		document.forms["EVENT"].elements["PRICE_DETAIL"].value = priceDetail;	
		document.forms["EVENT"].elements["TOTAL_PRICE"].value = totalPrice;	

	
	}

		//document.forms["EVENT"].elements["NOTE"].value = "package price: "+PRICES[package]+" \n"+" Today: "+myToday+"\nEnd date:"+myEndDate+"\n"+weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds";

	return false; // form should never submit, returns false
}// end dateDiff


function isValidDate(dateStr) {
	// Date validation function courtesty of 
	// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert(dateStr + " Date is not in a valid format.")
		return false;
	}
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
	   }
	}
	return true;
} // end isValidDate

function isValidTime(timeStr) {
	// Time validation function courtesty of 
	// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	if (hour <= 12 && ampm == null) {
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
			alert("You must specify AM or PM.");
			return false;
	   }
	}
	if  (hour > 12 && ampm != null) {
		alert("You can't specify AM or PM for military time.");
		return false;
	}
	if (minute < 0 || minute > 59) {
	alert ("Minute must be between 0 and 59.");
	return false;
	}
	if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
	}
	return true;
} // end isValidTime

//  End -->
