// Password checking: 2 password fields mut be equal, min 6 chars length
function passIsEqual( pass1ID, pass2ID ) {
	var pass1 =  document.getElementById( pass1ID );
	var pass2 =  document.getElementById( pass2ID );
	if( pass1.value == pass2.value ) {
		return true;
	}
	return false;
}

// Input is not empty
function isNotEmptyField( idElem ) {
	if( document.getElementById( idElem ) ) {
		if( document.getElementById( idElem ).value != "" && document.getElementById( idElem ).value != "0" ) {
			return true;
		}
		document.getElementById( idElem ).focus();
	}
	return false;
}

// Value is higher than (integer)
function higherThan( idElem, indexInt ) {
	if( document.getElementById( idElem ) ) {
		if( document.getElementById( idElem ).value.length > indexInt ) {
			return true;
		}
		document.getElementById( idElem ).focus();
	}
	return false;
}

// Value is equal (integer)
function equalAs( idElem, indexInt ) {
	if( document.getElementById( idElem ) ) {
		if( document.getElementById( idElem ).value.length == indexInt ) {
			return true;
		}
		document.getElementById( idElem ).focus();
	}
	return false;
}

// Radio or checkbox is selected
function isChecked( idElem ) {
	if( document.getElementById( idElem ) ) {
		if( document.getElementById( idElem ).checked ) {
			return true;
		}
	}
	return false;
}


// Valid e-mail
function isValidEmail( elem ) {
	str = document.getElementById(elem).value;
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

// Set focus on input
function setFocus( idElem ) {
	document.getElementById( idElem ).focus();
}

// Clear inputvalue
function clearValue( idElem ) {
	document.getElementById( idElem ).value = '';;
}



function getObj(name){
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	} else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	} else if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}


var elementList = new Array();
var nameList 	= new Array();

function addElementToListEmpty( element, ename ) {
	elementList[elementList.length] = element;
	nameList[nameList.length] 	= ename;
}

var varErrorString = '';
var varErrorMail = '';
	
function validateForm() {
	varErrorString = "";
	varErrorMail = "";
	for(i=0;i<elementList.length;i++) {
		if( !isNotEmptyField( elementList[i] ) ) {
			varErrorString = varErrorString + 'Pole "' +nameList[i]+ '" jest puste\n';
		}
	}


	if( isValidEmail(user) ) {
		return true;
	}
	alert("Proszę podać prawidłowy adres e-mail");
	

	if( varErrorString =='' ) {
		return true;
	}
	alert("Proszę wypełnic poniższe pola:\n"+varErrorString);
	

	
	
	
	return false;
}
