
// select sales reps based on territory selected
function getReps() {
  var u = document.form1.selTerritory.options[document.form1.selTerritory.selectedIndex].value;  
 
  
  var oXmlHttp = zXmlHttp.createRequest();
  oXmlHttp.open("get", "contact/getReps.aspx?id=" + u, true);  
  oXmlHttp.onreadystatechange = function() {
    if (oXmlHttp.readyState == 4) {
      if (oXmlHttp.status == 200) { 
        document.getElementById("rep").innerHTML = oXmlHttp.responseText;                 
            
      }
    }
  }
  oXmlHttp.send(null);	
};


// create cross-browser implementation of xmlhttp
var zXml = {
    useActiveX: (typeof ActiveXObject != "undefined"),
    useDom: document.implementation && document.implementation.createDocument,
    useXmlHttp: (typeof XMLHttpRequest != "undefined")
};

zXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.5.0", "MSXML2.XmlHttp.4.0", 
                         "MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp",
                         "Microsoft.XmlHttp"];

zXml.ARR_DOM_VERS = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", 
                     "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument",
                     "Microsoft.XmlDom"];
                   
/**
 * Static class for handling XMLHttp creation.
 * @class
 * @scope public
 */                     
function zXmlHttp() {
}

/**
 * Creates an XMLHttp object.
 * @static
 * @scope public
 * @return An XMLHttp object.
 */
zXmlHttp.createRequest = function ()/*:XMLHttp*/ {

    if (zXml.useXmlHttp) {
        return new XMLHttpRequest();
    } else if (zXml.useActiveX) {
  
        if (!zXml.XMLHTTP_VER) {
            for (var i=0; i < zXml.ARR_XMLHTTP_VERS.length; i++) {
                try {
                    new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
                    zXml.XMLHTTP_VER = zXml.ARR_XMLHTTP_VERS[i];
                    break;
                } catch (oError) {                
                }
            }
        }
        
        if (zXml.XMLHTTP_VER) {
            return new ActiveXObject(zXml.XMLHTTP_VER);
        } else {
            throw new Error("Could not create XML HTTP Request.");
        }
    } else {
        throw new Error("Your browser doesn't support an XML HTTP Request.");
    }

};

/**
 * Indicates if XMLHttp is available.
 * @static
 * @scope public
 * @return True if XMLHttp is available, false if not.
 */
zXmlHttp.isSupported = function ()/*:Boolean*/ {
    return zXml.useXmlHttp || zXml.useActiveX;
};
