// JavaScript Document

var associates = new Array()
var excl = false;

function parseXML (xmlObj){
	associatesNode = xmlObj.getElementsByTagName("associate");
	for (e=0; e < associatesNode.length; e++){
		var employee = null
		employee = new Object()
		employee.name = getAttr(associatesNode[e], "name")
		employee.group = getAttr(associatesNode[e], "group")
		employee.altgroup = getAttr(associatesNode[e], "altgroup")		
		employee.longgroup = getAttr(associatesNode[e], "longgroup")
		employee.shortgroup = getAttr(associatesNode[e], "shortgroup")
		employee.imagethumb = getAttr(associatesNode[e], "imagethumb")
		employee.imagesmall = getAttr(associatesNode[e], "imagesmall")
		employee.imagelarge = getAttr(associatesNode[e], "imagelarge")
		allquotes = associatesNode[e].getElementsByTagName("quote");
		quotearray = null;
		quotearray = new Array();
		for (i = 0; i < allquotes.length; i++){
			thisquote = null;
			thisquote = new Object();
			thisquote.type = getAttr(allquotes[i], "type")
			thisquote.header = getAttr(allquotes[i], "header")
			thisquote.quote = getVal(allquotes[i]);
			quotearray.push(thisquote);
		}
		employee.quote = quotearray;
		if ((employee.group.toLowerCase() == filtergroup.toLowerCase() || employee.altgroup.toLowerCase() == filtergroup.toLowerCase()) || (filtergroup.indexOf('all') > -1 || filtergroup.indexOf('tap') > -1)) {
			if (excl){
				if (excl.toLowerCase() != employee.name.toLowerCase()){associates.push(employee);}
			} else {
				associates.push(employee)
			}
		}
	}
	fillMeetOurAssociates();
}

function fillMeetOurAssociates(parm){
	// fills the sidebar with associates
	allassocs = associates.length - 1;
	var r = '';
	var i = 0;
	while (associates.length > 0 && i < totalTestimonials){
		if (filtergroup.toLowerCase().indexOf('all') == -1 && document.getElementById('associateSidebar')) {document.getElementById('associateSidebar').style.display = '';}
		var j = Math.floor((Math.random()*associates.length));
		thisemp = associates[j];
		for (ii = 0; ii < thisemp.quote.length; ii++){
			ourquote = thisemp.quote[ii];
			if (ourquote.type == 'short'){
				thisquote = ourquote.quote;
				break;
			}
		}		
		if (i < (allassocs) && i < (totalTestimonials -1)){quoteA = "A";} else {quoteA = "";}
		r += '<div class="testimonialEmployee">';
		r += '	<a href="/careers/working_here/associates/associate.html?nm='+ thisemp.name + '&grp=' + thisemp.shortgroup + '&ttl=' + escape(thisemp.longgroup) + '"><img src="/_img/testimonials/' + thisemp.imagethumb + '" height="58" width="58" alt="' + thisemp.name + '" /></a>' ;
		r += '	<br /><strong><a href="/careers/working_here/associates/associate.html?nm='+ thisemp.name + '&grp=' + thisemp.shortgroup + '&ttl=' + escape(thisemp.longgroup) + '">' + thisemp.name + '</a></strong><br />' + thisemp.longgroup + '';
		r += '</div>';
		r += '<div class="testimonialQuote' + quoteA + '">"' + thisquote + '"</div>';
		associates.splice(j, 1);
		i++;
	}
	document.getElementById('associatecontent').innerHTML = r;
}