var xmlHttp


//accountrightcolumn.asp, profile.asp...
function removeRc(fType, id, rid) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        var url = "includes/removeRc.asp?t=" + fType + "&favid=" + id + "&rid=" + rid + "&sid=" + Math.random();
        xmlHttp.onreadystatechange = $('#fav' + id).fadeOut('50', function() { $(this).remove(); });
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
}


//change delivery info fields on confirm.asp
function changeInfo(psAddress,psAddress2,psCity,psState,psPhone,psNotes) {
    document.frmConfirm.address.value = psAddress.replace(";;;", "'");
    document.frmConfirm.address2.value = psAddress2.replace(";;;", "'");
    document.frmConfirm.city.value = psCity.replace(";;;", "'");
    document.frmConfirm.phone.value = psPhone.replace(";;;", "'");
    document.frmConfirm.state.value = psState.replace(";;;", "'");
    document.frmConfirm.instructions.value = psNotes.replace(";;;", "'");
}


//set four step hide/show preference
function cCookie(name, value) {
    var date = new Date();
    date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = name + "=" + value + expires + "; path=/";
}


//add favorites...
function setFav(fType, acT, cID, getInID) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        inID = getInID;
        inProcessing = "";
        var url = "includes/manageFav.asp?t=" + fType + "&a=" + acT + "&favid=" + cID + "&pID=" + getInID + "&sid=" + Math.random();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
};

 //more featured restaurants...
function moreFeat() {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        inID = "featured";
        inProcessing = "";
        var url = "includes/featured.asp?sid=" + Math.random();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
};

//popular menu items...
function newMenu(restID, curID) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        inID = "popMenu";
        inProcessing = "";
        var url = "includes/popular.asp?cid=" + curID + "&rid=" + restID + "&tp=0&sid=" + Math.random();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
};

 //popular restaurant form...
function newRest(curID) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        inID = "popRest";
        inProcessing = "";
        var url = "includes/popular.asp?cid=" + curID + "&tp=1&sid=" + Math.random();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
};


// Menu add item
function menuItem(divID, curID, restID, rcID) {
    
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {
        inID = divID
        inProcessing = "";
        document.getElementById(divID).style.display = 'inline';
         var url = "includes/getMenuItem.asp?div=" + divID + "&cid=" + curID + "&rid=" + restID + "&rcID=" + rcID + "&sid=" + Math.random();
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }
       
};


//close menu form...
function closeItem(getItem) {
    document.getElementById(getItem).style.display = 'none';
}


//check for required repcode...
function isRep() {

    if (document.frmAddmenu.referrer.selectedIndex == '1') {
        document.getElementById('showrepcode').style.display = "block";
    } else {
        document.getElementById('showrepcode').style.display = "none";
    }
}

//new section on editmenu.asp...
function menuSec() {

    if (document.frmEditMenu.section.selectedIndex == '1') {
        document.getElementById('shownewsection').style.display = "block";
        document.getElementById('shownewsectiondesc').style.display = "block";
    } else {
        document.getElementById('shownewsection').style.display = "none";
        document.getElementById('shownewsectiondesc').style.display = "none";
    }
}

 //newsletter form...
function news() {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    } else {

        obj = document.getElementById('frmNewsletter');
        var getstr = "?";
        for (i = 0; i < obj.childNodes.length; i++) {
            if (obj.childNodes[i].tagName == "INPUT") {
                if (obj.childNodes[i].type == "text") {
                    getstr += obj.childNodes[i].name + "=" + encodeURIComponent(obj.childNodes[i].value) + "&";
                }
            }
        }

        inID = "newsletter";
        inProcessing = "";
        var url = "newsletter.asp" + getstr + "sid=" + Math.random();
        //alert (url);
        xmlHttp.onreadystatechange = stateChanged;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);

    }
};



function stateChanged() {
    var setID = document.getElementById(inID);
    if (xmlHttp.readyState == 4) {
        setID.innerHTML = xmlHttp.responseText;
    } else {
        setID.innerHTML = inProcessing;
    }
}


function GetXmlHttpObject() {
    var xmlHttp = null;
    try
  { xmlHttp = new XMLHttpRequest(); }
    catch (e) {
        try
    { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e)
    { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
    }
    return xmlHttp;
}