
function Validate(theForm) {


    if (theForm.LastName.value == "") {
        alert("Please enter your Last Name\r\nqing shu ru nin de xing shi");
        theForm.LastName.focus();
        return (false);
    }

    if (theForm.FirstName.value == "") {
        alert("Please enter your First Name\r\nqing shu ru nin de ming zi");
        theForm.FirstName.focus();
        return (false);
    }

    // check the length of the phone number..
    if (theForm.PhoneCountry.value.length == "") {
        alert("Your country number appear to be too short\r\nnin de guojia daima guo duan");
        theForm.PhoneCountry.focus();
        return (false);
    }

    if (theForm.PhoneArea.value.length == "") {
        alert("Your area number appear to be too short\r\nnin de quhao guo duan");
        theForm.PhoneArea.focus();
        return (false);
    }

    // check if numbers field is blank
    if (theForm.Phone.value == "") {
        alert("Please enter your Phone number.\r\nqing shu ru nin de dian hua hao ma");
        theForm.Phone.focus();
        return (false);
    }

    if (theForm.Phone.value.length < 7) {
        alert("Your number appear to be too short\r\nnin de hao ma guo duan");
        theForm.Phone.focus();
        return (false);
    }



    // check if EMail field is blank
    if (theForm.EMail.value == "") {
        alert("Please enter a value for the \"EMail\" field.\r\nqing shu ru email di zhi");
        theForm.EMail.focus();
        return (false);
    }

    // test if valid EMail address, must have @ and .
    var checkEMail = "@.";
    var checkStr = theForm.EMail.value;
    var EMailValid = false;
    var EMailAt = false;
    var EMailPeriod = false;
    for (i = 0; i < checkStr.length; i++) {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkEMail.length; j++) {
            if (ch == checkEMail.charAt(j) && ch == "@")
                EMailAt = true;
            if (ch == checkEMail.charAt(j) && ch == ".")
                EMailPeriod = true;
            if (EMailAt && EMailPeriod)
                break;
            if (j == checkEMail.length)
                break;
        }

        // if both the @ and . were in the string
        if (EMailAt && EMailPeriod) {
            EMailValid = true
            break;
        }
    }
    if (!EMailValid) {
        alert("The \"EMail\" field must contain an \"@\" and a \".\".\r\nemail di zhi bi xu bao kuo @ he .");
        theForm.EMail.focus();
        return (false);
    }

    $.getJSON("http://iframe.cnforex.com:81/cnforex/DemoAccount/Register.ashx?jsoncallback=?", createQueryString(), function(json) {
        //alert("JSON Data: ");

    });

    return true;

}

function createQueryString() {
    var lastname = $("#LastName").val(), firstname = $("#FirstName").val();

    var homecountry = $("select[name=HomeCountry] option[selected]").text();
    var phone = $("#PhoneCountry").val() + "-" + $("#PhoneArea").val() + "-" + $("#Phone").val();
    var email = $("#EMail").val(), initialaccountbalance = $("#InitialAccountBalance").val();
    var address = $("#Address").val(), city = '', provnice = $("#Provnice").val(), zip = $("#ZIP").val();

    var ib = "AsiafxsolCFD", agent = "fxsolution";
   // alert('l=' + lastname + '&f=' + firstname + '&h=' + homecountry + '&p=' + phone + '&e=' + email + '&i=' + initialaccountbalance + '&a=' + address + '&c=' + city + '&pr=' + provnice + '&z=' + zip+'&ib='+ib+'&agent='+agent);)

    var querystring = { l: lastname, f: firstname, h: homecountry, p:phone,e:email,i:initialaccountbalance,a:address,c:city,pr:provnice,z:zip,ib:ib,ag:agent };
    return querystring;
}