function mark_link_for_destroy(element) {
	$(element).next('.should_destroy').value = 1;
	$(element).up('.link').hide();
}

// Shrink a textarea
function textarea_shrink(id) {
  if($(id).clientHeight - 100 <= 100)
    $(id).style.height = '100px';
  else
    $(id).style.height = $(id).clientHeight - 100 +'px';
}

// Grow a textarea
function textarea_grow(id) {
  $(id).style.height = $(id).clientHeight + 100 +'px';
}

function enableForm() {
	$('video_submit').enable();
}

function clearAttachmentUpload() {
	$('attachment_form_container').down('#attachment_uploaded_data').clear();
}

function clearVideoUpload() {
	$('video_form_container').down('#uploaded_data').clear();
}

function selectAll(item) {
	item.focus();
	item.select();
}

function showMap(value) {
	if (value != "") {
		if (value.match(/https?/) == null) {
			$('map_link').update('(<a href="http://maps.google.com?q=' + value + '" target="_blank">view map</a>)');
		} else {
			$('map_link').update('(<a href="' + value + '" target="_blank">view map</a>)');
		}
		$('map_link').show();
	} else {
		$('map_link').update('');
		$('map_link').hide();
	}
	new Effect.Highlight('map_link', {startcolor:'#ffff99', endcolor:'#EEEEEE'});
}

function startDateUpdated(value) {
	if (Form.Element.getValue('professional_development_end_at') == "") {
		Form.Element.setValue('professional_development_end_at',value);
		new Effect.Highlight('professional_development_end_at');
	}
	
	Form.Element.setValue('professional_development_display_until',value);
	new Effect.Highlight('professional_development_display_until');
}

function displayCalendarOrList(item) {
	if (item == "list") {
		$('calendar_view').fade();
		$('list_view').appear();
	} else {	
		$('list_view').fade();
		$('calendar_view').appear();
	}
}

function changeSearchParams(value) {
	if (value.match(/google[^=]*=true/)) {
		autocompleter.options.minChars = 255;
	} else {
		autocompleter.options.minChars = 2;
	}
}