$(document).ready(function()
{
  $(".button").click(function()
  {
    switch ($(this).attr("rel"))
    {
      case 'gettech':
      var el=$(this);
      var code=$(this).parent().children(".codeinput").attr("value");
      $.ajax(
      {
        url:"/lib/js/techsupp/gettech.php?code="+code,
        dataType:"json",
        success:function(data){
          console.log(data);
          var th=$(el).parent().children(".result");
          var tx='';

          for(k in data)
          {
            console.log(data[k]);
            tx=tx+"<p><strong>"+k+"</strong>: "+data[k]+"</p>";
          }
          $(th).html(tx);
          $(th).show();
          return true;
        }
      });
      break;
      case 'techsupp':
      var el=$(this);
      $.ajax(
        {
          url:"/lib/js/techsupp/tech.php",
          dataType:"json",
          success:function(data){
            $(el).parent().children(".result").children("p").children(".data-code").html(data.code);
            $(el).parent().children(".result").children("p").children(".data-ip").html(data.ip);
            $(el).parent().children(".result").children("p").children(".data-browser").html(data.browser);
            $(el).parent().children(".result").show();
            $(el).hide();
          }
        }
      );
      break;
    }
  });
});

