jQuery(document).ready(function () {
    jQuery('#keyword').autocomplete({
        source:"/api/js/listings/",
        minLength: 2,
        delay: 0,
        focus: function (event, ui) {
            $(event.target).val(ui.item.label);
            return false;
        },
        select: function (event, ui) {
            $(event.target).val(ui.item.label);
            window.location = ui.item.value;
            return false;
        }
    });

    jQuery('.feedback.highlight').highlight();
    jQuery('.feedback.error').error();
    jQuery('.feedback.info').info();
    jQuery('.ui-button').button();

    // START AUTOCLEAR
    // Usage: <input type="text" title="Company Name" class="autoclear" />
    jQuery('.autoclear').each(function() {
        if (jQuery(this).val() == '') jQuery(this).val(jQuery(this).attr('title'));
        jQuery(this).focus(function() {
            if (jQuery(this).val() == jQuery(this).attr('title')) {
                jQuery(this).val('');
            }
        }).blur(function() {
            if (jQuery(this).val() == '') {
                jQuery(this).val(jQuery(this).attr('title'));
            }
        });
    });
    // END AUTOCLEAR

    // DATE PICKER
    jQuery('.datepicker').datepicker({ dateFormat: 'dd/mm/yy' });
    //

    // DEFAULT FORM VALIDATION/ERRORS
    // Usage:
    //      <div class="feedback error" id="client-errors">
    //          <strong>You have entered some information incorrectly, please review the following:</strong>
    //      </div>
    //      <form class="validated-form">
    //          <fieldset>
    //              <h2>Personal Details</h2>
    //              <div class="field">
    //                  <label for="name">Name *</label>
    //                  <div class="input-container">
    //                      <input type="text" name="name" id="name" class="required" title="Name is required"/>
    //                  </div>
    //              </div>
    //          </fieldset>
    //      </form>
    jQuery('#client-errors').hide();
    jQuery('.validated-form').validate({ errorLabelContainer: jQuery('.feedback.error')});
    //
    
    // START MAIN NAV DROPDOWN
    var timer;
    jQuery('#header-container #header .menu ul ul').hide();
    jQuery('#header-container #header .menu ul li').hover(
        function() {
            if (jQuery(this).find('ul').length > 0) {
                var el = this;
                timer = setTimeout(function() {
                    jQuery(el).find('ul').fadeIn(300);
                }, 200);
            }
        },
        function() {
            if (jQuery(this).find('ul').length > 0) {
                clearTimeout(timer);
                var el = this;
                setTimeout(function() {
                    jQuery(el).find('ul').fadeOut(300);
                }, 400);
            }
        }
    );
    // END MAIN NAV DROPDOWN
    
    jQuery('.lazyload').lazyload();
});

// jquery-ui-error.js
(function($){$.widget("ui.error",{_create:function(){this.element.addClass("ui-state-error ui-corner-all").prepend("<span class=\"ui-icon ui-icon-alert\"></span>");}});})(jQuery);
// jquery-ui-highlight.js
(function($){$.widget("ui.highlight",{_create:function(){this.element.addClass("ui-state-highlight ui-corner-all").prepend("<span class=\"ui-icon ui-icon-info\"></span>");}});})(jQuery);
// jquery-ui-info.js
(function($){$.widget("ui.info",{_create:function(){this.element.addClass("ui-state-info ui-corner-all").prepend("<span class=\"ui-icon ui-icon-info\"></span>");}});})(jQuery);
// jquery.limit-1.2.js
(function($){$.fn.extend({limit:function(limit,element){var interval,f;var self=$(this);$(this).focus(function(){interval=window.setInterval(substring,100)});$(this).blur(function(){clearInterval(interval);substring()});substringFunction="function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";if(typeof element!='undefined')substringFunction+="if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}";substringFunction+="}";eval(substringFunction);substring()}})})(jQuery);
// jquery.example.min.js
(function(a){a.fn.example=function(e,c){var d=a.isFunction(e);var b=a.extend({},c,{example:e});return this.each(function(){var f=a(this);if(a.metadata){var g=a.extend({},a.fn.example.defaults,f.metadata(),b)}else{var g=a.extend({},a.fn.example.defaults,b)}if(!a.fn.example.boundClassNames[g.className]){a(window).unload(function(){a("."+g.className).val("")});a("form").submit(function(){a(this).find("."+g.className).val("")});a.fn.example.boundClassNames[g.className]=true}if(a.browser.msie&&!f.attr("defaultValue")&&(d||f.val()==g.example)){f.val("")}if(f.val()==""&&this!=document.activeElement){f.addClass(g.className);f.val(d?g.example.call(this):g.example)}f.focus(function(){if(a(this).is("."+g.className)){a(this).val("");a(this).removeClass(g.className)}});f.change(function(){if(a(this).is("."+g.className)){a(this).removeClass(g.className)}});f.blur(function(){if(a(this).val()==""){a(this).addClass(g.className);a(this).val(d?g.example.call(this):g.example)}})})};a.fn.example.defaults={className:"example"};a.fn.example.boundClassNames=[]})(jQuery);
// jquery.lazyload.js
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(7($){$.Q.P=7(w){8 1={d:0,G:0,e:"m",B:"S",3:5};6(w){$.J(1,w)}8 r=c;6("m"==1.e){$(1.3).t("m",7(e){8 F=0;r.C(7(){6($.s(c,1)||$.x(c,1)){}f 6(!$.l(c,1)&&!$.o(c,1)){$(c).u("v")}f{6(F++>1.G){h E}}});8 H=$.N(r,7(9){h!9.k});r=$(H)})}c.C(7(){8 2=c;6(j==$(2).b("q")){$(2).b("q",$(2).b("i"))}6("m"!=1.e||j==$(2).b("i")||1.z==$(2).b("i")||($.s(2,1)||$.x(2,1)||$.l(2,1)||!$.l(2,1)||$.o(2,1))){6(1.z){$(2).b("i",1.z)}f{$(2).Z("i")}2.k=E}f{2.k=D}$(2).11("v",7(){6(!c.k){$("<Y />").t("U",7(){$(2).V().b("i",$(2).b("q"))[1.B](1.W);2.k=D}).b("i",$(2).b("q"))}});6("m"!=1.e){$(2).t(1.e,7(e){6(!2.k){$(2).u("v")}})}});$(1.3).u(1.e);h c};$.l=7(9,1){6(1.3===j||1.3===5){8 4=$(5).y()+$(5).I()}f{8 4=$(1.3).g().p+$(1.3).y()}h 4<=$(9).g().p-1.d};$.o=7(9,1){6(1.3===j||1.3===5){8 4=$(5).A()+$(5).M()}f{8 4=$(1.3).g().n+$(1.3).A()}h 4<=$(9).g().n-1.d};$.s=7(9,1){6(1.3===j||1.3===5){8 4=$(5).I()}f{8 4=$(1.3).g().p}h 4>=$(9).g().p+1.d+$(9).y()};$.x=7(9,1){6(1.3===j||1.3===5){8 4=$(5).M()}f{8 4=$(1.3).g().n}h 4>=$(9).g().n+1.d+$(9).A()};$.J($.10[\':\'],{"T-L-4":"$.l(a, {d : 0, 3: 5})","R-L-4":"!$.l(a, {d : 0, 3: 5})","O-K-4":"$.o(a, {d : 0, 3: 5})","n-K-4":"!$.o(a, {d : 0, 3: 5})"})})(X);',62,64,'|settings|self|container|fold|window|if|function|var|element||attr|this|threshold|event|else|offset|return|src|undefined|loaded|belowthefold|scroll|left|rightoffold|top|original|elements|abovethetop|bind|trigger|appear|options|leftofbegin|height|placeholder|width|effect|each|true|false|counter|failurelimit|temp|scrollTop|extend|of|the|scrollLeft|grep|right|lazyload|fn|above|show|below|load|hide|effectspeed|jQuery|img|removeAttr|expr|one'.split('|'),0,{}))
