﻿function ajaxAddAdventure_flash(id, type) {
    ajaxAddAdventure(id, type);
}

function ajaxAddAdventure(id, type, serviceLocation) {
    if(!serviceLocation)
        serviceLocation = '../js/ajax-add-adventure.aspx';
    
    var xmlHttp;
    try { xmlHttp = new XMLHttpRequest(); }
    catch(e) {
        try { xmlHttp = new ActiveXObject('Msxml2.XMLHTTP'); }
        catch(e) {
            try { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); }
            catch (e) { return true; }
        }
    }
    
    xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState == 4) {
            var responseText = xmlHttp.responseText.toUpperCase();
            
            if(responseText.indexOf('OKAY') > -1) alert('You have successfully added this selection to your Adventure Planner.');
            else if(responseText.indexOf('DUPLICATE') > -1) alert('This selection has already been added to your Adventure Planner.');
            else alert('There was a problem processing your request.');
        }
    }
    xmlHttp.open('GET', serviceLocation + '?id=' + id + '&type=' + type, true);
    xmlHttp.send(null);
    return false;
}
