function showErrors(xml) {
	$(".error").text("");
		
	$("error", xml).each(function() {
		var errortype = $(this).attr("type");
		var errortext = $(this).text();
		var errordiv = "#error_" + errortype;
		
		$(errordiv).text( errortext );
		$(errordiv).slideDown(100);
		
	});
	
	$('.error').each(function() {
		if ($(this).text() == "") {
			$(this).slideUp(100);	
		}
	});
}

function hideErrors(xml) {
	$(".error").slideUp(100);
}

function showMessages(xml) {
	$(".message").text("");
		
	$("message", xml).each(function() {
		var errortype = $(this).attr("type");
		var errortext = $(this).text();
		var errordiv = "#message_" + errortype;
		
		$(errordiv).text( errortext );
		$(errordiv).slideDown(100);
		
	});
	
	$('.message').each(function() {
		if ($(this).text() == "") {
			$(this).slideUp(100);	
		}
	});
}

function hideMessages(xml) {
	$(".message").slideUp(100);
}

function checkStatus(xml) {
	return $("status", xml).text() == "1";
}

$(document).ready(function() {
	$(".error").hide();
	$(".message").hide();
});

function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
