function cantaLoad()
{

	if ( window.location.href.indexOf("?as") != -1 || window.location.href.indexOf("&as") != -1 || window.location.href.indexOf("&amp;as") != -1 )
	{
		play_current_video();
	}
	
	
	attachAnchorEvents();
}

function attachAnchorEvents ()
{
  
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		switch (anchors[i].rel)
		{
			case "cantaShare":
				anchors[i].onclick = (function(e){
											   start = this.href.indexOf("#") + 1;
											   id = this.href.substring(start);
											   shareClip('http://clients.cantaloupebacklot.com/clients/theraplay/share.aspx', id);
											   return false;
											   });
			break;
			
			case "cantaSubscribe":
				anchors[i].onclick = (function(e){
											   start = this.href.indexOf("#") + 1;
											   id = this.href.substring(start);
											   shareClip('http://clients.cantaloupebacklot.com/clients/theraplay/subscribe.aspx', id);
											   return false;
											   });
			break;
			
			case "cantaArchive":
				anchors[i].onclick = (function(e){
											   alert("There are currently no archived videos.");
											   return false;
											   });
			break;
		}
	}
}


var winIndex = 0;
function shareClip(url, id) 
{
	var shareURL = url + "?itemID=" + id;
	window.open(shareURL, 'shareWin' + winIndex,'width=650,height=425,toolbar=no,status=no,scrollbars=no');
	winIndex++
}