jQuery(function(){

/* **************************** EMAIL SIGNUP FORM ************************ */
var EmailLabel = jQuery('#EmailLabel');
var EmailInput = jQuery('#EmailInput');

EmailInput.focus(function(){
	EmailLabel.hide();
})
.blur(function(){
	if (EmailInput.val() == '') {
		EmailLabel.show();
	}
});

/* ********************************* MULTIMEDIA TABS *********************** */
var tabsLinks = jQuery('#Multimedia .tabs li a');
var tabs = jQuery('#Multimedia .tab');
var photosTab = jQuery('#photosTab');
var videoTab = jQuery('#videoTab');
var defaultTab = 'photosTab';
var currentTab = '';

function displayTab(id) {
	if (id == currentTab) return;
	// make link active first
	tabsLinks.removeClass('active');
	jQuery("a[href='#" + id + "']").addClass('active');
	// now show the correct tab
	tabs.hide();
	jQuery('#' + id).show();
	var currentTab = id;
}

// tab click event functionality
tabsLinks.click(function(){
	var tgt = jQuery(this);
	displayTab(tgt.attr('href').substr(1));
	return false;
});

// show default tab
displayTab(defaultTab);

/* ************************************ PHOTOS TAB FUNCTIONALITY *********************** */

var PhotoEls = jQuery('#Multimedia #photosTab ul li');
var PhotoNav = jQuery('#photoNavBar');

function showPhoto(id) {
	//console.log(id);
	PhotoEls.hide();
	jQuery('#' + id).show();
	PhotoNav.find('a').removeClass('selected');
	jQuery("a[href*='#" + id + "']").addClass('selected');
}

// create the nav links in the photos nav
var count = 1;
PhotoEls.each(function(){
	var id = jQuery(this).attr('id');
	var link = jQuery('<a href="#' + id + '">' + count + '</a>');
	link.click(function(){
		showPhoto(id);
		return false;
	});
	PhotoNav.append(link);
	count++;
});

showPhoto(PhotoEls.get(0).id);

});