// JavaScript Document
function deconstruct(what){
	obj = eval(what);
	var temp = "";
	for (x in obj)
			temp += x + ": " + obj[x] + "\n";
	alert (temp);
}


    function displayDelicious(data) {
		
		if( data != null ){
			var urlinfo = data[0];
			
			if (!urlinfo) {
						
				return;
			}
	
			// info we've got: urlinfo.total_posts, urlinfo.url, urlinfo.top_tags
			$('#delicious-savedby').html('<li>'+urlinfo.total_posts + ' people</li>');
			
			var ct = $('#delicious-toptags');
			var hasTag = false;
			for (tag in urlinfo.top_tags) {
				var tagtext = '<li><a href="http://del.icio.us/tag/'+tag+'">'+tag+'</a></li>';
				$('#delicious-toptags').append(tagtext);
				hasTag = true;
			}
			if (hasTag) {
				$('#delicious-toptags-wrapper').show();
			}
			
		}
		
		$('#relatedcontent').show();
		$('#deliciousinfo').show();
		$('#drelatedcontent').show();


    }
	
	
	
	function getTechnorati(url){
		var requestUrl = 'http://working/villeneuve/smr.newswire.ca/technorati.php';
		//var requestUrl = 'http://smr.newswire.ca/technorati.php';
		var params = 'url='+ escape(url);
		//$.getJSON( requestUrl, params, displayTechnorati ); 
		$.ajax({url:requestUrl, dataType:'json', data:params, success:displayTechnorati, error:  technoratiError});
	}
	function technoratiError(x, txt, e) {
	   alert(txt);
	}
	
	function displayTechnorati(jsonData){
		
		if( jsonData != null ){
				if (jsonData.technoraticosmos.inboundlinks == 0) {
					//alert("Technorati Returned 0.");
					return;
				}
			// info we've got: urlinfo.total_posts, urlinfo.url, urlinfo.top_tags
			$('#techno-inbound').html('<li>'+jsonData.technoraticosmos.inboundlinks + '</li>');
		}
		$('#technoratiinfo').show();
		$('#relatedcontent').show();
		$('#drelatedcontent').show();
	}
	
	