function Common() {
	this.redirect=function(url)
	{
		window.location=url;
	}

	this.confirmRedirect=function(msg, url)
	{
		if (confirm(msg)==true) this.redirect(url);
	}
	
	this.checkForm=function(form, inputs, titles, errormsg)
	{
		function inArray(array, value)
		{
			for (var i=0; i<array.length; i++)
				if (array[i]==value) return i;
				
			return null;
		}
		
		function showError(element, field)
		{
			var msg=errormsg.replace(/#FIELD#/, field);
			alert(msg);
			element.focus();
		}
		
		for (var i=0; i<form.elements.length; i++)
		{
			var element=form.elements[i];
			
			var index=inArray(inputs, element.name)
			
			if (index!=null)
			{
				switch(element.type)
				{
				case 'text':
				case 'textarea':
				case 'password':
					if (element.value.length==0)
					{
						showError(element, titles[index]);
						return false;
					}
					
					break;
				}
			}
		}
		
		return true;
	}
}

var common=new Common();