/**
 * Extending jQuery with autocomplete
 * Version: 1.4.2
 * Author: Yanik Gleyzer (clonyara)
 
(function(jQuery) {

// some key codes
 var RETURN = 13;
 var TAB = 9;
 var ESC = 27;
 var ARRLEFT = 37;
 var ARRUP = 38;
 var ARRRIGHT = 39;
 var ARRDOWN = 40;
 var BACKSPACE = 8;
 var DELETE = 46;
 
function debug(s){
  jQuery('#info').append(htmlspecialchars(s)+'<br>');
}
// getting caret position obj: {start,end}
function getCaretPosition(obj){
  var start = -1;
  var end = -1;
 if(typeof obj.selectionStart != "undefined"){
    start = obj.selectionStart;
    end = obj.selectionEnd;
  }
  else if(document.selection&&document.selection.createRange){
    var M=document.selection.createRange();
    var Lp;
    try{
      Lp = M.duplicate();
      Lp.moveToElementText(obj);
    }catch(e){
      Lp=obj.createTextRange();
    }
    Lp.setEndPoint("EndToStart",M);
    start=Lp.text.length;
  //  if(start>obj.value.length)
  //    start = -1;
    
    Lp.setEndPoint("EndToStart",M);
    end=Lp.text.length;
//    if(end>obj.value.length)
//      end = -1;
  }
  return {'start':start,'end':end};
}
// set caret to
function setCaret(obj,l){
  obj.focus();
  if (obj.setSelectionRange){
    obj.setSelectionRange(l,l);
  }
  else if(obj.createTextRange){
    m = obj.createTextRange();      
    m.moveStart('character',l+1);
    m.collapse();
    m.select();
  }
}
// prepare array with velued objects
// required properties are id and value
// rest of properties remaines
function prepareArray(jsondata){
  var new_arr = [];
  for(var i=0;i<jsondata.length;i++){
    if(jsondata[i].id != undefined && jsondata[i].value != undefined){
      jsondata[i].id = jsondata[i].id+"";
      jsondata[i].value = jsondata[i].value+"";
   //   if(jsondata[i].info != undefined)
   //     jsondata[i].info = jsondata[i].info+"";
      new_arr.push(jsondata[i]);
    }
  }
  return new_arr;
}
// php analogs
function escapearg(s){
  if(s == undefined || !s) return '';
  return s.replace('\\','\\\\').
           replace('*','\\*').
           replace('.','\\.').
           replace('/','\\/');
}
function htmlspecialchars(s){
  if(s == undefined || !s) return '';
  return s.replace('&','&amp;').
           replace('<','&lt;').
           replace('>','&gt;');
}
function ltrim(s){
  if(s == undefined || !s) return '';
  return s.replace(/^\s+/g,'');
}

// extending jQuery
jQuery.fn.autocomplete = function(options){ return this.each(function(){
  // take me
  var me = jQuery(this);
  var me_this = jQuery(this).get(0);

  // test for supported text elements
  if(!me.is('input:text,input:password,textarea'))
  return;

  // get or ajax_get required!
  if(!options && (!jQuery.isFunction(options.get) || !options.ajax_get)){
  return;
  }  
  // check plugin enabled
  if(me.attr('jqac') == 'on') return;

  // plugin on!
  me.attr('jqac','on');

  // no browser's autocomplete!
  me.attr('autocomplete','off');

  // default options
  options = jQuery.extend({ 
                      delay     : 600 ,
                      timeout   : 3000 ,
                      minchars  : 1 ,
                      multi     : true ,
                      cache     : true , 
                      height    : 150 ,
                      autowidth : false ,
                      noresults : 'No property match found'
                      },
                      options);
  
  me.blur( function (ev) { 
    clearSuggestions();
      } );
  
  // bind key events
  // handle special keys here
  me.keydown(function(ev){
    switch(ev.which){
      // return choose highlighted item or default propogate
      case RETURN:
        if(!suggestions_menu){
         if(document.getElementById('frmSreachBykeyWord') != null && document.getElementById('frmSreachBykeyWord')!='' && document.getElementById('frmSreachBykeyWord')!= 'undefined'){
            submittfrm('frmSreachBykeyWord','keyword'); return true; }
         }
         //return true;
        else{ 
        setHighlightedValue(); 
            if(document.getElementById('frmSreachBykeyWord') != null && document.getElementById('frmSreachBykeyWord')!='' && document.getElementById('frmSreachBykeyWord')!= 'undefined'){
            submittfrm('frmSreachBykeyWord','keyword'); 
            }
            else {
                if(document.forms[0].id == "BasicSearchForm"){
					if(document.forms[0].elements["areaKeyWord"].value != "" || document.forms[0].elements["areaKeyWord"].value != ' e.g. City, Location, etc.'){
						try{
							document.forms[0].elements["isAdvance"].value='true';
						}catch(err){}
						document.forms[0].submit();
					}
                }
            }
        }
        return false;
      // escape clears menu
      case ESC:
        clearSuggestions();
        return false;
        // up changes highlight
        case ARRUP:
        var browser=navigator.appName;
        if ((browser=="Microsoft Internet Explorer"))
        {
        changeHighlight(ev.keyCode);
        setHighlightedValue();
        return false;
        }
        else{
        return false;
        }
      // down changes highlight or open new menu
      case ARRDOWN:
        var browser=navigator.appName;
        if ((browser=="Microsoft Internet Explorer"))
        {
        if(!suggestions_menu) getSuggestions(getUserInput());
        else{ changeHighlight(ev.keyCode); setHighlightedValue();}
        return false;
        }
        else{
        return false;
        }
    }
    return true;
  });
  me.keypress(function(ev){
    // ev.which doesn't work here - it always returns 0
    switch(ev.keyCode){
    //  case RETURN:
 //     {  submittfrm('frmSreachBykeyWord','keyword');
 //        return false;}
      case ESC:
        return false;
      // up changes highlight
      case ARRUP:
        changeHighlight(ev.keyCode);
        setHighlightedValue();
        return false;
      // down changes highlight or open new menu
      case ARRDOWN:
        if(!suggestions_menu) getSuggestions(getUserInput());
        else {changeHighlight(ev.keyCode);setHighlightedValue();}
        return false;
     }
     return true;
  });
  // handle normal characters here
  me.keyup(function(ev) {
      switch(ev.which) {
        case RETURN:
            {
                clearSuggestions();
                if(document.getElementById('frmSreachBykeyWord') != null && document.getElementById('frmSreachBykeyWord') != '' && document.getElementById('frmSreachBykeyWord') != 'undefined')
                {
                    submittfrm('frmSreachBykeyWord','keyword'); return true; 
                }
                //submittfrm('BasicSearchForm','keyword'); return true; 
                return true;
            }
        case ESC: case ARRLEFT: case ARRRIGHT: case ARRUP: case ARRDOWN:
           return false; 
        default:
          getSuggestions(getUserInput());
           return false;
      }
      return true;
  });

  // init variables
  var user_input = "";
  var input_chars_size  = 0;
  var suggestions = [];
  var current_highlight = 0;
  var suggestions_menu = false;
  var suggestions_list = false;
  var loading_indicator = false;
  var clearSuggestionsTimer = false;
  var getSuggestionsTimer = false;
  var showLoadingTimer = false;
  var zIndex = me.css('z-index');

  // get user input
  function getUserInput(){
    var val = me.val();
    if(options.multi){
      var pos = getCaretPosition(me_this);
      var start = pos.start;
      for(;start>0 && val.charAt(start-1) != ',';start--){}
      var end = pos.start;
      for(;end<val.length && val.charAt(end) != ',';end++){}
      var val = val.substr(start,end-start);
    }
    return ltrim(val);
  }
  // set suggestion
  function setSuggestion(val){
    user_input = val;
    if(options.multi){
      var orig = me.val();
      var pos = getCaretPosition(me_this);
      var start = pos.start;
      for(;start>0 && orig.charAt(start-1) != ',';start--){}
      var end = pos.end;
      for(;end<orig.length && orig.charAt(end) != ',';end++){}
      var new_val = orig.substr(0,start) + (start>0?' ':'') + val + orig.substr(end);
      me.val(new_val);
      setCaret(me_this,start + val.length + (start>0?1:0));
    }
    else{
      me_this.focus();
      me.val(val);
    }
  }
  // get suggestions
  function getSuggestions(val){
    // input length is less than the min required to trigger a request
    // reset input string
    // do nothing
    if (val.length < options.minchars){
      clearSuggestions();
      return false;
    }
    // if caching enabled, and user is typing (ie. length of input is increasing)
    // filter results out of suggestions from last request
    
    var newobj = false;
    
    var arr = [];
     for (var i=0;i<suggestions.length;i++){
        var re = new RegExp("("+escapearg(val)+")",'ig');
        if(re.exec(suggestions[i].value))
          {
          newobj = true;
          arr.push( suggestions[i] );
          }
      }
      
      if((newobj == true) && (val.length > input_chars_size))
      {
      user_input = val;
      input_chars_size = val.length;
      suggestions = arr;
      createList(suggestions);
      return false;
    }
      else{// do new request
      clearTimeout(getSuggestionsTimer);
      user_input = val;
      input_chars_size = val.length;
      getSuggestionsTimer = setTimeout( 
        function(){ 
          suggestions = [];
          // call pre callback, if exists
          if(jQuery.isFunction(options.pre_callback))
            options.pre_callback();
          // call get
          if(jQuery.isFunction(options.get)){
            suggestions = prepareArray(options.get(val));
            createList(suggestions);
          }
          // call AJAX get
          else if(jQuery.isFunction(options.ajax_get)){
            clearSuggestions();
            showLoadingTimer = setTimeout(show_loading,options.delay);
            options.ajax_get(val,ajax_continuation);
          }
        },
        options.delay );
    }
    return false;
  };
  // AJAX continuation
  function ajax_continuation(jsondata){
    hide_loading();
    suggestions = prepareArray(jsondata);
    createList(suggestions);
  }
  // shows loading indicator
  function show_loading(){
    if(!loading_indicator){
      loading_indicator = jQuery('<div class="jqac-menu" ><div style="width:292px;" class="jqac-loading">Loading...</div></div>').get(0);
      jQuery(loading_indicator).css('position','absolute');
      var pos = me.offset();
      jQuery(loading_indicator).css('left', pos.left + "px");
      jQuery(loading_indicator).css('top', ( pos.top + me.height() + 2 ) + "px");
      if(!options.autowidth)
        jQuery(loading_indicator).width(me.width());
      jQuery('body').append(loading_indicator);
    }
    jQuery(loading_indicator).show();
    setTimeout(hide_loading,1000000);
  }
  // hides loading indicator 
  function hide_loading(){
    if(loading_indicator)
      jQuery(loading_indicator).hide();
    clearTimeout(showLoadingTimer);
  }
  // create suggestions list
  function createList(arr){
    if(suggestions_menu)
      jQuery(suggestions_menu).remove();
    hide_loading();
    killTimeout();

    // create holding div
    suggestions_menu = jQuery('<div class="jqac-menu" id="jqac-menu-close"></div>').get(0);
    var b = 0;
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
    var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ieversion==6)
        {  b = 220; }
    else if (ieversion==7)
        {  b = 290; }
    }
    else
        {  b = 290; }
    jQuery(suggestions_menu).css({'position':'absolute',
                             'z-index':zIndex,
                             'max-height':options.height+'px',
                             'margin-top':'3px',
                             'overflow-y':'auto',
                             'width':b+'px'});

    // create and populate ul
    suggestions_list = jQuery('<ul></ul>').get(0);
    // set some CSS's
    jQuery(suggestions_list).
      css('list-style','none').
      css('margin','2px').
      css('padding','2px').
      css('overflow','hidden');
    // regexp for replace 
    var re = new RegExp("("+escapearg(htmlspecialchars(user_input))+")",'ig');
    // loop throught arr of suggestions creating an LI element for each suggestion
    for (var i=0;i<arr.length;i++){
      var val = new String(arr[i].value);
      // using RE
      var output = htmlspecialchars(val).replace(re,'<b>$1</b>');
      // using substr
      //var st = val.toLowerCase().indexOf( user_input.toLowerCase() );
      //var len = user_input.length;
      //var output = val.substring(0,st)+"<em>"+val.substring(st,st+len)+"</em>"+val.substring(st+len);

      var span = jQuery('<div class="jqac-link">'+output+'</div>').get(0);
      var span2 = '';
      
      if (arr[i].info != undefined && arr[i].info != ""){
        span2 = (jQuery('<div class="jqac-info">'+arr[i].info+' <span class="resultstyle">results</span></div>'));
      }
      jQuery(span).attr('name',i+1);
      jQuery(span).click(function () { setHighlightedValue();clearSuggestions(); });
      jQuery(span).mouseover(function () { setHighlight(jQuery(this).attr('name'),true);setHighlightedValue(); });

      var li = jQuery('<li></li>').get(0);
      jQuery(li).append(span);
      jQuery(li).append(span2);
          
      jQuery(suggestions_list).append(li);
     
    }

    // no results
    if (arr.length == 0){
      jQuery(suggestions_list).append('<li class="jqac-warning">'+options.noresults+'</li>');
    }
    
    jQuery(suggestions_menu).append(suggestions_list);
    // get position of target textfield
    // position holding div below it
    // set width of holding div to width of field
    var pos = me.offset();

    jQuery(suggestions_menu).css('left', pos.left + "px");
    jQuery(suggestions_menu).css('top', ( pos.top + me.height() + 2 ) + "px");
    if(!options.autowidth)
      jQuery(suggestions_menu).width(me.width());

    // set mouseover functions for div
    // when mouse pointer leaves div, set a timeout to remove the list after an interval
    // when mouse enters div, kill the timeout so the list won't be removed
    jQuery(suggestions_menu).mouseover(function(){ killTimeout() });
    jQuery(suggestions_menu).mouseout(function(){ resetTimeout() });

    // add DIV to document
    jQuery('body').append(suggestions_menu);

    // bgIFRAME support
    if(jQuery.fn.bgiframe)
      jQuery(suggestions_menu).bgiframe({height: suggestions_menu.scrollHeight});


    // adjust height: add +20 for scrollbar
    if(suggestions_menu.scrollHeight > options.height){
      jQuery(suggestions_menu).height(options.height);
      jQuery(suggestions_menu).width(jQuery(suggestions_menu).width()+2);
    }
	
    // currently no item is highlighted
    current_highlight = 0;

    // remove list after an interval
    clearSuggestionsTimer = setTimeout(function () { clearSuggestions() }, options.timeout);
  };
  // set highlighted value
  function setHighlightedValue(){
    if(current_highlight && suggestions[current_highlight-1]){
      var sugg = suggestions[ current_highlight-1 ];
      if(sugg.affected_value != undefined && sugg.affected_value != '')
        setSuggestion(sugg.affected_value);
      else
        setSuggestion(sugg.value);
      // pass selected object to callback function, if exists
      if (jQuery.isFunction(options.callback))
        options.callback( suggestions[current_highlight-1] );

      //clearSuggestions();
    }
  };
  // change highlight according to key
  function changeHighlight(key){	
    if(!suggestions_list || suggestions.length == 0) return false;
    var n;
    if (key == ARRDOWN)
      n = current_highlight + 1;
    else if (key == ARRUP)
      n = current_highlight - 1;

    if (n > jQuery(suggestions_list).children().size())
      n = 1;
    if (n < 1)
      n = jQuery(suggestions_list).children().size();
    setHighlight(n);
  };
  // change highlight
  function setHighlight(n,mouse_mode){
    if (!suggestions_list) return false;
    if (current_highlight > 0) clearHighlight();
    current_highlight = Number(n);
    var li = jQuery(suggestions_list).children().get(current_highlight-1);
    li.className = 'jqac-highlight';
    // for mouse mode don't adjust scroll! prevent scrolling jumps
    if(!mouse_mode) adjustScroll(li);
    killTimeout();
  };
  // clear highlight
  function clearHighlight(){
    if (!suggestions_list)return false;
    if (current_highlight > 0){
      jQuery(suggestions_list).children().get(current_highlight-1).className = '';
      current_highlight = 0;
    }
  };
  // clear suggestions list
  function clearSuggestions(){
    killTimeout();
    if(suggestions_menu){
      jQuery(suggestions_menu).remove();
      suggestions_menu = false;
      suggestions_list = false;
      current_highlight = 0;
    }
  };
  // set scroll
  function adjustScroll(el){
    if(!suggestions_menu) return false;
    var viewportHeight = suggestions_menu.clientHeight;        
    var wholeHeight = suggestions_menu.scrollHeight;
    var scrolled = suggestions_menu.scrollTop;
    var elTop = el.offsetTop;
    var elBottom = elTop + el.offsetHeight;
    if(elBottom > scrolled + viewportHeight){
      suggestions_menu.scrollTop = elBottom - viewportHeight;
    }
    else if(elTop < scrolled){
      suggestions_menu.scrollTop = elTop;
    }
    return true; 
  }
  // timeout funcs
  function killTimeout(){
    clearTimeout(clearSuggestionsTimer);
  };
  function resetTimeout(){
    clearTimeout(clearSuggestionsTimer);
    clearSuggestionsTimer = setTimeout(function () { clearSuggestions() }, 1000000);
  };

    function submittfrm(id, type)
             {
                    var form = document.getElementById(id);
                    if(type == "keyword")
                    {
                        if(form.elements["areaKeyWord"].value == " e.g. Bur Dubai, Dubai Marina, and Greens" || strTrim(form.elements["areaKeyWord"].value) == "" )
                        {
                            alert("Please provide a proper keyword to search");
                            return false;
                        }
                        else
                        { 
                            var strs = form.elements["areaKeyWord"].value.split(',');
                            var i = 0;
                            var haveVal = false;
                            for(i=0;i<strs.length;i++)
                            {
                                 if(strTrim(strs[i])!="")
                                 {
                                     haveVal = true;
                                 }
                            }   
                            if(!haveVal)
                            {
                                alert("Input not valid");
                            }                         
                            return haveVal;
                        }
                    }
                    else
                    {
                        if(form.elements["referenceNo"].value == " e.g. AP 5678, AP5678, or 5678" || strTrim(form.elements["referenceNo"].value) == "")
                        {
                            alert("Please provide a Ref no. to search");
                            return false;
                        }
                        else 
                        {
                            return true;
                        }
                    }
                    return false;                    
             }

})};

})(jQuery);

*/
(function(c){function E(b){var j=-1,h=-1;if(typeof b.selectionStart!="undefined"){j=b.selectionStart;h=b.selectionEnd}else if(document.selection&&document.selection.createRange){h=document.selection.createRange();var o;try{o=h.duplicate();o.moveToElementText(b)}catch(F){o=b.createTextRange()}o.setEndPoint("EndToStart",h);j=o.text.length;o.setEndPoint("EndToStart",h);h=o.text.length}return{start:j,end:h}}function N(b,j){b.focus();if(b.setSelectionRange)b.setSelectionRange(j,j);else if(b.createTextRange){m= b.createTextRange();m.moveStart("character",j+1);m.collapse();m.select()}}function G(b){for(var j=[],h=0;h<b.length;h++)if(b[h].id!=undefined&&b[h].value!=undefined){b[h].id+="";b[h].value+="";j.push(b[h])}return j}function H(b){if(b==undefined||!b)return"";return b.replace("\\","\\\\").replace("*","\\*").replace(".","\\.").replace("/","\\/")}function I(b){if(b==undefined||!b)return"";return b.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;")}function O(b){if(b==undefined||!b)return""; return b.replace(/^\s+/g,"")}var s=38,t=40;c.fn.autocomplete=function(b){return this.each(function(){function j(){var a=i.val();if(b.multi){for(var d=E(u),e=d.start;e>0&&a.charAt(e-1)!=",";e--);for(d=d.start;d<a.length&&a.charAt(d)!=",";d++);a=a.substr(e,d-e)}return O(a)}function h(a){v=a;if(b.multi){for(var d=i.val(),e=E(u),g=e.start;g>0&&d.charAt(g-1)!=",";g--);for(e=e.end;e<d.length&&d.charAt(e)!=",";e++);d=d.substr(0,g)+(g>0?" ":"")+a+d.substr(e);i.val(d);N(u,g+a.length+(g>0?1:0))}else{u.focus(); i.val(a)}}function o(a){if(a.length<b.minchars){q();return false}for(var d=false,e=[],g=0;g<k.length;g++)if((new RegExp("("+H(a)+")","ig")).exec(k[g].value)){d=true;e.push(k[g])}if(d==true&&a.length>z){v=a;z=a.length;k=e;A(k);return false}else{clearTimeout(J);v=a;z=a.length;J=setTimeout(function(){k=[];c.isFunction(b.pre_callback)&&b.pre_callback();if(c.isFunction(b.get)){k=G(b.get(a));A(k)}else if(c.isFunction(b.ajax_get)){q();K=setTimeout(P,b.delay);b.ajax_get(a,F)}},b.delay)}return false}function F(a){B(); k=G(a);A(k)}function P(){if(!p){p=c('<div class="jqac-menu" ><div style="width:292px;" class="jqac-loading">Loading...</div></div>').get(0);c(p).css("position","absolute");var a=i.offset();c(p).css("left",a.left+"px");c(p).css("top",a.top+i.height()+2+"px");b.autowidth||c(p).width(i.width());c("body").append(p)}c(p).show();setTimeout(B,1E6)}function B(){p&&c(p).hide();clearTimeout(K)}function A(a){f&&c(f).remove();B();w();f=c('<div class="jqac-menu" id="jqac-menu-close"></div>').get(0);var d=0;if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var e= new Number(RegExp.$1);if(e==6)d=220;else if(e==7)d=290}else d=290;c(f).css({position:"absolute","z-index":Q,"max-height":b.height+"px","margin-top":"3px","overflow-y":"auto",width:d+"px"});n=c("<ul></ul>").get(0);c(n).css("list-style","none").css("margin","2px").css("padding","2px").css("overflow","hidden");d=new RegExp("("+H(I(v))+")","ig");for(e=0;e<a.length;e++){var g=new String(a[e].value);g=I(g).replace(d,'<u class="" style="font-weight:bold;">$1</u>');g=c('<div class="jqac-link">'+ g+"</div>").get(0);var L="";if(a[e].info!=undefined&&a[e].info!="")L=c('<div class="jqac-info">'+a[e].info+' <span class="resultstyle">results</span></div>');c(g).attr("name",e+1);c(g).click(function(){r();q()});c(g).mouseover(function(){M(c(this).attr("name"),true);r()});var C=c("<li></li>").get(0);c(C).append(g);c(C).append(L);c(n).append(C)}a.length==0&&c(n).append('<li class="jqac-warning">'+b.noresults+"</li>");c(f).append(n);a=i.offset();c(f).css("left",a.left+"px");c(f).css("top",a.top+i.height()+ 2+"px");b.autowidth||c(f).width(i.width());c(f).mouseover(function(){w()});c(f).mouseout(function(){R()});c("body").append(f);c.fn.bgiframe&&c(f).bgiframe({height:f.scrollHeight});if(f.scrollHeight>b.height){c(f).height(b.height);c(f).width(c(f).width()+2)}l=0;x=setTimeout(function(){q()},b.timeout)}function r(){if(l&&k[l-1]){var a=k[l-1];a.affected_value!=undefined&&a.affected_value!=""?h(a.affected_value):h(a.value);c.isFunction(b.callback)&&b.callback(k[l-1])}}function y(a){if(!n||k.length==0)return false; var d;if(a==t)d=l+1;else if(a==s)d=l-1;if(d>c(n).children().size())d=1;if(d<1)d=c(n).children().size();M(d)}function M(a,d){if(!n)return false;l>0&&S();l=Number(a);a=c(n).children().get(l-1);a.className="jqac-highlight";d||T(a);w()}function S(){if(!n)return false;if(l>0){c(n).children().get(l-1).className="";l=0}}function q(){w();if(f){c(f).remove();n=f=false;l=0}}function T(a){if(!f)return false;var d=f.clientHeight,e=f.scrollTop,g=a.offsetTop;a=g+a.offsetHeight;if(a>e+d)f.scrollTop=a-d;else if(g< e)f.scrollTop=g;return true}function w(){clearTimeout(x)}function R(){clearTimeout(x);x=setTimeout(function(){q()},1E6)}function D(a,d){a=document.getElementById(a);if(d=="keyword")if(a.elements[0].value==" e.g. Bur Dubai, Dubai Marina, and Greens"||strTrim(a.elements[0].value)==""){alert("Please provide a proper keyword to search");return false}else{d=a.elements[0].value.split(",");a=0;var e=false;for(a=0;a<d.length;a++)if(strTrim(d[a])!="")e=true;e||alert("Input not valid"); return e}else if(a.elements.referenceNo.value==" e.g. AP 5678, AP5678, or 5678"||strTrim(a.elements.referenceNo.value)==""){alert("Please provide a Ref no. to search");return false}else return true}var i=c(this),u=c(this).get(0);if(i.is("input:text,input:password,textarea"))if(!(!b&&(!c.isFunction(b.get)||!b.ajax_get)))if(i.attr("jqac")!="on"){i.attr("jqac","on");i.attr("autocomplete","off");b=c.extend({delay:600,timeout:5E3,minchars:1,multi:true,cache:true,height:150,autowidth:false,noresults:"No property match found"}, b);i.keydown(function(a){switch(a.which){case 13:if(f){r();if(document.getElementById("frmSreachBykeyWord")!=null&&document.getElementById("frmSreachBykeyWord")!=""&&document.getElementById("frmSreachBykeyWord")!="undefined")D("frmSreachBykeyWord","keyword");else if(document.forms[0].id=="BasicSearchForm")if(document.forms[0].elements[0].value!=""||document.forms[0].elements[0].value!=" e.g. City, Location, etc."){if(document.forms[0].elements.isAdvance != null){document.forms[0].elements.isAdvance.value="true";};document.forms[0].submit()}}else if(document.getElementById("frmSreachBykeyWord")!= null&&document.getElementById("frmSreachBykeyWord")!=""&&document.getElementById("frmSreachBykeyWord")!="undefined"){D("frmSreachBykeyWord","keyword");return true}return false;case 27:q();return false;case s:var d=navigator.appName;if(d=="Microsoft Internet Explorer"){y(a.keyCode);r()}return false;case t:d=navigator.appName;if(d=="Microsoft Internet Explorer")if(f){y(a.keyCode);r()}else o(j());return false}return true});i.keypress(function(a){switch(a.keyCode){case 27:return false;case s:y(a.keyCode); r();return false;case t:if(f){y(a.keyCode);r()}else o(j());return false}return true});i.keyup(function(a){switch(a.which){case 13:q();if(document.getElementById("frmSreachBykeyWord")!=null&&document.getElementById("frmSreachBykeyWord")!=""&&document.getElementById("frmSreachBykeyWord")!="undefined"){D("frmSreachBykeyWord","keyword");return true}return true;case 27:case 37:case 39:case s:case t:return false;default:o(j());return false}});var v="",z=0,k=[],l=0,f=false,n=false,p=false,x=false,J=false, K=false,Q=i.css("z-index")}})}})(jQuery);
