function show_logo_offer() {
  $("#logo-offer").show();
  $("#overlay").css("height", $(document).height() + "px").show();
}
function hide_logo_offer() {
  $("#overlay").hide();
  $("#logo-offer").hide();
}

function isiThing(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1) ||
        (navigator.platform.indexOf("iPad") != -1)
    );
}

function hold_the_phone() {
  var w = $(window).width();
  var h = $(window).height();
  if (w < 250) {
    $("#holder").html("<abbr title=\"Too tight.\">Ow. Pain.</abbr>");
  } else if (w < 500) {
    $("#holder").html("<abbr title=\"OK, OK! More will appear here as and when it&#39;s ready.\">Please don&#39;t squeeze me.</abbr>");
    if (h < 250) {
      $("#holder").html("<abbr title=\"You&#39;re not trying to do any work in a browser this size are you?\">This really hurts.</abbr>");
    }
  } else if (w > 960) {
    var pwm = (isiThing() ? "Touch me." : "Play with me.");
    $("#holder").html("<abbr title=\"Ambition is good. What&#39;s keeping you?\">" + pwm + "</abbr>");
  } else if (w > 1200) {
    $("#holder").html("<abbr title=\"I&#39;m just a piece of text on a website; I know nothing.\">Why are you doing this to me?</abbr>");
  } else {
    $("#holder").html("<abbr title=\"Though only so it can be filled in.\">This space intentionally left blank.</abbr>");
  }
}

function logo_magic() {
  $("img#l").mouseenter(function() {
    $("img#l").attr( "src", switch_colour($("img#l").attr("src")) );
  });
  $("img#u").mouseenter(function() {
    $("img#u").attr( "src", switch_colour($("img#u").attr("src")) );
  });
  $("img#d").mouseenter(function() {
    $("img#d").attr( "src", switch_colour($("img#d").attr("src")) );
  });
  $("img#o").mouseenter(function() {
    $("img#o").attr( "src", switch_colour($("img#o").attr("src")) );
  });
  $("img#m").mouseenter(function() {
    $("img#m").attr( "src", switch_colour($("img#m").attr("src")) );
  });
  $("img#e").mouseenter(function() {
    $("img#e").attr( "src", switch_colour($("img#e").attr("src")) );
  });
  $("img#t").mouseenter(function() {
    $("img#t").attr( "src", switch_colour($("img#t").attr("src")) );
  });
  $("img#r").mouseenter(function() {
    $("img#r").attr( "src", switch_colour($("img#r").attr("src")) );
  });
  $("img#i").mouseenter(function() {
    $("img#i").attr( "src", switch_colour($("img#i").attr("src")) );
  });
  $("img#c").mouseenter(function() {
    $("img#c").attr( "src", switch_colour($("img#c").attr("src")) );
  });
  $("img#s").mouseenter(function() {
    $("img#s").attr( "src", switch_colour($("img#s").attr("src")) );
  });
}

function switch_colour(src) {
  var ltr = src.lastIndexOf('/');
  var col = src.indexOf('_');
  var dot = src.indexOf('.gif');
  
  var clr = src.substring(col+1, dot);
  var nc = clr;
  switch (clr) {
    case "blue":
      nc = "orange";
      break;
    case "orange":
      nc = "pink";
      break;
    case "pink":
      nc = "red";
      break;
    case "red":
      nc = "yellow";
      break;
    case "yellow":
      nc = "green";
      break;
    case "green":
      nc = "blue";
      break;
  }

  var r = '/img/logo/' + src.substring(ltr+1, ltr+3) + nc + '.gif';
  
  return r;
}

function typeOf (obj) {
  type = typeof obj;
  return type === "object" && !obj ? "null" : type;
}
function introspect(name, obj, indent, levels) {
  indent = indent || "";
  if (this.typeOf(levels) !== "number") levels = 1;
  var objType = this.typeOf(obj);
  var result = [indent, name, " ", objType, " :"].join('');
  if (objType === "object") {
    if (level > 0) {
      indent = [indent, "  "].join('');
      for (prop in obj) {
        var prop = this.introspect(prop, obj[prop], indent, level - 1);
        result = [result, "\n", prop].join('');
      }
      return result;
    }
    else {
      return [result, " ..."].join('');
    }
  }
  else if (objType === "null") {
    return [result, " null"].join('');
  }
  return [result, " ", obj].join('');
}

/*///////////////////////////////////////////////////////////////////////
Ported to jquery from prototype by Joel Lisenby (joel.lisenby@gmail.com)
http://joellisenby.com

original prototype code by Aarron Walter (aarron@buildingfindablewebsites.com)
http://buildingfindablewebsites.com

Distrbuted under Creative Commons license
http://creativecommons.org/licenses/by-sa/3.0/us/
///////////////////////////////////////////////////////////////////////*/

$(document).ready(function() {
  $('#signup').submit(function() {
    // update user interface
    $('#response').html('Adding email address...');
    
    // Prepare query string and send AJAX request
    $.ajax({
      url: '/inc/store-address.php',
      data: 'ajax=true&email=' + escape($('#email').val()),
      success: function(msg) {
        $('#response').html(msg);
        if (msg.indexOf("Success") == 0)
          $('#response').addClass("success");
        else
          $('#response').addClass("important");
      }
    });
  
    return false;
  });
});

