var globalTrackingTag = 'momtourage';

var theGreaterPath = window.location.protocol + "//" + window.location.host;
pathArray = window.location.pathname.split( '/' );
var newPathname = "";
var pathLength = pathArray.length - 1;
for (var iNode = 0; iNode < pathLength; iNode++) {
	newPathname += pathArray[iNode] + "/";
}

theGreaterPath+=newPathname;
var therequest = createXMLHttpRequest();

function createXMLHttpRequest() {
	var therequest = false;
	
	if (window.XMLHttpRequest){
		
		if(typeof XMLHttpRequest != 'undefined')
			try {
				therequest = new XMLHttpRequest();
			} catch (e) {
				therequest = false;
			}
	} else if (window.ActiveXObject) {
			try {
				therequest = new ActiveXObject('Msxml2.XMLHTTP');
			} catch (e) {
				try {
				therequest = new ActiveXObject('Microsoft.XMLHTTP');
				} catch (e) {
					therequest = false;
				}
			}
		
	}
		
	return therequest;
}

function getTheAHRss(theURL, theTrackingTag){

	globalTrackingTag = theTrackingTag;

	if (therequest) {
		
		theURLLength = theURL.length;
		if (theURL.substr(theURLLength-1,theURLLength-1)=="/"){
			theURL = theURL.substr(0,theURLLength-1);
		}
		
		therequest.open('GET',theURL, true);
		therequest.onreadystatechange = parseTheResponse;
		therequest.send('initializeParser');
	}

}

function trim(str)
{
     s = str.replace(/^(\s)*/, '');
     s = s.replace(/(\s)*$/, '');
     return s;
}

function parseTheResponse() {
	
	if (therequest.readyState == 4) {

		if (therequest.status == 200) {
			var response = therequest.responseXML;
			var topicsList = response.getElementsByTagName('item');
			for (var iNode = 0; iNode < 3; iNode++) {
				var theElement = topicsList[iNode].getElementsByTagName('title');
				var theURL= topicsList[iNode].getElementsByTagName('link');
				var n_elems =  theElement.length;
				for (i = 0; i < n_elems; i++){
					document.getElementById('ahinside').innerHTML = document.getElementById('ahinside').innerHTML + '<div id=\'ahItem'+iNode+'\' class=\'ahItem\' ><div class=\'aharrow\'><img src=\'http://i.ivillage.com/ivillage/celebritybabyblog/bbarrow.gif\' border=0/></div><div class=\'ahtitle\'><a onclick=\"trackclick(\''+theURL[i].firstChild.nodeValue+'?xid='+globalTrackingTag+'\',\''+globalTrackingTag+'\')\">'+theElement[i].firstChild.nodeValue+'</a></div></div>';	
				}
					
			}
			
		
		}
	}
}

function trackclick(theLinkURL, theTrackingTag)
{
	s_iv.eVar13 = 'mom:html:pcbm:' + theTrackingTag + ':click';
	sendAnalyticsEvent();
	window.open(theLinkURL);
}

function trackimpression(theTrackingTag)
{
	document.getElementById("cbbimptrack").src="http://oimg.nbcuni.com/b/ss/nbcuivsites,nbcuivprod/1/H.19.4--NS/123456?pe=lnk_o&amp;pev2=CelebrityBabyBlog&v13=mom:html:pcbm:"+theTrackingTag+":loaded";
}



