function load_screenname() {
    if (Trim(document.getElementById("fname").value)!='' && Trim(document.getElementById("lname").value)!='') {             // && Trim(document.forms[0].username.value)==''
    document.getElementById("name").value=Trim(document.getElementById("fname").value) + ' ' + Trim(document.getElementById("lname").value);
    document.getElementById("regemail").focus()
    }


}
function iff_alert (title,message) {
    message = "<center>" + message + "<br><a href=\"javascript:Close_subdiv();\">Close</a></center>";
    var inlinewin=dhtmlwindow.open("errbox", "inline", message, title, "width=300px,height=80px,left=150px,top=10px,resize=1,scrolling=0", "recal")
    return true;
}

function iff_alert_zip() {
    title = "Zip Code";
    message = "InterfaithFamily.com requires  a ZIP code as a way to distinguish between different users with the same name. We respect your privacy, ";
    message = message + "and will not share any of your private information with outside organizations or individuals without your explicit ";
    message  = message +  "permission.";

    message = "<img src=\"/templates/images/iff_dc.gif\" alt=\"\"><br>" + message + "<p><center><a href=\"javascript:Close_subdiv();\">Close</a></center>";
    var inlinewin=dhtmlwindow.open("errbox", "inline", message, title, "width=300px,height=200px,left=150px,top=10px,resize=1,scrolling=0", "recal")
    //return true;
}


function Close_subdiv(){
dhtmlwindow.close('errbox');
var styleObject = getStyleObject('errbox');
dhtmlwindow.close(styleObject);
styleObject.display = "none";
//return true;
}

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){
		   iff_alert("Error","Invalid E-mail ID")
		   return false
		}

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

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

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

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

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

		 if (str.indexOf(" ")!=-1){
		    iff_alert("Error","Invalid E-mail ID")
		    return false
		 }

 		 return true
	}
function hideAllErrors() {

document.getElementById("Efirstname").style.display = "none"
document.getElementById("Elastname").style.display = "none"
document.getElementById("Escreenname").style.display = "none"
document.getElementById("Eemail").style.display = "none"
document.getElementById("Ecemail").style.display = "none"
document.getElementById("Ecemail").innerHTML = ""
document.getElementById("Epassword1").style.display = "none"
document.getElementById("Epassword2").style.display = "none"
document.getElementById("Epassword2").innerHTML = ""

}
function ValidateForm(){
    hideAllErrors()
    validation_status = true
    if (Trim(document.getElementById("fname").value)=='') {
        document.getElementById("Efirstname").innerHTML = "<br>First Name is required."
        document.getElementById("Efirstname").style.display = "inline"
        if (validation_status) document.getElementById("fname").focus()
        validation_status = false
    }

    if (Trim(document.getElementById("lname").value)=='') {
        document.getElementById("Elastname").innerHTML = "<br>Last Name is required."
        document.getElementById("Elastname").style.display = "inline"
        if (validation_status) document.getElementByID("lname").focus()
        validation_status = false
    }

    if (Trim(document.getElementById("name").value)=='') {
        document.getElementById("Escreenname").innerHTML = "<br>Screen Name is required."
        document.getElementById("Escreenname").style.display = "inline"
        if (validation_status) document.getLementByID("screenname").focus()
        validation_status = false
    }

    document.getElementById("regemail").value=Trim(document.getElementById("regemail").value)
    document.getElementById("cemail").value=Trim(document.getElementById("cemail").value)
    document.getElementById("password1").value=Trim(document.getElementById("password1").value)
    document.getElementById("password2").value=Trim(document.getElementById("password2").value)

	var emailID=document.getElementById("regemail").value
    var emailID2=document.getElementById("cemail").value
    var password=document.getElementById("password1").value
    var password2=document.getElementById("password2").value

    if (emailID=='') {
        document.getElementById("Eemail").innerHTML = "<br>Email is required."
        document.getElementById("Eemail").style.display = "inline"
        if (validation_status) document.getElementById("regemail").focus()
        validation_status = false
    }

    if (emailID2=='') {
        document.getElementById("Ecemail").innerHTML = "<br>Confirm Email is required."
        document.getElementById("Ecemail").style.display = "inline"
        if (validation_status) document.getElementById("cemail").focus()
        validation_status = false
    }

    if (emailID != emailID2) {
        document.getElementById("Ecemail").innerHTML = document.getElementById("Ecemail").innerHTML + "<br>Your Email and Confirm Email values do not match:<br>   Email: " + document.getElementById('regemail').value  + "<br>Confirm: " + document.getElementById('cemail').value
        document.getElementById("Ecemail").style.display = "inline"
        if (validation_status) document.getElementById("cemail").focus()
        validation_status = false
    }

    if (password=='') {
        document.getElementById("Epassword1").innerHTML = "<br>Password is required."
        document.getElementById("Epassword1").style.display = "inline"
        if (validation_status) document.getElementById("password1").focus()
        validation_status = false
    }
    if (password2=='') {
        document.getElementById("Epassword2").innerHTML = "<br>Confirm Password is required."
        document.getElementById("Epassword2").style.display = "inline"
        if (validation_status) document.getElementById("password1").focus()
        validation_status = false
    }


    if (password=='' != password2=='') {
        document.getElementById("Epassword2").innerHTML = document.getElementById("Epassword2").innerHTML + "<br>Password and Confirm Password do not match."
        document.getElementById("Epassword2").style.display = "inline"
        if (validation_status) document.getElementById("password1").focus()
        validation_status = false
    }

    if (password.length < 6) {
        document.getElementById("Epassword2").innerHTML = document.getElementById("Epassword2").innerHTML + "<br>Password must be at least 6 characters in length."
        document.getElementById("Epassword2").style.display = "inline"
        if (validation_status) document.getElementById("password1").focus()
        validation_status = false
    }

    document.getElementById("username1").value = document.getElementById("regemail").value;
  //  alert (document.getElementById("username1").value);
   // return false
    return validation_status
 }

