function submitOnEnter(e) {
	if (window.event && window.event.keyCode == 13) {
		doLogin();
	}
	else if (e.keyCode == 13) {
		doLogin();
	}
}

function onRegisterPressed()
{
    document.location="/inregistrare.aspx";
}

function onNotRegisterPressed()
{
    document.getElementById("hAction").value = "SkipRegister";
    //alert(document.getElementById("hAction").value);
    document.getElementById('frmMain').submit();
}

function doLogin()
{
    var errors = "";
    
    if ((trim(document.getElementById("txEmail").value) == "") || (!isEmail(document.getElementById("txEmail").value)))
    {
        errors += " -introduceti o adresa de e-mail valida"+" \n";
    }
    
    if (trim(document.getElementById("txPassword").value) == "")
    {
        " - introduceti o parola"+" \n";
    }
    
    if (errors.length > 0)
    {
        alert(" Va rugam remediati problemele :"+" \n" + errors);
    }
    else
    {
        document.getElementById("hAction").value = "Login";
        document.getElementById('frmMain').submit();
    }
    
   
}

function doSubscribe(id)
{
    var errors = "";
    
    name            = trim(document.getElementById("txName").value);
    surname         = trim(document.getElementById("txSurname").value);
    email           = trim(document.getElementById("txEmail").value);
    password        = trim(document.getElementById("txPassword").value);
    passwordAgain   = trim(document.getElementById("txPasswordAgain").value);
    cnp             = trim(document.getElementById("txCNP").value);
    phone           = trim(document.getElementById("txPhone").value);
    country         = document.getElementById("ddCountry").selectedIndex;
    city            = trim(document.getElementById("txCity").value);
    address         = trim(document.getElementById("txAdress").value);
    agree           = document.getElementById("ckTerms").checked;
    
    if (name.length == 0) 
    {
        errors += " - completati campul Nume" + " \n";
    }
    
    if (surname.length == 0) 
    {
        errors += " - completati campul Prenume"+" \n";
    }
    
    if (email.length == 0 || (!isEmail(email)))
    {
        errors += "- introduceti o adresa de e-mail valida"+" \n";
    }
    
    //alert(password+"  "+passwordAgain);
    if(id == 0)
    {
        if (password.length < 6)
        {
            errors += " - campul Parola trebuie sa aiba minim 6 caractere"+" \n";
        }
        if (passwordAgain.length == 0)
        {
            errors += " - completati campul Parola, din nou"+" \n";
        }
        if (password != passwordAgain)
        {
            errors += " - campurile Parola si Parola din nou trebuie sa fie identice"+"\n";
        }
    }
    else 
    {
        if(password.length > 0)
        {
            if (password.length < 6)
            {
                errors += " - campul Parola trebuie sa aiba minim 6 caractere"+" \n";
            }
            if (passwordAgain.length == 0)
            {
                errors += " - completati campul Parola, din nou"+" \n";
            }
            if (password != passwordAgain)
            {
                errors += " - campurile Parola si Parola din nou trebuie sa fie identice"+"\n";
            }
        }
    }
    
   if (cnp.length == 0)
   {
       errors += "- completati campul CNP;"+" \n"; 
   }
   
   if (phone.length == 0)
   {
       errors += " -completati campul Telefon cu un numar de telefon valid"+" \n"; 
   }
   
   if (country == 0)
   {
       errors += "- alegeti Tara;"+" \n"; 
   }
   
   if (city.length == 0) 
   {
        errors += " - completati campul Oras"+" \n";
   }
   if (address.length == 0) 
   {
        errors += " - completati campul Adresa"+" \n";
   }
   
   if (!agree)
   {
       errors += "- Trebuie sa fiti de acord cu Politica de confidentialitate si protectia datelor personale si cu termenii si conditiile de utilizare a site-ului;"+" \n"; 
   }
    
    
    //Date pesonale


//    if (trim(document.getElementById("txBI").value).length == 0)
//    {
//        errors += getJSPH("Login_completati campul BI")+" \n"; 
//    }
    //Informatii de livrare


//    //Informatii autentificare
//    try{

//        
//    }catch (ex){}
//    //Alte informatii
//    if (document.getElementById("ddDomains").selectedIndex == 0)
//    {
//        errors += getJSPH("Login_alegeti un domeniu de activitate")+" \n";
//    }
//    //Informatii firma
//    try{
//        if (document.getElementById("ckIsCompany").checked)
//        {
//            if (trim(document.getElementById("txCompanyName").value) == "")
//            {
//                errors += getJSPH("Login_campul Nume firma")+" \n";
//            }
//            if (trim(document.getElementById("txCF").value) == "")
//            {
//                errors += getJSPH("Login_completati campul Cod fiscal")+" \n";
//            }
//            //Informatii  Sediul social (pentru facturare)
//            if (document.getElementById("ddCountry").selectedIndex == 0)
//            {
//                errors += getJSPH("Login_alegeti un judet-sediu")+" \n";
//            }
//            if (trim(document.getElementById("txCity").value).length == 0) 
//            {
//                errors += getJSPH("Login_completati campul Localitate-sediu")+" \n";
//            }
//            if (trim(document.getElementById("txAddress").value).length == 0) 
//            {
//                errors += getJSPH("Login_completati campul Adresa-sediu")+" \n";
//            }
//        }
//    }catch (ex){}
    
    if (errors.length > 0)
    {
        alert(getJSPH("Contact_RemediatiProblemele")+" \n" + errors);
    }
    else
    {
        document.getElementById("hAction").value = "Subscribe";
        document.getElementById('frmMain').submit();
    }
}

function showDiv(element)
{
    document.getElementById(element).style.display = "block";
}

function hideDiv(element)
{
    document.getElementById(element).style.display = "none";
}

/*
jQuery(document).ready(function(document.getElementById){
    //Initialize the element state
    toggleElement(document.getElementById('#companyToggler input'),document.getElementById('#dvCompany'));

    document.getElementById('#companyToggler input')
        .bind('click change',function(){
            toggleElement(document.getElementById('#companyToggler input'),document.getElementById('#dvCompany'))
        });
});
*/
