/*$(window).load(function () {
  myIP();
})*/

function getXMLHTTPRequest() {
   var req =  false;
   try {
      /* for Firefox */
      req = new XMLHttpRequest(); 
   } catch (err) {
      try {
         /* for some versions of IE */
         req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (err) {
         try {
            /* for some other versions of IE */
            req = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (err) {
            req = false;
         }
     }
   }

   return req;
}

function myIP() {
    
    var ipVal, countryIP , cityIP, input, xmlhttp;
    
    xmlhttp = new getXMLHTTPRequest();
	xmlhttp.onreadystatechange = function() {
        alert(xmlhttp.readyState);
    };
    xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
    xmlhttp.send();
    hostipInfo = xmlhttp.responseText.split("\n");
    xmlhttp.close;
    
    alert("length = "+hostipInfo.length);
    for (i = 0; i < hostipInfo.length; ++i) {
        alert(hostipInfo[i]);
       line = hostipInfo[i].split(":");
       if (String(line[0]) == "IP") {
         ipVal = line[1];
       }
       else if (String(line[0]) == "City") {
         cityIP = line[1];
       }
       else if (String(line[0]) == "Country") {
         countryIP = line[1];
       }
    }
    return ipVal;
}
