var TestValidation = {

	someFormValidator: null,
	
	init: function() {
		var options = {};
/*		switch(lang){
		case 'en':
			var options = {
				tokenField: "The space", 									// Pole
				tokenNotFieldProperly: "is not filled in properly",			// nie jest wypełnione poprawnie
				tokenGeneral: "the space is required", 
				tokenFulldate: "Pełna data",
				tokenMonth: "miesiąc",
				tokenDay: "dzień",
				tokenYear: "rok",
				tokenPhone: "phone number",
				tokenInteger: "liczba całkowita",
				tokenFloat: "liczba z przecinkiem",
				tokenZipcode: "post code",
				tokenEmail: "e-mail",
				tokenRegex: "wyrażenia regularne",
				tokenMustBeChecked: "must be checked",
				tokenMustBeSelected: "must be selected"
			}
			break;
		case 'de':
			var options = {
				tokenField: "Das Feld", 									// Pole
				tokenNotFieldProperly: "ist nicht richtig ausgefüllt",			// nie jest wypełnione poprawnie
				tokenGeneral: "erforderliches Feld", 
				tokenFulldate: "Pełna data",
				tokenMonth: "miesiąc",
				tokenDay: "dzień",
				tokenYear: "rok",
				tokenPhone: "Telefonnummer",
				tokenInteger: "liczba całkowita",
				tokenFloat: "liczba z przecinkiem",
				tokenZipcode: "Postleitzahl",
				tokenEmail: "E-mail",
				tokenRegex: "wyrażenia regularne",
				tokenMustBeChecked: "muss geprüft werden",
				tokenMustBeSelected: "muss ausgewählt werden"
			}
			break;
		default:
			break;
		}*/
		
		options.onFormInvalid = function(failures) {
				failures.each(function(fail) {
					$("validation-errors").adopt(new Element("li", {'html': fail}));
				});
			};
		options.onFormValid = function() {
				$('autoForm').submit();
			};
		options.onElementValidating = function(el) {
				el.removeClass("valid").removeClass("error");
			};
		options.onElementInvalid = function(el, err) {
				el.addClass("error");
			};
		options.onElementValid = function(el) {
				el.addClass("valid");
			};
	
		this.someFormValidator = new Validation("autoForm", options);
		
		$("autoForm").addEvent("submit", function(e) {
			new Event(e).stop();
			
			$("validation-errors").empty();
			TestValidation.someFormValidator.validate();

		});
		
	}
}



/********** INICJACJA DATAPICKER **********************/
window.addEvent("domready", function() {
	var options = {};
/*	switch(lang){
	 case 'en':
		var options = {
						dayNames: ["Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sun"],
						monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
					};
	 	break;
	 case 'de':
		var options = {
						dayNames: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"],
						monthNames: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"]
					};
	 	break;
	 case 'pl':
	 	break;
	}*/
	$$('input[subtype="fulldate"]').each(function(e){
		if(e.getProperty('subtype')=='fulldate'){
//			var reservedDays = new Array();
//			reservedDays[6]=new Array();
//			reservedDays[6][18]=true;
			var mooCal = new MooCal(e.getProperty('id'), options);
//			mooCal.reservedDays = reservedDays[1];
			mooCal.minYear = new Date().getFullYear();
			mooCal.maxYear = "2100";
			$("datCal_"+e.getProperty('name')).addEvent("click", function(e){
				var event = new Event(e).stop();
				var x = event.page.x;
				var y = event.page.y;
				mooCal.show(x,y); // Display the calendar at the position of the mouse cursor
			});
		};
	});
});

// validacja formularzy
window.addEvent("domready", TestValidation.init.bind(TestValidation));

