<!--
// JavaScript Document

/*
#########################################################################################
					CONSTANTS
#########################################################################################
*/
var req;

/* 	
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUNCTION: URLEncode 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
function URLEncode(origString)	{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	
	var plaintext = origString;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				/*
				alert( "Unicode Character '" 
						+ ch 
						+ "' cannot be encoded using standard URL encoding.\n" +
						  "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				*/
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	
	//document.URLForm.F2.value = encoded;
	return encoded;
};

/* 	
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUNCTION: clk = Used for click through reporting
			valId: Id of hit
			searchFormName: Which form holds the query
				element?
			queryElementName: What element holds the query
				text?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
function clk(valId) {
	var strUrl 			= encodeURIComponent(document.getElementById(valId).getAttribute("href"));
	var strAnchorText 	= encodeURIComponent(document.getElementById(valId).innerHTML);
	var strQuery 		= encodeURIComponent(document.forms[searchFormName].elements[queryElementName].value);
	strParentSite		= encodeURIComponent(strParentSite);
	strParentURL		= encodeURIComponent(strParentUrl);
	var urlString 		= MY_DOMAIN + "clickTicker.cfm?sf=" + strQuery + "&pa=" + strParentSite + "&upp=" + strParentURL + "&uc=" + strUrl + "&t=" + strAnchorText;
	
	//alert (urlString);
	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		//req.onreadystatechange = processReqChange();
		req.open("GET", urlString , true);
		req.send(null);
				
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			//req.onreadystatechange = processReqChange();
			req.open("GET", urlString , true);
			req.send();
		}
	}
}

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            alert(req.responseText)
        } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
        }
    }
}

/* 	
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUNCTION: keyhandler = Used for handling "enter" key
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
function keyhandler(e) {
	if (document.layers)
		Key = e.which;
	else
		Key = window.event.keyCode;
	if (Key == 13)
	{
		document.forms[1].elements[4].click();return false;
	}
	else return true;
}

/* 	
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUNCTION: left = Trim left side of string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
function left(str, n)
{
	if (n <= 0)
	{
		return "";
	}
	else if (n > String(str).length)
	{
		return str;
	}
	else
	{
		return String(str).substring(0,n);
	}
}

/* 	
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FUNCTION: right = Trim right side of string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
function right(str, n)
{
	if (n <= 0)
	{
	   return "";
	}
	else if (n > String(str).length)
	{
	   return str;
	}
	else
	{
	   var iLen = String(str).length;
	   return String(str).substring(iLen, iLen - n);
	}
}
//-->