function showEmailThis(title, id) {
  emailed(id)
  fullURL = "http://www.emailthis.clickability.com/et/emailThis?clickMap=create&fb=Y&url="+window.location.href+"&title="+title;
  window.open(fullURL,"emailThis","menubar=no,width=500,height=500,toolbar=no,resizable=yes,scrollbars=yes");
}

function showShare(elemId) {
  document.getElementById(elemId).style.display = "block";
}

function hideShare(elemId) {
  document.getElementById(elemId).style.display = "none";
}


function emailed(contentId){
	var name = "em"+contentId;
	if (readCookie(name)) return;
	new Ajax.Request('/emailed/save?content.id='+contentId, {
	  method: 'post',
	  onSuccess: function(transport) {
	    createCookie(name, "true", 30);
	  }
	});
}


var PageView = {
  
  save: function(contentId) {
	var name = "pv"+contentId;
	if (readCookie(name)) return;
	new Ajax.Request('/pageview/save?content.id='+contentId, {
	  method: 'post',
	  onSuccess: function(transport) {
	    createCookie(name, "true", 30);
	  }
	});
  }

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


