function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function Confirm(){
	var confirmpassword = document.getElementById('con').value;
	var newpassword = document.getElementById('new').value;
	
	if ( newpassword == confirmpassword ){;
		document.getElementById('verify').innerHTML = "Valid";	
	}else{
		document.getElementById('verify').innerHTML = "Fields don't match";
	}
}

function SizeOfPassword(){
	var newpassword = document.getElementById('new').value;
	var newpasswordlength = newpassword.length;
	
	if ( newpasswordlength < 5 ){
		document.getElementById('verifylength').innerHTML = "too short";	
	}else{
		document.getElementById('verifylength').innerHTML = "Valid";
	}	
}

function CheckEmpty(){
	
	input1 = trim(document.getElementById('firstname').value);
	input2 = trim(document.getElementById('surname').value);
	input3 = trim(document.getElementById('company').value);
	input4 = trim(document.getElementById('new').value);
	input5 = trim(document.getElementById('con').value);
	input6 = trim(document.getElementById('displayname').value);
	input7 = document.getElementById('display').innerHTML;
	input8 = document.getElementById('email').innerHTML;
	input9 = document.getElementById('verify').innerHTML;
	
	if(!(input1 == "") && !(input2 == "") && !(input3 == "") && !(input4 == "") && !(input5 == "") && !(input6 == "")){
		if(input7 == "Display name exists" || input8 == "Email address already used" || input9 == "Fields don't match"){
			document.getElementById('submitit').disabled=true;
		}else{
			document.getElementById('submitit').disabled=false;
		}
	}else{
		document.getElementById('submitit').disabled=true; 
	}
	
}