function highlightErrors( errors )
{
	$(document).ready( function(){
		var d = function(i,p,o){if(o instanceof Array) o=o.join(', ');if(typeof(o)=='string'){if(i[p])i[p]+=', '+o;else i[p]=o;}else for(x in o)d(i,p+'_'+x,o[x]);return i;}
		var flat = d({},'inp',errors);
		for(x in flat){
			var sp = document.createElement('span');
			sp.className = 'invalid';
			sp.innerHTML = flat[x]+'<br>';
			$('#'+x).parent().prepend( sp ); 
		}
			
		$('label[for]').each(function(){ 
			var f = this.getAttribute('for');
			if(f && flat[ f ]){
				$(this).addClass('invalid')
			}; 
		});
		
		$('.invalid').each(function(){ $(this).closest('.fold').show().prevAll('h4:eq(0)').addClass('invalid'); });

	});
}

$(function(){
	$('form').submit( handleFormTranslation );	
});

function handleFormTranslation(e)
{
	var m,h = $('#image-home-link').get(0).href
	if(m = h.match(/#.*$/)){
		e.target.action += m;
	}
}

