
function isUserCerchia(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=isCerchiaMember&email=" + email;
    
    a = new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.alreadymember == "yes"){
                window.location= alternative_dest_url + "?email=" + resp.email;
            }
            else {
                submitForm();
            }
            
        },onFailure: function(transport){
            submitForm();
        }
        
    });
}

function canRenewCerchia(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=isCerchiaMember&email=" + email + "&all=1";
    a = new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.alreadymember == "yes"){
                submitForm();
            }
            else {
                window.location= alternative_dest_url + "?email=" + resp.email + "&error=" + "not_found" + "&prev_url=" + window.location.href;;    
            }
            
        },onFailure: function(transport){
            submitForm();
        }
        
    });
    
}

function hasFinishedGold(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=hasFinishedGold&email=" + email;
    new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.success && resp.success!=""){
                submitForm();  
                
            }
            else {
                window.location= alternative_dest_url + "?email=" + resp.email + "&error=" + resp.error + "&prev_url=" + window.location.href;      
            }
            
        },onFailure: function(transport){
            window.location= alternative_dest_url + "?email=" + email + "&error=failure" ;      
        }
        
    });    

}

function hasFinishedPlatinum(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=hasFinishedPlatinum&email=" + email;
    new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.success && resp.success!=""){
                submitForm();  
                
            }
            else {
                window.location= alternative_dest_url + "?email=" + resp.email + "&error=" + resp.error + "&prev_url=" + window.location.href;      
            }
            
        },onFailure: function(transport){
            window.location= alternative_dest_url + "?email=" + email + "&error=failure" ;      
        }
        
    });     

}



function canOrderEternity(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=canOrderEternity&email=" + email;
    new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.success && resp.success!=""){
                submitForm();  
                
            }
            else {
                window.location= alternative_dest_url + "?email=" + resp.email + "&error=" + resp.error + "&prev_url=" + window.location.href;      
            }
            
        },onFailure: function(transport){
            window.location= alternative_dest_url + "?email=" + email + "&error=failure" ;      
        }
        
    });    

}

function canRenewEnergy(email,alternative_dest_url){
    url = "http://nuovo-internet-marketing.com/Gestione_Memberships/ext_ajax_requests/check-continuity.php?action=canRenewEnergy&email=" + email + "";
    a = new Ajax.Request(url, {
        method: 'get',
        onSuccess: function(transport){
            var resp = transport.responseText.evalJSON(true);      
            
            if (resp.success && resp.success!=""){
                submitForm();  
                
            }
            else {
                window.location= alternative_dest_url + "?email=" + resp.email + "&error=" + resp.error + "&prev_url=" + window.location.href;                                                                                     
            }
            
        },onFailure: function(transport){
            submitForm();
        }
        
    });
    
}

function submitForm(){
    document.forms.OrderInitPackageForm.submit();
}