// UTF-8 Dreamweaver detect (éàç)
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Global vars
////////////////////////////////////////////////////////////////////////////////////////////////////////
	var req = createXMLHttpRequest(); 
	var keycode = null;
	var submitted = false;	
	
	document.onkeydown = checkKeycode
	function checkKeycode(e) {
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		return;
	}


////////////////////////////////////////////////////////////////////////////////////////////////////////
// Superform v0.2
////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Constructor
	////////////////////////////////////////////////////////////////////////////////////////////////////
	function superForm(theForm) {
		this.myForm = theForm
		this.elements = theForm.elements;
		this.flagValid = null;
		this.flagInvalid = null;
		this.fieldErrors=null;
		this.groupFields = new Array();
		this.mainFields = new Array();
		this.handler=null;
		this.errors = 0;
		this.errorsField = false;/*KLR*/

		if(theForm.getAttribute("ajaxSubmitTo")) {
			this.ajaxSubmitTo = theForm.getAttribute("ajaxSubmitTo");
		}
		if(theForm.getAttribute("invalidFlagImg")) {
			this.flagInvalid ="<img src='" + theForm.getAttribute("invalidFlagImg") + "' alt='' border=0 /><br>";
		}
		if(theForm.getAttribute("validFlagImg")) {
			this.flagValid ="<img src='" + theForm.getAttribute("validFlagImg") + "' alt='' border=0 /><br>";
		}

		for(i=0; i < this.elements.length; i++) {
			this.firstCheckElement(this.myForm.elements[i]);
		}
		
		// Build mainFields array
		for (i=0; i < this.mainFields.length; i++){
			for(j=0; j < this.groupFields.length; j++) {
				// Set mainFields
				if(this.groupFields[j].getAttribute("multiFieldGroup") == this.mainFields[i].id ){
					this.groupFields[j].setAttribute("mainField",this.mainFields[i].id);
				}
			}
		}
		
		/*KLR>*/
		if(theForm.getAttribute("errorsField")) {
			this.errorsField = theForm.getAttribute("errorsField");
		}
		/*<KLR*/
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Tiers
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Pre-Tier (T0)
	superForm.prototype.firstCheckElement = function(el) {
		if(el.getAttribute("clearValue")) {
			this.checkClearValue(el);
		}
		if(el.getAttribute("multiFieldGroupMain")) {
			this.mainFields.push(el);
		}

		if(el.getAttribute("multiFieldGroup")) {
			this.groupFields.push(el);
		}
	}
	
	// Tier 1
	superForm.prototype.checkElementT1 = function(el) {
		// Being filled in
		this.fieldErrors=0;
		//if (el.getAttribute("isUnfilled")) this.checkFilled(el);
		if(el.getAttribute("clearValue")) this.checkClearValue(el);
		if(el.getAttribute("isNotNumeric")) this.checkNumeric(el);
		if(el.getAttribute("isNotAlpha")) this.checkAlpha(el);
		
		if(this.fieldErrors == 0 && el.value != ""){
			this.voidError(el);
		}
	}
	
	// Tier 2
	superForm.prototype.checkElementT2 = function(el) {
		// Has been filled in
		this.fieldErrors=0;
		if (el.getAttribute("isUnfilled")) this.checkFilled(el);
		if (el.getAttribute("isInvalidEmail")) this.checkMail(el);
		if(el.getAttribute("isInvalidEmailMulti")) this.checkMails(el);
		if(el.getAttribute("isInvalidPostalCode")) this.checkPostalCode(el);
		if(el.getAttribute("isConfirmationOf")) this.checkConfirmation(el);
		if(el.getAttribute("clearValue")) this.checkClearValue(el);
		if(el.getAttribute("isNotNumeric")) this.checkNumeric(el);
		if(el.getAttribute("isNotAlpha")) this.checkAlpha(el);
		if(el.getAttribute("minRange") && el.getAttribute("maxRange") && el.getAttribute("isOutOfRange")) this.checkRange(el);
		if(el.getAttribute("reqLength")) this.checkLength(el);
		if(el.getAttribute("ajaxCheck")) this.ajaxCheck(el);

		if(this.fieldErrors == 0 && el.value != ""){
			this.clearError(el);
		}
	}
	
	// Tier 3
	superForm.prototype.checkElementT3 = function(el) {
		// Ready to submit?
		this.fieldErrors=0;

		if(el.getAttribute("isUnselected")) this.checkSelected(el);
		if(el.getAttribute("isUnchecked")) this.checkUnchecked(el);
		if(el.getAttribute("isUnfilled")) this.checkFilled(el);
		if(el.getAttribute("isInvalidEmail")) this.checkMail(el);
		if(el.getAttribute("isInvalidEmailMulti")) this.checkMails(el);
		if(el.getAttribute("isInvalidPostalCode")) this.checkPostalCode(el);
		if(el.getAttribute("isConfirmationOf")) this.checkConfirmation(el);
		if(el.getAttribute("clearValue")) this.checkClearValue(el);
		if(el.getAttribute("isNotNumeric")) this.checkNumeric(el);
		if(el.getAttribute("isNotAlpha")) this.checkAlpha(el);
		if(el.getAttribute("minRange") && el.getAttribute("maxRange") && el.getAttribute("isOutOfRange")) this.checkRange(el);
		if(el.getAttribute("reqLength")) this.checkLength(el);
		if(el.getAttribute("ajaxCheck")) this.ajaxCheck(el);
		

		if(this.fieldErrors == 0 && el.value != ""){
			this.clearError(el);
		}
	}
	
	superForm.prototype.checkSubmit = function() {
		this.errors=0;
		
		// Clear mainFields
		for(i=0; i < this.mainFields.length; i++) {
			this.clearErrors(this.mainFields[i]);
		}
		
		// Check each element
		for(i=0; i < this.elements.length; i++) {
			this.checkElementT3(this.myForm.elements[i]);
		}
		
		// Check mainFields
		for(i=0; i < this.mainFields.length; i++) {
			if(this.mainFields[i].getAttribute("groupErrors") == "") {
				if(this.mainFields[i].value != ""){
					if(this.mainFields[i].getAttribute("reqLength")) {
						reqLength = parseInt(this.mainFields[i].getAttribute("reqLength"));
						if(this.mainFields[i].value.length == reqLength ) {
							this.clearError(this.mainFields[i]);
						}
					} else {
						this.clearError(this.mainFields[i]);	
					}
				}
			} else {
				this.showErrors(this.mainFields[i]);
			}
		}
	
		// Submit	
		this.submitIt();
	}
	
	superForm.prototype.submitIt = function() {
		// Delay final submit check if ajax isn't yet done

		if(req.readyState && (req.readyState == 1 || req.readyState == 2 || req.readyState == 3)) {
			if(this.me.submitIt()){
				setTimeout(this.me + ".submitIt();" , 50);
			}
		} else {
			if(this.errors==0) {
				if(this.ajaxSubmitTo) {
					this.ajaxSubmit();
				} else {
					this.myForm.submit();
				}
			 }
		}
	 }
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Tests
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.checkClearValue = function(el) {
		if(el.value=="") {
			el.value = el.getAttribute("clearValue");
		}
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Checks
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.checkNumeric= function(el) {
		var NumericRegex = new RegExp("[^0-9]", "g");
		if(NumericRegex.test(el.value)) {
			this.showError(el, el.getAttribute("isNotNumeric"))
		}
	}

	superForm.prototype.checkAlpha= function(el) {
		if(AlphaRegex.test(el.value)) {
			this.showError(el, el.getAttribute("isNotAlpha"))
		}
	}

	superForm.prototype.checkRange = function(el) {
		minR = parseInt(el.getAttribute("minRange"));
		maxR = parseInt(el.getAttribute("maxRange"));

		if(el.value=="" || el.value < minR || el.value > maxR) {
			this.showError(el, el.getAttribute("isOutOfRange"))
		}
	}

	superForm.prototype.checkLength = function(el) {
		reqLength = parseInt(el.getAttribute("reqLength"));
		if(el.value=="" || el.value.length != reqLength) {
			if(el.getAttribute("isUnfilled")){
				this.showError(el, el.getAttribute("isUnfilled"))
			}
		}
	}

	superForm.prototype.checkFilled = function(el) {
		if(el.getAttribute("clearValue")) {
			clearValue = el.getAttribute("clearValue");
		} else {
			clearValue = "";
		}
		if(el.value == "" || el.value == clearValue) {
			this.showError(el, el.getAttribute("isUnfilled"));
		}
	}
	
	superForm.prototype.checkSelected = function(el){
		if(el.type=="radio"){
			if(el.selectedIndex==0) {
				this.showError(el, el.getAttribute("isUnselected"));
			}
		} else {
			if(el.selectedIndex==0) {
				this.showError(el, el.getAttribute("isUnselected"));
			}
		}
	}

	superForm.prototype.checkUnchecked = function(el){
		oneSelected = false;
		if(el.type == "radio") {
			// If radio button make sure at least one is selected
			for(z=0; z < this.elements.length; z++) {
				if(this.elements[z].id == el.id && this.elements[z].checked == true ){
					oneSelected = true;
				}
			}
			if(oneSelected == false){
				this.showError(el, el.getAttribute("isUnchecked"));
			}
			
		} else {
			/*if(!el.checked) {
				this.showError(el, el.getAttribute("isUnchecked"));
			}*/
			/*KLR>*/
			if(!el.checked) {
				var label = document.getElementById(el.id+'_label');
				label.normalColor = label.style.color;
				label.style.color = '#bb0606';
				this.errors++;
				this.fieldErrors++;
			}else{
				var label = document.getElementById(el.id+'_label');
				label.style.color = label.normalColor;
			}
			/*<KLR*/
		}
	}
	
	superForm.prototype.checkConfirmation = function(el){
		confirmationOf = eval("this.myForm." + el.getAttribute("isConfirmationOf"));
		if(el.value != "") {
			if(el.value !=  confirmationOf.value) {
				this.showError(el, el.getAttribute("isNotTheSame"));
			}
		}
	}
	
	superForm.prototype.checkPostalCode = function (el) {
		code = el.value;
		//filter  = /^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i;
		filter  = /^[a-z]\d[a-z][-\s]?\d[a-z]\d$/i;
		if (!filter.test(code)) {
			this.showError(el, el.getAttribute("isInvalidPostalCode"));
		}
	}

	superForm.prototype.checkMail = function(el) {
		addy = el.value;
		filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(addy)) {
			this.showError(el, el.getAttribute("isInvalidEmail"));
		}
	}

	superForm.prototype.checkMails = function(el) {
		addy = el.value.split(",");
		filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		for(z=0; z < addy.length; z++){
			if(!filter.test(addy[z])) {
				this.showError(el, el.getAttribute("isInvalidEmailMulti"));
			}
		}
	}

	superForm.prototype.checkMaxChars = function(el) {
		myMax = el.getAttribute("maxChars");
		if(el.value.length > myMax) {
			m = parseInt(el.getAttribute("maxChars"))+1;
			el.value = el.value.substr(0,m);
			this.showError(el, el.getAttribute("isTooLong"));
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Field Tips / Password Strength
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.showTips= function(el) {
		which = el.id;
		if(document.getElementById("fieldTips_" + which)) {
			document.getElementById("fieldTips_" + which).style.display = "block";
		}
	}

	superForm.prototype.hideTips= function(el) {
		which = el.id;
		if(document.getElementById("fieldTips_" + which)) {
			document.getElementById("fieldTips_" + which).style.display = "none";
		}
	}

	superForm.prototype.evaluatePWStrength= function(el) {
		var strongestRegex = new RegExp("^(?=.{9,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
		var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
		var mediumRegex = new RegExp("^(?=.{7,})|(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
		var enoughRegex = new RegExp("(?=.{6,}).*", "g");
		str=0;
		if(enoughRegex.test(el.value)) str=1;
		if(mediumRegex.test(el.value)) str=2;
		if(strongRegex.test(el.value)) str=3;
		if(strongestRegex.test(el.value)) str=4;
		
		document.getElementById("pwStrengthImg").src = "img/pws" + str + ".gif";
		
	}

	superForm.prototype.evaluateTipConditions= function(el) {
		for(i=1; i < 6; i++) {
			if(document.getElementById("tip_" + el.id + "_" + i)){
				cond = new RegExp(document.getElementById("tip_" + el.id + "_" + i).getAttribute("condition"),"g");
				if(cond.test(el.value)) {
					document.getElementById("tipFlag"+i).src = "img/mini-accept.gif";
				} else {
					document.getElementById("tipFlag"+i).src = "img/mini-cross.gif";
				}
			}
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Error handling
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.showError= function(el, error) {
		this.errors++;
		this.fieldErrors++;

		if(el.getAttribute("multiFieldGroup") || el.getAttribute("multiFieldGroupMain")){
			if(el.getAttribute("multiFieldGroup")) {
				which = document.getElementById(el.getAttribute("multiFieldGroup"));
			} else {
				which = document.getElementById(el.getAttribute("multiFieldGroupMain"))
			}
			if(which.getAttribute("groupErrors")=="") {
				which.setAttribute("groupErrors", which.getAttribute("groupErrors") + error + "%%");
			}
			
		} else {
			which = el.id;
/*		
			if(document.getElementById("flag_" + which) && document.getElementById("flag_" + which).innerHTML != this.flagInvalid) {
				document.getElementById("flag_" + which).innerHTML = this.flagInvalid;
			}
*/			
			if(document.getElementById("wrap_" + which) && document.getElementById("wrap_" + which).className != "formWrapperInvalid") {
				document.getElementById("wrap_" + which).className  = "formWrapperInvalid";
			}
			if(document.getElementById("confirmations_" + which)) {
				document.getElementById("confirmations_" + which).style.display="none";
			}
			if(document.getElementById("errors_" + which)) {
				/*if(el.type=="checkbox"){
					document.getElementById("errors_" + which).innerHTML = error;
					document.getElementById("errors_" + which).style.display = "block";
				}else{
					document.getElementById("errors").innerHTML = err;
				}*/
				/*KLR>*/
				//errorField: specific field for errors
				if(el.type=="checkbox"){
					document.getElementById("errors_" + which).innerHTML = error;
					document.getElementById("errors_" + which).style.display = "block";
				}else if(el.getAttribute("alreadyUse")){
					if (this.errorsField){
						document.getElementById(this.errorsField).innerHTML = error;
					}else{
						document.getElementById("errors").innerHTML = error;
					}
				}else{
					if (this.errorsField){
						document.getElementById(this.errorsField).innerHTML = err;
					}else{
						document.getElementById("errors").innerHTML = err;
					}
				}
				/*<KLR*/
				
			} else {
				//alert(error);
			}
		}
	}
	
	superForm.prototype.showErrors= function(el) {
		which= el.id;
		error = el.getAttribute("groupErrors");
/*
		if(document.getElementById("flag_" + which) && document.getElementById("flag_" + which).innerHTML != this.flagInvalid) {
			document.getElementById("flag_" + which).innerHTML = this.flagInvalid;
		}
*/		
		if(document.getElementById("wrap_" + which) && document.getElementById("wrap_" + which).className != "formWrapperInvalid") {
			document.getElementById("wrap_" + which).className  = "formWrapperInvalid";
		}
		if(document.getElementById("confirmations_" + which)) {
			document.getElementById("confirmations_" + which).style.display="none";
		}
		if(document.getElementById("errors_" + which)) {
			error = error.replace(/%%/g,"<br />");
			//document.getElementById("errors_" + which).innerHTML = error;
			//document.getElementById("errors_" + which).style.display = "block";
		} else {
			error = error.replace(/%%/g,"\n");
			
			//alert(error);
		}
	}

	superForm.prototype.clearErrors= function(el) {
		el.setAttribute("groupErrors","");
	}


	superForm.prototype.clearError= function(el) {
		which = el.id;
		/*
		if(document.getElementById("flag_" + which)) {
			document.getElementById("flag_" + which).innerHTML = this.flagValid;
		}
		*/
		if(document.getElementById("wrap_" + which) && document.getElementById("wrap_" + which).className != "formWrapperValid") {
			document.getElementById("wrap_" + which).className  = "formWrapperValid";
		}
		if(document.getElementById("errors_" + which)) {
			document.getElementById("errors_" + which).innerHTML = "";
			document.getElementById("errors_" + which).style.display = "none";		
		}
	}
	
	superForm.prototype.clearAllErrors= function() {
		for(i=0; i < this.elements.length; i++) {
			which = this.elements[i].id;
			if(document.getElementById("errors_" + which)) {
				document.getElementById("errors_" + which).innerHTML = "";
				document.getElementById("errors_" + which).style.display = "none";		
			}
		}
	}

	superForm.prototype.voidError= function(el) {
		which = el.id;
		if(document.getElementById("flag_" + which)) {
			document.getElementById("flag_" + which).innerHTML = "";
		}
		if(document.getElementById("wrap_" + which) && document.getElementById("wrap_" + which).className != "formWrapperValid") {
			document.getElementById("wrap_" + which).className  = "formWrapperValid";
		}
		if(document.getElementById("errors_" + which)) {
			document.getElementById("errors_" + which).innerHTML = "";
			document.getElementById("errors_" + which).style.display = "none";		
		}
		if(document.getElementById("errors_concours")) {
			document.getElementById("errors_concours").innerHTML = '';
		}
		if(document.getElementById("errors_inspiration")) {
			document.getElementById("errors_inspiration").innerHTML = '';
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Events
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.checkOnSelect = function(el) {
		clearValue = el.getAttribute("clearValue");
		if(el.value == clearValue) { el.value=""; }
		return true;
	}
	
	
	superForm.prototype.checkEnter = function() {
		var charCode = (evt.which) ? evt.which : event.keyCode;

		if(charCode == 13) { this.checkSubmit(); }
		
		return true;
	}
	
	superForm.prototype.checkOnBlur = function(el) {
		if(el.getAttribute("clearValue")) {
			this.checkClearValue(el);
		}
		 return true;
	}

	
	superForm.prototype.checkOnChange = function(el) {
		mainField = null;		
		reqLength = 0;
		if(el.getAttribute("mainField")) { 
			mainField = document.getElementById(el.getAttribute("mainField")); 
			if(mainField.getAttribute("reqLength")){
				reqLength = parseInt(mainField.getAttribute("reqLength"));
			}
		}
		if(el.getAttribute("multiFieldGroup")){
			this.updateMainField(el, mainField);
			this.checkMultiFieldGroup(el, mainField, 2);
		} else {
			this.checkElementT2(el);
		}

		return true;
	}


	superForm.prototype.checkOnType = function(el){
		
		//var charCode = (evt.which) ? evt.which : event.keyCode;
		charCode = keycode;
		reqLength = 0;
		mainField = null;		
		if(el.getAttribute("mainField")) { 
			mainField = document.getElementById(el.getAttribute("mainField")); 
		}

		if(el.getAttribute("multiFieldGroup")){
			this.updateMainField(el, mainField);
			this.checkMultiFieldGroup(el, mainField, 1);
		} else {
			this.checkElementT1(el);
		}

		if(el.getAttribute("autoTabTo") && el.getAttribute("maxlength") && charCode != 9 && charCode != 16) {
			if(el.value.length == el.getAttribute("maxlength")) {
				d=document.getElementById(el.getAttribute("autoTabTo"));
				if(mainField.getAttribute("reqLength")) {
					if(mainField.value.length == mainField.getAttribute("reqLength")) {
						if(mainField){
							this.checkElementT1(mainField);
						} else {
							this.checkElementT1(el);
						}
					}
				}
				d.focus();
			}
		}

		return true;
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	// Group fields
	////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.checkMultiFieldGroup = function(el, mainField, tier) {
		// Clear mainField
		this.clearErrors(mainField);
		
		if(mainField.getAttribute("reqLength")){
			reqLength = parseInt(mainField.getAttribute("reqLength"));
		} else {
			reqLength = 0;
		}

		// Check each element in group
		for(j=0; j < this.groupFields.length; j++) {
			if(this.groupFields[j].getAttribute("multiFieldGroup") == mainField.id ){
				this.checkElementT1(this.groupFields[j]);
			}
		}

		// Check mainField
		if(tier==1 && mainField.value.length < reqLength) {
			this.checkElementT1(mainField);
			
			if(mainField.getAttribute("groupErrors") == ""){
				this.voidError(mainField);
			} else {
				this.showErrors(mainField);	
			}
			
		}
		
		if(tier==2 || mainField.value.length >= reqLength) {
			this.checkElementT2(mainField);
			if(mainField.value.length >= reqLength) {
				if(mainField.getAttribute("groupErrors") == ""){
					this.clearError(mainField);
				} else {
					this.showErrors(mainField);	
				}
			} else {
				if(mainField.getAttribute("groupErrors") == ""){
					this.voidError(mainField);	
				}
			}
		}
		
	}

	superForm.prototype.updateMainField = function(el, mainField) {
		myGroup = el.getAttribute("multiFieldGroup");
		r=new Array();
		for(i=0; i < this.elements.length; i++) {
			if(this.elements[i].getAttribute("multiFieldGroup")) {
				if(this.elements[i].getAttribute("multiFieldGroup") == myGroup) {
					if(this.elements[i].getAttribute("clearValue")) {
						if(this.elements[i].value != this.elements[i].getAttribute("clearValue")) {
							r.push(this.elements[i].value);
						}
					} else {
						r.push(this.elements[i].value);
					}
				}
			}
		}
		
		if(mainField) {
			mainField.value = r;
			if(mainField.getAttribute('multiFieldGroupSeperator')) {
				sep = mainField.getAttribute('multiFieldGroupSeperator')
			} else {
				sep = "";
			}
			mainField.value = mainField.value.replace(/,/g,sep);
		}
	}
	

////////////////////////////////////////////////////////////////////////////////////////////////////////
// Ajax / Comet
////////////////////////////////////////////////////////////////////////////////////////////////////////
	superForm.prototype.ajaxSubmit = function() {
		args="";	
		for(i=0; i < this.elements.length; i++) {
			el = this.elements[i];
			if(!el.getAttribute("noSubmit")) {
				if(el.type != "radio" || el.checked == true) {
					//if(el.checked == true) {
					if(el.checked == true && el.type == "checkbox") {/*KLR*/
						v = 1;
					} else {
						v = el.value;
						if (el.getAttribute("encode_amp")){
							v = v.replace(/&/g, "|amp");
						}
						if (el.getAttribute("encode_br")){
							v = v.replace(/(\r|\n)/g, "<br>");
						}
					}
					
					args+= el.id + "=" + v;
					args+="&";
				}
			}
		}
		args+="errors=" + this.errors;
		if(!submitted) {
			submitted= true;
			cometPost(this.ajaxSubmitTo, args, this.handler);
		}
	}

	superForm.prototype.ajaxCheck = function(el){	
		url = el.getAttribute("ajaxCheck") + el.value;
		comet(url, this.checkAjaxErrors);
	}
	
	superForm.prototype.checkAjaxErrors = function() {
		
		if(req.readyState == 4){ 
			var response = "" + req.responseText;
			
			if(response.length > 4) {
				
				//temp fix
				registerF.showError(document.registration.email, document.registration.email.getAttribute("isUsed"));
				
				/*
				response=response.split("||");
				for(i=0; i < response.length; i+=2) {
					el = document.getElementById(response[i]);
					err = response[i+1];
					err= el.getAttribute(err);

					this.showError(el, err);
				}
				*/
			}
		}
	}

	function createXMLHttpRequest() { 
		var ua; 
		if(window.XMLHttpRequest) { 
			try { 
				ua = new XMLHttpRequest(); 
			} catch(e) { 
				ua = false; 
			} 
		} else if(window.ActiveXObject) { 
			try { 
				ua = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch(e) { 
				ua = false; 
			} 
		} 
		return ua; 
	} 


	function comet(url, callback) {
		// FIX FF XMLHTTP bug
		if(req.readyState && (req.readyState == 1 || req.readyState == 2 || req.readyState == 3)) {
			setTimeout("delayedSend('" + url + "', " + callback + ");" , 10);
		} else {
			req.open('get', url); 
			req.onreadystatechange = callback; 
			req.send(null);
		}
	}


	function cometPost(url, params, callback) {
		// FIX FF XMLHTTP bug
		if(req.readyState && (req.readyState == 1 || req.readyState == 2 || req.readyState == 3)) {
			setTimeout("delayedSend('" + url + "', " + callback + ");" , 10);
		} else {
			req.open('post', url, true); 
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			req.setRequestHeader("Content-length", params.length);
			req.setRequestHeader("Connection", "close");
			req.onreadystatechange = callback; 
			req.send(params);
		}
	}

	function delayedSend(url, callback) {
			if(req.readyState != 4 && req.readyState != 0) {
				//debug("delayedSend('" + url + "', " + callback + ");");
				setTimeout("delayedSend('" + url + "', " + callback + ");" , 10);
			} else {
				//req.abort();
				req.open('get', url); 
				req.onreadystatechange = callback; 
				req.send(null);
			}
	}

	function debug(inp){
		document.getElementById("debug").innerHTML = inp;
	}
