function try_register(){

    fname = document.reg.fname.value;
    lname = document.reg.lname.value;
    tel = document.reg.tel.value;
    email = document.reg.email.value;
    adr = document.reg.adr.value;
    captcha = document.reg.captcha.value;
    com = document.reg.com.value;
    cook = getCookie('captcha');
    
    eq = MD5(captcha);
    eq = MD5(eq);
    //alert(captcha+"\n"+eq+"\n"+cook);
    
    p1 = document.reg.pass1.value;
    p2 = document.reg.pass2.value;
    time = document.reg.time1.options[document.reg.time1.selectedIndex].value + "-" + document.reg.time2.options[document.reg.time2.selectedIndex].value;
    city_id = document.reg.city.options[document.reg.city.selectedIndex].value;
    
    if (!lname) {
        document.reg.lname.focus();
        alert(lang['enter_all_fields']);
        return;
    }
    if (!fname) {
        document.reg.fname.focus();
        alert(lang['enter_all_fields']);
        return;
    }
    
    if (document.reg.time1.options[document.reg.time1.selectedIndex].value == document.reg.time2.options[document.reg.time2.selectedIndex].value) {
        document.reg.time1.focus();
        alert(lang['enter_all_fields']);
        return;
    }
    
    if (!email) {
        document.reg.email.focus();
        alert(lang['enter_all_fields']);
        return;
    }
    if (!tel) {
        document.reg.tel.focus();
        alert(lang['enter_all_fields']);
        return;
    }
    if (p1 != p2) {
        document.reg.pass1.focus();
        alert(lang['pass_no']);
        return;
    }
    
    if (eq != cook) {
        document.reg.captcha.focus();
        alert(lang['wrong_captcha']);
        return;
    }
    
    
    if (document.getElementById('email_result').value == 'false') {
        document.reg.email.focus();
        alert(lang['wrong_email']);
        return;
    }
    p = MD5(p1);
    p = MD5(p);
    
    data = "reg=1&lname=" + lname + "&fname=" + fname + "&email=" + email + "&tel=" + tel;
    data += "&pass=" + p + "&time=" + time + "&city_id=" + city_id;
    if (com) 
        data += "&com=" + com;
    if (city_id != '1') 
        data += "&adr" + adr;
    
    //alert(data);
    
    
    document.getElementById('content').innerHTML = loading;
    url = "ajax_post.php?reg=1";
    postData(get_req(), url, 'content', data);
    
    
}

function reload_captcha(){
    alert(lang['look_better']);
    
    d = document.getElementById('captcha');
    //d.innerHTML="";
    //alert(d.innerHTML);
    d.innerHTML = "<div id=new_captcha><input type=hidden id=hid_captcha></div><b id=loading_captcha>" + loading_small + "</b>";
    
    
    hid = document.getElementById('hid_captcha');
    
    img = document.createElement("img");
    img.onload = function(){
        document.getElementById('loading_captcha').innerHTML = "";
        document.getElementById('new_captcha').insertBefore(img, hid);
        //alert(d.innerHTML);
    }
    img.src = "captcha.php";
    
}



function try_email(e){

    //alert(e.value);
    url = "ajax_req.php?try_email=1&email=" + e.value;
    document.getElementById('email_td').innerHTML = loading_small;
    
    
    loadData(get_req(), url, 'email_td');
    
    
}

function try_login(){
    e = document.login.email.value;
    p = document.login.pass.value;
    r = document.login.reg.value;
    if (r == '1') {
        p2 = document.login.pass2.value;
        if (p != p2) {
            document.login.pass.focus();
            alert(lang['pass_no']);
            return;
        }
    }
    data = "login=1&email=" + e + "&pass=" + p + "&r=" + r;
    to_div = "content";
    document.getElementById(to_div).innerHTML = loading;
    URL = "ajax_post.php?login=1";
    
    
    /*************************************************************************************/
    xmlReq = get_req();
    xmlReq.onreadystatechange = function(){
        if (xmlReq.readyState == 4) {
            document.getElementById(to_div).innerHTML = "";
            document.getElementById(to_div).innerHTML = xmlReq.responseText;
            
        }
    }
    
    xmlReq.open('post', URL, true);
    var content_type = 'application/x-www-form-urlencoded';
    xmlReq.setRequestHeader('Content-Type', content_type);
    xmlReq.send(data);
    /*************************************************************************************/
}














