goodInputs = new Array('text', 'password', 'textarea', 'select-one', 'file');

wrongInputsTypes = new Array();
wrongInputsTypes[goodInputs[0]] = 'text-field text-input-wrong';
wrongInputsTypes[goodInputs[1]] = 'text-field text-input-wrong';
wrongInputsTypes[goodInputs[2]] = 'textarea-wrong';
wrongInputsTypes[goodInputs[3]] = 'select-input-wrong';
wrongInputsTypes[goodInputs[4]] = 'file-input-wrong';

goodInputsTypes = new Array();
goodInputsTypes[goodInputs[0]] = 'text-field';
goodInputsTypes[goodInputs[1]] = 'text-field';
goodInputsTypes[goodInputs[2]] = '';
goodInputsTypes[goodInputs[3]] = '';
goodInputsTypes[goodInputs[4]] = '';

function createXMLObject(){
	var verificationRequest = false;
	if(window.XMLHttpRequest){
		verificationRequest = new XMLHttpRequest();
		if(verificationRequest.overrideMimeType){
			verificationRequest.overrideMimeType('text/xml');
		}
	}
	else if(window.ActiveXObject){
		try{
			verificationRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				verificationRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){}
		}
	}
	if(!verificationRequest) {
		return false;
	}
	return verificationRequest;
}

function defaultReturnErrors(verificationRequest, inputsArray, currentStyle){
	if(verificationRequest.readyState == 4){
		if(verificationRequest.status == 200){
			
			var returnedString = verificationRequest.responseText;
			
			var errorsDivision = document.getElementById('errors-division');
			
			if(returnedString !== ''){
				errorsDivision.style.marginBottom = '20px;'
				errorsDivision.style.marginLeft = '20px'
				errorsDivision.style.marginRight = '20px'
				errorsDivision.style.marginTop = '20px'
				
				var largeArray = returnedString.split('<-|->');
				
				var errorsDivisionText = '';
				
				var badInputs = new Array();
				
				for(var i = 0; i < largeArray.length; i++){
					var currentArray = largeArray[i].split('<|-|>');
					if(currentArray[0] !== 'none'){
						var currentInput = document.getElementById(inputsArray[currentArray[0]]);
						
						if(inArray(currentInput.type, goodInputs)){
							currentInput.setAttribute("class", wrongInputsTypes[currentInput.type]);
							currentInput.setAttribute("className", wrongInputsTypes[currentInput.type]);
						}
						errorsDivisionText += '<div><img src="template/'+currentStyle+'/images/arrow.gif" alt="" />'+currentArray[1]+'</div>';
						
						badInputs[i] = currentArray[0];
					}
					else errorsDivisionText += '<div><img src="template/'+currentStyle+'/images/arrow.gif" alt="" />'+currentArray[1]+'</div>';
				}
				
				for(var i = 0; i < inputsArray.length; i++){
					if(inputsArray[i] !== 'none'){
						
						if(!inArray(i, badInputs)){
							currentInput = document.getElementById(inputsArray[i]);
							if(inArray(currentInput.type, goodInputs)){
								currentInput.setAttribute("class", goodInputsTypes[currentInput.type]);
								currentInput.setAttribute("className", goodInputsTypes[currentInput.type]);
							}
						}
					}
				}
				
				errorsDivision.innerHTML = errorsDivisionText;
			}
			else{
				errorsDivision.innerHTML = '';
				
				errorsDivision.style.marginBottom = '0;'
				errorsDivision.style.marginLeft = '0'
				errorsDivision.style.marginRight = '0'
				errorsDivision.style.marginTop = '0'
				
				for(var i in inputsArray){
					if(i != 'none'){
						currentInput = document.getElementById(inputsArray[i]);
						if(inArray(currentInput.type, goodInputs)){
							currentInput.setAttribute("class", goodInputsTypes[currentInput.type]);
							currentInput.setAttribute("className", goodInputsTypes[currentInput.type]);
						}
					}
				}
				
				document.currentForm.submit();
			}
		}
	}
}