/* *** TAG CLOUD *** */


function tagClicked(id, wordToSearch){
//	$('#pane')[0].scrollTo(0); // try scroll back to the top.
	$("#pane").html("<p>Cargando...</p>");
	tagSearchClick(wordToSearch);

	/* //Use the below if you're getting user interaction.
	$.ajax({
		type: "POST",
		url: "vzService/tagCloud-admin-process.php",
		data: "wordToClickID="+id+"",
		contentType: CONTENT_TYPE,
		success: function(msg){ 
			try{
				//alert("came back: " +msg );
				refreshTags(); //get the new tag collection.
				tagSearchClick(wordToSearch);

				//you have to put in a search for this keyword.

			}catch(exception){
				//alert("no videos returned for this playlist. Error details:" + exception);
			}
		}
	});
	*/
}


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

theTagCloud = theTagCloud +  "<a href='javascript:return false;' id='tagCloudStyle' onclick=\"javascript:pageTracker._trackEvent('Administracion', 'Nube de Tags','"+tagcloudArray[i].TagName+"');cmCreatePageviewTag('NUBE DE TAGS LTC: "+tagcloudArray[i].TagName+"', 'ltc:nube de tags');tagClicked(" + tagcloudArray[i].TagID + ",'" + tagcloudArray[i].TagName + "'); return false;\" style='font-size: "+ tagcloudArray[i].TagSize +"px'>"+tagcloudArray[i].TagName+"</a> ";

		}
		$("#tagCloud").html(theTagCloud);
	}
}



function tagSearchClick(wordsToSearch){
	//$('#pane')[0].scrollTo(0); // try scroll back to the top.
	$("#pane").html("<p>Cargando...</p>");
	$.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);
								$(".movepane").css({'top' : ' 5px'});
				}else{
					alert("no videos returned for this search.");
				}
			}catch(exception){
				alert("no videos returned for this search.");
			}
		}
	});
}