var recentBookmarkArray = [];

function processRecentBookmarks(theXml) {

	recentBookmarkArray.length = 0;
	
	totalFavorites = 0;
	
	if($("favData", theXml).text() != 'none') {
	
	    $("favData", theXml).each(function(i) {

			var statItem = new Object();
	        statItem.id = i;
			statItem.favId = $('favId', this).text();
			statItem.favName = unescape($('favName', this).text());
			statItem.favUrl = unescape($('favUrl', this).text());
			statItem.favTags = unescape($('favTags', this).text());
			statItem.favTagsNames = unescape($('favTagsNames', this).text());
			statItem.favDesc = unescape($('favDesc', this).text());
			statItem.favVisits = $('favVisits', this).text();
			statItem.createdMonth = $('createdMonth', this).text();
			statItem.createdDay = $('createdDay', this).text();
			statItem.createdYear = $('createdYear', this).text();
			statItem.createdDate = $('createdDate', this).text();
			statItem.publicPrivate = $('publicPrivate', this).text();
			statItem.visibility = "visible";
			statItem.tagsConverted = '';
	        recentBookmarkArray.push(statItem);
	    });
		
	}
		
    createRecentBookmarksTiles();

}





function createRecentBookmarksTiles() {

	var theDiv = $('#recentBookmarks');
	
	$(theDiv).empty();
	
	tilesCounter = 0;
	
	var theHtml = '';
	

	
	theHtml +='<div class="recentLabelsWrapper"><div class="recentLabelsPadding"><div class="recentLabels">';
		theHtml +='<div class="favThumbLabel">Thumbnail</div>';
		theHtml +='<div class="hr"><div></div></div>';
		theHtml +='<div class="favNameLabel">Name</div>';
		theHtml +='<div class="hr"><div></div></div>';
		theHtml +='<div class="favUrlLabel">URL</div>';
		//theHtml +='<div class="hr"><div></div></div>';
		//theHtml +='<div class="favAddedByLabel">Created By</div>';
		theHtml +='<div class="hr"><div></div></div>';
		theHtml +='<div class="favDateLabel">Date</div>';
		theHtml +='<div class="hr"><div></div></div>';
		theHtml +='<div class="favTagsLabel">Tags</div>';
	theHtml +='</div></div></div> <!-- end: <div class="recentLabelsWrapper"> -->';
	
	$.each(recentBookmarkArray, function(i){ 
	
		
	
		var theImageName = this.siteName;
		var theId = this.id;
		var theFavId = this.favId;
		var theFavName = this.favName;
		var theFavUrl = this.favUrl;
		var theFavTags = this.favTags;
		var theFavTagsNames = this.favTagsNames;
		var theDateAdded = this.createdMonth +'/'+ this.createdDay +'/'+ this.createdYear;
		var theDescription = this.favDesc;

		var favTagsArray = theFavTags.split(',');
		var favTagsNamesArray = theFavTagsNames.split(',');
		
		
		theHtml +='<div class="recentBookmarkWrapper"><div class="recentBookmarkPadding"><div class="recentBookmark">';
		
			theHtml +='<div class="thumbWrapper"><div class="thumb"><a href="'+theFavUrl+'" target="_blank"><img src="http://images.shrinktheweb.com/xino.php?stwembed=1&stwinside=1&stwaccesskeyid=aae05bcd5bab416&stwsize=lg&stwurl='+theFavUrl+'" border="0" alt="Clicks: 100" /></a></div></div>';
			theHtml +='<div class="hr"><div></div></div>';
			theHtml +='<div class="favName">'+theFavName+'</div>';
			theHtml +='<div class="hr"><div></div></div>';
			theHtml +='<div class="favUrl"><a href="'+theFavUrl+'" target="_blank">'+theFavUrl+'</a></div>';
			theHtml +='<div class="hr"><div></div></div>';
			theHtml +='<div class="favDate">'+theDateAdded+'</div>';
			theHtml +='<div class="hr"><div></div></div>';
			theHtml +='<div class="favTags">';

			for (i = 0; i <= (favTagsArray.length - 1); i++) {
				theHtml +='<a href=bookmarks/index.asp?uid='+uid+'#'+favTagsArray[i]+'>'+favTagsNamesArray[i] +'</a>';
			}

			theHtml +='</div>';

		theHtml +='</div></div></div> <!-- end: <div class="recentBookmarksWrapper"> -->';

		
		


	});
	

	
	theDiv.append(theHtml);


}



function convertTags(n){

	var tempSiteTagsArray = n.split(',');
	var convertedSiteTags = '';

	$.each(tempSiteTagsArray,function(i) {
		$.each(tagsArray, function(y){ 
	
			if (tempSiteTagsArray[i] == tagsArray[y].tagUniqueId) {
				convertedSiteTags = convertedSiteTags + this.tagName + ',';
			}
			
		});
	});

	convertedSiteTags = stringLeft(convertedSiteTags,convertedSiteTags.length-1);
	
	return convertedSiteTags
	
}
