//
//  Copuright (c) 2008 gama All Right Reserved.
//  gama@miyachu.com
//
//		2009/10/01 modify blog. -> www.

function zip2addr(zip,pref,addr,func)     {
    if (addr.value)  {
        return(null);
    }
//alert(zip.value);
    httpObj = createXMLHttpRequest(func);
    if (httpObj)    {
        dd = new Date();
        cgi =   "http://www.toyokitchen.co.jp/cgi-bin/zipcode/bin/zip2addr.cgi?" +  zip.value + '&' + dd.getTime();
//alert(cgi);
        httpObj.open("GET",cgi,true);
        httpObj.send(null);
    }
}

function zipReadComplete(zip,pref,addr)  {
    if ((httpObj.readyState == 4) && (httpObj.status == 200))   {
        if (httpObj.responseText == '')  {
            return(null);
        }
        r    =   httpObj.responseText.split("\t");
        var max =   pref.length;
        // alert(r[0]+"\n"+r[1]+"\n"+r[2]+"\n"+max);
        for (i = 0; i < max; i++) {
            if (pref.options[i].text == r[1]) {
                pref.selectedIndex   =   i;
                break;
            }
        }
        zip.value           =   r[0];
        addr.value          =   r[2];
        addr.focus();
    }
}

