--- asterisk-1.8.2.3/main/features.c	2010-12-09 13:48:44.000000000 -0700
+++ features.c	2011-06-07 08:58:13.505544834 -0600
@@ -743,18 +743,47 @@
 	struct parkeduser *pu;
 	int i, parking_space = -1, parking_range;
 	const char *parkinglotname = NULL;
-	const char *parkingexten;
+	const char *parkingexten, *temp;
 	struct ast_parkinglot *parkinglot = NULL;
 
+
+	/* Park() does not resprect the PARKINGLOT channel variable and ParkAndAnnounce() does.
+	   I would like to change this behavior, so if i have a PARKINGLOT channel variable, use it
+	   even I have a lot already picked out. PCPIII */
+/*	if (peer) {
+		temp = pbx_builtin_getvar_helper(peer, "PARKINGLOT");
+		if (temp) {
+			ast_verb(3, "PCPIII PSR - chan: %s, chanlot: %s, chanvar: %s\n", peer->name, peer->parkinglot, temp);
+		} else {
+			ast_verb(3, "PCPIII PSR - chan: %s, chanlot: %s, no chanvar.\n", peer->name, peer->parkinglot);
+		}
+	}
+	if (chan) {
+                temp = pbx_builtin_getvar_helper(chan, "PARKINGLOT");
+                if (temp) {
+                        ast_verb(3, "PCPIII PSR - chan: %s, chanlot: %s, chanvar: %s\n", chan->name, chan->parkinglot, temp);
+                } else {
+                        ast_verb(3, "PCPIII PSR - chan: %s, chanlot: %s, no chanvar.\n", chan->name, chan->parkinglot);
+                }
+	}	*/
 	if (args->parkinglot) {
 		parkinglot = args->parkinglot;
 		parkinglotname = parkinglot->name;
+//		ast_verb(3,"PCPIII PSR - already have lot.\n");
+		temp = findparkinglotname(chan);
+		if (temp) {
+			parkinglotname = temp;
+			args->parkinglot = NULL;
+		}
 	} else if (peer) {
 		parkinglotname = findparkinglotname(peer);
+//		ast_verb(3,"PCPIII PSR - getting lot name from peer.\n");
 	} else { /* peer was NULL, check chan (ParkAndAnnounce / res_agi) */
 		parkinglotname = findparkinglotname(chan);
 	}
 
+//	ast_verb(3,"PCPIII PSR - name: %s\n", parkinglotname);
+
 	if (!args->parkinglot) {
 		if (parkinglotname) {
 			parkinglot = find_parkinglot(parkinglotname);
@@ -1055,6 +1084,7 @@
 {
 	struct ast_parkinglot *found_lot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, (void *) parkexten);
 
+//	ast_verb(3,"PCPIII parking a call: lot: %s, exten: %s\n", found_lot->name, parkexten);
 	struct ast_park_call_args args = {
 		.timeout = timeout,
 		.extout = extout,
@@ -1079,7 +1109,7 @@
 		args->timeout = timeout;
 		args->extout = extout;
 	}
-
+//	ast_verb(3,"PCPIII: masq_park_call\n");
 	if ((args->pu = park_space_reserve(rchan, peer, args)) == NULL) {
 		if (peer) {
 			ast_stream_and_wait(peer, "pbx-parkingfailed", "");
@@ -1127,11 +1157,13 @@
 /* Park call via masqueraded channel */
 int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout)
 {
+//	ast_verb(3,"PCPIII ast_masq_park_call\n");
 	return masq_park_call(rchan, peer, timeout, extout, 0, NULL);
 }
 
 static int masq_park_call_announce(struct ast_channel *rchan, struct ast_channel *peer, struct ast_park_call_args *args)
 {
+//	ast_verb(3,"PCPIII masq_park_call_announce\n");
 	return masq_park_call(rchan, peer, 0, NULL, 1, args);
 }
 
@@ -1325,6 +1357,7 @@
 {
 	int res = 0;
 
+//	ast_verb(3,"PCPIII parkcall_helper\n");
 	if (args) {
 		ast_debug(1, "Parkinglot specified for builtin_parkcall: %s\n", args->parkinglot->name);
 	}
@@ -4005,6 +4038,7 @@
 	if (!res)
 		res = ast_safe_sleep(chan, 1000);
 
+//	ast_verb(3, "PCPIII park_call_exec\n");
 	/* Park the call */
 	if (!res) {
 		struct ast_park_call_args args = {
@@ -4037,6 +4071,8 @@
 		args.flags = flags.flags;
 
 		args.parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_exten_cb, &orig_exten);
+
+		ast_verb(3,"PCPIII park_call_exec - log: %s, exten: %s\n", args.parkinglot->name, orig_exten);
 		res = masq_park_call_announce(chan, chan, &args);
 		/* Continue on in the dialplan */
 		if (res == 1) {
@@ -4061,14 +4097,30 @@
 	int park = 0;
 	struct ast_bridge_config config;
 	struct ast_parkinglot *parkinglot;
+	const char *temp;
 
 	if (data) {
 		park = atoi((char *) data);
 	}
+	/* The issue I have with this is that it fetches by extension only, no regard to the actual lot.
+	 * This means that all lot slots need to be universally unique. No fun to manage.
+	 * I want this to pay attention to the lot and search it. PCPIII
+	 */
 
-	parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_position_cb, (void *) &park);
-	if (!parkinglot)
+	temp = findparkinglotname(chan);
+	if (temp) {
+		parkinglot = find_parkinglot(temp);
+	} else {
+		ast_verb(3, "PCPIII park_exec_full - did not find a lot name, searching by slot number.\n");
+		parkinglot = ao2_callback(parkinglots, 0, find_parkinglot_by_position_cb, (void *) &park);
+	}
+
+	if (!parkinglot) {
+		ast_verb(3, "PCPIII call back returned nothing\n");
 		parkinglot = default_parkinglot;
+	}
+
+	ast_verb(3,"PCPIII: using lot %s-%s-%s (data: %s)\n", parkinglot->name, parkinglot->parkext, parkinglot->parking_con, data);
 
 	AST_LIST_LOCK(&parkinglot->parkings);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot->parkings, pu, list) {
@@ -4334,6 +4386,8 @@
 				parkinglot->parking_start = start;
 				parkinglot->parking_stop = end;
 			}
+		} else if (!strcasecmp(confvar->name, "parkedmusicclass")) {
+			ast_copy_string(parkinglot->mohclass, confvar->value, sizeof(parkinglot->mohclass));
 		} else if (!strcasecmp(confvar->name, "findslot")) {
 			parkinglot->parkfindnext = (!strcasecmp(confvar->value, "next"));
 		} else if (!strcasecmp(confvar->name, "parkedcalltransfers")) {
@@ -5191,6 +5245,7 @@
 	struct ast_channel *ch1, *ch2;
 	struct ast_park_call_args args = {0,};
 
+//	ast_verb(3,"PCPIII manager_park\n");
 	if (ast_strlen_zero(channel)) {
 		astman_send_error(s, m, "Channel not specified");
 		return 0;
