function validEmail(email) {
    if (email=="" || email== null) {
        return false;
    } else {
        var emailReg = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/; // valid
        if (!emailReg.test(email)) { // if syntax is valid
            return false;
        }
        return true;
    }
}

function chkReg(registration) {
    if (document.registration.m_userNick.value=="") {
        alert(errorNoUserName);
        document.registration.m_userNick.focus();
        return false;
    
    } else if (document.registration.m_email.value=="") {
        alert(errorNoEmail);
        document.registration.m_email.focus();
        return false; 
        
    } if (!validEmail(registration.m_email.value)) {
        alert(errorNoValidEmail);
        registration.m_email.focus();
        return false;
                
    } else if (document.registration.m_userPass1.value=="") {
        alert(errorNoPassword);
        document.registration.m_userPass1.focus();
        return false;       

    } else if (registration.m_userPass1.value!=registration.m_userPass2.value) {
        alert(errorMsgPasswordAreNotSame);
        registration.m_userPass1.value=""
        registration.m_userPass2.value=""
        registration.m_userPass1.focus();
        return false;

    }
    return true;
}



function chkRegMod(registration) {
    if (document.registration.m_country.value=="0") {
        alert(errorNoCountry);
        document.registration.m_country.focus();
        return false;         

    } else if (registration.m_userPass1.value!=registration.m_userPass2.value) {
        alert(errorMsgPasswordAreNotSame);
        registration.m_userPass1.value=""
        registration.m_userPass2.value=""
        registration.m_userPass1.focus();
        return false;

    }
    return true;
}



function chkCartAddress(sheet) {
    if (document.sheet.m_country.value=="0") {
        alert(errorNoCountry);
        document.sheet.m_country.focus();
        return false;         

    } 
    return true;
}



function copyAddress() {
    with (document.sheet) {
    	m_bill_name.value = m_order_name.value;
    	m_bill_country.value = m_order_country.value;
    	m_bill_city.value = m_order_city.value;
    	m_bill_postcode.value = m_order_postcode.value;
    	m_bill_address.value = m_order_address.value;      
    }
}
