function resizeTabset(){
	$("ul.tab-nav").each(function(){
		var _firstitem = $(this).find("li:first-child");
		var _lastitem = $(this).find("li:last-child");
		_firstitem.addClass("first");
		_lastitem.addClass("last");

		var _hwidth = $(this).width();
		var _iwidth = 0;
		var _icount = 0;

		$(this).find(" > li").each(function() {
			_iwidth+=$(this).width();
			_icount++;
		});

		var _offset = (_hwidth - _iwidth)/(_icount-1);
		$(this).find(" > li").each(function() {
			$(this).css({paddingRight:_offset});
		});

		_lastitem.css({
			marginLeft: -10,
			paddingRight: 5,
			float: "right"
		});
	});
}

$(document).ready(function(){
	resizeTabset();
});

function togglePhotoCredit() {
	var pc = document.getElementById("photoCredit");
	if(pc.style.display == "block") {
    		pc.style.display = "none";
			document.getElementById("i").src="/wp-content/themes/babybites/images/i.png";
  	}
	else {
		pc.style.display = "block";
		document.getElementById("i").src="/wp-content/themes/babybites/images/i-open.gif";
	}
} 

function setVisibility(id, visibility) {
	document.getElementById(id).style.display = visibility;
}

function showTab($tabId) {
	document.getElementById("tab1").style.display = "none";
	document.getElementById("tab2").style.display = "none";
	document.getElementById("tab3").style.display = "none";
	document.getElementById($tabId).style.display = "block";

}

function showTabEvent($tabEventId) {
	for (var i = 1; i<5 ; i++) {
		if (document.getElementById("tabEvent" + i)) {
			document.getElementById("tabEvent" + i).style.display = "none";
		}
	}
	document.getElementById($tabEventId).style.display = "block";

}


function goButtonClick() {
	var dropdownIndex = document.getElementById('select-1').selectedIndex;
	var dropdownValue = document.getElementById('select-1')[dropdownIndex].value;
	window.open(dropdownValue,"_top");

}

function displayPhotoCredit() {
	var imgsrc = document.getElementById('headerImage').src;
	var imgSplit = imgsrc.toString().split('/');
	var photoCredit = imgSplit[imgSplit.length - 1].split('-');
	document.write(photoCredit[0].replace('_', ' '));
}

function displayPhotoURL() {
	var imgsrc = document.getElementById('headerImage').src;
	var imgSplit = imgsrc.toString().split('/');
	var srcarr = imgSplit[imgSplit.length - 1].split('-');
	var URL = srcarr[2].replace('.jpg', '');
	document.write('<a href="http://' + URL + '" target="_blank">' + URL + '</a>');
}