function showReferralSource(){
	var name = "mssReferrals"; //cookieName
	var days = 30; // days before expiration
	var s1='adid'; // first query string name to check
	var s2='gclid'; // second query string name to check
	var con='content'; // 3rd query string name to check
	var s2val='2999'; // value to return if 2nd name found and first not found
	var emptyval='1000'; // value to return if neither value found
	var pHeader=document.createElement('span'); // creates span that will hold the Priority Code Header
	var pHeadText='Priority Code: '; // the text of the priority code header
	var pSpan=document.createElement('span'); // creates the span that will contain the generated code
	var formField=document.getElementById('prioritycode'); //the form field whose value will be populated with the code
	var pCodeContainer=document.getElementById('pCodeContainer'); //place  <span id="pCodeContainer"></span> on the page where you want the code written
	


	// create cookie assigning name, value and expiration days
	function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/";}
	
	// read cookie by name and list value
	function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null;}
	
	// return value of name/value pair
	function querySt(n) {
		qs = window.location.search.substring(1);
		pairs = qs.split("&");
		for (i=0;i<pairs.length;i++) {
		   pair = pairs[i].split("=");
		   if (pair[0] == n) {return pair[1];}
		}  
		return false;
	}
	
	// apply business logic
	function getValue(){
		var qs=querySt(s1)*1;
		if(qs>999 && qs<10000){
			if(querySt(con)=="Y"){qs=qs+1;}
			return qs;
		}
		else if(querySt(s2)){return s2val;}
		else {return readCookie(name);}
	}
	
	// write appropriate value to cookie
	function writeCookie(){
		var val = getValue();
		if (val>999 && val<10000){createCookie(name,val,days)}
		else{createCookie(name,emptyval,days)}
	}
	writeCookie(); // set cookie
	
	// if form field exists, read cookie and populate field with its value
	if(formField){
		formField.value=readCookie(name);
	}
	// if span exists, read cookie and write priority code message
	if(pCodeContainer){
		pCodeContainer.appendChild(pHeader);
		pHeader.innerHTML=pHeadText;
		pCodeContainer.appendChild(pSpan);
		pSpan.id='priorityCode';
		pSpan.innerHTML=readCookie(name);
	}
}
