/*
	zip2addr ajax 
*/
function handleHttpResponse() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var addr	= "";
        var xmlDoc = xmlHttp.responseXML;
		
        if (xmlDoc.documentElement) {
            var pref  = xmlDoc.getElementsByTagName('pr').item(0).firstChild;
            var city  = xmlDoc.getElementsByTagName('ct').item(0).firstChild;
            var street = xmlDoc.getElementsByTagName('st').item(0).firstChild;
			
            if (pref != null) addr += decodeURIComponent(pref.data);
            if (city != null) addr += decodeURIComponent(city.data);
            if (street != null) addr += decodeURIComponent(street.data);
		
        }
		document.getElementById('addr').value = addr;
    }
}

function getAddress() {
    var zip = document.getElementById('zip').value;
	if(zip.length>=3){
		xmlHttp.open('GET', '/cms/cms-utils/ajZip/?zip=' + escape(zip), true);
    	xmlHttp.onreadystatechange = handleHttpResponse;
    	xmlHttp.send(null);
	}
}

function getXmlHttpObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    @else
        xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
            xmlhttp.overrideMimeType("text/xml"); 
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

var xmlHttp = getXmlHttpObject();


