// JavaScript Document

var loading = '<div class="loading"><img src="/assets/images/ajax-loader.gif" /></div>';

$(document).ready(function(){
	
	$("#social a").click(function(e){
		
		if ($(this).attr("href") == "#")
		{
			e.preventDefault();
		}
	});
	
	$("#events table").hide();
	
	$("#events tr").tooltip({
		position: "center left",
		relative: true,
		tip: "#eventlisting",
		onBeforeShow: clearTips,
		onShow: showEvent
	});
	
	$("#past, #full").fancybox({
		autoDimensions : false,
		width: 500,
		height: 400	
	});
	
	$("#albums li a").fancybox({
		titlePosition: 'inside'	
	});
	
	$(".video-thumb").fancybox();
	$(".video-thumb").mouseover(function(){
		$(this).prepend("<span>Click To View</span>");
	});
	$(".video-thumb").mouseout(function(){
		$(".video-thumb span").remove();
	});
	$(".video-thumb span").mouseover(function(e){ e.stopPropagation(); });
	$(".video-thumb span").mouseout(function(e){ e.stopPropagation(); });
	
});

function showEvent(e)
{
	//clearTips();
	
	this.getTip().html("<table>" + this.getTrigger().find("table").html() + "</table>");
	//console.log(this.getTrigger());
	
	//var id = this.getTrigger().attr("title");
	
	//getAjaxData(id, this.getTip());
}



function clearTips()
{
	$("#events tr").each(function() {
  		$(this).data('tooltip').hide();
	});	
}

function getAjaxData(id, $tip) 
{
	$tip.html(loading);
	$.ajax({
		url:"/get-schedule-item?id=" + id,
		success: function(response) {
			$tip.html(response);
		}
	});
}

function popWindow(page, width, height)
{
	var args = "height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes";
	window.open(page,null,args);
}

