var zoom =1;
var direction = true;
function handleKeys(e){
  var evtobj=window.event? event : e ; //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
  var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode;
  var actualkey=String.fromCharCode(unicode);
  
  if (actualkey=="e"&& evtobj.ctrlKey) {
    var docHref = document.location.href;
    if(docHref.lastIndexOf('?')>0)
      document.location.href=docHref.substring(0,docHref.lastIndexOf('?'));
    else
      document.location.href=docHref+"?edit=yes";  
  }
  else if (actualkey=="+"|| actualkey=="-"  ) {
    (document.body.style.fontSize) ? document.body.style.fontSize=document.body.style.fontSize : document.body.style.fontSize="1em";
    if (actualkey=="+" && direction) { zoom +=0.02; direction = true } 
    else if (actualkey=="+" && !direction) { zoom =1.02; direction = !direction }
    else if (actualkey=="-" && direction) { zoom =0.98; direction = !direction }
    else { zoom -= 0.02; direction = false };
    document.body.style.fontSize=parseFloat(document.body.style.fontSize)*zoom +"em";
  }
  
}
document.onkeypress=handleKeys;
$().ready(function() {
  $('.button').click( function(event) {
    $(this).parent().parent().parent().ajaxSubmit({
      //success: showResponse(event)
      success: function() {
        if(arguments[1]=="success")
          alert(arguments[0]);       
      }
    });    
    return false;
  });
  var docHref = document.location.href;
  $('#nav').find('a').each( function() {
    var docRel = docHref.substr(docHref.lastIndexOf('/')+1);
    //console.log("docRel " + docRel);
    if($(this).attr("href") == docRel)
      $(this).addClass('selected');
  });
});

function showResponse(responseText, statusText, el)  {
  el.text(responseText);
      alert('status: ' + statusText + '\n\nresponseText: \n' + responseText); 
} 

