function updateorderinfo(form){
	form.isUpdate.value = "1";
	if (form.ddate.length > 1){
		for (var i=0; i<form.ddate.length; i++){
			form.ddate[i].value = form.day1[i].value + " " + monthname(form.month1[i].value) + " " + form.year1[i].value;
			form.submit();
		}
	}
	else {
		form.ddate.value = form.day1.value + " " + monthname(form.month1.value) + " " + form.year1.value;
		form.submit();
	}
}

function charcount(obj,num){
	if (obj.value.length > 250){
		alert("The character count of greeting message for item is "+obj.value.length+", which exceeds 250 characters. Please limit your greeting message to 250 characters. ");
		obj.focus();
		obj.value = jtrim(obj.value.substring(0,250));
	}
	else {
		var form = document.frmOrderInfo;
		chkOption(form.txtcnt,num).value = obj.value.length;
	}
}

function chgRecipient(obj,form,num){
	if (obj.selectedIndex==0){
		chkOption(form.recipient,num).value = "";
		chkOption(form.tel,num).value = "";
		chkOption(form.address,num).value = "";
		chkOption(form.postal,num).value = "";
	}
	else {
		var addrbookinfo = obj.options[obj.selectedIndex].value.split("?|?");
		chkOption(form.recipient,num).value = addrbookinfo[0];
		chkOption(form.tel,num).value = addrbookinfo[1];
		chkOption(form.address,num).value = addrbookinfo[2];
		chkOption(form.postal,num).value = addrbookinfo[3];
	}
}

function chkOption(obj,num){
	if (document.frmOrderInfo.recipient.length > 1) return obj[num];
	else return obj;
}

function RecipientUpd(num,upd,rid){
	var form = document.frmOrderInfo;
	form.action = "orderinfo.asp";
	form.recipient_action.value = upd;
	form.recipient_id.value = rid;

	if (upd == "del"){
		var bln = confirm("confirm to delete this recipient info?");
		if (bln){
			var addrbook = chkOption(form.addrbook,num);
			var addrbookinfo = addrbook.options[addrbook.selectedIndex].value.split("?|?");
			form.recipient_id.value = addrbookinfo[4];
			form.submit();
		}
	}
	else if (upd == "upd"){
		var msg = "";
		var focuspost = null;
		form.rec_name.value = chkOption(form.recipient,num).value;
		form.rec_tel.value = chkOption(form.tel,num).value;
		form.rec_address.value = chkOption(form.address,num).value;
		form.rec_postal.value = chkOption(form.postal,num).value;
		if (isWhitespace(form.rec_name.value)){
			msg += "Please enter recipient name.\n"
			if (focuspost==null) focuspost = chkOption(form.recipient,num);
		}
		if (isWhitespace(form.rec_tel.value)){
			msg += "Please enter recipient tel.\n"
			if (focuspost==null) focuspost = chkOption(form.tel,num);
		}
		if (isWhitespace(form.rec_address.value)){
			msg += "Please enter recipient address.\n"
			if (focuspost==null) focuspost = chkOption(form.address,num);
		}
		if (isWhitespace(form.rec_postal.value)){
			msg += "Please enter recipient postal code.\n"
			if (focuspost==null) focuspost = chkOption(form.postal,num);
		}
		if (msg == ""){
			var addrbook1 = chkOption(form.addrbook,num);
			if (addrbook1.selectedIndex==0){
				alert("Please select a recipient.");
				addrbook1.focus();
			}
			else {
				var bln = confirm("confirm to update this recipient info?");
				if (bln){
					var addrbookinfo = addrbook1.options[addrbook1.selectedIndex].value.split("?|?");
					form.recipient_id.value = addrbookinfo[4];
					form.submit();
				}
			}
		}
		else {
			msg = "We are unable to process your request because of the errors below:\n\n" + msg + "\nplease enter or amend the necessary info and submit again."
			alert(msg);
			if (focuspost!=null) focuspost.focus();
		}
	}
	else if (upd == "add"){
		var msg = "";
		var focuspost = null;
		form.rec_name.value = chkOption(form.recipient,num).value;
		form.rec_tel.value = chkOption(form.tel,num).value;
		form.rec_address.value = chkOption(form.address,num).value;
		form.rec_postal.value = chkOption(form.postal,num).value;
		if (isWhitespace(form.rec_name.value)){
			msg += "Please enter recipient name.\n"
			if (focuspost==null) focuspost = chkOption(form.recipient,num);
		}
		if (isWhitespace(form.rec_tel.value)){
			msg += "Please enter recipient tel.\n"
			if (focuspost==null) focuspost = chkOption(form.tel,num);
		}
		if (isWhitespace(form.rec_address.value)){
			msg += "Please enter recipient address.\n"
			if (focuspost==null) focuspost = chkOption(form.address,num);
		}
		if (isWhitespace(form.rec_postal.value)){
			msg += "Please enter recipient postal code.\n"
			if (focuspost==null) focuspost = chkOption(form.postal,num);
		}
		if (msg == ""){
			var bln = confirm("confirm to add this recipient info?");
			if (bln) form.submit();
		}
		else {
			msg = "We are unable to process your request because of the errors below:\n\n" + msg + "\nplease enter or amend the necessary info and submit again."
			alert(msg);
			if (focuspost!=null) focuspost.focus();
		}
	}
}

function populate1(form,objYear,objMonth,objDay,num) {

	timeA = new Date(chkOption(objYear,num).options[chkOption(objYear,num).selectedIndex].text, chkOption(objMonth,num).options[chkOption(objMonth,num).selectedIndex].value, 1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < chkOption(objDay,num).length; i++) {
		chkOption(objDay,num).options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) {
		chkOption(objDay,num).options[i] = new Option(i+1,i+1);
	}
}

