function submit(inobjArgs)
{
	//alert(inobjArgs.Params.a)
	var XHR_Success;
	try {
	    XHR_Success = eval(inobjArgs.Params.a + "_Callback");
	} catch(objE) {
	    XHRSuccess = function() {}
	}
	new Ajax.Request(inobjArgs.URL || 'XHRBase.php',
        {
            parameters: inobjArgs.Params,
            onSuccess : XHR_Success
        }
	);
}

/**
 * validates a form
 */
var FormValidator = function(inobjForm) {
	// forms can be passed as Array too.. Do something with them.
	if(Object.isArray(inobjForm)) {
		inobjForm.each(function(elm) {
			new FormValidator(elm);
		});
		return;
	}
		
	/**
	 * Enable su**it or not
	 */
	var evalRequired = function() {
		var blnHasEmpty = _conf.Required.any(function(elm) {return $F(elm).blank();});
		_conf.SubmitButton.disabled = !(passwordsMatch() && !blnHasEmpty);
	}

	
	/**
	 * Does passwords match or not?
	 */
	var passwordsMatch = function() {
		var strCheck = null;
		return !_conf.Form.select('input[type="password"]').any(function(elm) {
			strCheck = strCheck == null ? $F(elm)
										: strCheck;
			return $F(elm) != strCheck;
		});
	}
	
	var submitForm = function(inobjElm) {
		//if(_conf.Form.hasClassName('xhr')) {
		//	_conf.Form.request();
		//} else {
		alert(inobjElm.element().onclick)
		_conf.Form.submit();
		//}
	}
	
	// Configuration array, touch this and die..
	var _conf = {
		Form: 			$(inobjForm),
		SubmitButton:	$(inobjForm).select('input[type="submit"]', 'input[type="button"].submit')[0],
		Required: 		$(inobjForm).select('.required'),
		// Captcha is captcha if 1 else null
		Captcha: 		$(inobjForm).select('img.captcha').length == 1
						? $(inobjForm).select('img.captcha')[0]
						: null
	};
	_conf.Form.reloadCaptcha = function() {
		var objForm = _conf.Form;
		objForm.select('input[name="captcha"]')[0].value = '';
		objForm.select('img.captcha')[0].src = '/secimg.png?' + Math.random();
	}
	//_conf.SubmitButton.observe('click', submitForm);

	
	var objElm = _conf.Form.select('input.focus');
	if(objElm[0]) {
		objElm[0].select();
		objElm[0].focus();
		//alert(objElm[0].tagName); //.focus();
	}
	
	// Assign some nice events to captcha, if any were found.
	if(_conf.Captcha != null) {
		_conf.Captcha.style.cursor = 'pointer';
		_conf.Captcha.observe('click', _conf.Form.reloadCaptcha);
	}
	
	// keyUp handlers for required fields
	_conf.Required.each(function(elm) {
		elm.observe('keyup', evalRequired);
	});
	
	// put some fire on this beauty
	evalRequired();
} // FormValidator

document.observe("dom:loaded", function() {
		$('sp').innerHTML = '<strong>EMAIL / MSN: info@utvecklarna.se</strong>'
					  + ' &copy 2004 - 2010';
		$$('.ml').each(
			function(inobjCurr) {
				inobjCurr.innerHTML = '<a href="mailto:rikard@utvecklarna.se">' + inobjCurr.innerHTML + '</a>';
			}
		);
		//new FormValidator($$('form.autovalidate'));
});


var i18n = {
	lang: 'se'
}
