
	// private only... do not use
	function formVarsFromArray(arr,killCR) {
		var i,ct,inp,vars='',val;
		for (i=0,ct=arr.length; i<ct; ++i) {
			inp = arr[i];
			val = killCR ? inp.value.replace(/[\n\r]/g,'~~') : inp.value;	// replaces CR with ~~ (if requested)
			val = val.replace(/ /g,'+');
			vars+=inp.getAttribute("name")+"="+escape(val)+"&";
		}
		return vars;
	}

// return all inputs, selects, and textareas in VAR=VALUE format
function getFormVars(f) {
	var npts = f.getElementsByTagName("input"),
		slcts = f.getElementsByTagName("select"),
		txts = f.getElementsByTagName("textarea");
	return	formVarsFromArray( npts,false) +
			formVarsFromArray( slcts,false) + 
			formVarsFromArray( txts,true);		// textareas get their CRs replaced
}


//----------- SPECIAL PURPOSE ----------

// ensure that the exp-date is formatted according to Starr/Vindi requireiments: MM/YYYY
// this must be linked to an onchange event.
//
// CODE COPIED into /GM/expiry-date.asp
//
function expiryChanged(obj) {
	var val = obj.value + '', arr, i, ct, s='';
	
	// replace dashes, dots, or backslashes with forward slashes. then replace the first
	// space with a slash (if it's inside the text). then remove all remaining white space
	//
	val = val.replace(/[-\.\\]/g, "/").replace(/\s(\w)/, "/$1").replace(/\s/g, "");
	
	// ensure all pieces are 2 digits long (i.e., "5" => "05")
	arr = val.split("/");
	for ( i=0, ct=arr.length; i<ct; ) {
		if ( arr[i].length == 1) s += '0';
		s += arr[i];
		if ( ++i < ct) s += '/';
	}
	// now fix up "0607" or "062007", or the reverse: "200706"
	if ( ct == 1) {
		if ( s.length == 4 || s.length == 6) {
			if ( /^20/.test(s) )
				s = s.substring(4) + '/' + s.substr(0,4);
			else
				s = s.substr(0,2) + '/' + s.substring(2);
		}
	}
	// fix up "09/01/2008" (eliminate the day)
	else if ( ct == 3) {
		s = s.replace(/\/[^/]*\//,"/");	// replaces /XX/ with /
	}
	// swap around "2009/05"
	s = s.replace( /^(\d{4})\/(\d{1,2})$/, "$2/$1" )	// (4 digits) / (1 or 2 digits)
	
	// and finally...ensure our year is 4 digits
	s = s.replace( /\/([012]\d)$/, "/20$1" )
	obj.value = s;
}


// ensure the user hasn't entered non-numeric characters (spaces and hyphens)
function cardnumChanged(obj) {
	var val = obj.value + '';
	obj.value = val.replace(/[\s-]/g, "");
}

// use these with the "addEvent" method in basics.js
// here, the form elt is "this"
//
function expiryChangeEvent(e) {
	expiryChanged(this);
}
function cardnumChangedEvent(e) {
	cardnumChanged(this);
}