function regValidation()
{var email = document.register.email.value;
var password = document.register.password.value;
var password2 = document.register.password2.value;
var fname = document.register.fname.value;
var sname = document.register.sname.value;
var company = document.register.company.value;
var accept = document.register.accept.value;
var uType = document.register.UserType

for (i = 0 ; i < uType.length ; i++)
if (uType[i].checked == true)
	{var userType = uType[i].value;
	}
if (email.length < 1)
	{alert("Please enter a valid email");
	return false;
	}
else
	{var atPos = email.indexOf("@");
    if(atPos < 1)
    	{alert("Please enter a valid email");
        return false
        }
   	//check if the @ sign is atleast 4 places away from the end of the address
    if (atPos > (email.length - 3))
		{alert("Please enter a valid email");
        return false
        }
    }
if (password.length < 1)
	{alert("Please enter a password");
	return false;
	}
if (password2.length < 1)
	{alert("Please confirm password");
	return false;
	}
if (password != password2)
	{alert("The two passwords do not match");
	return false;
	}
if (fname.length < 1)
	{alert("Please enter a first name");
	return false;
	}
if (sname.length < 1)
	{alert("Please enter a surname");
	return false;
	}

if (userType=='Professional')
	{if (document.getElementById('ProfessionalCountry').value<=0)
		{alert("Please enter a country");
		return false;
		}
	if (document.getElementById('Town').value<=0)
		{alert("Please enter a town");
		return false;
		}
	if (document.getElementById('Phone').value<=0)
		{alert("Please enter a phone number");
		return false;
		}
	if (document.getElementById('Role').value<=0)
		{alert("Please enter a role");
		return false;
		}
	}
else
	{if (document.getElementById('InvestorCountry').value<=0)
		{alert("Please enter a country");
		return false;
		}
	/*if (document.getElementById('InvestorCity').value<=0)
		{alert("Please enter your nearest city");
		return false;
		}*/
	}
if (!document.register.accept.checked)
	{alert("You have not accepted the terms and conditions");
	return false;
	}

return true
}




function externalTerms()
{
	var accept = document.from_sponsor.accept.value;	
	if (!document.from_sponsor.accept.checked)
    {
		alert("You have not accepted the terms and conditions");
        return false;
    }
	return true
}


















function loginVal()
{
    var email = document.login.preAuthEmail.value;
	var password = document.login.password.value;
	if (email.length < 1)
	{
		alert("Please enter a valid email");
		return false;
	}
	else
	{
                var atPos = email.indexOf("@");
                if(atPos < 1)
                {
                  alert("Please enter a valid email");
                  return false
                }
                //check if the @ sign is atleast 4 places away from the end of the address
                if (atPos > (email.length - 3))
                {
                  alert("Please enter a valid email");
                  return false
                }
        }
	if (password.length < 1)
	{
		alert("Please enter a password");
		return false;
	}
	return true
}


function docsFormValidation()
{
    var title = document.docs.title.value;
	var file = document.docs.file.value;
	var type = document.docs.type.value;
	var about = document.docs.about.value;


	if (title.length < 1)
	{
		alert("Please enter a title");
		return false;
	}
	if (file.length < 1)
	{
		alert("Please choose a file");
		return false;
	}
	if (type.length < 1)
	{
		alert("Please choose a document type");
		return false;
	}
	if (about.length < 1)
	{
		alert("Please about text");
		return false;
	}
	return true
}


function searchValidation()
{
        var search = document.search.search.value;

	if (search.length < 1)
	{
		alert("Please enter some search criteria");
		return false;
	}

	return true
}

