﻿
// JavaScript Document
var xmlhttp=false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
catch (e) { xmlhttp = false; }

if (!xmlhttp)
    try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
    catch (e) { xmlhttp = false; }
    
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
    try { xmlhttp = new XMLHttpRequest(); } 
    catch (e) { xmlhttp = false; }


function OnPostcodeChange(page, bike_intid, postcodeId, divId, lastRowId) 
{
    var postcode = document.getElementById(postcodeId).value;
    var url = page + "?" + "postcode=" + postcode + "&" + "bike_intid=" + bike_intid;
    var lastRowObj = document.getElementById(lastRowId);

    xmlhttp.open("POST", url, true);
    xmlhttp.onreadystatechange=function() {
        var elem = document.getElementById(divId);
        
        if (xmlhttp.readyState==1 && elem.innerHTML != '') 
        {
            elem.innerHTML = 'Loading..';
        }

        if (xmlhttp.readyState==4) {
            elem.innerHTML = xmlhttp.responseText;
            lastRowObj.style.display = xmlhttp.responseText == '' ? 'block' : 'none';
        }
    }
    xmlhttp.send('');
}

