/*
     General AJAX technique samples--how to talk to the server + return data and do stuff with it.
     Direct questions, answers, rants, flames to sbenfield@clearnova.com

      1.0: 2005-07-14   Initial Release
      1.1: 2005-07-15   Fixed bugs, changed text for clarity, added ability to register for updates
      1.2: 2005-07-21   Cleaned up samples for clarity. Original version was all over the board using all sorts of different ways of calling XMLHTTPRequest
                        This version is cleaner. Only ping uses its own custom AJAX handling, everything else uses AJAXRequest
			Added many many comments
			
     If you find any bugs or have any ideas of enhancement--send them on.
     
*/
     
var _ms_XMLHttpRequest_ActiveX = ""; // Holds type of ActiveX to instantiate
var _ajax;                           // Reference to a global XMLHTTPRequest object for some of the samples
var _logger = true;                  // write output to the Activity Log
var _status_area;                    // will point to the area to write status messages to

BASE_URL = "."
if ( document.location.href.indexOf("www.clearnova.com") > 0 ) {
	BASE_URL = "/ThinkCAP"
}

if (!window.Node || !window.Node.ELEMENT_NODE) {
    var Node = { ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,
                  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, 
    		  DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12 };
}

// From prototype.js @ www.conio.net | Returns an object reference to one or more strings
// ignore the fact that there are no arguments to this method -- javascript doesn't care how many you send (not strongly typed)
// The method checks the actual # of arguments -- returns a single object or an array
function $() {
    var elements = new Array();

    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];

        if (typeof element == 'string')
            element = document.getElementById(element);

        if (arguments.length == 1)
            return element;

        elements.push(element);
    }

    return elements;
}

// Method to get text from an XML DOM object
function getTextFromXML( oNode, deep ) {
    var s = "";
    var nodes = oNode.childNodes;

    for (var i = 0; i < nodes.length; i++) {
        var node = nodes[i];

        if (node.nodeType == Node.TEXT_NODE) {
            s += node.data;
        } else if (deep == true && (node.nodeType == Node.ELEMENT_NODE || node.nodeType == Node.DOCUMENT_NODE
                                       || node.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {
            s += getTextFromXML(node, true);
        };
    }

    ;
    return s;
}

;

// If you plan on doing anything outside of North America, then you'd better encode the things you pass back and forth
// the escape() method in Javascript is deprecated -- should use encodeURIComponent if available
function encode( uri ) {
    if (encodeURIComponent) {
        return encodeURIComponent(uri);
    }

    if (escape) {
        return escape(uri);
    }
}

function decode( uri ) {
    uri = uri.replace(/\+/g, ' ');

    if (decodeURIComponent) {
        return decodeURIComponent(uri);
    }

    if (unescape) {
        return unescape(uri);
    }

    return uri;
}

// log information to the status area textfield
function logger( text, clear ) {
    if (_logger) {
        if (!_status_area) {
            _status_area = document.getElementById("status_area");
        }

        if (_status_area) {
            if (clear) {
                _status_area.value = "";
            }

            var old = _status_area.value;
            _status_area.value = text + ((old) ? "\r\n" : "") + old;
        }
    }
}


/*
 * AJAXRequest: An encapsulated AJAX request. To run, call
 * new AJAXRequest( method, url, async, process, data )
 *
 */

function executeReturn( AJAX ) {
    if (AJAX.readyState == 4) {
        if (AJAX.status == 200) {
//            logger('AJAXRequest is complete: ' + AJAX.readyState + "/" + AJAX.status + "/" + AJAX.statusText);
	    if ( AJAX.responseText ) {
//		    logger(AJAX.responseText);
//		    logger("-----------------------------------------------------------");
			if(document.getElementById("debug") != null){
				document.getElementById("debug").innerHTML = AJAX.responseText;
			}
		    eval(AJAX.responseText);
	    }
	}
    }
}

function AJAXRequest( method, url, data, process, async, dosend) {
    // self = this; creates a pointer to the current function
    // the pointer will be used to create a "closure". A closure
    // allows a subordinate function to contain an object reference to the
    // calling function. We can't just use "this" because in our anonymous
    // function later, "this" will refer to the object that calls the function 
    // during runtime, not the AJAXRequest function that is declaring the function
    // clear as mud, right?
    // Java this ain't
    
    var self = this;

    // check the dom to see if this is IE or not
    if (window.XMLHttpRequest) {
	// Not IE
        self.AJAX = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
	// Hello IE!
        // Instantiate the latest MS ActiveX Objects
        if (_ms_XMLHttpRequest_ActiveX) {
            self.AJAX = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);
        } else {
	    // loops through the various versions of XMLHTTP to ensure we're using the latest
	    var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                        "Microsoft.XMLHTTP"];

            for (var i = 0; i < versions.length ; i++) {
                try {
		    // try to create the object
		    // if it doesn't work, we'll try again
		    // if it does work, we'll save a reference to the proper one to speed up future instantiations
                    self.AJAX = new ActiveXObject(versions[i]);

                    if (self.AJAX) {
                        _ms_XMLHttpRequest_ActiveX = versions[i];
                        break;
                    }
                }
                catch (objException) {
                // trap; try next one
                } ;
            }

            ;
        }
    }

	
    // if no callback process is specified, then assing a default which executes the code returned by the server
    if (typeof process == 'undefined' || process == null) {
        process = executeReturn;
    }

    self.process = process;

    // create an anonymous function to log state changes
    self.AJAX.onreadystatechange = function( ) {
        //logger("AJAXRequest Handler: State =  " + self.AJAX.readyState);
        self.process(self.AJAX);
    }

    // if no method specified, then default to POST
    if (!method) {
        method = "POST";
    }

    method = method.toUpperCase();

    if (typeof async == 'undefined' || async == null) {
        async = true;
    }

//    logger("----------------------------------------------------------------------");
//    logger("AJAX Request: " + ((async) ? "Async" : "Sync") + " " + method + ": URL: " + url + ", Data: " + data);

    self.AJAX.open(method, url, async);

    if (method == "POST") {
        self.AJAX.setRequestHeader("Connection", "close");
//        self.AJAX.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      	self.AJAX.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
//		self.AJAX.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
        self.AJAX.setRequestHeader("Method", "POST " + url + "HTTP/1.1");
    }

    // if dosend is true or undefined, send the request
    // only fails is dosend is false
    // you'd do this to set special request headers
    if ( dosend || typeof dosend == 'undefined' ) {
	    if ( !data ) data=""; 
	    self.AJAX.send(data);
    }
    return self.AJAX;
}

// handle some key press events
function handleKeyUp( e ) {
    e = (!e) ? window.event : e;
    target = (!e.target) ? e.srcElement : e.target;

    if (e.type == "keyup") {
        // skip shift, alt, control keys
        if (e.keyCode == 16 || e.keyCode == 17 || e.keyCode == 18) {
        // do nothing
        }

        else {
            if (target.name == "state1" && !$('state1').value) {
                clearCustomersByState();
            } else if (target.name == "state2" && !$('state2').value) {
                clearCustomersByStateXML();
            } else if (target.name == "google_search") {
                if (target.value) {
                    getSuggest(target);
                } else {
                    $('google_suggest_target').innerHTML = "";
                }
            }
        }
    }
}

<!------------------------------------- BEGIN SELECT ------------------------------------------->


// Clears each select that was passed to this method
// uses Javascripts dynamic argument capability--method isn't declared with args, they are looped through
// in the code using the built-in arguments array
function clearSelect() {
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];

        if (typeof element == 'string')
            element = document.getElementsByName(element)[0];

        if (element && element.options) {
            element.options.length = 0;
            element.selectedIndex = -1;
        }
		else if(element){
			element.value = "";
		}
    }
}


// base method for calling the get_select servlet
// takes dataset such as customers, cities, states, etc

function checkMemberEmail(input) {
	var email = document.getElementById("email"+input);
	return new AJAXRequest("POST", "checkMemberEmail", "input=" +input+ "&email=" + email.value);
}

function getSelectData( dataset, key, target ) {
	//alert("target "+target);
	var keyValue = key.options[key.options.selectedIndex].value;
	return new AJAXRequest("POST", "validate", "dataset=" +dataset+ "&type=" + keyValue + "&target=" + target);
}

function PollScroll(month, day, year, type, loc, res) {
    return new AJAXRequest("POST", "PollScroll", "month=" + month + "&day=" + day + "&year=" + year + "&type=" + type + "&loc=" + loc + "&res=" + res);
}

function Voting(answerID, questionID, nVote, IP, userId, loc) {
    return new AJAXRequest("POST", "Voting", "answerID=" + answerID + "&questionID=" + questionID +"&nVote=" + nVote + "&IP=" + IP + "&loc=" + loc + "&userId=" + userId);
}

function RestRandom(begin, end, action) {
    return new AJAXRequest("POST", "RestRandom", "begin=" + begin + "&end=" + end + "&action=" + action);
}

function RestRandom1(begin, end, action) {
    return new AJAXRequest("POST", "RestRandom1", "begin=" + begin + "&end=" + end + "&action=" + action);
}

function EventScroller(begin, end, viewCount, action, place) {
    return new AJAXRequest("POST", "http://" + location.host +"/EventScroller", "begin=" + begin + "&end=" + end + "&viewCount=" + viewCount + "&action=" + action + "&place=" + place);
}

function SpecialOffersScroller(begin, end, viewCount, action) {
    return new AJAXRequest("POST", "http://" + location.host + "/SpecialOffersScroller", "begin=" + begin + "&end=" + end + "&viewCount=" + viewCount + "&action=" + action);
}

function addStatistics(type, typeID, IP ) {
    return new AJAXRequest("POST", "addStatistics", "type=" + type + "&typeID=" + typeID + "&IP=" + IP);
}

function getCompoundRSS(){
    return new AJAXRequest("POST", "getCompoundRSS","");
}

function GetTopics(ID){
    return new AJAXRequest("POST", "GetTopics","ID="+ID);
}

function GetTopics2Params(ID1,ID2){
    return new AJAXRequest("POST", "GetTopics","ID="+ID1+"&ID2="+ID2);
}

function GetInnerTopics(ID,place){
    return new AJAXRequest("POST", "GetTopics","ID="+ID+"&place="+place);
}

function GetRecentTopics(){
    return new AJAXRequest("POST", "GetRecentTopics","");
}

function GetRSSTopics(topicID,title,ID){
    return new AJAXRequest("POST", "GetRSSTopics","topicID="+topicID+"&title="+title+"&ID="+ID);
}

function getBusiness(input){
    return new AJAXRequest("POST", "../AdminBusiness", "ID=" + input.value);
}




//--------------------------------------  ONLINE MENU --------------------------------------//
function getOnlineMenu() {
    return new AJAXRequest("POST", "getOnlineMenu","");
}

function moveMenuItemUp(dinID, menuID, menuType, cat, itemOrder,i,x,z) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
	
	
	//alert("menuTypeValue "+menuTypeValue);
    return new AJAXRequest("POST", "getOnlineMenu","action=order&target=itm&dir=up&menuID=" + menuID + "&dinID=" + dinID + "&menuType=" + menuTypeValue + "&cat=" + catValue+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveMenuCatUp(dinID, cat, menuType, catOrder,i) {
    //alert("moveMenuCatUp "+menuCat);	
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
	//alert(menuTypeValue);
	return new AJAXRequest("POST", "getOnlineMenu","action=order&target=cat&dir=up&dinID=" + dinID + "&cat=" + catValue + "&menuType=" + menuTypeValue + "&catOrder=" + catOrder+ "&i=" + i );
}

function moveMenuTypeUp(dinID, menuType, menuOrder) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
    return new AJAXRequest("POST", "getOnlineMenu","action=order&target=type&dir=up&dinID=" + dinID + "&menuType=" + menuTypeValue + "&menuOrder=" + menuOrder);
}
// ------------------------------------
function moveMenuItemDown(dinID, menuID, menuType, cat, itemOrder,i,x,z) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
    return new AJAXRequest("POST", "getOnlineMenu","action=order&target=itm&dir=down&menuID=" + menuID + "&dinID=" + dinID + "&menuType=" + menuTypeValue + "&cat=" + catValue+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveMenuCatDown(dinID, cat, menuType, catOrder,i) {
	//alert("moveMenuCatDown "+menuCat);	
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
    var catValue 		= replaceAll(catValue1,"&","11and11");
	return new AJAXRequest("POST", "getOnlineMenu","action=order&target=cat&dir=down&dinID=" + dinID + "&cat=" + catValue + "&menuType=" + menuTypeValue + "&catOrder=" + catOrder+ "&i=" + i );
}

function moveMenuTypeDown(dinID, menuType, menuOrder) {
	//alert("moveMenuTypeDown "+menuCat);	
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	
    return new AJAXRequest("POST", "getOnlineMenu","action=order&target=type&dir=down&dinID=" + dinID + "&menuType=" + menuTypeValue + "&menuOrder=" + menuOrder);
}
//--------------------------------------

function deleteMenuItem(dinID, menuType, cat, itemOrder, i, x, z) {
	var menuID 			= document.getElementById("menuID"+i+""+x+""+z).value;	
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
    return new AJAXRequest("POST", "getOnlineMenu","action=delete&target=itm&menuID=" + menuID + "&dinID=" + dinID + "&cat=" + catValue + "&menuType=" + menuTypeValue +  "&itemOrder=" + itemOrder+  "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function deleteMenuCat(dinID, menuType, cat, i, catOrder) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
    return new AJAXRequest("POST", "getOnlineMenu","action=delete&target=cat" + "&dinID=" + dinID + "&cat=" + catValue + "&menuType=" + menuTypeValue + "&i=" + i + "&catOrder=" + catOrder);
}

function deleteMenuType(dinID, menuType, menuOrder) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
    return new AJAXRequest("POST", "getOnlineMenu","action=delete&target=type" + "&dinID=" + dinID + "&menuType=" + menuTypeValue + "&menuOrder=" + menuOrder);
}

//--------------------------------------

function updateMenuItem(dinID, menuID, menuType, cat, menuItem, desc, price, i, x, z) {	
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	var catValue1 		= replaceAll(document.getElementById(cat).value,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
	
	var menuItemValue1 	= replaceAll(menuItem,"&quot;","\"");
	var menuItemValue2 	= replaceAll(menuItemValue1,"&apos;","\\\'");
	var menuItemValue 	= replaceAll(menuItemValue2,"&","11and11");
	
	var descValue1 	= replaceAll(desc,"&quot;","\"");
	var descValue2 	= replaceAll(descValue1,"&apos;","\\\'");
	var descValue 	= replaceAll(descValue2,"&","11and11");

    return new AJAXRequest("POST", "getOnlineMenu","action=update&target=itm&menuID=" + menuID + "&dinID=" + dinID + "&menuItem=" + menuItemValue + "&menuType=" + menuTypeValue+ "&cat=" + catValue + "&desc=" + descValue+ "&price=" + price+  "&i=" + i+ "&x=" + x+ "&z=" + z);
}

function updateMenuCat(dinID, menuType, cat, nCat, i) {
	var menuTypeValue1 	= replaceAll(document.getElementById(menuType).value,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	
	var catValue1 		= replaceAll(cat,"&quot;","\"");
	var catValue 		= replaceAll(catValue1,"&","11and11");
	
	var nCatValue1 		= replaceAll(nCat,"&quot;","\"");
	var nCatValue 		= replaceAll(nCatValue1,"&","11and11");
	
    return new AJAXRequest("POST", "getOnlineMenu","action=update&target=cat&dinID=" + dinID + "&menuType=" + menuTypeValue+ "&cat=" + catValue + "&nCat=" + nCatValue + "&i=" + i );
}

function updateMenuType(dinID, menuType, nMenuType) {
	var menuTypeValue1 	= replaceAll(menuType,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	
	var nMenuTypeValue1 	= replaceAll(nMenuType,"&quot;","\"");
	var nMenuTypeValue2 	= replaceAll(nMenuTypeValue1,"&apos;","\\\'");
	var nMenuTypeValue 		= replaceAll(nMenuTypeValue2,"&","11and11");
	
    return new AJAXRequest("POST", "getOnlineMenu","action=update&target=type&dinID=" + dinID + "&nMenuType=" + nMenuTypeValue + "&menuType=" + menuTypeValue);
}

//--------------------------------------
function addMenuItem(dinID, menuType, cat, menuItem, desc, price) {
	var menuTypeValue1 	= replaceAll(menuType,"&quot;","\"");
	var menuTypeValue2 	= replaceAll(menuTypeValue1,"&apos;","\\\'");
	var menuTypeValue 	= replaceAll(menuTypeValue2,"&","11and11");
	
	var catValue1 	= replaceAll(cat,"&quot;","\"");
	var catValue2 	= replaceAll(catValue1,"&apos;","\\\'");
	var catValue 	= replaceAll(catValue2,"&","11and11");
	
	var menuItemValue1 	= replaceAll(menuItem,"&quot;","\"");
	var menuItemValue2 	= replaceAll(menuItemValue1,"&apos;","\\\'");
	var menuItemValue 	= replaceAll(menuItemValue2,"&","11and11");
	
	var descValue1 	= replaceAll(desc,"&quot;","\"");
	var descValue2 	= replaceAll(descValue1,"&apos;","\\\'");
	var descValue 	= replaceAll(descValue2,"&","11and11");
	
    return new AJAXRequest("POST", "getOnlineMenu","action=add&dinID=" + dinID +"&menuType=" + menuTypeValue+"&cat=" + catValue+"&menuItem=" + menuItemValue+ "&desc=" + descValue+ "&price=" + price );
}

//--------------------------------------  WINE LIST --------------------------------------//

function addWineItem(dinID, wineCat, subCat, bevItem,  year, sc, bottle, halfBottle, glass) {
	var scValue1 	= replaceAll(document.getElementById(sc).value,"&quot;","\"");
	var scValue2 	= replaceAll(scValue1,"&apos;","\\\'");
	var scValue 	= replaceAll(scValue2,"&","11and11");
	
	var bevItemValue1 	= replaceAll(document.getElementById(bevItem).value,"&quot;","\"");
	var bevItemValue2 	= replaceAll(bevItemValue1,"&apos;","\\\'");
	var bevItemValue	= replaceAll(bevItemValue2,"&","11and11");
	
    return new AJAXRequest("POST", "getWineList","action=add&dinID=" + dinID +"&wineCat=" + wineCat+"&subCat=" + subCat+"&bevItem=" + bevItemValue+ "&year=" + year+ "&sc=" + scValue + "&bottle=" + bottle + "&halfBottle=" + halfBottle + "&glass=" + glass);
}

//--------------------------------------

function updateWineItem(dinID, bevID, bevItm, wineCat, subCat, year, sc, bottle, halfBottle, glass, i, x, z) {
	var scValue1 	= replaceAll(document.getElementById(sc).value,"&quot;","\"");
	var scValue2 	= replaceAll(scValue1,"&apos;","\\\'");
	var scValue 	= replaceAll(scValue2,"&","11and11");
	
	var bevItemValue1 	= replaceAll(document.getElementById(bevItm).value,"&quot;","\"");
	var bevItemValue2 	= replaceAll(bevItemValue1,"&apos;","\\\'");
	var bevItemValue 	= replaceAll(bevItemValue2,"&","11and11");
	
    return new AJAXRequest("POST", "getWineList","action=update&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat + "&bevItem=" + bevItemValue +  "&year=" + year+ "&sc=" + scValue + "&bottle=" + bottle + "&halfBottle=" + halfBottle + "&glass=" + glass +  "&i=" + i+ "&x=" + x+ "&z=" + z);
}

function updateWineSubCategory(dinID, subCat, wineCat, thisInput, subCatOrder, i) {
	var nSubCat = thisInput.options[thisInput.options.selectedIndex].value;
    return new AJAXRequest("POST", "getWineList","action=update&target=subCat&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat + "&nSubCat=" + nSubCat + "&subCatOrder=" + subCatOrder+  "&i=" + i );
}

function updateWineSubCategoryDropDown(catName) {
    return new AJAXRequest("POST", "getWineList","action=update&target=cat&catName=" + catName.options[catName.options.selectedIndex].value + "&subCatID=subCat");
}

// ------------------------------------
function moveWineItemDown(dinID, bevID, wineCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getWineList","action=order&target=itm&dir=down&bevID=" + bevID + "&dinID=" + dinID + "&wineCat=" + wineCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveWineItemUp(dinID, bevID, wineCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getWineList","action=order&target=itm&dir=up&bevID=" + bevID + "&dinID=" + dinID + "&wineCat=" + wineCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveWineSubCatDown(dinID, subCat, wineCat, subCatOrder,i) {
	//alert("moveMenuCatDown "+menuCat);
    return new AJAXRequest("POST", "getWineList","action=order&target=subCat&dir=down&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveWineSubCatUp(dinID, subCat, wineCat, subCatOrder,i) {
    //alert("moveMenuCatUp "+menuCat);
	return new AJAXRequest("POST", "getWineList","action=order&target=subCat&dir=up&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveWineCatDown(dinID, wineCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getWineList","action=order&target=cat&dir=down&dinID=" + dinID + "&wineCat=" + wineCat + "&catOrder=" + catOrder);
}

function moveWineCatUp(dinID, wineCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getWineList","action=order&target=cat&dir=up&dinID=" + dinID + "&wineCat=" + wineCat + "&catOrder=" + catOrder);
}
// ------------------------------------
function deleteWineItem(dinID, bevID, wineCat, subCat, itemOrder, i, x, z) {
    return new AJAXRequest("POST", "getWineList","action=delete&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat +  "&itemOrder=" + itemOrder+  "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function deleteWineSubCat(dinID, wineCat, subCat, i, catOrder, subCatOrder) {
    return new AJAXRequest("POST", "getWineList","action=delete&target=subCat" + "&dinID=" + dinID + "&subCat=" + subCat + "&wineCat=" + wineCat + "&i=" + i + "&catOrder=" + catOrder + "&subCatOrder=" + subCatOrder);
}

function deleteWineCat(dinID, wineCat, catOrder) {
    return new AJAXRequest("POST", "getWineList","action=delete&target=cat" + "&dinID=" + dinID + "&wineCat=" + wineCat + "&catOrder=" + catOrder);
}

//--------------------------------------  BEER LIST --------------------------------------//

function addBeerItem(dinID, beerCat, subCat, bevItem,  size, price) {
    return new AJAXRequest("POST", "getBeerList","action=add&dinID=" + dinID +"&beerCat=" + beerCat+"&subCat=" + subCat+"&bevItem=" + bevItem+ "&size=" + size+ "&price=" + price );
}

// ------------------------------------
function updateBeerItem(dinID, bevID, bevItm, beerCat, subCat, size, price, i, x, z) {
    return new AJAXRequest("POST", "getBeerList","action=update&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&beerCat=" + beerCat + "&bevItem=" + bevItm +  "&size=" + size+ "&price=" + price +  "&i=" + i+ "&x=" + x+ "&z=" + z);
}

function updateBeerSubCat(dinID, beerCat, subCat, nSubCat, i) {
    return new AJAXRequest("POST", "getBeerList","action=update&target=subCat&dinID=" + dinID + "&beerCat=" + beerCat+ "&subCat=" + subCat+ "&nSubCat=" + nSubCat + "&i=" + i );
}

function updateBeerType(dinID, beerCat, nBeerCat) {
    return new AJAXRequest("POST", "getBeerList","action=update&target=cat&dinID=" + dinID + "&nBeerCat=" + nBeerCat + "&beerCat=" + beerCat);
}
// ------------------------------------
function deleteBeerItem(dinID, bevID, beerCat, subCat, itemOrder, i, x, z) {
    return new AJAXRequest("POST", "getBeerList","action=delete&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&beerCat=" + beerCat +  "&itemOrder=" + itemOrder+  "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function deleteBeerSubCat(dinID, beerCat, subCat, i, subCatOrder) {
    return new AJAXRequest("POST", "getBeerList","action=delete&target=subCat" + "&dinID=" + dinID + "&subCat=" + subCat + "&beerCat=" + beerCat + "&i=" + i + "&subCatOrder=" + subCatOrder);
}

function deleteBeerCat(dinID, beerCat, catOrder) {
    return new AJAXRequest("POST", "getBeerList","action=delete&target=cat" + "&dinID=" + dinID + "&beerCat=" + beerCat + "&catOrder=" + catOrder);
}
// ------------------------------------
function moveBeerItemDown(dinID, bevID, beerCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getBeerList","action=order&target=itm&dir=down&bevID=" + bevID + "&dinID=" + dinID + "&beerCat=" + beerCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveBeerItemUp(dinID, bevID, beerCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getBeerList","action=order&target=itm&dir=up&bevID=" + bevID + "&dinID=" + dinID + "&beerCat=" + beerCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveBeerSubCatDown(dinID, subCat, beerCat, subCatOrder,i) {
	//alert("moveMenuCatDown "+menuCat);
    return new AJAXRequest("POST", "getBeerList","action=order&target=subCat&dir=down&dinID=" + dinID + "&subCat=" + subCat + "&beerCat=" + beerCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveBeerSubCatUp(dinID, subCat, beerCat, subCatOrder,i) {
    //alert("moveMenuCatUp "+menuCat);
	return new AJAXRequest("POST", "getBeerList","action=order&target=subCat&dir=up&dinID=" + dinID + "&subCat=" + subCat + "&beerCat=" + beerCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveBeerCatDown(dinID, beerCat, catOrder,i) {
	var beerCatValue = encodeURIComponent(document.getElementById(beerCat).value);
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getBeerList","action=order&target=cat&dir=down&dinID=" + dinID + "&beerCat=" + beerCatValue + "&catOrder=" + catOrder+ "&i=" + i);
}

function moveBeerCatUp(dinID, beerCat, catOrder,i) {
	var beerCatValue = encodeURIComponent(document.getElementById(beerCat).value);
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getBeerList","action=order&target=cat&dir=up&dinID=" + dinID + "&beerCat=" + beerCatValue + "&catOrder=" + catOrder+ "&i=" + i);
}

//--------------------------------------  NON-ALLCAHLOIC LIST --------------------------------------//

function addNonAllcItem(dinID, NonAllcCat, subCat, bevItem, prc, desc) {
    return new AJAXRequest("POST", "getNonAllcList","action=add&dinID=" + dinID +"&NonAllcCat=" + NonAllcCat+"&subCat=" + subCat+"&bevItem=" + bevItem+ "&prc=" + prc+ "&desc=" + desc );
}

//--------------------------------------

function updateNonAllcItem(dinID, bevID, bevItm, NonAllcCat, subCat, prc, desc, i, x, z) {
    return new AJAXRequest("POST", "getNonAllcList","action=update&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&NonAllcCat=" + NonAllcCat + "&bevItem=" + bevItm +  "&prc=" + prc+ "&desc=" + desc + "&i=" + i+ "&x=" + x+ "&z=" + z);
}

function updateNonAllcSubCat(dinID, NonAllcCat, subCat,nSubCat, i) {
    return new AJAXRequest("POST", "getNonAllcList","action=update&target=subCat&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat+ "&subCat=" + subCat+ "&nSubCat=" + nSubCat + "&i=" + i );
}

function updateNonAllcCat(dinID, NonAllcCat, nNonAllcCat) {
    return new AJAXRequest("POST", "getNonAllcList","action=update&target=cat&dinID=" + dinID + "&nNonAllcCat=" + nNonAllcCat + "&NonAllcCat=" + NonAllcCat);
}

// ------------------------------------
function moveNonAllcItemDown(dinID, bevID, NonAllcCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getNonAllcList","action=order&target=itm&dir=down&bevID=" + bevID + "&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveNonAllcItemUp(dinID, bevID, NonAllcCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getNonAllcList","action=order&target=itm&dir=up&bevID=" + bevID + "&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveNonAllcSubCatDown(dinID, subCat, NonAllcCat, subCatOrder,i) {
	//alert("moveMenuCatDown "+menuCat);
    return new AJAXRequest("POST", "getNonAllcList","action=order&target=subCat&dir=down&dinID=" + dinID + "&subCat=" + subCat + "&NonAllcCat=" + NonAllcCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveNonAllcSubCatUp(dinID, subCat, NonAllcCat, subCatOrder,i) {
	return new AJAXRequest("POST", "getNonAllcList","action=order&target=subCat&dir=up&dinID=" + dinID + "&subCat=" + subCat + "&NonAllcCat=" + NonAllcCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveNonAllcCatDown(dinID, NonAllcCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getNonAllcList","action=order&target=cat&dir=down&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat + "&catOrder=" + catOrder);
}

function moveNonAllcCatUp(dinID, NonAllcCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getNonAllcList","action=order&target=cat&dir=up&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat + "&catOrder=" + catOrder);
}
// ------------------------------------
function deleteNonAllcItem(dinID, bevID, NonAllcCat, subCat, itemOrder, i, x, z) {
    return new AJAXRequest("POST", "getNonAllcList","action=delete&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&NonAllcCat=" + NonAllcCat +  "&itemOrder=" + itemOrder+  "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function deleteNonAllcSubCat(dinID, NonAllcCat, subCat, i, subCatOrder) {
    return new AJAXRequest("POST", "getNonAllcList","action=delete&target=subCat" + "&dinID=" + dinID + "&subCat=" + subCat + "&NonAllcCat=" + NonAllcCat + "&i=" + i + "&subCatOrder=" + subCatOrder);
}

function deleteNonAllcCat(dinID, NonAllcCat, catOrder) {
    return new AJAXRequest("POST", "getNonAllcList","action=delete&target=cat" + "&dinID=" + dinID + "&NonAllcCat=" + NonAllcCat + "&catOrder=" + catOrder);
}

//--------------------------------------  SPIRITS LIST --------------------------------------//

function addSpiritItem(dinID, SpiritCat, subCat, bevItem, prc, desc) {
    return new AJAXRequest("POST", "getSpiritList","action=add&dinID=" + dinID +"&SpiritCat=" + SpiritCat+"&subCat=" + subCat+"&bevItem=" + bevItem+ "&prc=" + prc+ "&desc=" + desc );
}

//--------------------------------------

function updateSpiritItem(dinID, bevID, bevItm, SpiritCat, subCat, prc, desc, i, x, z) {
    return new AJAXRequest("POST", "getSpiritList","action=update&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&SpiritCat=" + SpiritCat + "&bevItem=" + bevItm +  "&prc=" + prc+ "&desc=" + desc + "&i=" + i+ "&x=" + x+ "&z=" + z);
}

function updateSpiritSubCat(dinID, SpiritCat, subCat,nSubCat, i) {
    return new AJAXRequest("POST", "getSpiritList","action=update&target=subCat&dinID=" + dinID + "&SpiritCat=" + SpiritCat+ "&subCat=" + subCat+ "&nSubCat=" + nSubCat + "&i=" + i );
}

function updateSpiritCat(dinID, SpiritCat, nSpiritCat) {
    return new AJAXRequest("POST", "getSpiritList","action=update&target=cat&dinID=" + dinID + "&nSpiritCat=" + nSpiritCat + "&SpiritCat=" + SpiritCat);
}

// ------------------------------------
function moveSpiritItemDown(dinID, bevID, SpiritCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getSpiritList","action=order&target=itm&dir=down&bevID=" + bevID + "&dinID=" + dinID + "&SpiritCat=" + SpiritCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveSpiritItemUp(dinID, bevID, SpiritCat, subCat, itemOrder,i,x,z) {
    return new AJAXRequest("POST", "getSpiritList","action=order&target=itm&dir=up&bevID=" + bevID + "&dinID=" + dinID + "&SpiritCat=" + SpiritCat + "&subCat=" + subCat+ "&itemOrder=" + itemOrder+ "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function moveSpiritSubCatDown(dinID, subCat, SpiritCat, subCatOrder,i) {
	//alert("moveMenuCatDown "+menuCat);
    return new AJAXRequest("POST", "getSpiritList","action=order&target=subCat&dir=down&dinID=" + dinID + "&subCat=" + subCat + "&SpiritCat=" + SpiritCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveSpiritSubCatUp(dinID, subCat, SpiritCat, subCatOrder,i) {
	return new AJAXRequest("POST", "getSpiritList","action=order&target=subCat&dir=up&dinID=" + dinID + "&subCat=" + subCat + "&SpiritCat=" + SpiritCat + "&subCatOrder=" + subCatOrder+ "&i=" + i );
}

function moveSpiritCatDown(dinID, SpiritCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getSpiritList","action=order&target=cat&dir=down&dinID=" + dinID + "&SpiritCat=" + SpiritCat + "&catOrder=" + catOrder);
}

function moveSpiritCatUp(dinID, SpiritCat, catOrder) {
	//alert("moveMenuTypeDown "+menuCat);
    return new AJAXRequest("POST", "getSpiritList","action=order&target=cat&dir=up&dinID=" + dinID + "&SpiritCat=" + SpiritCat + "&catOrder=" + catOrder);
}
// ------------------------------------
function deleteSpiritItem(dinID, bevID, SpiritCat, subCat, itemOrder, i, x, z) {
    return new AJAXRequest("POST", "getSpiritList","action=delete&target=itm&bevID=" + bevID + "&dinID=" + dinID + "&subCat=" + subCat + "&SpiritCat=" + SpiritCat +  "&itemOrder=" + itemOrder+  "&i=" + i+ "&x=" + x+ "&z=" + z );
}

function deleteSpiritSubCat(dinID, SpiritCat, subCat, i, subCatOrder) {
    return new AJAXRequest("POST", "getSpiritList","action=delete&target=subCat" + "&dinID=" + dinID + "&subCat=" + subCat + "&SpiritCat=" + SpiritCat + "&i=" + i + "&subCatOrder=" + subCatOrder);
}

function deleteSpiritCat(dinID, SpiritCat, catOrder) {
    return new AJAXRequest("POST", "getSpiritList","action=delete&target=cat" + "&dinID=" + dinID + "&SpiritCat=" + SpiritCat + "&catOrder=" + catOrder);
}

//--------------------------------------  EVENTS --------------------------------------//
function addEvent(advID, eventType, headerValue, fromDateValue, toDateValue, recTypeSelected, fromTimeValue, toTimeValue, descrValue) {
    return new AJAXRequest("POST", "getEvents","action=add&advID=" + advID +"&eventType=" + eventType + "&headerValue=" + headerValue+"&fromDateValue=" + fromDateValue+"&toDateValue=" + toDateValue+ "&recTypeSelected=" + recTypeSelected + "&fromTimeValue=" + fromTimeValue  + "&toTimeValue=" + toTimeValue+ "&descrValue=" + descrValue );
}

/////////////////////////////////////// show  articles//////////////////////////////////////
function saveHomeSectionArticles(ids, orders,sectionID){
	return new AJAXRequest("Post","../SaveHomeSectionArticles", "ids="+ids+"&orders="+orders+"&sec="+sectionID);
	}

function updateDropDown(id){
	var selectedId = document.getElementById(id).value;
	return new AJAXRequest("Post","../updateDropDown", "pos=none&id="+selectedId);
	}
	
function updateDropLeft(id){
	var selectedId = document.getElementById(id).value;
	return new AJAXRequest("Post","../updateDropDown", "pos=left&id="+selectedId);
	}
	
function updateDropRight(id){
	var selectedId = document.getElementById(id).value;
	return new AJAXRequest("Post","../updateDropDown", "pos=right&id="+selectedId);
	}
function showAllArticles(id){
	var selectedId = document.getElementById(id).value;
		var nextAction = document.getElementById("noneNextAction").value;
	return new AJAXRequest("Post","../showAllArticle", "pos=none&next="+nextAction+"&noneSecID="+selectedId);
	}
function showAllLeft(id){
	var selectedId = document.getElementById(id).value;
		var nextAction = document.getElementById("leftNextAction").value;
	return new AJAXRequest("Post","../showAllArticle", "pos=left&next="+nextAction+"&leftSecID="+selectedId);
	}
	
function showAllRight(id){
	var selectedId = document.getElementById(id).value;
		var nextAction = document.getElementById("rightNextAction").value;
	return new AJAXRequest("Post","../showAllArticle", "pos=right&next="+nextAction+"&rightSecID="+selectedId);
	}

/////////////////////////////////////// show articles//////////////////////////////////////



//////////////////////////////////////    vedio  //////////////////////////////////////


function nextVideo(videoNo) {

    return new AJAXRequest("POST", "videoBrowser", "videoNo=" + videoNo);
}
function previousVideo(videoNo) {
    return new AJAXRequest("POST", "videoBrowser", "videoNo=" + videoNo);
}



function nextTopicVideo(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID);
}
function previousTopicVideo(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID);
}



function nextTopicEntVideo(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID+"&vWidth=450&vHeight=377&Ent=Ent");
}
function previousTopicEntVideo(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID+"&vWidth=450&vHeight=377&Ent=Ent");
}

function nextTopicEntVideo2(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID+"&movie1=0&vWidth=450&vHeight=377&Ent=Ent");
}
function previousTopicEntVideo2(videoNo,topicID) {
    return new AJAXRequest("POST", "VideoTopicBrowser", "videoNo="+videoNo+"&topicID="+topicID+"&movie1=0&vWidth=450&vHeight=377&Ent=Ent");
}

//////////////////////////////////////    flicker  //////////////////////////////////////

function navigateFliker( pIter , phst , w , h ) {
	document.getElementById("loadingFlicker").style.display = "";
	var params = "pIter=" + pIter;
	if(phst){
		params = params+"&phst="+phst;
	}
	if(w){
		params = params+"&w="+w;
	}
	if(h){
		params = params+"&h="+h;
	}
    return new AJAXRequest("POST", "http://" + location.host + "/flickerBrowser", params);
}

function navigateTopicFliker( pIter , topicID , phst , w , h ) {
	document.getElementById("loadingFlicker").style.display = "";
	var params = "pIter=" + pIter;
	if(topicID){
		params = params+"&topicID="+topicID;
	}
	if(phst){
		params = params+"&phst="+phst;
	}
	if(w){
		params = params+"&w="+w;
	}
	if(h){
		params = params+"&h="+h;
	}
    return new AJAXRequest("POST", "FlickerTopicBrowser", params);
}
//////////////////////////////////////    flicker  //////////////////////////////////////

function loadRss( rssType ) {
	showLoading();
    return new AJAXRequest("POST", "getFeeds", "RSSType=" + rssType);
}




//********************************************* Begin Comments ************************************************\\

function getComments(articleID) {
    return new AJAXRequest("POST", "GetComments", "ID=" + articleID);
}

function addComments(articleID,addComment,email,name,comment,code) {
    return new AJAXRequest("POST", "GetComments", "ID=" + articleID+"&addComment=true"+"&email="+email+"&name="+name+"&comment="+comment+"&code="+code);
}

function ajaxAddShopReview( shopID, UserReview, UserName, UserEmail , vCode) {
    return new AJAXRequest("POST", "addShopReview", "shopID=" + shopID +
                              "&UserReview=" + UserReview +
                              "&UserEmail=" + UserEmail +
                              "&UserName=" + UserName +
                              "&vCode="+ vCode);
}

function reportComments(commentID,reason,email,name,message) {
    return new AJAXRequest("POST", "ReportComments", "ID=" + commentID+"&reason="+encode(reason)+"&email="+encode(email)+"&name="+encode(name)+"&message="+encode(message));
}

function ChangeCaptcha() {
    return new AJAXRequest("POST", "ChangeCaptcha" , "loadC=true" );
}
//********************************************* End Comments ************************************************\\

/* -------------------------------------------
				shop photos   
--------------------------------------------*/
function updatePhotoCaption(id,caption){
		//alert(id);
		captionValue = document.getElementById("span_"+id+"_field").value;
		return new AJAXRequest("POST", "UpdatePhotoCaption","id="+id+"&caption="+captionValue);
}
/* -------------------------------------------*/



/* -------------------------------------------
				URL Validaton   
--------------------------------------------*/
function CheckDiningUrl(inputValue, id) {
	var params =  "value="+inputValue;
	if(id){
		params =  params + "&id="+id;
	}
    return new AJAXRequest("POST", "servlets/CheckDiningUrl",params);
}
/* -------------------------------------------*/


function getOrders( key, target ) {
    return getSelectData( "orders", key, target );
}

function getCustomers( key, target ) {
    return getSelectData( "customers", key, target );
}

function getCustomerType( key, target ) {
	var keyValue = key.options[key.options.selectedIndex].value;
    return new AJAXRequest("POST", "getCustomerTypeAJAX", "custID=" + keyValue + "&target=" + target);
}

function getDiscount ( key, target ) {
	var keyValue = key.options[key.options.selectedIndex].value;
    return new AJAXRequest("POST", "getDiscountAJAX", "custTypeID=" + keyValue + "&target=" + target);
}


function setUserType( key ) {
	var keyValue = key.options[key.options.selectedIndex].value;
	document.getElementById("userType").value = keyValue; 
}

function setOrderType( key ) {
	var keyValue = key.options[key.options.selectedIndex].value;
	document.getElementById("orderType").value = keyValue; 

}


<!------------------------------------- END SELECT --------------------------------------------->

<!--------------------------------- BEGIN "GET FORM VALUES" ------------------------------------>


function getFormData( value, dataset, target, parm2, parm3 ) {
    return new AJAXRequest( "POST", BASE_URL + "/servlet/get_formdata", "dataset=" + dataset + "&target=" + target + "&value=" + value ); 
}

// build a string containing every field on the passed form
// skip disabled controls
function getFormValues( form ) {
    form = $(form);
    var field = "";
    var value = "";
    var valueString = "";
    var replaceID = "";
    var parentNode = form.parentNode;

    for (var i = 0; i < form.elements.length; i++) {
        var field = form.elements[i];

        if (!field.disabled) {
            filedName = encode(field.name);

            if (field.type == 'select-one') {
                if (field.selectedIndex > -1) {
                    value = field.options[field.selectedIndex].value;
                }
            } else {
                value = field.value;
            }

            valueString += ((i) ? '&' : '') + field.name + '=' + encode(value);
        }
    }

    return valueString
}

function saveForm( form, extravalues, process ) {
    // process is an optional parameter
    // 
    var form = $(form);

    if (!form.method) {
        form = $(form.form);
    }

    if (form) {
        var valueString = getFormValues(form) + (!!(extravalues) ? extravalues : '');
        valueString += "&AJAX_FORM_NAME=" + encode(form.id);
        var functionToCall = null;

        if (typeof process == 'function') {
            functionToCall = process;
        } else {
            functionToCall = executeReturn; // generic function will execute what is returned
        }

        new AJAXRequest('POST', BASE_URL + form.action, valueString, functionToCall);
    }
}

function saveCustomerForm( form ) {
    saveForm(form, null, function( AJAX ) {
        if (AJAX.readyState == 4) {
            if (AJAX.status == 200) {
                $('customerFormStatus').innerHTML = "<img src='./checkbox.gif' border=0 /> " + AJAX.statusText;
                $('customerFormStatus').style.color = null;
                form.save.disabled = true
            } else {
                $('customerFormStatus').innerHTML = AJAX.statusText
                $('customerFormStatus').style.color = 'red';
            }
        }
    });

    // do not submit form if this is a submit button
    return false;
}

<!----------------------------------- END "GET FORM VALUES" ------------------------------------->

<!----------------------------------- BEGIN CUSTOMERS BY STATE (NON-XML) ------------------------>


function getCustomersByState( state, target ) {
    // if no state given then clear out
    if (!state) {
        clearCustomersByState();
    } else {
	// otherwise open up the state1_div
        var state1_div = $('state1_div');
        state1_div.style.visibility = 'visible';
        return new AJAXRequest("post", BASE_URL + "/servlet/get_customers", "state=" + encode(state),
                               processGetCustomersByState);
    }
}

function clearCustomersByState() {
    var state1_div = $('state1_div');
    state1_div.innerHTML = "";
    state1_div.style.visibility = 'hidden';
    document.getElementById("state1_info").innerHTML = "";
}

function processGetCustomersByState( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
            var response = myAJAX.responseText;
            // Resonse text is in this format:
            //    state=XXX&customers=cust1!cust2!cust3!cust4
            var customers;

            var returnParms = response.split('&');

            for (var i = 0; i < returnParms.length; i++) {
                var pair = returnParms[i].split('=');

                if (pair[0] == "customers") {
                    customers = pair[1];

                    if (customers == "") {
                        custList = "No customers found.";
                        document.getElementById("state1_info").innerHTML = "";
                    } else {
                        var custList = customers.split("!");
                        document.getElementById("state1_info").innerHTML
                            = "&nbsp;&nbsp;&nbsp;" + custList.length + " customer" + (custList.length == 1 ? "" : "s") + " found";
                    }
                }
            }

            var div = document.getElementById("state1_div");

            if (div) {
                div.innerHTML
                    = "<ol style=\"padding-left:2em\"><li>" + decode(custList.join("</li><li>")) + "</li></ol>";
                div.style.visibility = "visible"
            }
        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}

<!------------------------------------- END CUSTOMERS BY STATE (NON-XML) ------------------------>


<!----------------------------------- BEGIN CUSTOMERS BY STATE WITH XML  ------------------------>


function getCustomersByStateXML( state ) {
    if (!state) {
        clearCustomersByStateXML();
    } else {
        return new AJAXRequest("post", BASE_URL + "/servlet/get_customersXML", "state=" + encode(state), processGetCustomersByStateXML);
    }
}

function clearCustomersByStateXML() {
    var state2_div = document.getElementById("state2_div");
    state2_div.innerHTML = "Please enter a state...";
    $("state2_info").innerHTML = "";
}

function processGetCustomersByStateXML( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
            logger(myAJAX.responseText);
            xml = myAJAX.responseXML;
            // Resonse text is in this format:
            //    state=XXX&customers=cust1!cust2!cust3!cust4

            var div = "";

	    // parse the XML
            if (xml.documentElement) {
                var state = xml.documentElement.getElementsByTagName("state")[0].firstChild.nodeValue;
                var customers = xml.documentElement.getElementsByTagName("customer");

                if (customers.length <= 0) {
                    div += "<tr><td class=\"customers_by_state_error\">No customers found for state: <strong>" + state
                               + "</strong></td></tr>";
                } else {
                    document.getElementById("state2_info").innerHTML
                        = "&nbsp;&nbsp;&nbsp;" + customers.length + " customer" + 
				(customers.length == 1 ? "" : "s") + " found"

                    div += "<table>";

                    for (var i = 0; i < customers.length; i++) {
                        var cust = customers[i];
                        var id = customers[i].getAttributeNode("custnum").nodeValue;
                        var name = decode(customers[i].firstChild.firstChild.nodeValue);

                        div += "<tr>"
                        div += "<td class=\"cust_num\">" + id + "</td><td class=\"cust_name\">" + name + "</td>";
                        div += "</tr>";
                    }
                }

                div += "</table>";

                var state2_div = document.getElementById("state2_div");

                if (state2_div) {
                    state2_div.innerHTML = div;
                    state2_div.style.display = 'block';
                }
            }
        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}

<!------------------------------------- END CUSTOMERS BY STATE (XML) ------------------------>

<!------------------------------------- BEGIN SUGGEST --------------------------------------------->


// this function is called when the call to the google_suggest servlet (AJAXSuggest) is finished
// google returns 'sendRPCDone( .... )'
function getSuggest( field ) {
	// pass the query the user has typed
	// Since no callback handler is specified, AJAXRequest will execute the code returned
	return new AJAXRequest("POST", BASE_URL + "/servlet/ajax_suggest", "qu=" + encode(field.value));
}

// The google suggest functionality makes a call to this method automatically.
function sendRPCDone( notUsed, search_term, term_array, results_array, unused_array ) {
    var div = "<table>";

    if (results_array.length == 0) {
        div += "<tr><td class=\"search_error\">No results found for <strong>" + search_term + "</strong></td></tr>";
    } else {
        for (var i = 0; i < results_array.length; i++) {
            div += "<tr><td class=\"search_term\"><a href='http://www.google.com/search?q=" + encode(term_array[i]);
            div += "'>" + term_array[i] + '</a></td><td class="number_of_results">' + results_array[i]
                       + "</td></tr>";
        }
    }

    div += "</table>";
    var google_suggest_target = $("google_suggest_target");

    if (google_suggest_target) {
        google_suggest_target.innerHTML = div;
    }
}


<!------------------------------------- END SUGGEST --------------------------------------------->

_description = new Object();
_description.div_ping = function( ) {
    var desc = "<b>Ping</b><br>Ping sends the current date to the server. Basic AJAX functionality. See server console for date.";
    desc += "<br><br><b>Spam</b><br>Sends 10 pings to the server to show how long it takes to send 1 request to the server.";
    desc += "<br><br><b>Big File</b><br>Returns up to 10 megs from the server. Shows # of times onreadystatechange has been called (its a lot!).";
    desc += "<br>While the file is downloaded, you can work on other fields and see server activity. This shows that the behavior is truly asynchronous and multiple requests can be handled.";
    desc += "<br>The server stops sending data after 60 seconds so your file size might be smaller if you have a slower connection.";
    desc += "<br>If you shut down the server while downloading the big file, you will see an error message.";
    return desc;
};

_description.div_track_changes = function( ) {
    var desc = "<b>Track Changes As Fields Change</b><br>";
    desc += "As each field changes, the change is sent to the server. If all is well, the word OK shows up next to the field along with the text sent to the server.";
    desc += "<br>The server console shows the values sent to the server.";
    desc += "<br><br><b>Track Changes On Key Up</b><br>";
    desc += "As each key is released, the current value of the field is sent to the server. If all is well, the word OK shows up next to the field.";
    desc += "<br>The server console shows the values sent to the server.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.div_dropdowns = function( ) {
    var desc = "<b>Drop Downs & Form Handling</b><br>";
    desc += "An AJAX call is made to the server to get the states and populate the select box (drop down). ";
    desc += "The server dynamically creates Javascript that is executed through an eval statement.";
    desc += "The final line of the Javascript calls the onchange event of the state drop down which then retrieves all the cities for that state.";
    desc += "<br><br>The city drop down is populated and its onchange event retrieves all the customers for a given city.";
    desc += "<br><br>When the customer changes, the server returns Javascript that replaces all customer fields with the appropriate values.";
    desc += "If you open the Track Changes section, you'll notice that both address fields on the page are updated.";
    desc += "<br><br>In the samples, if you add a new INPUT field that matches a column in the customer table, it will be populated for you during runtime";
    desc += "<br><br>The routines to retrieve the state, city, and customer dropdowns all use variations of encapsulating XMLHTTPRequests instead of using a global XMLHTTPRequest (_ajax).";
    desc += "<br><br><b>Save</b><br>Sends the contents of the customer form back to the server. A message is shown indicating a successful save or a failure.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.div_customers_by_state = function( ) {
    var desc = "<b>Retrieve Customers By State (non-XML)</b><br>";
    desc += "This calls the server when the state is changed. The server returns a data set that includes the customer ID and the customer name. ";
    desc += "<br><br>Each pair is delimited by a comma, and each set is delimited by a !";
    desc += "<br><br>To see all customers, enter a '%' sign.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.div_customers_by_state_xml = function( ) {
    var desc = "<b>Retrieve Customers By State (XML)</b><br>";
    desc += "This calls the server when the state is changed. The server returns a data set that includes the customer ID and the customer name. ";
    desc += "<br><br>The data is returned back as an XML document and the returnXML property of the XMLHTTPRequest is parsed to pull out the data.";
    desc += "<br><br>To see all customers, enter a '%' sign.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.div_google_suggest_hack = function( ) {
    var desc = "<b>Google Suggests Hack</b><br>";
    desc += "This fires on each keystroke and calls the server passing the current search field.";
    desc += "<br><br>The server in turn calls the google suggest URL and then passes the results back to the user's browser.";
    desc += "<br><br>Google returns a Javascript method call to sendRPCDone(). We have our own sendRPCDone that loops through the results and presents the top 10 hits + # of pages.";
    desc += "<br><br>The reason Google is not called directly from the browser is that XMLHTTPRequest can only be used to call the orignal server or a trusted server setup in the Browser settings.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.div_activity_log = function( ) {
    var desc = "<b>Activity Log</b><br>";
    desc += "Shows various activity logs for each of the examples.";
    desc += "<br><br>The log is shown with the most recent log item at the top of the list.";
    desc += "<br><br>To write to this log, use the logger() function in the Javascript.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};

_description.default_text = function( ) {
    var desc = "<b>Basic AJAX Examples</b><br>";
    desc += "<br><b>The downloadable samples include full JavaScript & Java Source, a sample database for any SQL database, and a PowerPoint presentation.</b>";
    desc += "<br><br>This sampler shows some basic techniques to demonstrate some of the possibilities of using AJAX/XMLHTTPRequest techniques in web applications.";
    desc += "<br><br>Basic browser & server interaction is demonstrated along with dynamic population of visual elements such as DIVs and SELECT drop downs.";
    desc += "<br><br>In addition, many ways of instantiating & encapsulating XMLHTTPRequest objects are shown in the Javascript.";
    desc += "<br><br>This sample is freeware and has no copyright restrictions whatsoever. It is doesn't carry a warranty or a guarantee.";
    desc += "<br><br>Written by Steve Benfield.<br><a href='mailto:sbenfield@clearnova.com&subject=AJAX Samples' style='color:white' alt='email the author'>sbenfield@clearnova.com</a>";
    desc += "<br><br>ClearNova provides ThinkCAP&trade;, a framework & visual workbench ideally suited for building Rich Internet Applications using AJAX techniques. For information on ThinkCAP, visit <a href='/'>www.clearnova.com</a>"
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    desc += "<h3>This page is running on a development server--uptime is not guaranteed.</h3>"
    desc += "<br><br>Last Updated: July 15, 2005 | Version 1.1";

    return desc;
}

function toggleDiv( element ) {
    var e = $(element);

    if (e) {
        e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
        $('div_upper_right').innerHTML = _description[e.id]();
    }
}

function toggleLog( button ) {
	var disp=$('status_area').style.display;
	if ( disp == 'none' ) {
		$('status_area').style.display = 'block';
		button.value= 'Stop & Hide Log';
		_logger = true;
	} else {
		$('status_area').style.display = 'none';
		button.value= 'Show Log';
		_logger = false;
	}
}