var j = jQuery.noConflict();


function quickJump() {
  var id = j("#idsString").val();
  id = id.replace(/^\s+|\s+$/g, ''); //trim
  if(validateJumpId(id)) {
      var appServerRootUrl = j("#app_server_root_url").val();

      self.document.location = appServerRootUrl + "/sf/go/" + id;
  } else {
    j("#jumpToErrorDialog").attr("style", "visibility=''"); 
  }
  return false;
}

function validateJumpId(id) {
  // keep in sync with WikiTranslator.OBJECT_KEY_PATTERN
  // also split into two blocks, since one long ( | | ) or clause was causing issue for testing
  return id.match(/^(artf|cmmt|doc|frs|news|post|report|task|forum|pkg)\d{4,}$/i) ||
         id.match(/^(rel|docr|docf|topc|tracker|user|proj|reps|taskgrp|wiki|page|srch)\d{4,}$/i);
}

function closeJumpDialog() {
    j("#jumpToErrorDialog").attr("style", "visibility:hidden");
}

jQuery(document).ready(function() {
    j("#idsString").focus(function(){
      var jumpValue = j(this).val();
      j(this).removeClass("jumpToFieldInactive");
      if(jumpValue == jumpExample) {
        j(this).val("");
      }
      return false;
    });
    j("#idsString").blur(function(){
      if(j(this).val() == "") {
        j(this).val(jumpExample);
        j(this).addClass("jumpToFieldInactive");
      }
      return false;
    });
});
