if ((location.href.indexOf("hd-diy-stage.homedepot.ca") != -1)||(location.href.indexOf("diy.homedepot.ca") != -1)) {
	//do nothing
}
else {

$(document).ready(function() {
	initSuggestionBox();
});

function initSuggestionBox() {
	if($.cookie('hd_search_cookie') == '' || $.cookie('hd_search_cookie') == null) {
		$.cookie('hd_search_cookie', '1', {path: '/', domain: 'homedepot.ca'}); // Set Cookie
	}
	
	var lang = $(document).getUrlParam("langId"); // Language ID
	
	// Display only on English Site
	if(lang == -15) {
		var lookup = function() {
			if ($.cookie('hd_search_cookie') == 0) return;
			
			var searchTerm = $(this).val();
			var replaceSearchTerm = searchTerm.replace(/\s/g, '+').replace('&', '%26').replace('&icirc', '%ee'); // Replace all spaces and ampersands
	
			if (searchTerm.length > 2) {
				$('#searchSuggestionsBox .suggestions').load('/webapp/wcs/stores/servlet/TypeAheadView?catalogId=10051&storeId=10051&langId=' + lang + '&searchterm=' + replaceSearchTerm + '*');
				$('#searchSuggestionsBox').addClass('show');
				$('#sList select').hide(); // Hides Top Sellers Select Box
			} else {
				$('#searchSuggestionsBox').removeClass('show');
				$('#sList select').show(); // Shows Top Sellers Select Box
			}

		}
	
		// Disable Cookie
		if ($.cookie('hd_search_cookie') == '1') { 		
			$('body').append('<div id="searchSuggestionsBox"><div class="suggestions"></div><div class="clear"></div><a class="btnToggleSuggestions">Disable</a></div>');
			$('#srchField').keyup(lookup);
			
			$('.btnToggleSuggestions').click(function() {
				$.cookie('hd_search_cookie', '0', {domain: 'homedepot.ca'}); 
				$('#searchSuggestionsBox').removeClass('show');
			});

		}
	}	
}

	$(document).ready(function(){
        $('#searchSuggestionsBox').click(function(e) {
            e.stopPropagation();
        });
        $(document).click(function() {
            $('#searchSuggestionsBox').removeClass('show');
        });
    }); 

}
