﻿/// Slider
//jQuery.noConflict();
//    jQuery(window).load(function() {
//        jQuery('#slider').nivoSlider();
//    });
    /// AutoComplete de criterio de busquedas
    enableAcHighlight();
    jQuery.noConflict();
         jQuery(document).ready(function() {
             jQuery(function() {
                 var cache = {},
			lastXhr;
                 jQuery('#ctl00_MainContent_SearchBoxId_busquedaTxt').autocomplete({
                     select: function(event, ui) {GotoClass(ui.item.id, ui.item.descUrl)},
                     minLength: 2,
                     source: function(request, response) {
                     request.lang = document.getElementById('ctl00_MainContent_SearchBoxId_tabSelected').value;
                         var term = request.term;                         
                         if (term in cache) {
                             response(cache[term]);
                             return;
                         }
                         lastXhr = jQuery.getJSON("http://www.paginasamarillas.com.do/httpHandler/AutoCompleteHandler.ashx", request, function(data, status, xhr) {
                             cache[term] = data;
                             if (xhr === lastXhr) {
                                 response(data);
                             }
                         });
                     }
                 });
             });
         });         

         /// Autocoomplete del texbox ciudad
         jQuery.noConflict();
         jQuery(document).ready(function() {
             jQuery(function() {
                 var cache = {},
			lastXhr;
                 jQuery('#ctl00_MainContent_SearchBoxId_ciudadTxt').autocomplete({
                     select: function(event, ui) {GotoCiudad(ui.item.id, ui.item.descUrl)},
                     minLength: 2,
                     source: function(request, response) {
                     request.lang = document.getElementById('ctl00_MainContent_SearchBoxId_tabSelected').value;
                         var term = request.term;                         
                         if (term in cache) {
                             response(cache[term]);
                             return;
                         }
                         lastXhr = jQuery.getJSON("http://www.paginasamarillas.com.do/httpHandler/AutoCompleteCiudadHandler.ashx", request, function(data, status, xhr) {
                             cache[term] = data;
                             if (xhr === lastXhr) {
                                 response(data);
                             }
                         });
                     }
                 });
             });
         });
       function enableAcHighlight()
        {
            jQuery.noConflict();
           jQuery.ui.autocomplete.prototype._renderItem = function (ul, item) {
                item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + jQuery.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
                return jQuery("<li></li>")
                        .data("item.autocomplete", item)
                        .append("<a>" + item.label + "</a>")
                        .appendTo(ul);
            };
      }  
    /* Enable the use of the $ sign, even if jQuery is in compatibility mode
    This method of invoking jQuery also makes sure the document is ready before
    doing anything. */
    jQuery.noConflict();
    jQuery(function( jQuery ) {
    jQuery('#ctl00_MainContent_SearchBoxId_busquedaTxt').placeHeld();
    });
    /* Enable the use of the $ sign, even if jQuery is in compatibility mode
    This method of invoking jQuery also makes sure the document is ready before
    doing anything. */
    jQuery.noConflict();
    jQuery(function( jQuery ) {
    jQuery('#ctl00_MainContent_SearchBoxId_ciudadTxt').placeHold();
    });
