validateShare = function(id) {
	
	var fm = eval('document.share_form_'+id);
	
	fm.from.value = trim(fm.from.value);
	fm.to.value = trim(fm.to.value);

	if (fm.from.value == '') 
	{
		alert('Enter your email address');
		fm.from.focus();
		return false;
	}

	if (!checkEmail(fm.from.value)) {
		alert('Your email address is not formatted correctly.');
		fm.from.focus();
		return false;
	}

	if (fm.to.value == '') 
	{
		alert('Enter one or more friend email addresses, separated by commas.');
		fm.to.focus();
		return false;
	}
	
	return true;
}

checkEmail = function (val) {
   var format = /^[0-9a-z]([-+_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,3}$/i;
   return (val.match(format));
};

showShare = function(which, id) {
	closeShare(id);
	
	switch(which) {
		case 1:
			el('share_box_'+id).style.display = 'block';
			var fm = eval('document.share_form_'+id);
			if (fm) fm.from.focus();
			break;

		case 2:
			el('embed_box_'+id).style.display = 'block';
			break;

		case 3:
			el('aggregate_box_'+id).style.display = 'block';
			break;
	}
}

closeShare = function(id) {
	if (el('share_box_'+id)) el('share_box_'+id).style.display = 'none';
	if (el('embed_box_'+id)) el('embed_box_'+id).style.display = 'none';
	el('aggregate_box_'+id).style.display = 'none';
}
