// Roshan's Ajax dropdown code with php

// This notice must stay intact for legal use

// Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com

// If you have any problem contact me at http://roshanbh.com.np



function getXMLHTTP() { //fuction to return the xml http object

                var xmlhttp=false;



                try{

                    xmlhttp=new XMLHttpRequest();

                    }

                catch(e)

                        {

                        try{

                        xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");

                        }

                        catch(e){

                                try {

                                    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

                                    }

                                catch(e1)

                                         {

                                        xmlhttp=false;

                                        }

                        }

                }

                return xmlhttp;

    }



        function getModell(manufacturerId) {



                var strURL="findmodell.php?manufacturer="+manufacturerId;

                var req = getXMLHTTP();

                if (req) {



                        req.onreadystatechange = function() {



                        if (req.readyState == 1)

                        {

                        // Display Loading Image before content is loaded

                        document.getElementById('statediv').innerHTML = '<img src="images/loading.gif" alt="Loading" />';

                        }



                                if (req.readyState == 4) {

                                        // only if "OK"

                                        if (req.status == 200) {

                                                document.getElementById('statediv').innerHTML=req.responseText;

                                        } else {

                                                alert("There was a problem while using XMLHTTP getModell:\n" + req.statusText + "\n" + req.status + "\n" +strURL);

                                        }

                                }

                        }

                        req.open("GET", strURL, true);

                        req.send(null);

                }

        }



        function getTeileart(manufacturerId,modellId) {

                var strURL="findteileart.php?manufacturer="+manufacturerId+"&modell="+modellId;

                var req = getXMLHTTP();



                if (req) {



                        req.onreadystatechange = function() {

                          if (req.readyState == 1)

                        {

                        // Display Loading Image before content is loaded

                        document.getElementById('citydiv').innerHTML = '<img src="images/loading.gif" alt="Loading" />';

                        }

                                if (req.readyState == 4) {

                                        // only if "OK"

                                        if (req.status == 200)

                                                        {

                                                 document.getElementById('citydiv').innerHTML=req.responseText;

                                                        }

                                                        else {

                                                        alert("There was a problem while using XMLHTTP getTeileart:\n" + req.statusText + "\n" + req.status + "\n" +strURL);

                                                        }

                                }

                        }

                        req.open("GET", strURL, true);

                        req.send(null);

                }

        }
