// JavaScript Document
function update_text () {
    // Replacing the yellow bar with just click to use this coupon when no coupon code - **amended- 04-14-10**
    $(".codenum:has(a:empty)").each(function(i) {
        $(this).removeClass('codenum').addClass('codenum_none');
	$(this).find("a").attr('title', 'Just click to use this coupon'); 
	$(this).find("a").text('Click to save now!'); 
    });

    $(".codenum:not(:has(a:empty))").each(function(i) {
	$(this).find("a").prepend('Use Code: '); 
    });

    // When there is no expiration date, replace it with "on going offer"
    $(".expire_yes:empty").each(function(i) {
        $(this).removeClass('expire_yes').addClass('expire_no');
	$(this).text('Ongoing Offer');
    });
};



$(document).ready(function() {
    update_text();

    // Search for all tiles that have a class of "merchtile" put them in an array
    // use that number to determine if you should hide the arrows
    var elems = $(".merchtile");
    if (elems.length <= 4) {
	$(":button[class=prev]").hide();
	$(":button[class=next]").hide();
    }

	// carousel 
		$(function() {
			$(".carousel").jCarouselLite({
				btnNext: ".next",
				btnPrev: ".prev",
				    visible: 4,
				    scroll: 1,
				    circular: false
			});
		});
		// end carousel


   $("#product-search-field").autocomplete({
      source: "/cgi/broker.plx?ajax=1&args=product_search_dropdown",
      minLength: 2,
      select: function(event, ui) {
	  document.topsearch.submit();
      }
	});
 });

