
	/**
	 * Keyword Content Function
	 * Purpose: Loads keyword-specific content into any element based on search engine referrer query parameter.
	 * Author:  Think Say Do, LLC, Noblesville, Indiana (http://thinksaydo.com/)
	 * Implementation: DK New Media, LLC (http://www.dknewmedia.com/)
	 */
	function keywordContent(elementID,substitutionHash) {
		keywordFrom = 'referrer';
		keywordParam = 'q|p';
		
		// Get The Keyword Parameter
		var keywordParams = keywordParam.split('|');
		for(i=0;i < keywordParams.length;i++) {
			var keywordParam = keywordParams[i].replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+keywordParam+"=([^&#]*)";
			var regex = new RegExp( regexS );
			if(keywordFrom=='url') {
				var results = regex.exec( window.location.href );
			}
			else {
				var results = regex.exec( document.referrer );
			}
			if(results == null) {
				keywordParam = "";
			} else {
				keywordParam = results[1];
				break;
			}
		}
		var keywordValue = unescape(decodeURIComponent(keywordParam)).toLowerCase().replace(/\+/g,' ');

		// Recognized Keyword, Set Content
		if(keywordValue!=="" && substitutionHash[keywordValue]!==undefined) {
			document.getElementById(elementID).innerHTML = substitutionHash[keywordValue];
			return substitutionHash[keywordValue];
		}

		// Unrecognized Keyword, Set Generic Content
		else if(keywordValue!=="" && substitutionHash[keywordValue]===undefined) {
			document.getElementById(elementID).innerHTML = substitutionHash["_unrecognized"];
			return substitutionHash["_unrecognized"];
		}

		// No Keyword, Set Default Content
		else {
			document.getElementById(elementID).innerHTML = substitutionHash["_none"];
			return substitutionHash["_none"];
		}
	}

	/*
	Example Usage with a phone number:

	keywordContent(
		// load content into this element ID
		'phonenumber',

		{
			// match keywords with content
			"my product name":"18000000001",
			"my company name":"1800000002",
			"my employee name":"18000000003",

			// match unrecognized keywords with content
			"_unrecognized":"18000000004",

			// default content when no keyword present
			"_none":"18000000005"
		}
	);
	
	Example Usage with a coupon code:

	keywordContent(
		// load content into this element ID
		'couponfield',

		{
			// match keywords with content
			"my product name":"COUPON1",
			"my company name":"COUPON2",
			"my employee name":"COUPON3",

			// match unrecognized keywords with content
			"_unrecognized":"COUPON4",

			// default content when no keyword present
			"_none":""
		}
	);
	
	*/

