//////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
	showLoader();

	footSlide();
	formFields();
	shareLink();
	clearVal();
	showMenu();
	
	vidOpen();
	vidClose();
	
	tags();
	related();
	note();
	noteLink();
	shopLink();
	
	viewMap();
	mapClose();
	
	videoWidth();
	videoWidthVimeo();
	
	hideLoader();
	$('#header').slideDown('slow');
});
//////////////////////////////////////////////////////////////////////////
function showMenu() {
	$('#header').hover(function(){
		$('#nav nav').fadeToggle();
		$('#header-top').slideToggle();
	});
}
//////////////////////////////////////////////////////////////////////////
function workGrid() {
	var imgheight = $('.work-grid-img').width();
	$('.work-grid-img').css('height',imgheight);
	$('.works-img-sml').css('min-height',imgheight);
}
//////////////////////////////////////////////////////////////////////////
function vidOpen() {
	$('.broadcast-img-sml').click(function(){
		var id = $(this).attr('data-video-ref');

		$('#video-box').html('<img id="vid-loader-img" src="img/broadcasts/ajax-loader.gif" />');
		
		$('#header').fadeOut('slow');
		$('#video-all-box').fadeOut('slow');
		
		$('#video-box').load('/broadcasts/getvid/'+id,function(){
			$('#video-box').slideDown('slow');
			$('#video-box').append('<p class="broadcast-img-sml-link-close"><img src="/img/icons/x16.png" alt="Close" /></p>');
		});
	});
}
//////////////////////////////////////////////////////////////////////////
function vidClose() {
	$('.broadcast-img-sml-link-close').live('click',function(){
		$('#video-box').slideUp();
		$('#video-box').empty();

		$('#header').show();
		$('#video-all-box').show();
	});
}
//////////////////////////////////////////////////////////////////////////
function noteLink() {
	$('.note-snippet').live('click',function(){
		var link = jQuery("a", this).attr('href');
		window.location.href = link;
	});
}
//////////////////////////////////////////////////////////////////////////
function shopLink() {
	$('.shop-grid-img').live('click',function(){
		var link = jQuery("a", this).attr('href');
		window.location.href = link;
	});
}
//////////////////////////////////////////////////////////////////////////
function tags() {
	$('.tags-link').live('click',function(){
		$('#tags').toggle();
	});
}
//////////////////////////////////////////////////////////////////////////
function related() {
	$('.related-link').live('click',function(){
		$('#related').toggle();
	});
}
//////////////////////////////////////////////////////////////////////////
function note() {
	$('.note-link').live('click',function(){
		$('#note').toggle();
	});
}
//////////////////////////////////////////////////////////////////////////
function showLoader() {
	var msg = new Array('Unto the content, I will carry thee.','Loading...one moment');
	var rand = Math.floor(Math.random()*2);
	$('#loading-msg').html(msg[rand]);
	$('#loader-wrap').show();
}
//////////////////////////////////////////////////////////////////////////
function hideLoader() {
	$('#loader-wrap').hide();
}
//////////////////////////////////////////////////////////////////////////
function viewMap() {
	$('#venue-map').live('click',function(){
		$('#map').slideDown();
		return false;
	});
}
//////////////////////////////////////////////////////////////////////////
function mapClose() {
	$('#map-close').live('click',function(){
		$('#map').slideUp();
		return false;
	});
}
//////////////////////////////////////////////////////////////////////////
function videoWidth() {
	var wid = $('#av .video video').attr('width');
	$('#av .video').css('width',wid);
}
//////////////////////////////////////////////////////////////////////////
function videoWidthVimeo() {
	var wid = $('#av .video iframe').attr('width');
	$('#av .video').css('width',wid);
}
//////////////////////////////////////////////////////////////////////////
