function echeck(str) {

            var at='@'
            var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var str_username = document.registration_form.username
	var str_password = document.registration_form.password
	var str_password2 = document.registration_form.password2
	var str_emailID = document.registration_form.email
	var str_emailID2 = document.registration_form.email2
	var str_sex = document.registration_form.sex
	var str_country = document.registration_form.country
	var str_interest = document.registration_form.interest
	var str_relationship = document.registration_form.relationship
	var str_birthyear = document.registration_form.birthyear

	if (( str_username.value == null )||( str_username.value == "" )){
		alert("Please Enter Your Username.")
		str_username.focus()
		return false
	}
    if (!(/^[a-zA-Z]+$/.test(str_username.value.substr(0,1)))){
		alert("First character must be a letter from either a-z or A-Z")
		str_username.focus()
		return false
	}
	if ((str_username.value.length<3)||(str_username.value.length>30)){
		alert("You must have at least 3 characters and a max of 30 characters in your username.")
		str_username.focus()
		return false
	}
	if (( str_password.value == null )||( str_password.value == "" )){
		alert("Please Enter Your Password.")
		str_password.focus()
		return false
	}
	if (( str_password.value.length<6 )){
		alert("You must have at least 6 characters for password.")
		str_password.focus()
		return false
	}
	if ( str_password.value != str_password2.value){
		alert("Passwords do not match.")
		str_password2.focus()
		return false
	}
	if (( str_emailID.value == null )||( str_emailID.value == "" )){
		alert("Please Enter Your Email Address.")
		str_emailID.focus()
		return false
	}
	if (echeck(str_emailID.value)==false){
		str_emailID.focus()
		return false
	}
	if (( str_emailID.value != str_emailID2.value)){
		alert("Email Address do not match.")
		str_emailID.focus()
		return false
	}
	if (( str_sex.value == '0')){
		alert("Please select gender.")
		str_emailID.focus()
		return false
	}
	if (( str_country.value == null )||( str_country.value == "" )){
		alert("Please select your country.")
		str_emailID.focus()
		return false
	}
	if (( str_interest.value == 0)){
		alert("Please select your social interest.")
		str_interest.focus()
		return false
	}
	if (( str_relationship.value == '0')){
		alert("Please select your relationship type.")
		str_relationship.focus()
		return false
	}
	if (( str_birthyear.value == '0')){
		alert("Please select your year of birth.")
		str_birthyear.focus()
		return false
	}
	return true
 }
