function cantaLoad()
{
	var thumbs = document.getElementById("thumbs").getElementsByTagName("li");
	var current_video_title =  document.getElementById("episode_info_heading");
	var current_video_description = document.getElementById("episode_info_description");
	
	var defaultVideoTitle = current_video_title.innerHTML;
	var defaultVideoDescription = current_video_description.innerHTML;
	
	for (var i=0; i<thumbs.length; i++)
	{
		
	
		thumbs[i].onmouseover = function ()
		{
			var currentAnchor = this.getElementsByTagName("a")[0];
			var videoTextBits = currentAnchor.title.split("|");
			var videoTitle = videoTextBits[0];
			var videoDescription =  videoTextBits[1];
			
			if (videoTitle && videoDescription)
			{
				current_video_title.innerHTML = videoTitle;
				current_video_description.innerHTML = videoDescription;
			}
			else
			{
				current_video_title.innerHTML = "Video Coming Soon...";
				current_video_description.innerHTML = "";
			}
			
			return;
		}
		
		thumbs[i].onmouseout = function()
		{
			current_video_title.innerHTML = defaultVideoTitle;
			current_video_description.innerHTML = defaultVideoDescription;
		}
		
		thumbs[i].onclick = function()
		{
			if (this.href=="#" || this.rel == "cs")
			{
				return false;
			}
		}
		
		
	}
		
		
	
	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('/share.aspx', id);
											   return false;
											   });
			break;
			
			case "cantaSubscribe":
				anchors[i].onclick = (function(e){
											   start = this.href.indexOf("#") + 1;
											   id = this.href.substring(start);
											   shareClip('/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++
}