//Counts the number of requests in this session
    var requestNum = 0;
    //Choose the correct script to run based on dropdown selection
    function callRoute(callType) {
            returnDnsDetails(document.getElementById("domain").value, callType)
    }

    function requestTitle(callType){
        if (callType == "getTxt.php") {
            return "SPF/TXT Lookup"
        } else if (callType == "getMx.php") {
            return "MX Lookup"
        } else if (callType =="getA.php") {
            return "IP Lookup"
        } else if (callType == "getAll.php") {
            return "Look up all the things"
        } else if (callType == "getAAAA.php") {
            return "IPV6 Lookup"
        } else if (callType == "getWhois.php") {
            return "Who Is Lookup"
        } else if (callType == "getHinfo.php") {
            return "H Info Lookup"
        } else {
            return callType
        }

    }

    //Get DNS Details
    function returnDnsDetails(domain, callType) {
        //checks for valid input
        if (domain.length == 0) {
            document.getElementById("txtHint").innerHTML = " Please enter a valid domain";
            return;
        } else {
            var xmlhttp = new XMLHttpRequest();
            
            xmlhttp.onreadystatechange = function () {
                var date = new Date();
                if (this.readyState == 4 && this.status == 200) {
                    //Clears the hint field
                    document.getElementById("txtHint").innerHTML = "";
                    //parse the response into a JS Object
                    dnsResp = JSON.parse(this.responseText);

                    //cosole data validation
                    console.log(dnsResp);
                    console.log(dnsResp.length);


                    if (dnsResp.length == 0) {
                        $(".responseTable").prepend("<table class=\"responseRow" + requestNum + "\"></table>");
                        $(".responseRow" + requestNum).append("<td colspan='2' class='thead'>" + requestTitle(callType) + "</td>");
                        $(".responseRow" + requestNum).append("<tr><td colspan='2' style='text-align:center'>NO DATA FOUND</td></tr>");
                    } else {

                        //creates thes the table to store the response details each table has a unique class
                        $(".responseTable").prepend("<table class=\"responseRow" + requestNum + "\"></table>");
                        $(".responseRow" + requestNum).append("<td colspan='2' class='thead'>" + requestTitle(callType) + "</td>");
                        for (i = 0, len = dnsResp.length; i < len; i++) {
                            var jsonData = dnsResp[i];
                            console.log(jsonData);

                            //iterates through object keys
                            for (j = 0, len = Object.keys(jsonData).length; j < len; j++) {
                                $(".responseRow" + requestNum).append("<tr><td class='left-row'>" + Object.getOwnPropertyNames(jsonData)[j] + ":</td><td>" + jsonData[Object.keys(jsonData)[j]] + "</td></tr>");
                            }
                            $(".responseRow" + requestNum).append("<tr><td colspan='2' class='last-row'></td></tr>");
                        }
                   
                    }
                 

                    
                }
            };
            xmlhttp.open("GET", callType + "?domain=" + domain, true);
            xmlhttp.send();
            
        }
        requestNum++;
    }

@@ -307,19 +307,22 @@
         
-if 
+switch
 (callTyp
@@ -318,27 +318,44 @@
 tch(callType
- ==
+)%7B%0D%0A            case
  %22getTxt.php
@@ -351,29 +351,31 @@
 %22getTxt.php%22
-) %7B%0D%0A
+:%0D%0A    
             
@@ -389,32 +389,33 @@
 %22SPF/TXT Lookup%22
+;
 %0D%0A        %7D else
@@ -408,38 +408,48 @@
         
-%7D else if (callType ==
+        break;%0D%0A            case
  %22getMx.
@@ -448,29 +448,31 @@
  %22getMx.php%22
-) %7B%0D%0A
+:%0D%0A    
             
@@ -481,32 +481,33 @@
 turn %22MX Lookup%22
+;
 %0D%0A        %7D else
@@ -500,38 +500,49 @@
         
-%7D else if (callType ==
+        break;%0D%0A            case 
 %22getA.ph
@@ -539,29 +539,31 @@
 e %22getA.php%22
-) %7B%0D%0A
+:%0D%0A    
             
@@ -572,32 +572,33 @@
 turn %22IP Lookup%22
+;
 %0D%0A        %7D else
@@ -591,38 +591,48 @@
         
-%7D else if (callType ==
+        break;%0D%0A            case
  %22getAll
@@ -632,27 +632,25 @@
 %22getAll.php%22
-) %7B
+:
 %0D%0A          
@@ -651,24 +651,28 @@
         
+    
 return %22
 Look up 
@@ -667,31 +667,35 @@
 rn %22
-Look up all the thing
+All available DNS record
 s%22
+;
 %0D%0A  
@@ -700,38 +700,48 @@
         
-%7D else if (callType ==
+        break;%0D%0A            case
  %22getAAA
@@ -742,27 +742,25 @@
 getAAAA.php%22
-) %7B
+:
 %0D%0A          
@@ -753,32 +753,36 @@
 %22:%0D%0A            
+    
 return %22IPV6 Loo
@@ -777,32 +777,33 @@
 rn %22IPV6 Lookup%22
+;
 %0D%0A        %7D else
@@ -796,38 +796,48 @@
         
-%7D else if (callType ==
+        break;%0D%0A            case
  %22getWho
@@ -839,29 +839,31 @@
 etWhois.php%22
-) %7B%0D%0A
+:%0D%0A    
             
@@ -876,32 +876,33 @@
  %22Who Is Lookup%22
+;
 %0D%0A        %7D else
@@ -899,30 +899,40 @@
     
-%7D else if (callType ==
+        break;%0D%0A            case
  %22ge
@@ -942,19 +942,17 @@
 nfo.php%22
-) %7B
+:
 %0D%0A      
@@ -949,32 +949,36 @@
 %22:%0D%0A            
+    
 return %22H Info L
@@ -983,36 +983,24 @@
  Lookup%22
+;
 %0D%0A     
-   %7D else %7B%0D%0A
         
@@ -1006,24 +1006,14 @@
     
- return callType
+break;
 %0D%0A  
@@ -1017,26 +1017,24 @@
 %0A        %7D%0D%0A
-%0D%0A
     %7D%0D%0A%0D%0A   

switch else ifs to a switch case