function jumpBySelect(element) {
	if (typeof(element) == 'object') {
		var select = element;
	} else {
		var select = document.getElementById(element);
	}
	if (!select) {
		return false;
	}
	document.location = select.options[select.selectedIndex].value;
}

function showElement(id) {
	document.getElementById(id).style.visibility = 'visible';
}

function hideElement(id) {
	document.getElementById(id).style.visibility = 'hidden';
}

function gotoLocation(location, message) {
	if (message) {
		answer = confirm(message);
		if (answer !=0) {
			document.location = location;
		}
	} else {
		document.location = location;	
	}
}

function ajaxSend() {
	$('fieldset').append('<div class="lockup"></div>');
	$('button').css('visibility', 'hidden');
	$('#ajax_return').addClass('loading').html('&nbsp;');	
}

function post(url, data) {
	$.ajax({
		type: 'POST',
		url: url,
		data: data,
		success: function(data, status) {
			ajaxReturn(data);
		}
	});
}

function ajaxReturn(response) {
	$('.lockup').remove();
	$('button').css('visibility', 'visible');	
	if (response) {
		frames['ajax_handler'].history.back();
		if (response.substring(0, 4) == 'b64:') {
			response = Base64.decode(response.substring(4));
		}
		try {
			eval ('var response=' + response);
		} catch (error) {
			alert(error + ': ' + response);
			$('#ajax_return').removeClass('error').removeClass('loading').html(response['body']);
			return false;
		}
		$('#ajax_return').removeClass('loading').html(response['body']);
		if (response['code'] != 1) {
			$('#ajax_return').addClass('error');
		} else {
			$('#ajax_return').removeClass('error');
			if (typeof(response['location']) != 'undefined') {			
				gotoLocation(response['location']);
			}
		}
		if (response['alert']) {
			alert(response['alert']);
		}
		//showElement('ajax_return');
		//setTimeout('hideElement("ajax_return");', 5000);		
	}
}

function equalHeight(group, minimal, insistent) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	if (insistent) {
		group.css('height', Math.max(tallest, minimal));
	} else {
		group.css('min-height', Math.max(tallest, minimal));
	}	
}

function documentReady() {
	equalHeight($('.column'), 500);
	$('.column').resize(function() {
  	equalHeight($('.column'), 500);	
	});
}

function windowLoaded() {
	equalHeight($('.column'), 500, true);
}
