dartCalls = new Array; //To stop the JS error when debugging

//-- HEADER NAVBAR --//

var globalNav = {
	initialize: function(){
		if (!$('globalNav')) {
			return false
	  	}
		this.menu = $('globalNav');
		this.duration = 250;
		this.buttons = [];
		$A(this.menu.getElementsByTagName('li')).each(function(item){
			 if((item.parentNode == this.menu) && (item.id != 'nav-subscribe')) { this.buttons.push($(item)); }
		}.bind(this));
		this.buttons.each(
			function(button) {
				Event.observe(button, 'mouseover', this.expand.bindAsEventListener(this));
				Event.observe(button, 'mouseout', this.collapse.bindAsEventListener(this));
			}.bind(this)
		);
	},
	findButton: function(element) {
		var button = false;
		while(element.parentNode) {
			if(this.buttons.indexOf(element) != -1) { button = element; }
			element = element.parentNode;
		}
		return button;
	},
	findSubmenu: function(element) {
		var button = this.findButton(element);
		var submenu = button.getElementsByTagName('ul')[0];
		return submenu;
	},
	expand: function(event) {
		 var button = this.findButton(event.target || event.srcElement);
		 if(!button.hasClassName('over')) { button.addClassName('over'); }
		 if (navigator.appVersion.match(/\bMSIE\b/)) checkInter("SELECT", false, button);
	},
	collapse: function(event) {
		 var button = this.findButton(event.target || event.srcElement);
		 button.removeClassName('over'); 
		 if (navigator.appVersion.match(/\bMSIE\b/)) checkInter("SELECT", true, button);
	}
}


function globalNavHover() {
	if (document.getElementById("globalNav")) {
		var navElements = $$('#globalNav .topNav div');
		for (var i=0; i<navElements.length; i++) {
			navElements[i].onmouseover = function() {
				if (!$(this).hasClassName('selected') && !$(this).hasClassName('over') ) {
				   $(this).addClassName('over');
				}
				var obj;
				obj = this.up(0).getElementsByTagName("UL");
				if (obj.length > 0) { obj[0].style.left = 'auto'; }
				if (this.getElementsByTagName("LI").length > 0) {
					checkInter("SELECT", false, this);
				}
			}
			navElements[i].onmouseout = function() {
				var obj;
				//this covers the top level elements
				if ($(this).hasClassName('over')) {
				   $(this).removeClassName('over');
				}
				obj = this.up(0).getElementsByTagName("UL");
				if (obj.length > 0) { obj[0].style.left = '-1000px'; }
				if (this.getElementsByTagName("LI").length > 0) {
					checkInter("SELECT", true, this);
				}
			}
		}
	}
}

//checks if nav intersects select boxes
function checkInter(strTag, blnShow, objNav) {
	var sel = document.getElementsByTagName(strTag);
	//Create the intersection array if needed
	if (!objNav.smartIntersect) {
		var arrSel = new Array;
		var objDropR = new Recto(objNav.getElementsByTagName("UL")[0]);	//dropdown list rectangle
		for (var i=0; i<sel.length; i++) {
			var objSelR = new Recto(sel[i]);
			arrSel[i] = RectoInter(objDropR, objSelR)	//check select is under the nav
		}
		objNav.smartIntersect = arrSel;	//asign to DOM object for later access
	}
	//apply the styles to select dropdowns as needed
	for (var i=0; i<sel.length; i++) {
		if (objNav.smartIntersect[i]) {
			sel[i].style.visibility = blnShow ? "visible" : "hidden"; 
		}
	}
}

//Rectangle object constructor, takes any DOM object
function Recto(obj) {
	if (obj) {
		this.left = getParentOffLeft(obj);
		this.top = getParentOffTop(obj);
		this.width = obj.offsetWidth;
		this.height = obj.offsetHeight;
		this.bottom = this.top + this.height;
		this.right = this.left + this.width;
	}
}

//checks to see if two Recto objects intersect
function RectoInter(r1, r2) {
	var inter = false;
	//Find the leftmost etc rectangle. 
	var leftMost = r1.left < r2.left ? r1 : r2;
	var nonLeftMost = r1.left >= r2.left ? r1 : r2;
	var topMost = r1.top < r2.top ? r1 : r2;
	var nonTopMost = r1.top >= r2.top ? r1 : r2;
/*  If the left x co-ordinate of the non-leftmost rectangle is between the 
left and the right of the leftmost rectangle, you have the left cordinate of 
your intersection. If it is to the right you have no intersection, and the 
rectangles don't overlap. */
	if (nonLeftMost.left >= leftMost.left && nonLeftMost.left <= leftMost.right && nonTopMost.top >= topMost.top && nonTopMost.top <= topMost.bottom) inter = true;
	return inter;
}

//returns full offset value of an object on the page
function getParentOffTop(obj) {
	if (obj.offsetParent != null ) {
		return obj.offsetTop + getParentOffTop(obj.offsetParent);
	} else {
		return 0;
	}
}

function getParentOffLeft(obj) {
	if (obj.offsetParent != null ) {
		return obj.offsetLeft + getParentOffLeft(obj.offsetParent);
	} else {
		return 0;
	}
}
//Event.observe(window, 'load', globalNav); //only for IE, FF uses classes

//-- RELOAD ASSETS --//
// This is how to register a hit (and refresh ads) in a JS call
var page = new Object();
var eventList = null;
page.reloadAssets = function() {
    adReloadAll();
    //TrackingObject.setDomain(zagTopDomain);
    //TrackingObject.setNodeId("zagTopHolder");
    //TrackingObject.drawTracking();
    TrackingObject.setDomain(zagDomain);
    TrackingObject.setNodeId("zagHolder");
    TrackingObject.drawTracking();
    urchinTracker();
    if(eventList != null){ eventList.writeJavaScriptTags(); }
}
// This is what's called when a comment is submitted
page.reloadAssetsCommentSubmit = function() {
    adReloadAll();
    TrackingObject.setDomain(zagDomain);
    TrackingObject.setNodeId("zagHolder");
    TrackingObject.setComponentUrl("commentSubmit");
    TrackingObject.drawTracking();
    urchinTracker();
    if(eventList != null){ eventList.writeJavaScriptTags(); }
}
page.reloadAssetsNoEventTracking = function() {
	adReloadAll();
	TrackingObject.drawTracking();
}
var autoRefreshIterations = 0;
function AutoRefreshAssets(seconds, maxIterations) {
  setTimeout("TimedAssetsRefresh(" + seconds + ", " + maxIterations + ")",seconds * 1000);
}
function TimedAssetsRefresh(seconds, maxIterations){
  if (autoRefreshIterations < maxIterations) {
    page.reloadAssetsNoEventTracking();
    ++autoRefreshIterations;
    setTimeout("TimedAssetsRefresh(" + seconds + ", " + maxIterations + ")",seconds * 1000);
  }
}
//-- TRACK CHART COMPONENTS --//
// 
page.trackComponents = function() {
		var strUrl = '';
		for (var i=0; i < arguments.length; i++) {
			strUrl += arguments[i] + ((i == arguments.length-1) ? '' : '/');
		}
		if (strUrl.length != 0) {
			strUrl = 'charts/' + strUrl;
			strUrl = escape(strUrl);
		}
		TrackingObject.setComponentUrl(strUrl);
		TrackingObject.setDomain(zagDomain);
    TrackingObject.setNodeId("zagHolder");
    TrackingObject.drawTracking();
}

page.trackVideo = function() {
		var strUrl = '';
		for (var i=0; i < arguments.length; i++) {
			strUrl += arguments[i] + ((i == arguments.length-1) ? '' : '/');
		}
		if (strUrl.length != 0) {
			strUrl = 'video/' + strUrl;
			strUrl = escape(strUrl);
		}
		TrackingObject.setComponentUrl(strUrl);
		TrackingObject.setDomain(zagDomain);
    TrackingObject.setNodeId("zagHolder");
    TrackingObject.drawTracking();
}


//Email a page launching function
function gotoEmailAFriend(qstring, popup) {
	var strURL = "/content/email/?referringPage="+escape('http://'+location.host)+escape(location.pathname)+qstring;
	if (popup) {
		window.open(strURL);
	} else {
		document.location = strURL;
	}
}

//-- SLIDESHOW POPUP --//
function popUpSlideshow(url) {
	window.open(url, 'portfolio_popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=924,height=594');
}
function popUpInfographic(url) {
	window.open(url, 'portfolio_popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=924,height=594');
}
function popUpVideo(url) {
	window.open(url, 'portfolio_popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=924,height=634');
}
function popUpMedia(url,w,h) {
	if (w > self.screen.availWidth) { w = self.screen.availWidth }
	if (h > self.screen.availHeight) { h = self.screen.availHeight }
	window.open(url, 'portfolio_popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+ w +',height='+ h);
}

//-- SET BREADCRUMB --//
function setBreadcrumb(position, value) {
  document.getElementById('breadcrumb_' + position).innerHTML = value;
}
//-- SET BREADCRUMB --//
function setBreadcrumbTitle(position,value,titleid) {
	setBreadcrumb(position, value)
  document.getElementById(titleid).innerHTML = value;
}

//-- MISC UTILITY --//
function openInParent(url) {
    if (opener != null) {
    	opener.location.href = url;
        window.close();
	}
	else {
		window.location.href = url;
	}
}

//-- FONT SIZER --//
//Global text resizer for toolbar
//size is integer 0, 1, 2
function textSize(size) {
	var divs = document.getElementsByTagName('DIV');
	var ts = document.getElementById("smallimage");
	var tm = document.getElementById("mediumimage");
	var tl = document.getElementById("largeimage");
	var strClass;
	var div;
	
	if (size == 0) {
		ts.src="/images/site/icn/icon_textSize_small_bold.gif";
		tm.src = "/images/site/icn/icon_textSize_medium.gif";
		tl.src = "/images/site/icn/icon_textSize_large.gif";
	}
	
	if (size == 1) {
		ts.src = "/images/site/icn/icon_textSize_small.gif";
		tm.src = "/images/site/icn/icon_textSize_medium_bold.gif";
		tl.src = "/images/site/icn/icon_textSize_large.gif";
	}
	
	if (size == 2) {
		ts.src = "/images/site/icn/icon_textSize_small.gif";
		tm.src = "/images/site/icn/icon_textSize_medium.gif";
		tl.src = "/images/site/icn/icon_textSize_large_bold.gif";
	}
	for (var i=0; i<divs.length; i++) {
		div = divs[i];
		strClass = div.className;
		if (strClass && strClass.indexOf('bodyText') > -1) {
			
			strClass = strClass.replace(new RegExp("mediumText"), "");
			strClass = strClass.replace(new RegExp("largeText"), "");
			switch (size) {
				case 0:
					strClass = strClass.replace(new RegExp("bodyText"), "bodyText");
					break;
				case 1:
					strClass = strClass.replace(new RegExp("bodyText"), "bodyText mediumText");
					break;
				case 2:
					strClass = strClass.replace(new RegExp("bodyText"), "bodyText largeText");
					break;
			}
			div.className = strClass;
		
		}
	}
}
//-- PRINT FUNCTIONS --//
//Opens a popup for the print window
function doPrint() {
	var URL = document.location.href;
	if (URL.indexOf('#') > 0 ) {
		var cleanURL = URL.split("#");
		doPrintURL(cleanURL[0]);	
	}
	else {
		doPrintURL(URL);	
	}
}
function doPrintURL(URL) {
	if (URL.indexOf('?') > 0) {
		URL += '&print=true';
	} else {
		URL += '?print=true';
	}
	window.open(URL, 'print_popup', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1');
}

//Makes the paper come out of the printer
function executePrint() {
	window.print();
}

function writePrintURL() {
	var strHTML = '<div class="printFooterBox"><div class="subHeader">Web address of this article</div>';
	var origURL = document.location.href.replace('#', '').replace('?print=true', '').replace('&print=true', '');
	strHTML += '<a href="' + origURL + '">' + origURL + '</a>';
	strHTML += '</div>';
	document.write(strHTML);
}

function writePrintLinks() {
	var strHTML = '';
	var objTxt = document.getElementById('bodyTextWrapper');
	var objLinks = objTxt.getElementsByTagName('A');
	if (objLinks) {
	  strHTML += '<div class="printFooterBox"><div class="subHeader">Links in this article</div>';
	  for (var i=0; i<objLinks.length; i++) {
	    if (objLinks[i].href) {
	      strHTML += '<div class="linkList"><img src="/images/site/bg/bullet-carved-arrow.gif" height="6" width="5" /><a href="' + objLinks[i].href + '">' + objLinks[i].href + '</a></div>';
	    }
	  }
	  strHTML += '</div>';
	}
	document.write(strHTML);
}

//////////
//Global Pause function
var objPause = new PauseManager();

//Pauses for a set number of milliseconds
//	after which it calls a specified function in the context of the Object passed
function pauseObjectMethod(objObject, objFunction, intMilliSec) {
	var id = objPause.StoreObject(objObject, objFunction);
	window.setTimeout('objPause.Finish(' + id + ');', intMilliSec);
}

//Pause Manager Constructor
function PauseManager() {
	//methods
	this.StoreObject = mtdStoreObject;
	this.Finish = mtdFinish;
	//locals
	var arrObjects = new Array;
	var arrFunctions = new Array;
	
//stores pause details
function mtdStoreObject(objObject, objFunction) {
	//save objects to array
	//we start at the beginning and reuuse first null array
	var next = arrObjects.length;
	OutLoop:
	for (i=0; i<arrObjects.length; i++) {
		if (arrObjects[i] == null) {
			next = i;
			break OutLoop;
		}
	}
	//window.status = 'TEST arrObjects[next] ' + next + '       ' + next;
	arrObjects[next] = objObject;
	arrFunctions[next] = objFunction;
	return next;
}

//finishes pause
function mtdFinish(id) {
	var fn = arrFunctions[id];
	var obj = arrObjects[id];
	//wipe values, but don't delete them or it'll screw up the indexes
	arrFunctions[id] = null;
	arrObjects[id] = null;
	//call function
	fn.apply(obj);
}
}


// Adds trim() function to String class
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function findExternalLinks(elmnt){
	//elmnt = DOM Object ref to element that needs to be parsed through for external links
	var linksArray = elmnt.getElementsByTagName("A");
	for(var idx=0;idx<linksArray.length;idx++){
		if(linksArray[idx].href.indexOf(window.location.host) < 0){
			if((linksArray[idx].href.indexOf("http://") > -1) || (linksArray[idx].href.indexOf("https://") > -1)){
				linksArray[idx].target = "_blank";
				linksArray[idx].setAttribute("target","_blank");
			}
		}
	}
}

var currentPage;
var pages;
var totalPages;
var topNav;
var botNav;
var aID;
var initPage;
function paginateArticle(page,aID,hist){
	pages.each(function(item,indx){
		item.hide();
	});
	if (!pages[page]) { page = 0 }
	pages[page].show();
	updateNav(page);
	currentPage = page;
	if (hist != 'noHist') dhtmlHistory.add("page" + (page + 1), page);	
	return false;
} 

function updateNav(page){
	updateLinks(topNav,page)
	updateLinks(botNav,page)
	if (page != 0) {
		if ($('photo')) $('photo').hide();
		if ($('headDeck')) $('headDeck').hide();
	}
	else {
		if ($('photo')) $('photo').show();
		if ($('headDeck')) $('headDeck').show();
	}
} 
function changePage(lnk) {

	toggleArticleByline('hide');

	pageNumb = this.innerHTML;
	if (pageNumb.length != 1 && pageNumb.indexOf('Next') != -1) {
		pageNumb = currentPage + 1;
	}
	else if (pageNumb.length != 1 && pageNumb.indexOf('Prev') != -1) {
		pageNumb = currentPage - 1;
	}
	else {
		pageNumb = pageNumb-1
	}
	if (this.parentNode.id == 'bottomPagination') $('outerWrapper').scrollTo(); 
	page.reloadAssets();
	paginateArticle(pageNumb,aID);
	toggleArticleByline('show', pageNumb+1);
	
	return false;
}
function updateLinks(links,page){
	var currentSet = Math.ceil((page+1)/4)
	links.each(function(item,indx){
		item.removeClassName('currentPage')
		if ((links.length - 2) > 5) {
			if (  (indx > (currentSet*4) || indx <= ((currentSet-1)*4)) && indx != 1 && indx != links.length -2 ) {
				item.setStyle({display:'none'});
			}
			else {
				item.setStyle({display:'inline'});
			}
		}
		if (indx == 0 && page == 0) {
			item.setStyle({display:'none'});
		}
		else if (indx == 0 && page != 0) {
			item.setStyle({display:'inline'});
		}
		if ((indx + 1) == links.length && ((page + 1) == totalPages) ) {
			item.setStyle({display:'none'});
		}
		else if ((indx + 1) == links.length ) {
			item.setStyle({display:'inline'});
		}
		if ((indx + 1) != links.length && indx != 0 && ((page+1) == indx)) {
			item.addClassName('currentPage')
		}
	});
	var dots = $$('#'+ links[0].parentNode.id +' span')
	dots.each(function(dot,indx){
		dot.remove()
	});
	if ((links.length - 2) > 5 && page < 4 ) {
		new Insertion.After(links[links.length - 3], "<span> &hellip; </span>")
	}
	else if (((links.length - 2) > 5 && (links.length - 2) > 8 ) && page > 3 && page >= ((currentSet-1)*4) && page <= (links.length - 5)) {
		new Insertion.After(links[1], "<span> &hellip; </span>")
		new Insertion.After(links[links.length - 3], "<span> &hellip; </span>")
	}	
	else if ((links.length - 2) > 5 && page >= ((currentSet-1)*4) ) {
		new Insertion.After(links[1], "<span> &hellip; </span>")
	}	
	
} 
function showAll() {
	//handles the byline at the bottom of the page
	toggleArticleByline('show');	
	if ($('photo')) $('photo').show();
	if ($('headDeck')) $('headDeck').show();
	pages.each(function(item){
		item.show();
	});
	$('outerWrapper').scrollTo()
	$('toolPagination').hide();
	$('bottomPagination').hide();	
	$('viewAll').hide();
	return false
}
function setupPagination(articleID) {

	//handles the byline at the bottom of the page
	toggleArticleByline('hide');

	pages = $$('.articlePage');
	totalPages = pages.length;
	topNav = $$('#toolPagination a');
	botNav = $$('#bottomPagination a');	
	var topLinks = $$('#toolPagination a','#bottomPagination a');
	topLinks.each(function(item,indx){
		item.onclick = changePage;
	});
	pages.each(function(item,indx){
		item.id = 'pageNo'+ indx;
	});
	$('viewAll').onclick = showAll;
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(historyChange);
	aID = articleID.substr(0, 20);
	if (window.location.hash != '' && window.location.hash.indexOf('page') != -1){
		var newPage = window.location.hash.substr(window.location.hash.length-1, 1);
		currentPage = newPage - 1;
		initPage =  newPage - 1;
		paginateArticle((newPage - 1), aID,'noHist');
		
		toggleArticleByline('show', newPage);
	}
	else {
		initPage = 0;
		paginateArticle(0, aID,'noHist')
	}
}
function historyChange(newLocation,historyData) {
	if (historyData == null ) { 
		historyData = initPage; 
	}
	paginateArticle( historyData, aID , 'noHist')
}

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=/";
}

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;
}

function countLetters(textObj, maxNum, divName, divName1){
	var currentCount = textObj.value.length;
	var currentCountMax = maxNum;
	if(currentCount > maxNum){
		textObj.value = textObj.value.substr(0,maxNum);
		currentCount = textObj.value.length;
	}	
	if (divName1) {
		currentCountMax = maxNum - currentCount;
		var outputDiv1 = document.getElementById(divName1);
		outputDiv1.innerHTML = currentCountMax;
	}
	
	var outputDiv = document.getElementById(divName);
	outputDiv.innerHTML = currentCount;
}

var socialShare = {
	initialize: function(){
		this.share = $('socialShare');
		this.caller = '';
		this.newTimer = null;
		if (this.share != null) {
			Event.observe('socialShare', 'mouseover', function(){ socialShare.showObj(); return false; },false);
			Event.observe('socialShare', 'mouseout', function(){ socialShare.initHide(); return false; },false);
		}
		this.showIt = function(){ socialShare.showObj(); return false; };
	},
	moveObject: function(target) {
		if (this.share != undefined) {
			this.caller = $(target.id);
			if (this.newTimer != null) { clearTimeout(this.newTimer) }
			var pos = Position.cumulativeOffset(this.caller);
			var xPos = pos[0];
			var yPos = pos[1] + this.caller.up(0).getHeight();
			if (this.caller.up(0).id == 'captionRight' || this.caller.up(1).hasClassName('marketEcom-toolbar') ||  this.caller.up(1).id == 'mm-share') xPos = xPos - 141;
			if (this.caller.hasClassName('share')) this.caller.addClassName('over');
			if (this.caller.up(0).hasClassName('toolShare')) this.caller.up(0).setStyle({ backgroundColor: '#f2f1ef'});
			this.share.setStyle({
			  left: xPos +'px',
			  top: yPos +'px'
			});
			this.share.setStyle( {
			 visibility:'visible'
			})
			Event.observe(this.caller.id, 'mouseover',  this.showIt ,false);
		}
		var popAdFunc = getPopupAdFunction('socialShare');
        if (popAdFunc != null) {
            popAdFunc();
        }
		page.reloadAssets();
	},
	initHide: function(target) {
		if ( target ) this.caller = $(target.id);
		this.newTimer = setTimeout("socialShare.hideObj()",250);
	},
	showObj:function() {
		if (this.share != undefined) {
			if (this.newTimer != null) { clearTimeout(this.newTimer) }
			this.share.setStyle( {
			 visibility:'visible'
			})
		}
	},
	hideObj: function(target) {
		if (this.share != undefined) {
			this.share.setStyle( {
			 visibility:'hidden'
			})
			this.caller.up(0).setStyle({
				backgroundColor: 'transparent' 
			});
		    if (this.caller.hasClassName('over')) this.caller.removeClassName('over');
			Event.stopObserving(this.caller.id, 'mouseover', this.showIt ,false);
		}
	},
	passURL: function (el){
        this.caller.href = this.caller.href.replace(/#/, '');
		var nuURL = el.href + URLEncode(this.caller.href)	
		if (this.caller.rel && el.href.indexOf('technorati') == -1) {
			if (el.href.indexOf('newsvine') != -1) {
				nuURL = nuURL +'&h='+ URLEncode(this.caller.rel)
			}
			else {
				nuURL = nuURL +'&title='+ URLEncode(this.caller.rel)
			}
		}
		window.open(nuURL);
		return false
	}

}
Event.observe(window, 'load', function(){ socialShare.initialize(); });
function URLEncode(plaintext)
{
	// 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 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

	return encoded;
};

function toggleArticleByline(toggle, curPage){
	var bottomByline = document.getElementById('articleBylineBottom');
	if(bottomByline != null){
		if(toggle == 'hide'){
			bottomByline.style.display = 'none';
		}else if(toggle == 'show'){
			if(curPage == totalPages || curPage == null){
				bottomByline.style.display = 'block';	
			}
		}
	}
}

// Home.js
var heroTabs = {
	initialize: function(){
		this.hero = $('hero-feature')
		this.tabs = $$('#hero-tabs li');
		this.tabLinks = $$('#hero-feature a');
		this.features = $$('#hero-feature .feature');
		this.currentTab = 0;
		this.heroTimer = setInterval("heroTabs.showNextTab()", 5000);
		this.tabs.each(function(item,indx){
			Event.observe(item, 'mouseover', function(){ heroTabs.showTab(indx,1);return false; },false);
		});
		this.tabLinks.each(function(item){
			Event.observe(item, 'mouseover', function(){ heroTabs.stopCarusel();return false; },false);
		});
	},
	showTab: function(indx,noAuto){
		this.tabs.each(function(item,indx){
			item.removeClassName('selected');
		});
		this.features.each(function(item){
			item.hide();
		});
		this.hero.removeClassName('tab-'+ (this.currentTab));
		this.hero.addClassName('tab-'+(indx));
		this.tabs[indx].addClassName('selected');
		this.features[indx].show();
		this.currentTab = indx;
		if (noAuto|| indx == 0) {
		 clearInterval(this.heroTimer); 
		}
	},
	showNextTab: function(){
		if (this.currentTab == this.tabs.length - 1) {
			var newTab = 0;
		}
		else {
			var newTab = this.currentTab +1;
		}
		this.showTab(newTab);
	},
	stopCarusel: function(){
		clearInterval(this.heroTimer); 
	}
}
var weekendFeat = {
	initialize: function(){
		this.thumbs = $$('#wknd-thmbs img');
		this.mainImgs = $$('#wknd-main-img div');
		this.featLinks = $$('#wknd-feats a');
		this.features = $$('#wknd-feats .feature');
		this.currentFeat = 0;
		this.featureTimer = setInterval("weekendFeat.showNextFeat()", 5000);
		this.thumbs.each(function(item,indx){
			Event.observe(item, 'mouseover', function(){ weekendFeat.showFeat(indx,1);return false; },false);
		});
		this.featLinks.each(function(item){
			Event.observe(item, 'mouseover', function(){ weekendFeat.stopCarusel();return false; },false);
		});
	},
	showFeat: function(indx,noAuto){
		this.thumbs.each(function(item,nIndx){
			item.removeClassName('selected');
		});
		this.features.each(function(item){
			item.hide();
		});
		this.mainImgs.each(function(item){
			item.hide();
		});
		this.thumbs[indx].addClassName('selected');
		this.features[indx].show();
		this.mainImgs[indx].show();
		this.currentFeat = indx;
		if (noAuto || indx == 0) {
		 clearInterval(this.featureTimer); 
		}
	},
	showNextFeat: function(){
		if (this.currentFeat == this.thumbs.length - 1) {
			var newFeat = 0;
		}
		else {
			var newFeat = this.currentFeat +1;
		}
		this.showFeat(newFeat);
	},
	stopCarusel: function(){
		clearInterval(this.featureTimer); 
	}
}

var rssLinks = {
	initialize: function(id){
		$(id).newTimer = null;
	},
	initHide: function(id) {
		clearTimeout($(id).newTimer);
		$(id).newTimer = setTimeout("rssLinks.hideObj('"+ id +"')",750);
	},
	intShow:function(id) {
		Event.observe(id, 'mouseout', function(){ rssLinks.initHide(id); return false; },false);
		clearTimeout($(id).newTimer);
		var pos = Position.cumulativeOffset($(id));
		if (self.pageYOffset) // all except Explorer
		{
			this.x = self.pageXOffset;
			this.y = self.pageYOffset;
			this.yV = self.innerHeight;
		}
		else if (document.documentElement)
			// Explorer 6 Strict
		{
			this.x = document.documentElement.scrollLeft;
			this.y = document.documentElement.scrollTop;
			this.yV = document.documentElement.clientHeight;
		}
		else if (document.body) // all other Explorers
		{
			this.x = document.body.scrollLeft;
			this.y = document.body.scrollTop;
			this.yV = document.body.clientHeight;
		}
		if (id == 'top5rss') {
			var left = pos[0];
		} else {
			var left = pos[0] - ($(id+'box').getWidth() - $(id).getWidth())
		}
		$(id+'box').setStyle({
		  top: (pos[1]+15)+'px',
		  left: left +'px'
		});
		$(id+'box').show();
		var boxPos = Position.cumulativeOffset($(id+'box'));
		if (id != 'top5rss' && boxPos[1]+$(id+'box').getHeight() > (this.y + this.yV)) {
			if ((this.y == 0) && (this.yV == 0)) {
				var scrollThis = $(id+'box').getHeight();
			}
			else {
				var scrollThis = (this.y) + (boxPos[1]+$(id+'box').getHeight() - (this.y + this.yV))+20
			}
			window.scrollTo(this.x, scrollThis)
		}
	},
	showObj: function(id) {
		clearTimeout($(id).newTimer);
		$(id+'box').show();
	},
	hideObj: function(id) {
		$(id+'box').hide();
	}
}

var inThisIssue = {
	initialize: function(){
		this.issue = $('inThisIssue')
		this.imgs = $$('#inThisIssue .promoImg');
		this.blrbs = $$('#inThisIssue .promoBlurb');
		this.currentBlrb = 0;
		this.imgs.each(function(item,indx){
			Event.observe(item, 'mouseover', function(){ inThisIssue.showBlrb(indx);return false; },false);
		});
	},
	showBlrb: function(indx){
		this.imgs.each(function(item,indx){
			item.removeClassName('selected');
		});
		this.blrbs.each(function(item){
			item.hide();
		});
		this.imgs[indx].addClassName('selected');
		this.blrbs[indx].show();
		return true;
	}
}

var hypeFuncs = {
	initialize: function(){
		this.hypeIcons = $$('#hypereport .icn');
		this.hypeLbls = $$('#hypereport .lbl'); 
		this.compLnks = $$('#hypCom .lbl a')
		this.hypeIcons.each(function(item,indx){
			Event.observe(item, 'mouseover', function(){ hypeFuncs.hiLite(indx); return false; },false);
			Event.observe(item, 'mouseout', function(){ hypeFuncs.deLite(indx); return false; },false);
		});
		this.hypeLbls.each(function(item,indx){
			Event.observe(item, 'mouseover', function(){ hypeFuncs.hiLite(indx); return false; },false);
			Event.observe(item, 'mouseout', function(){ hypeFuncs.deLite(indx); return false; },false);
		});
		this.compLnks.each(function(item,indx){
			var newName = new Array();
			newName = item.innerHTML.split(',');
			item.innerHTML = newName[0];
		});
		Event.observe($('comp_tab'), 'click', function(){ $('hypereport').className = 'module companies'; return false; },false);
		Event.observe($('exec_tab'), 'click', function(){ $('hypereport').className = 'module executives'; return false; },false);
	},
	hiLite: function(indx) {
		this.hypeLbls[indx].addClassName('over');
	},
	deLite: function(indx) {
		this.hypeLbls[indx].removeClassName('over');
	}
}
//adddomloadevent-compressed.js
function addDOMLoadEvent(f){ Event.observe(window, 'load', f ); }

//PopOver.js
function popOver(linkObj){
	var aObj = linkObj;
	popName = linkObj.id + 'Pop';
	var myPop = document.getElementById(popName);
	linkObj.timer =	setTimeout("movePop('" + popName + "','"+ linkObj.id +"')", 1000);
	lockPop(myPop);
    var popAdFunc = getPopupAdFunction(linkObj.id);
    popAdFunc();
}
function movePop (popName, linkObj ){ 
    var myPop = document.getElementById(popName);       
    var aLink = document.getElementById(linkObj);   
    var myPopURL = window.location.href; 
    
    var checkmyCompanyURL = myPopURL.match("company-profiles"); 
    var checkmyExecURL = myPopURL.match("executive-profiles"); 
    
   if (checkmyCompanyURL != "company-profiles" && checkmyExecURL != "executive-profiles") { 
       var offsetPx = 14; 
           myPop.style.left = getTotalLeft(aLink) + 'px'; 
           myPop.style.top = getTotalTop(aLink) + offsetPx + 'px'; 
   } else { 

   aLink.style.position = "relative"; 
   myPop.style.position = "absolute"; 

    var pos = Position.cumulativeOffset(aLink); 
    var newTop = (pos[1] - 540) + 'px'; 
    myPop.style.top = newTop; 
    var newLeft = (pos[0] - 100) + 'px'; 
    myPop.style.left = newLeft; 
} 

} 
function unPopOver(myObj){
	clearTimeout(myObj.timer);
	var myId = myObj.id;
	if(myId.indexOf('Pop') < 0){
		myId = myId + 'Pop';
	}
	var myPop = document.getElementById(myId);
	myPop.popLock = false;
	setTimeout("closePopOver('" + myId + "')", 1000);
}
function closePopOver(myId, overRide){
	var myPop = document.getElementById(myId);
	if(!myPop.popLock || overRide){
		myPop.style.left = '-1000px';
		myPop.style.top = '-1000px';
		myPop.popLock = false;
	}
}
function lockPop(myPop){
	myPop.popLock = true;
}
function getTotalTop(obj) {
	return getTotalCommon(obj,true);
}
function getTotalLeft(obj) {
	return getTotalCommon(obj,false);
}
function getTotalCommon(obj, blnTop) {
	var i = 0;
	while (obj.tagName != 'BODY') {
		i += blnTop ? obj.offsetTop : obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return i;
}
//tabManger.js
var tabmanager = new Object();
tabmanager.loadTabOnly = function(tab) {
    //TURN ON TAB
    var tab_container = tab.parentNode;
    var divs = tab_container.getElementsByTagName("DIV");

    for (var i=0; i < divs.length; i++) {
        divs[i].className = "tab";
    }
    tab.className += " on";

	//TURN ON TAB CONTENT
	var tabid = tab.id;
	var content_id = tabid + "content";
	tabc = document.getElementById(content_id);
	var tabc_container = tabc.parentNode;

    var cdivs = tabc_container.getElementsByTagName("div");
    for (var i=0; i < cdivs.length; i++) {
	   if (cdivs[i].className == "tab on" || cdivs[i].className == "tab  on") {
	       cdivs[i].className = "tab";
	   }
	}
	tabc.className += " on";
};
tabmanager.loadTab = function(tab) {
	tabmanager.loadTabOnly(tab);
	page.reloadAssets();    
};
tabmanager.msOver = function(tab){ tab.style.cursor="pointer"; };
tabmanager.msOut = function(tab){ tab.style.cursor="auto"; };
tabmanager.formatPluck = function(tab){
    var tabid = tab.id;
    var content_id = tabid + "content";
    tabc = document.getElementById(content_id);
	var tabc_container = tabc.parentNode;
	/* Commented out until RSS for Most comented created...
	   var morelink = null;
	   //GRAB MORE LINK
	   if (content_id=="mostc_tabcontent" && document.getElementById('mostc_morelink')) {
	       morelink = document.getElementById('mostc_morelink');
	   }
    */
    //FORMAT PLUCK INCLUDE
    if (content_id=="mostc_tabcontent" && document.getElementById('SummaryArticlesMostCommented')) {
        var pluck_div = document.getElementById('SummaryArticlesMostCommented');
        var pluck_list = pluck_div.getElementsByTagName("div");
        var newOL = document.createElement('ol');

        for (var i=2; i < pluck_list.length; i++) {
            var innerNode = pluck_list[i].getElementsByTagName("a");
            var newLI = document.createElement('li');
            newLI = newLI.cloneNode(true);
            newLI.appendChild(innerNode[0]);
            newOL = newOL.cloneNode(true);
            newOL.appendChild(newLI);
        }

        pluck_div.parentNode.removeChild(pluck_div);
        tabc.appendChild(newOL);
        //tabc.appendChild(morelink);
    }
};

tabmanager.loadAttribution = function(tab,attr,tabid,type){
    var attributeDiv = document.getElementById(attr);
    var informImage =  "<a href=\"http://www.inform.com/\" target=\"_new\"><img src=\"/images/site/logos/logo_poweredbyinform.gif\" class=\"inline\" alt=\"\" border=\"0\" /></a>";
    var bizjournalImage ="<a href=\"http://www.bizjournals.com\" target=\"_new\"><img src=\"/images/site/logos/logo_poweredby_bizjournal.gif\" class=\"inline\" alt=\"\" border=\"0\" /></a>";
    if(type=='inform'&& attr=='national_attribution'){
        attributeDiv.innerHTML = informImage;
    }
    else{
        if(tabid=='nap'){attributeDiv.innerHTML="&nbsp;";}
        else if(tabid=='nreuters'){attributeDiv.innerHTML="&nbsp;";}
        else if(tabid=='nmr'){attributeDiv.innerHTML=informImage;}
    }
};
//cookies.js
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + value +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
//adrefresh.js
var popupAdFunctions = new Array();

function setPopupAdFunction(name, func) {
  popupAdFunctions[name] = func;
}

function getPopupAdFunction(name) {
  return popupAdFunctions[name];
}

function adReload(iframe)
{
    if (iframe.contentWindow.location) {
  	    iframe.contentWindow.location.reload(false); 
    }
  	else {
        iframe.src = iframe.src;
    }
}

function adReloadAll()
{
  setDoubleclickOrd();
  var iframes = document.getElementsByTagName('iframe');
  for(var i = 0 ; i < iframes.length ; ++i) {
    if (iframes[i].className == 'PortfolioDartAdUnitLocal') {
      adReload(iframes[i]);
    }
  }
}

function getIFrameDocument(iframe)
{
  var doc = (iframe.contentDocument // For NS6
          || iframe.contentWindow.document // For IE5.5 and IE6
          || iframe.document); // For IE5 et al
  return doc;
}

function adAutoResizeHeight(id){
    var iframe = document.getElementById(id);
    var iframeDocument = getIFrameDocument(iframe);
	  

    var newheight = iframeDocument.getElementById('bottom_div').offsetTop;
	iframe.height = (newheight) + "px";
}

//search.js
/**
 * Clears header search box if default value is present.
 */
function clearSearchBox()
{
    var box = document.getElementById( 'searchTextBox' );
    
    if( box.value == 'Search Portfolio.com' )
    {
        box.value = "";
    }
    
    enableButton();
}


/**
 * Enables the search button if a valid search query is entered.
 * Disables the search button if default or no query is entered.
 */
function checkQuery()
{    
    var box = document.getElementById( 'searchTextBox' );
    var button = document.getElementById( 'searchButton' );
    
    var isInvalid = box.value == null || box.value == "" || box.value == "Search Portfolio.com";
    
    if( button.disabled == false && isInvalid )
    {
        disableButton();
    }
    else if( button.disabled == true && !isInvalid )
    {
        enableButton();
    }
}

/**
* Validates the Advanced Search form on search results pages.
*/

function checkAdvQuery()

{    
    var advTxtbox = document.getElementById( 'advTxtSearch' );
    var advTxtbutton = document.getElementById( 'searchAdvButton' );
    var txtSearchErrormsg = document.getElementById( 'txtSearchError' );
    var advTxtSearch =  document.getElementById( 'searchTextBox' );
    
    
    
    var isInvalid = advTxtbox.value == null || advTxtbox.value == "";

	advTxtSearch.value = advTxtbox.value;
    if( advTxtbutton.disabled == false && isInvalid )
    {
        advTxtbutton.disabled = true;
        txtSearchErrormsg.style.display = 'inline';

    }
    else if( advTxtbutton.disabled == true && !isInvalid )
    {
        
        advTxtbutton.disabled = false;
        txtSearchErrormsg.style.display = 'none';


    
    }    
    
    
    
}

/**
* Fix for IE6 to submmit the Advanced Search form on search results pages.
*/

function checkAdvSubmit()

{    
    var advTxtbox = document.getElementById( 'advTxtSearch' );
    
    if( advTxtbox.value == null || advTxtbox.value == "" )
    {
		return false;

    }
    else
    {
        document.frmSearch.submit();
        return false;
    
    }    
    
    
    
}


/**
 * Resets the default state of the box if no query string is entered, and the user
 * clicks outside of the box.
 */
function resetSearchBox()
{
    var box = document.getElementById( 'searchTextBox' );
    
    if( box.value == null || box.value == "" )
    {
        box.value = "Search Portfolio.com";
        disableButton();
    }    
}


/**
 * Enables the search button, swaps the source of the image and sets cursor style.
 */
function enableButton()
{
    var box = document.getElementById( 'searchTextBox' );
    var button = document.getElementById( 'searchButton' );
    
    button.disabled = false;
    button.src = "http://www.portfolio.com/images/site/btn/button-do-search.gif";
    button.style.cursor = "pointer";
}


/**
 * Disables the search button, swaps the source of the image and sets cursor style.
 */
function disableButton()
{
    var box = document.getElementById( 'searchTextBox' );
    var button = document.getElementById( 'searchButton' );
    
    button.disabled = true;
    button.src = "http://www.portfolio.com/images/site/btn/search_arrows_off.jpg";
    button.style.cursor = "default";
}


/**
 * Submits original query with selected sorting option;
 * used to ignore any new text entered in the search box since selecting value
 * in the "sort by" drop-down doesn't trigger new search.
 */
function submitSortBy( selectBox, searchValue )
{
    var sortValue = selectBox.value;
    document.advSearch.txtSearch.value = searchValue;
    document.advSearch.submit();
}


/**
 * Ensures that search text is not empty.
 */
function checkQueryText( fieldName )
{
    var queryValue = (document.getElementById( fieldName )).value;
    queryValue = queryValue.trim();
    
    if( queryValue == '' )
    {
        return false;
    }
}


/**
 * Ensures that at least one search parameter is entered for the company profile search.
 */
function checkCompanySearchInput()
{
    var companyName = (document.getElementById( 'nameSymbol' )).value;
    var industry = (document.getElementById( 'industry' )).value;
    var city = (document.getElementById( 'city' )).value;
    var state = (document.getElementById( 'state' )).value;
    companyName = companyName.trim();
    city = city.trim();
    
    if( companyName == '' && industry == -1 && city == '' && state == 'notSelected' )
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkCompanySearchInputDefault()
{
    var companyName = (document.getElementById( 'nameSymbol' )).value;
    companyName = companyName.trim();
    
    if( companyName == '')
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkCompanySearchInputIndustry()
{
    var companyName = (document.getElementById( 'nameSymbol' )).value;
	var industry = (document.getElementById( 'industry' )).value;
    companyName = companyName.trim();
    
    if( companyName == '' && industry == -1)
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkCompanySearchInputLocation()
{
    var companyName = (document.getElementById( 'nameSymbol' )).value;
    var city = (document.getElementById( 'city' )).value;
    var state = (document.getElementById( 'state' )).value;
    companyName = companyName.trim();
    city = city.trim();
    
    if( companyName == '' && city == '' && state == 'notSelected' )
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}
/**
 * Ensures that at least one search parameter is entered for the executive profile search.
 */
function checkExecSearchInput()
{
    var execName = document.getElementById( 'nameSymbol' ).value;
    var industry = document.getElementById( 'industry' ).value;
    execName = execName.trim();
    
    if( execName == '' && industry == -1 )
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkExecSearchInputDefault()
{
    var execName = document.getElementById( 'nameSymbol' ).value;
    execName = execName.trim();
    
    if( execName == '')
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkExecSearchInputIndustry()
{
    var execName = document.getElementById( 'nameSymbol' ).value;
    var industry = document.getElementById( 'industry' ).value;
    execName = execName.trim();
    
    if( execName == '' && industry == -1 )
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function checkExecSearchInputLocation()
{
    var execName = document.getElementById( 'nameSymbol' ).value;
    var city = document.getElementById( 'city' ).value;
	var state = document.getElementById( 'state' ).value;
    execName = execName.trim();
	city = city.trim();
    
    if( execName == '' && city == '' && state == 'notSelected')
    {
        alert( "Please enter at least one search field." );
        return false;
    }
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function checkEmail(nameTab) {
	if(nameTab == 'newsletter') {
	    var x=document.getElementById("txtEmail");
	    document.newsletter.confirmEmail.value = x.value;
	    document.newsletter.submit();
	    document.newsletter.reset();
	}	
	else {
	    var x1=document.getElementById("txtEmail1");
	    document.newsletter1.confirmEmail.value = x1.value;
	    document.newsletter1.submit();
	    document.newsletter1.reset();
	}
    return false;
}

function selectText(formobj) {
   var x=document.getElementById("txtEmail");
   x.select();
}
function newsletterDesc (id) {
   var nDiv = document.getElementById(id);
   var newTopN = '100px';
   nDiv.style.top = newTopN;
   var newLeftN = '20px';
   nDiv.style.left = newLeftN;
   nDiv.style.visibility = 'visible';
}
function clearEmailBox(el)
{
    if( el.value == ' Enter Email Address' )
    {
        el.value = "";
    }
    enableButton();
}

function resetEmailBox(el)
{
    if( el.value == null || el.value == "" )
    {
        el.value = " Enter Email Address";
        disableButton();
    }    
}

/* Override TID in Teamsite for alsoIns */

function overrideManTID() {

	var checkTSTID = myString.match("alsoin");
	var checkFeedroom = myString.match("video.portfolio.com");
    splitString = myString.split("?");

	if (checkFeedroom == "video.portfolio.com") {
		document.write(splitString[0] + "?" + splitString[1] + "\&PMID="); 	
	} else if (checkTSTID == "alsoin") {
		document.write( splitString[0] + "\?PMID=");
    } else {
		document.write( splitString[0] + "\?PMID=");
    }
    		
}
	

/* Remove spaces from strings */

function replaceCharacters(entry, out, add) {
//out = "a"; // replace this
//add = "z"; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}

myReplacedText = temp;
document.write(myReplacedText);
}




/* Parse the current page's querystring */

var qsParm = new Array();

function qs() {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}
}
}



