/* *** TAG CLOUD *** */
function tagClicked(id, wordToSearch)
{
	wordsToSearch = wordToSearch;
	tagSearchClick(wordToSearch);
}

function refreshTags()
{
	$.ajax({
		type: "POST",
		url: "vzService/tagCloud.php",
		data: "process=refresh",
		contentType: CONTENT_TYPE,
		success: function(msg){ 
			try{
				eval(msg);
				displayTagCloud();
			}catch(exception){
				//alert("no videos returned for this playlist. Error details:" + exception);
			}
		}
	});
}

function jumpToAnchor2() 
{
	// window.location = window.location + "#busca"; //old
 	//document.getElementById("searchResults").scrollIntoView();
}

function displayTagCloud()
{
	var tagCloudLength = tagcloudArray.length;

	if(tagCloudLength > 0){
		var theTagCloud = "";
		for(var i=0;i < tagCloudLength; i++){ // imprime todas las tags 
	//	for(var i=0;i < 16; i++){ // imprimo sólo 10 tags
		lolo = tagcloudArray[i].TagName;
		theTagCloud = theTagCloud +  "<a href='javascript:return false;' id='tagCloudStyle' onclick=\"javascript:setTimeout('jumpToAnchor2()',3000);tagClicked(" + tagcloudArray[i].TagID + ",'" + tagcloudArray[i].TagName + "'); _gaq.push(['_trackEvent', 'Herramientas', 'Tag Cloud', '" + tagcloudArray[i].TagName + "']); return false;\" style='font-size: "+ tagcloudArray[i].TagSize +"px'>"+tagcloudArray[i].TagName+"</a> ";
		}
		$("#tagcloud").html(theTagCloud);
	}
}

//Funcion comparar tags
function compareTag(key)
{
	var tagCloudLength = tagcloudArray.length;
	
	if(tagCloudLength > 0)
	{
		var theTagCloud = "";
	
		for(var i=0;i < tagCloudLength; i++)
		{ 
			//alert("tagCloud: "+tagcloudArray[i].TagName);
		
			if (key == tagcloudArray[i].TagName)
			{
				tagCommon(tagcloudArray[i].TagID,tagcloudArray[i].TagName,posicion);
			}
		}
	}
}

function tagSearchClick(wordsToSearch)
{
	$("#categoriatitulo").html("B&Uacute;SQUEDA DE "+wordsToSearch);
	
	$.ajax({
		type: "POST",
		url: "vzService/search.php",
		data: "clientID="+thisChannel.ClientID+"&channelID="+thisChannel.ChannelID+"&wordsToSearch="+escape(wordsToSearch)+"",
		contentType: CONTENT_TYPE,
		success: function(msg){ 
			try{
				//alert(msg);
				eval(msg);
				if(searchContentArray[0].Title != ""){
					currentlyShowing = 'search';
					buildPlaylistContent();
					playVideo(0, currentlyShowing);
				}else{
					//alert("No hay resultados que mostrar.");
				}
			}catch(exception){
				//alert("No hay resultados que mostrar.");
			}
		}
	});
}

