
	//var root = '';

	function ajaxError(msg) {
		
		alert(msg);
		
	} // ajaxError
	
	function clipIt(link, table, table_id, user_id, sitemap_id) {
		$.post(root + 'clips/save/?ajax', 
			{
				clip_table : table,
				clip_table_id : table_id,
				clip_user_id : user_id,
				clip_sitemap_id : sitemap_id
			}, 
			function(data, textStatus) {
				if (data.indexOf('true||') > -1) {
					//alert('Clipped!');
					//$(link).html('Clipped! (<'+'span class="clips">' + data.substr(6) + '<'+'/span>)');
					var img = $(link).html().replace('clip.gif', 'clipped.gif');
					$(link).replaceWith(img);
				} else {
					ajaxError(data);
				}
			}
		);
	} // clipIt
	
	function favoriteIt(link, table, table_id, user_id, sitemap_id) {
		$.post(root + 'clips/save/?ajax', 
			{
				clip_table : table,
				clip_table_id : table_id,
				clip_user_id : user_id,
				clip_sitemap_id : sitemap_id,
				is_clip : 'false'
			}, 
			function(data, textStatus) {
				if (data.indexOf('true||') > -1) {
					//alert('Favorited!');
					//$(link).html('Clipped! (<'+'span class="clips">' + data.substr(6) + '<'+'/span>)');
					var img = $(link).html().replace('btn-favorite.gif', 'btn-favorited.gif').replace('btn-becomefan.gif', 'btn-alreadyfan.gif');
					$(link).replaceWith(img);
				} else {
					ajaxError(data);
				}
			}
		);		
	} // favoriteIt
	
	function recommend(link, table, table_id, sitemap_id) {
		$.post(root + 'votes/save/?ajax', 
			{
				vote_table : table,
				vote_table_id : table_id,
				vote_sitemap_id : sitemap_id
			}, 
			function(data, textStatus) {
				if (data.indexOf('true||') > -1) {
					// should probably replace with a 'recommended' button.
					// should also store a cookie.
					$(link.parentNode).find('span').html("" + data.substr(6));
					var img = $(link).html().replace('btn-recommend-article.gif', 'btn-recommended.gif');
					$(link).replaceWith(img);
				} else {
					ajaxError(data);
				}
			}
		);
	} // recommend
	
	var shareTimer;
	function share(link, url, title, delay) {
		if (!$('#share-container').get(0)){
			$(link.parentNode).append('<div id="share-container"></div>');
			$('#share-container').load(root + 'includes/share/', { url : url, title : title})
				.mouseover(function(){
					share(link, url, title, delay);
					clearTimeout(shareTimer);
				})
				.mouseout(function(){
					shareTimer = setTimeout("$('#share-container').hide();", delay);
				})
		}
		$('#share-container').show();
		clearTimeout(shareTimer);
		shareTimer = setTimeout("$('#share-container').hide();", delay);
	} // share
	
	function selectNavItem(link, parent, item) {
		$('.'+parent+'-content-nav').parent().find('.'+parent+'-content-nav ul li, .'+parent+'-content-nav li').removeClass('selected');
		$('.'+parent+'-content-nav').parent().find('.'+parent+'-content, .content-items').hide();
		$('.'+parent+'-content-nav').parent().find('#'+parent+'-content-nav-'+item).addClass('selected');
		$('.'+parent+'-content-nav').parent().find('#'+parent+'-content-'+item+', #'+parent+'-content-'+item+' ol').show();		
	} // selectSubNavItem

	$(document).ready(function(){
		$('.content-nav').parent().find('.content-nav li:first').addClass('selected').end().find('.content-items:first').show();
	});


	function rating(link,rating) {
		var ul = link.parentNode.parentNode;
		var lis = ul.getElementsByTagName('li');
		var currentRatingLI = lis[0];
		var ratingInput = $("#comments-rating").get(0);
		ratingInput.setAttribute('value',rating);
		currentRatingLI.replaceChild(document.createTextNode(rating),currentRatingLI.firstChild);
		currentRatingLI.style.width = (parseInt(rating) * 19) + "px";
		return false;
	} // rating
	
	function attending(link, event_type, event_id, date) {
		if ($(link).find('img').attr('src').indexOf('-notgoing.gif') > 0) {
			imnotgoing(link, event_type, event_id, date);
		} else {
			imgoing(link, event_type, event_id, date);
		}
	} // attending

	function imgoing(link, event_type, event_id, date) {
		$.post(root + 'scripts/attending/?ajax', 
			{ event_type : event_type , event_id : event_id , date : date },
			function (data, textStatus) {
				if (data == 'true') {
					$(link).find('img').attr('src', root + 'images/btn-event-notgoing.gif');
					var count = $(link.parentNode).find('.upcoming-attending-people span').html();
					$(link.parentNode).find('.upcoming-attending-people span').html(""+(1+parseInt(count)));
				} else {
					ajaxError(data);
				}
			}
		);		
	} // imgoing
	
	function imnotgoing(link, event_type, event_id, date) {
		$.post(root + 'scripts/attending/?ajax', 
			{ event_type : event_type , event_id : event_id , date : date , attending : 'no' },
			function (data, textStatus) {
				if (data == 'true') {
					$(link).find('img').attr('src', root + 'images/btn-event-going.gif');
					var count = $(link.parentNode).find('.upcoming-attending-people span').html();
					$(link.parentNode).find('.upcoming-attending-people span').html(""+(-1+parseInt(count)));
				} else {
					ajaxError(data);
				}
			}
		);		
	} // imnotgoing
	
	$(function() {
		jQuery.fn.fancybox.defaults.path = root + 'images/';
		$(".photozoom a:not(.no-photozoom), a.photozoom").fancybox({
	       	'fancyIn'	: false,
			'fancyOut'	: false,
			zoomSpeedIn	: 500,
			zoomSpeedOut: 0,
			overlayShow	: true,
			overlayOpacity: 0
		});
		$('.TellAFriend').popup({ 'height' : 310 });
		$('.flag').popup({ 'height' : 300 });
		$('.content-mediaplayer').find('ul.mediaplayer-content-nav li:first, div.mediaplayer-content-container:first').addClass('selected');
		
	}); 
		
	AudioPlayer.setup(root + "sites/" + site + "/" + theme + "/files/player.swf", {  
		width: 250, 
		initialvolume: 50, 
		transparentpagebg: "yes", 
		leftbg: "dadada",
		lefticon: "ffffff", 
		rightbg: "cacaca",
		rightbghover: "ababab",
		righticon: "8d8d8d",
		righticonhover: "737373",
		loader: "e8ffe8",
		text: "666666",
		volslider: "8d8d8d"
	});  
	jQuery.fn.fancybox.defaults = {
		hideOnContentClick:	false,
		zoomSpeedIn:		0,
		zoomSpeedOut:		0,
		frameWidth:			450,
		frameHeight:		350,
		overlayShow:		true,
		overlayOpacity:		0.4,
		itemLoadCallback:	null
	};
	
