// Cisco.com keyCode Passing Code
//   Acceptable page URLs include SID=, PR_CODE=, and KEYCODE= parameters
//   Registration page URLs include this:
//   onclick="javascript:myLink('http://my.url.com/mypage.html?PRIORITY_CODE=', '000000_00', true);" 

var defaultKeycode = "undefined";

// Extracts the values from the url
function getQueryString() {
	var urlEnd = document.URL.indexOf('?');
	var values = new Array();
	var names;
	if (urlEnd != -1){
		var params = document.URL.substring(urlEnd+1, document.URL.length).split('&');
		for(i=0; i<params.length; i++) {
			names = params[i].split('=');
			values[names[0].toLowerCase()] = names[1];
			}
		}
	return values;
	}

function myLink(target, myKeycode, newWindow) {
	values = getQueryString();
	//Check to see if sid is defined
	var keycode = unescape(values["sid"]);
	if (keycode == 'undefined') {
		// Check to see if "pr_code" parameter exists if "sid" not found.
		keycode = unescape(values["pr_code"]);
		if (keycode == 'undefined') {
			// Check to see if "keycode" parameter exists if "pr_code" not found.
			keycode = unescape(values["keycode"]);
			}
		}
	// Default value for keycode when there is no sid, pr_code, or keycode value found
	if ((keycode == 'undefined') || (keycode == '')) {
		if (myKeycode)
			keycode = myKeycode;
		else
			keycode = defaultKeycode;
		}
	var url = target + keycode;
	if (newWindow)
		window.open(url,'form').focus();
	else
		window.location.href = url;
	}

